@sveltejs/kit 1.0.0-next.339 → 1.0.0-next.341

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.
@@ -64,19 +64,13 @@ function normalize(loaded) {
64
64
 
65
65
  if (loaded.redirect) {
66
66
  if (!loaded.status || Math.floor(loaded.status / 100) !== 3) {
67
- return {
68
- status: 500,
69
- error: new Error(
70
- '"redirect" property returned from load() must be accompanied by a 3xx status code'
71
- )
72
- };
67
+ throw new Error(
68
+ '"redirect" property returned from load() must be accompanied by a 3xx status code'
69
+ );
73
70
  }
74
71
 
75
72
  if (typeof loaded.redirect !== 'string') {
76
- return {
77
- status: 500,
78
- error: new Error('"redirect" property returned from load() must be a string')
79
- };
73
+ throw new Error('"redirect" property returned from load() must be a string');
80
74
  }
81
75
  }
82
76
 
@@ -85,10 +79,7 @@ function normalize(loaded) {
85
79
  !Array.isArray(loaded.dependencies) ||
86
80
  loaded.dependencies.some((dep) => typeof dep !== 'string')
87
81
  ) {
88
- return {
89
- status: 500,
90
- error: new Error('"dependencies" property returned from load() must be of type string[]')
91
- };
82
+ throw new Error('"dependencies" property returned from load() must be of type string[]');
92
83
  }
93
84
  }
94
85
 
@@ -616,8 +607,9 @@ function create_client({ target, session, base, trailing_slash }) {
616
607
  * @param {string[]} redirect_chain
617
608
  * @param {boolean} no_cache
618
609
  * @param {{hash?: string, scroll: { x: number, y: number } | null, keepfocus: boolean, details: { replaceState: boolean, state: any } | null}} [opts]
610
+ * @param {() => void} [callback]
619
611
  */
620
- async function update(url, redirect_chain, no_cache, opts) {
612
+ async function update(url, redirect_chain, no_cache, opts, callback) {
621
613
  const intent = get_navigation_intent(url);
622
614
 
623
615
  const current_token = (token = {});
@@ -690,6 +682,10 @@ function create_client({ target, session, base, trailing_slash }) {
690
682
  if (started) {
691
683
  current = navigation_result.state;
692
684
 
685
+ if (navigation_result.props.page) {
686
+ navigation_result.props.page.url = url;
687
+ }
688
+
693
689
  root.$set(navigation_result.props);
694
690
  } else {
695
691
  initialize(navigation_result);
@@ -744,7 +740,6 @@ function create_client({ target, session, base, trailing_slash }) {
744
740
  load_cache.promise = null;
745
741
  load_cache.id = null;
746
742
  autoscroll = true;
747
- updating = false;
748
743
 
749
744
  if (navigation_result.props.page) {
750
745
  page = navigation_result.props.page;
@@ -753,7 +748,9 @@ function create_client({ target, session, base, trailing_slash }) {
753
748
  const leaf_node = navigation_result.state.branch[navigation_result.state.branch.length - 1];
754
749
  router_enabled = leaf_node?.module.router !== false;
755
750
 
756
- return true;
751
+ if (callback) callback();
752
+
753
+ updating = false;
757
754
  }
758
755
 
759
756
  /** @param {import('./types').NavigationResult} result */
@@ -771,12 +768,12 @@ function create_client({ target, session, base, trailing_slash }) {
771
768
  hydrate: true
772
769
  });
773
770
 
774
- started = true;
775
-
776
771
  if (router_enabled) {
777
772
  const navigation = { from: null, to: new URL(location.href) };
778
773
  callbacks.after_navigate.forEach((fn) => fn(navigation));
779
774
  }
775
+
776
+ started = true;
780
777
  }
781
778
 
782
779
  /**
@@ -934,7 +931,7 @@ function create_client({ target, session, base, trailing_slash }) {
934
931
  const session = $session;
935
932
 
936
933
  if (module.load) {
937
- /** @type {import('types').LoadInput} */
934
+ /** @type {import('types').LoadEvent} */
938
935
  const load_input = {
939
936
  routeId,
940
937
  params: uses_params,
@@ -1362,18 +1359,22 @@ function create_client({ target, session, base, trailing_slash }) {
1362
1359
  });
1363
1360
  }
1364
1361
 
1365
- const completed = await update(normalized, redirect_chain, false, {
1366
- scroll,
1367
- keepfocus,
1368
- details
1369
- });
1370
-
1371
- if (completed) {
1372
- const navigation = { from, to: normalized };
1373
- callbacks.after_navigate.forEach((fn) => fn(navigation));
1362
+ await update(
1363
+ normalized,
1364
+ redirect_chain,
1365
+ false,
1366
+ {
1367
+ scroll,
1368
+ keepfocus,
1369
+ details
1370
+ },
1371
+ () => {
1372
+ const navigation = { from, to: normalized };
1373
+ callbacks.after_navigate.forEach((fn) => fn(navigation));
1374
1374
 
1375
- stores.navigating.set(null);
1376
- }
1375
+ stores.navigating.set(null);
1376
+ }
1377
+ );
1377
1378
  }
1378
1379
 
1379
1380
  /**
@@ -885,33 +885,11 @@ function base64(bytes) {
885
885
  /** @type {Promise<void>} */
886
886
  let csp_ready;
887
887
 
888
- /** @type {() => string} */
889
- let generate_nonce;
888
+ const array = new Uint8Array(16);
890
889
 
891
- /** @type {(input: string) => string} */
892
- let generate_hash;
893
-
894
- if (typeof crypto !== 'undefined') {
895
- const array = new Uint8Array(16);
896
-
897
- generate_nonce = () => {
898
- crypto.getRandomValues(array);
899
- return base64(array);
900
- };
901
-
902
- generate_hash = sha256;
903
- } else {
904
- // TODO: remove this in favor of web crypto API once we no longer support Node 14
905
- const name = 'crypto'; // store in a variable to fool esbuild when adapters bundle kit
906
- csp_ready = import(name).then((crypto) => {
907
- generate_nonce = () => {
908
- return crypto.randomBytes(16).toString('base64');
909
- };
910
-
911
- generate_hash = (input) => {
912
- return crypto.createHash('sha256').update(input, 'utf-8').digest().toString('base64');
913
- };
914
- });
890
+ function generate_nonce() {
891
+ crypto.getRandomValues(array);
892
+ return base64(array);
915
893
  }
916
894
 
917
895
  const quoted = new Set([
@@ -1014,7 +992,7 @@ class Csp {
1014
992
  add_script(content) {
1015
993
  if (this.#script_needs_csp) {
1016
994
  if (this.#use_hashes) {
1017
- this.#script_src.push(`sha256-${generate_hash(content)}`);
995
+ this.#script_src.push(`sha256-${sha256(content)}`);
1018
996
  } else if (this.#script_src.length === 0) {
1019
997
  this.#script_src.push(`nonce-${this.nonce}`);
1020
998
  }
@@ -1025,7 +1003,7 @@ class Csp {
1025
1003
  add_style(content) {
1026
1004
  if (this.#style_needs_csp) {
1027
1005
  if (this.#use_hashes) {
1028
- this.#style_src.push(`sha256-${generate_hash(content)}`);
1006
+ this.#style_src.push(`sha256-${sha256(content)}`);
1029
1007
  } else if (this.#style_src.length === 0) {
1030
1008
  this.#style_src.push(`nonce-${this.nonce}`);
1031
1009
  }
@@ -1124,7 +1102,7 @@ async function render_response({
1124
1102
  resolve_opts,
1125
1103
  stuff
1126
1104
  }) {
1127
- if (state.prerender) {
1105
+ if (state.prerendering) {
1128
1106
  if (options.csp.mode === 'nonce') {
1129
1107
  throw new Error('Cannot use prerendering if config.kit.csp.mode === "nonce"');
1130
1108
  }
@@ -1192,7 +1170,7 @@ async function render_response({
1192
1170
  routeId: event.routeId,
1193
1171
  status,
1194
1172
  stuff,
1195
- url: state.prerender ? create_prerendering_url_proxy(event.url) : event.url
1173
+ url: state.prerendering ? create_prerendering_url_proxy(event.url) : event.url
1196
1174
  },
1197
1175
  components: branch.map(({ node }) => node.module.default)
1198
1176
  };
@@ -1232,7 +1210,7 @@ async function render_response({
1232
1210
  await csp_ready;
1233
1211
  const csp = new Csp(options.csp, {
1234
1212
  dev: options.dev,
1235
- prerender: !!state.prerender,
1213
+ prerender: !!state.prerendering,
1236
1214
  needs_nonce: options.template_contains_nonce
1237
1215
  });
1238
1216
 
@@ -1341,7 +1319,7 @@ async function render_response({
1341
1319
  <script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ''}>${init_service_worker}</script>`;
1342
1320
  }
1343
1321
 
1344
- if (state.prerender) {
1322
+ if (state.prerendering) {
1345
1323
  const http_equiv = [];
1346
1324
 
1347
1325
  const csp_headers = csp.get_meta();
@@ -1379,7 +1357,7 @@ async function render_response({
1379
1357
  headers.set('permissions-policy', 'interest-cohort=()');
1380
1358
  }
1381
1359
 
1382
- if (!state.prerender) {
1360
+ if (!state.prerendering) {
1383
1361
  const csp_header = csp.get_header();
1384
1362
  if (csp_header) {
1385
1363
  headers.set('content-security-policy', csp_header);
@@ -1941,19 +1919,13 @@ function normalize(loaded) {
1941
1919
 
1942
1920
  if (loaded.redirect) {
1943
1921
  if (!loaded.status || Math.floor(loaded.status / 100) !== 3) {
1944
- return {
1945
- status: 500,
1946
- error: new Error(
1947
- '"redirect" property returned from load() must be accompanied by a 3xx status code'
1948
- )
1949
- };
1922
+ throw new Error(
1923
+ '"redirect" property returned from load() must be accompanied by a 3xx status code'
1924
+ );
1950
1925
  }
1951
1926
 
1952
1927
  if (typeof loaded.redirect !== 'string') {
1953
- return {
1954
- status: 500,
1955
- error: new Error('"redirect" property returned from load() must be a string')
1956
- };
1928
+ throw new Error('"redirect" property returned from load() must be a string');
1957
1929
  }
1958
1930
  }
1959
1931
 
@@ -1962,10 +1934,7 @@ function normalize(loaded) {
1962
1934
  !Array.isArray(loaded.dependencies) ||
1963
1935
  loaded.dependencies.some((dep) => typeof dep !== 'string')
1964
1936
  ) {
1965
- return {
1966
- status: 500,
1967
- error: new Error('"dependencies" property returned from load() must be of type string[]')
1968
- };
1937
+ throw new Error('"dependencies" property returned from load() must be of type string[]');
1969
1938
  }
1970
1939
  }
1971
1940
 
@@ -2105,13 +2074,15 @@ async function load_node({
2105
2074
  /** @type {import('types').LoadOutput} */
2106
2075
  let loaded;
2107
2076
 
2077
+ const should_prerender = node.module.prerender ?? options.prerender.default;
2078
+
2108
2079
  /** @type {import('types').ShadowData} */
2109
2080
  const shadow = is_leaf
2110
2081
  ? await load_shadow_data(
2111
2082
  /** @type {import('types').SSRPage} */ (route),
2112
2083
  event,
2113
2084
  options,
2114
- !!state.prerender
2085
+ should_prerender
2115
2086
  )
2116
2087
  : {};
2117
2088
 
@@ -2132,13 +2103,18 @@ async function load_node({
2132
2103
  redirect: shadow.redirect
2133
2104
  };
2134
2105
  } else if (module.load) {
2135
- /** @type {import('types').LoadInput} */
2106
+ /** @type {import('types').LoadEvent} */
2136
2107
  const load_input = {
2137
- url: state.prerender ? create_prerendering_url_proxy(event.url) : event.url,
2108
+ url: state.prerendering ? create_prerendering_url_proxy(event.url) : event.url,
2138
2109
  params: event.params,
2139
2110
  props: shadow.body || {},
2140
2111
  routeId: event.routeId,
2141
2112
  get session() {
2113
+ if (node.module.prerender ?? options.prerender.default) {
2114
+ throw Error(
2115
+ 'Attempted to access session from a prerendered page. Session would never be populated.'
2116
+ );
2117
+ }
2142
2118
  uses_credentials = true;
2143
2119
  return $session;
2144
2120
  },
@@ -2270,9 +2246,9 @@ async function load_node({
2270
2246
  }
2271
2247
  );
2272
2248
 
2273
- if (state.prerender) {
2249
+ if (state.prerendering) {
2274
2250
  dependency = { response, body: null };
2275
- state.prerender.dependencies.set(resolved, dependency);
2251
+ state.prerendering.dependencies.set(resolved, dependency);
2276
2252
  }
2277
2253
  } else {
2278
2254
  // external
@@ -2416,7 +2392,7 @@ async function load_node({
2416
2392
  }
2417
2393
 
2418
2394
  // generate __data.json files when prerendering
2419
- if (shadow.body && state.prerender) {
2395
+ if (shadow.body && state.prerendering) {
2420
2396
  const pathname = `${event.url.pathname.replace(/\/$/, '')}/__data.json`;
2421
2397
 
2422
2398
  const dependency = {
@@ -2424,7 +2400,7 @@ async function load_node({
2424
2400
  body: JSON.stringify(shadow.body)
2425
2401
  };
2426
2402
 
2427
- state.prerender.dependencies.set(pathname, dependency);
2403
+ state.prerendering.dependencies.set(pathname, dependency);
2428
2404
  }
2429
2405
 
2430
2406
  return {
@@ -2749,11 +2725,11 @@ async function respond$1(opts) {
2749
2725
 
2750
2726
  let page_config = get_page_config(leaf, options);
2751
2727
 
2752
- if (state.prerender) {
2728
+ if (state.prerendering) {
2753
2729
  // if the page isn't marked as prerenderable (or is explicitly
2754
2730
  // marked NOT prerenderable, if `prerender.default` is `true`),
2755
2731
  // then bail out at this point
2756
- const should_prerender = leaf.prerender ?? state.prerender.default;
2732
+ const should_prerender = leaf.prerender ?? options.prerender.default;
2757
2733
  if (!should_prerender) {
2758
2734
  return new Response(undefined, {
2759
2735
  status: 204
@@ -3114,7 +3090,7 @@ async function respond(request, options, state) {
3114
3090
  /** @type {Record<string, string>} */
3115
3091
  let params = {};
3116
3092
 
3117
- if (options.paths.base && !state.prerender?.fallback) {
3093
+ if (options.paths.base && !state.prerendering?.fallback) {
3118
3094
  if (!decoded.startsWith(options.paths.base)) {
3119
3095
  return new Response(undefined, { status: 404 });
3120
3096
  }
@@ -3128,7 +3104,7 @@ async function respond(request, options, state) {
3128
3104
  url = new URL(url.origin + url.pathname.slice(0, -DATA_SUFFIX.length) + url.search);
3129
3105
  }
3130
3106
 
3131
- if (!state.prerender || !state.prerender.fallback) {
3107
+ if (!state.prerendering?.fallback) {
3132
3108
  const matchers = await options.manifest._.matchers();
3133
3109
 
3134
3110
  for (const candidate of options.manifest._.routes) {
@@ -3147,7 +3123,7 @@ async function respond(request, options, state) {
3147
3123
  if (route?.type === 'page') {
3148
3124
  const normalized = normalize_path(url.pathname, options.trailing_slash);
3149
3125
 
3150
- if (normalized !== url.pathname && !state.prerender?.fallback) {
3126
+ if (normalized !== url.pathname && !state.prerendering?.fallback) {
3151
3127
  return new Response(undefined, {
3152
3128
  status: 301,
3153
3129
  headers: {
@@ -3238,7 +3214,7 @@ async function respond(request, options, state) {
3238
3214
  };
3239
3215
  }
3240
3216
 
3241
- if (state.prerender && state.prerender.fallback) {
3217
+ if (state.prerendering?.fallback) {
3242
3218
  return await render_response({
3243
3219
  event,
3244
3220
  options,
@@ -3340,7 +3316,7 @@ async function respond(request, options, state) {
3340
3316
  });
3341
3317
  }
3342
3318
 
3343
- if (state.prerender) {
3319
+ if (state.prerendering) {
3344
3320
  return new Response('not found', { status: 404 });
3345
3321
  }
3346
3322
 
@@ -1,4 +1,4 @@
1
- import { c as commonjsGlobal } from '../install-fetch.js';
1
+ import { c as commonjsGlobal } from '../node/polyfills.js';
2
2
  import require$$1 from 'crypto';
3
3
  import 'node:http';
4
4
  import 'node:https';
@@ -1,12 +1,12 @@
1
1
  import path__default from 'path';
2
2
  import { svelte } from '@sveltejs/vite-plugin-svelte';
3
- import vite from 'vite';
3
+ import * as vite from 'vite';
4
4
  import { d as deep_merge } from './object.js';
5
5
  import { g as get_runtime_path, r as resolve_entry, $, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as get_aliases, p as print_config_conflicts } from '../cli.js';
6
6
  import fs__default from 'fs';
7
7
  import { URL } from 'url';
8
8
  import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
9
- import { installFetch } from '../install-fetch.js';
9
+ import { installPolyfills } from '../node/polyfills.js';
10
10
  import { update, init } from './sync.js';
11
11
  import { getRequest, setResponse } from '../node.js';
12
12
  import { p as posixify } from './filesystem.js';
@@ -23,6 +23,7 @@ import 'node:zlib';
23
23
  import 'node:stream';
24
24
  import 'node:util';
25
25
  import 'node:url';
26
+ import 'crypto';
26
27
  import './write_tsconfig.js';
27
28
  import 'stream';
28
29
 
@@ -30,12 +31,13 @@ import 'stream';
30
31
  // https://github.com/vitejs/vite/blob/3edd1af56e980aef56641a5a51cf2932bb580d41/packages/vite/src/node/plugins/css.ts#L96
31
32
  const style_pattern = /\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/;
32
33
 
34
+ const cwd$1 = process.cwd();
35
+
33
36
  /**
34
37
  * @param {import('types').ValidatedConfig} config
35
- * @param {string} cwd
36
38
  * @returns {Promise<import('vite').Plugin>}
37
39
  */
38
- async function create_plugin(config, cwd) {
40
+ async function create_plugin(config) {
39
41
  const runtime = get_runtime_path(config);
40
42
 
41
43
  process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
@@ -47,7 +49,7 @@ async function create_plugin(config, cwd) {
47
49
  name: 'vite-plugin-svelte-kit',
48
50
 
49
51
  configureServer(vite) {
50
- installFetch();
52
+ installPolyfills();
51
53
 
52
54
  /** @type {import('types').SSRManifest} */
53
55
  let manifest;
@@ -123,7 +125,7 @@ async function create_plugin(config, cwd) {
123
125
  types,
124
126
  shadow: route.shadow
125
127
  ? async () => {
126
- const url = path__default.resolve(cwd, /** @type {string} */ (route.shadow));
128
+ const url = path__default.resolve(cwd$1, /** @type {string} */ (route.shadow));
127
129
  return await vite.ssrLoadModule(url, { fixStacktrace: false });
128
130
  }
129
131
  : null,
@@ -139,7 +141,7 @@ async function create_plugin(config, cwd) {
139
141
  names,
140
142
  types,
141
143
  load: async () => {
142
- const url = path__default.resolve(cwd, route.file);
144
+ const url = path__default.resolve(cwd$1, route.file);
143
145
  return await vite.ssrLoadModule(url, { fixStacktrace: false });
144
146
  }
145
147
  };
@@ -150,7 +152,7 @@ async function create_plugin(config, cwd) {
150
152
 
151
153
  for (const key in manifest_data.matchers) {
152
154
  const file = manifest_data.matchers[key];
153
- const url = path__default.resolve(cwd, file);
155
+ const url = path__default.resolve(cwd$1, file);
154
156
  const module = await vite.ssrLoadModule(url, { fixStacktrace: false });
155
157
 
156
158
  if (module.match) {
@@ -261,13 +263,13 @@ async function create_plugin(config, cwd) {
261
263
  // can get loaded twice via different URLs, which causes failures. Might
262
264
  // require changes to Vite to fix
263
265
  const { default: root } = await vite.ssrLoadModule(
264
- `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/generated/root.svelte`))}`,
266
+ `/${posixify(path__default.relative(cwd$1, `${config.kit.outDir}/generated/root.svelte`))}`,
265
267
  { fixStacktrace: false }
266
268
  );
267
269
 
268
270
  const paths = await vite.ssrLoadModule(
269
271
  true
270
- ? `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/runtime/paths.js`))}`
272
+ ? `/${posixify(path__default.relative(cwd$1, `${config.kit.outDir}/runtime/paths.js`))}`
271
273
  : `/@fs${runtime}/paths.js`,
272
274
  { fixStacktrace: false }
273
275
  );
@@ -286,7 +288,7 @@ async function create_plugin(config, cwd) {
286
288
  return res.end(err.reason || 'Invalid request body');
287
289
  }
288
290
 
289
- const template = load_template(cwd, config);
291
+ const template = load_template(cwd$1, config);
290
292
 
291
293
  const rendered = await respond(
292
294
  request,
@@ -328,7 +330,10 @@ async function create_plugin(config, cwd) {
328
330
  assets
329
331
  },
330
332
  prefix: '',
331
- prerender: config.kit.prerender.enabled,
333
+ prerender: {
334
+ default: config.kit.prerender.default,
335
+ enabled: config.kit.prerender.enabled
336
+ },
332
337
  read: (file) => fs__default.readFileSync(path__default.join(config.kit.files.assets, file)),
333
338
  root,
334
339
  router: config.kit.browser.router,
@@ -437,9 +442,10 @@ async function find_deps(vite, node, deps) {
437
442
  await Promise.all(branches);
438
443
  }
439
444
 
445
+ const cwd = process.cwd();
446
+
440
447
  /**
441
448
  * @typedef {{
442
- * cwd: string,
443
449
  * port: number,
444
450
  * host?: string,
445
451
  * https: boolean,
@@ -449,7 +455,7 @@ async function find_deps(vite, node, deps) {
449
455
  */
450
456
 
451
457
  /** @param {Options} opts */
452
- async function dev({ cwd, port, host, https, config }) {
458
+ async function dev({ port, host, https, config }) {
453
459
  init(config);
454
460
 
455
461
  const [vite_config] = deep_merge(
@@ -501,7 +507,7 @@ async function dev({ cwd, port, host, https, config }) {
501
507
  },
502
508
  configFile: false
503
509
  }),
504
- await create_plugin(config, cwd)
510
+ await create_plugin(config)
505
511
  ],
506
512
  base: '/'
507
513
  });
@@ -4,12 +4,12 @@ import { p as posixify, m as mkdirp, r as rimraf } from './filesystem.js';
4
4
  import { all } from './sync.js';
5
5
  import { p as print_config_conflicts, b as get_aliases, r as resolve_entry, g as get_runtime_path, l as load_template } from '../cli.js';
6
6
  import { g as generate_manifest } from './index3.js';
7
- import vite from 'vite';
7
+ import * as vite from 'vite';
8
8
  import { s } from './misc.js';
9
9
  import { d as deep_merge } from './object.js';
10
10
  import { svelte } from '@sveltejs/vite-plugin-svelte';
11
11
  import { pathToFileURL, URL as URL$1 } from 'url';
12
- import { installFetch } from '../install-fetch.js';
12
+ import { installPolyfills } from '../node/polyfills.js';
13
13
  import './write_tsconfig.js';
14
14
  import 'sade';
15
15
  import 'child_process';
@@ -22,6 +22,7 @@ import 'node:zlib';
22
22
  import 'node:stream';
23
23
  import 'node:util';
24
24
  import 'node:url';
25
+ import 'crypto';
25
26
 
26
27
  const absolute = /^([a-z]+:)?\/?\//;
27
28
  const scheme = /^[a-z]+:/;
@@ -388,7 +389,10 @@ export class Server {
388
389
  method_override: ${s(config.kit.methodOverride)},
389
390
  paths: { base, assets },
390
391
  prefix: assets + '/${config.kit.appDir}/',
391
- prerender: ${config.kit.prerender.enabled},
392
+ prerender: {
393
+ default: ${config.kit.prerender.default},
394
+ enabled: ${config.kit.prerender.enabled}
395
+ },
392
396
  read,
393
397
  root,
394
398
  service_worker: ${has_service_worker ? "base + '/service-worker.js'" : 'null'},
@@ -1065,7 +1069,7 @@ async function prerender({ config, entries, files, log }) {
1065
1069
  return prerendered;
1066
1070
  }
1067
1071
 
1068
- installFetch();
1072
+ installPolyfills();
1069
1073
 
1070
1074
  const server_root = join(config.kit.outDir, 'output');
1071
1075
 
@@ -1137,8 +1141,7 @@ async function prerender({ config, entries, files, log }) {
1137
1141
 
1138
1142
  const response = await server.respond(new Request(`http://sveltekit-prerender${encoded}`), {
1139
1143
  getClientAddress,
1140
- prerender: {
1141
- default: config.kit.prerender.default,
1144
+ prerendering: {
1142
1145
  dependencies
1143
1146
  }
1144
1147
  });
@@ -1274,9 +1277,8 @@ async function prerender({ config, entries, files, log }) {
1274
1277
 
1275
1278
  const rendered = await server.respond(new Request('http://sveltekit-prerender/[fallback]'), {
1276
1279
  getClientAddress,
1277
- prerender: {
1280
+ prerendering: {
1278
1281
  fallback: true,
1279
- default: false,
1280
1282
  dependencies: new Map()
1281
1283
  }
1282
1284
  });
@@ -5,7 +5,7 @@ import { join } from 'path';
5
5
  import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
6
6
  import { pathToFileURL } from 'url';
7
7
  import { getRequest, setResponse } from '../node.js';
8
- import { installFetch } from '../install-fetch.js';
8
+ import { installPolyfills } from '../node/polyfills.js';
9
9
  import 'querystring';
10
10
  import 'stream';
11
11
  import 'node:http';
@@ -15,6 +15,7 @@ import 'node:stream';
15
15
  import 'node:util';
16
16
  import 'node:url';
17
17
  import 'net';
18
+ import 'crypto';
18
19
 
19
20
  /** @typedef {import('http').IncomingMessage} Req */
20
21
  /** @typedef {import('http').ServerResponse} Res */
@@ -42,7 +43,7 @@ const mutable = (dir) =>
42
43
  * }} opts
43
44
  */
44
45
  async function preview({ port, host, config, https: use_https = false }) {
45
- installFetch();
46
+ installPolyfills();
46
47
 
47
48
  const { paths } = config.kit;
48
49
  const base = paths.base;
@@ -1,7 +1,7 @@
1
1
  import 'node:fs';
2
2
  import 'node:path';
3
3
  import { MessageChannel } from 'node:worker_threads';
4
- import { F as FormData, a as File } from '../install-fetch.js';
4
+ import { F as FormData, a as File } from '../node/polyfills.js';
5
5
  import 'node:http';
6
6
  import 'node:https';
7
7
  import 'node:zlib';
@@ -9,6 +9,7 @@ import 'node:stream';
9
9
  import 'node:util';
10
10
  import 'node:url';
11
11
  import 'net';
12
+ import 'crypto';
12
13
 
13
14
  globalThis.DOMException || (() => {
14
15
  const port = new MessageChannel().port1;
@@ -535,8 +535,8 @@ function count_occurrences(needle, haystack) {
535
535
  * @param {string[]} [files]
536
536
  */
537
537
  function list_files(dir, path = '', files = []) {
538
- fs__default.readdirSync(dir, { withFileTypes: true })
539
- .sort(({ name: a }, { name: b }) => {
538
+ fs__default.readdirSync(dir)
539
+ .sort((a, b) => {
540
540
  // sort each directory in (__layout, __error, everything else) order
541
541
  // so that we can trace layouts/errors immediately
542
542
 
@@ -553,10 +553,12 @@ function list_files(dir, path = '', files = []) {
553
553
  return a < b ? -1 : 1;
554
554
  })
555
555
  .forEach((file) => {
556
- const joined = path ? `${path}/${file.name}` : file.name;
556
+ const full = `${dir}/${file}`;
557
+ const stats = fs__default.statSync(full);
558
+ const joined = path ? `${path}/${file}` : file;
557
559
 
558
- if (file.isDirectory()) {
559
- list_files(`${dir}/${file.name}`, joined, files);
560
+ if (stats.isDirectory()) {
561
+ list_files(full, joined, files);
560
562
  } else {
561
563
  files.push(joined);
562
564
  }
@@ -55,6 +55,19 @@ function write_tsconfig(config, cwd = process.cwd()) {
55
55
  include.push(config_relative(`${dir}/**/*.svelte`));
56
56
  });
57
57
 
58
+ /** @type {Record<string, string[]>} */
59
+ const paths = {};
60
+ const alias = {
61
+ $lib: project_relative(config.kit.files.lib),
62
+ ...config.kit.alias
63
+ };
64
+ for (const [key, value] of Object.entries(alias)) {
65
+ if (fs__default.existsSync(project_relative(value))) {
66
+ paths[key] = [project_relative(value)];
67
+ paths[key + '/*'] = [project_relative(value) + '/*'];
68
+ }
69
+ }
70
+
58
71
  write_if_changed(
59
72
  out,
60
73
  JSON.stringify(
@@ -62,12 +75,7 @@ function write_tsconfig(config, cwd = process.cwd()) {
62
75
  compilerOptions: {
63
76
  // generated options
64
77
  baseUrl: config_relative('.'),
65
- paths: fs__default.existsSync(config.kit.files.lib)
66
- ? {
67
- $lib: [project_relative(config.kit.files.lib)],
68
- '$lib/*': [project_relative(config.kit.files.lib + '/*')]
69
- }
70
- : {},
78
+ paths,
71
79
  rootDirs: [config_relative('.'), './types'],
72
80
 
73
81
  // essential options
package/dist/cli.js CHANGED
@@ -290,12 +290,20 @@ function get_mime_lookup(manifest_data) {
290
290
 
291
291
  /** @param {import('types').ValidatedConfig} config */
292
292
  function get_aliases(config) {
293
+ /** @type {Record<string, string>} */
293
294
  const alias = {
294
295
  __GENERATED__: path__default.posix.join(config.kit.outDir, 'generated'),
295
296
  $app: `${get_runtime_path(config)}/app`,
297
+
298
+ // For now, we handle `$lib` specially here rather than make it a default value for
299
+ // `config.kit.alias` since it has special meaning for packaging, etc.
296
300
  $lib: config.kit.files.lib
297
301
  };
298
302
 
303
+ for (const [key, value] of Object.entries(config.kit.alias)) {
304
+ alias[key] = path__default.resolve(value);
305
+ }
306
+
299
307
  return alias;
300
308
  }
301
309
 
@@ -338,6 +346,18 @@ const options = object(
338
346
  return input;
339
347
  }),
340
348
 
349
+ alias: validate({}, (input, keypath) => {
350
+ if (typeof input !== 'object') {
351
+ throw new Error(`${keypath} should be an object`);
352
+ }
353
+
354
+ for (const key in input) {
355
+ assert_string(input[key], `${keypath}.${key}`);
356
+ }
357
+
358
+ return input;
359
+ }),
360
+
341
361
  // TODO: remove this for the 1.0 release
342
362
  amp: error(
343
363
  (keypath) =>
@@ -884,7 +904,7 @@ async function launch(port, https, base) {
884
904
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
885
905
  }
886
906
 
887
- const prog = sade('svelte-kit').version('1.0.0-next.339');
907
+ const prog = sade('svelte-kit').version('1.0.0-next.341');
888
908
 
889
909
  prog
890
910
  .command('dev')
@@ -906,10 +926,7 @@ prog
906
926
  async function start(config) {
907
927
  const { dev } = await import('./chunks/index.js');
908
928
 
909
- const cwd = process.cwd();
910
-
911
929
  const { address_info, server_config, close } = await dev({
912
- cwd,
913
930
  port,
914
931
  host,
915
932
  https,
@@ -923,8 +940,7 @@ prog
923
940
  open: first && (open || !!server_config.open),
924
941
  base: config.kit.paths.base,
925
942
  loose: server_config.fs.strict === false,
926
- allow: server_config.fs.allow,
927
- cwd
943
+ allow: server_config.fs.allow
928
944
  });
929
945
 
930
946
  first = false;
@@ -1106,7 +1122,7 @@ async function check_port(port) {
1106
1122
  function welcome({ port, host, https, open, base, loose, allow, cwd }) {
1107
1123
  if (open) launch(port, https, base);
1108
1124
 
1109
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.339'}\n`));
1125
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.341'}\n`));
1110
1126
 
1111
1127
  const protocol = https ? 'https:' : 'http:';
1112
1128
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
@@ -5,6 +5,9 @@ import Stream, { PassThrough, pipeline } from 'node:stream';
5
5
  import { types, deprecate } from 'node:util';
6
6
  import { format } from 'node:url';
7
7
  import { isIP } from 'net';
8
+ import { webcrypto } from 'crypto';
9
+
10
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
8
11
 
9
12
  /**
10
13
  * Returns a `Buffer` instance from the given data URI `uri`.
@@ -58,8 +61,6 @@ function dataUriToBuffer(uri) {
58
61
  return buffer;
59
62
  }
60
63
 
61
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
62
-
63
64
  var ponyfill_es2018 = {exports: {}};
64
65
 
65
66
  /**
@@ -4840,7 +4841,7 @@ class Body {
4840
4841
  return formData;
4841
4842
  }
4842
4843
 
4843
- const {toFormData} = await import('./chunks/multipart-parser.js');
4844
+ const {toFormData} = await import('../chunks/multipart-parser.js');
4844
4845
  return toFormData(this.body, ct);
4845
4846
  }
4846
4847
 
@@ -6489,30 +6490,25 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
6489
6490
  });
6490
6491
  }
6491
6492
 
6493
+ /** @type {Record<string, any>} */
6494
+ const globals = {
6495
+ crypto: webcrypto,
6496
+ fetch,
6497
+ Response,
6498
+ Request,
6499
+ Headers
6500
+ };
6501
+
6492
6502
  // exported for dev/preview and node environments
6493
- function installFetch() {
6494
- Object.defineProperties(globalThis, {
6495
- fetch: {
6496
- enumerable: true,
6497
- configurable: true,
6498
- value: fetch
6499
- },
6500
- Response: {
6503
+ function installPolyfills() {
6504
+ for (const name in globals) {
6505
+ // TODO use built-in fetch once https://github.com/nodejs/undici/issues/1262 is resolved
6506
+ Object.defineProperty(globalThis, name, {
6501
6507
  enumerable: true,
6502
6508
  configurable: true,
6503
- value: Response
6504
- },
6505
- Request: {
6506
- enumerable: true,
6507
- configurable: true,
6508
- value: Request
6509
- },
6510
- Headers: {
6511
- enumerable: true,
6512
- configurable: true,
6513
- value: Headers
6514
- }
6515
- });
6509
+ value: globals[name]
6510
+ });
6511
+ }
6516
6512
  }
6517
6513
 
6518
- export { FormData as F, File as a, commonjsGlobal as c, installFetch };
6514
+ export { FormData as F, File as a, commonjsGlobal as c, installPolyfills };
package/dist/node.js CHANGED
@@ -1,5 +1,208 @@
1
1
  import { Readable } from 'stream';
2
2
 
3
+ var setCookie = {exports: {}};
4
+
5
+ var defaultParseOptions = {
6
+ decodeValues: true,
7
+ map: false,
8
+ silent: false,
9
+ };
10
+
11
+ function isNonEmptyString(str) {
12
+ return typeof str === "string" && !!str.trim();
13
+ }
14
+
15
+ function parseString(setCookieValue, options) {
16
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
17
+ var nameValue = parts.shift().split("=");
18
+ var name = nameValue.shift();
19
+ var value = nameValue.join("="); // everything after the first =, joined by a "=" if there was more than one part
20
+
21
+ options = options
22
+ ? Object.assign({}, defaultParseOptions, options)
23
+ : defaultParseOptions;
24
+
25
+ try {
26
+ value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
27
+ } catch (e) {
28
+ console.error(
29
+ "set-cookie-parser encountered an error while decoding a cookie with value '" +
30
+ value +
31
+ "'. Set options.decodeValues to false to disable this feature.",
32
+ e
33
+ );
34
+ }
35
+
36
+ var cookie = {
37
+ name: name, // grab everything before the first =
38
+ value: value,
39
+ };
40
+
41
+ parts.forEach(function (part) {
42
+ var sides = part.split("=");
43
+ var key = sides.shift().trimLeft().toLowerCase();
44
+ var value = sides.join("=");
45
+ if (key === "expires") {
46
+ cookie.expires = new Date(value);
47
+ } else if (key === "max-age") {
48
+ cookie.maxAge = parseInt(value, 10);
49
+ } else if (key === "secure") {
50
+ cookie.secure = true;
51
+ } else if (key === "httponly") {
52
+ cookie.httpOnly = true;
53
+ } else if (key === "samesite") {
54
+ cookie.sameSite = value;
55
+ } else {
56
+ cookie[key] = value;
57
+ }
58
+ });
59
+
60
+ return cookie;
61
+ }
62
+
63
+ function parse(input, options) {
64
+ options = options
65
+ ? Object.assign({}, defaultParseOptions, options)
66
+ : defaultParseOptions;
67
+
68
+ if (!input) {
69
+ if (!options.map) {
70
+ return [];
71
+ } else {
72
+ return {};
73
+ }
74
+ }
75
+
76
+ if (input.headers && input.headers["set-cookie"]) {
77
+ // fast-path for node.js (which automatically normalizes header names to lower-case
78
+ input = input.headers["set-cookie"];
79
+ } else if (input.headers) {
80
+ // slow-path for other environments - see #25
81
+ var sch =
82
+ input.headers[
83
+ Object.keys(input.headers).find(function (key) {
84
+ return key.toLowerCase() === "set-cookie";
85
+ })
86
+ ];
87
+ // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
88
+ if (!sch && input.headers.cookie && !options.silent) {
89
+ console.warn(
90
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
91
+ );
92
+ }
93
+ input = sch;
94
+ }
95
+ if (!Array.isArray(input)) {
96
+ input = [input];
97
+ }
98
+
99
+ options = options
100
+ ? Object.assign({}, defaultParseOptions, options)
101
+ : defaultParseOptions;
102
+
103
+ if (!options.map) {
104
+ return input.filter(isNonEmptyString).map(function (str) {
105
+ return parseString(str, options);
106
+ });
107
+ } else {
108
+ var cookies = {};
109
+ return input.filter(isNonEmptyString).reduce(function (cookies, str) {
110
+ var cookie = parseString(str, options);
111
+ cookies[cookie.name] = cookie;
112
+ return cookies;
113
+ }, cookies);
114
+ }
115
+ }
116
+
117
+ /*
118
+ Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
119
+ that are within a single set-cookie field-value, such as in the Expires portion.
120
+
121
+ This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
122
+ Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
123
+ React Native's fetch does this for *every* header, including set-cookie.
124
+
125
+ Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
126
+ Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
127
+ */
128
+ function splitCookiesString(cookiesString) {
129
+ if (Array.isArray(cookiesString)) {
130
+ return cookiesString;
131
+ }
132
+ if (typeof cookiesString !== "string") {
133
+ return [];
134
+ }
135
+
136
+ var cookiesStrings = [];
137
+ var pos = 0;
138
+ var start;
139
+ var ch;
140
+ var lastComma;
141
+ var nextStart;
142
+ var cookiesSeparatorFound;
143
+
144
+ function skipWhitespace() {
145
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
146
+ pos += 1;
147
+ }
148
+ return pos < cookiesString.length;
149
+ }
150
+
151
+ function notSpecialChar() {
152
+ ch = cookiesString.charAt(pos);
153
+
154
+ return ch !== "=" && ch !== ";" && ch !== ",";
155
+ }
156
+
157
+ while (pos < cookiesString.length) {
158
+ start = pos;
159
+ cookiesSeparatorFound = false;
160
+
161
+ while (skipWhitespace()) {
162
+ ch = cookiesString.charAt(pos);
163
+ if (ch === ",") {
164
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
165
+ lastComma = pos;
166
+ pos += 1;
167
+
168
+ skipWhitespace();
169
+ nextStart = pos;
170
+
171
+ while (pos < cookiesString.length && notSpecialChar()) {
172
+ pos += 1;
173
+ }
174
+
175
+ // currently special character
176
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
177
+ // we found cookies separator
178
+ cookiesSeparatorFound = true;
179
+ // pos is inside the next cookie, so back up and return it.
180
+ pos = nextStart;
181
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
182
+ start = pos;
183
+ } else {
184
+ // in param ',' or param separator ';',
185
+ // we continue from that comma
186
+ pos = lastComma + 1;
187
+ }
188
+ } else {
189
+ pos += 1;
190
+ }
191
+ }
192
+
193
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
194
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
195
+ }
196
+ }
197
+
198
+ return cookiesStrings;
199
+ }
200
+
201
+ setCookie.exports = parse;
202
+ setCookie.exports.parse = parse;
203
+ setCookie.exports.parseString = parseString;
204
+ var splitCookiesString_1 = setCookie.exports.splitCookiesString = splitCookiesString;
205
+
3
206
  /** @param {import('http').IncomingMessage} req */
4
207
  function get_raw_body(req) {
5
208
  return new Promise((fulfil, reject) => {
@@ -56,6 +259,7 @@ async function getRequest(base, req) {
56
259
  if (req.httpVersionMajor === 2) {
57
260
  // we need to strip out the HTTP/2 pseudo-headers because node-fetch's
58
261
  // Request implementation doesn't like them
262
+ // TODO is this still true with Node 18
59
263
  headers = Object.assign({}, headers);
60
264
  delete headers[':method'];
61
265
  delete headers[':path'];
@@ -74,8 +278,11 @@ async function setResponse(res, response) {
74
278
  const headers = Object.fromEntries(response.headers);
75
279
 
76
280
  if (response.headers.has('set-cookie')) {
77
- // @ts-expect-error (headers.raw() is non-standard)
78
- headers['set-cookie'] = response.headers.raw()['set-cookie'];
281
+ const header = /** @type {string} */ (response.headers.get('set-cookie'));
282
+ const split = splitCookiesString_1(header);
283
+
284
+ // @ts-expect-error
285
+ headers['set-cookie'] = split;
79
286
  }
80
287
 
81
288
  res.writeHead(response.status, headers);
@@ -84,7 +291,7 @@ async function setResponse(res, response) {
84
291
  response.body.pipe(res);
85
292
  } else {
86
293
  if (response.body) {
87
- res.write(await response.arrayBuffer());
294
+ res.write(new Uint8Array(await response.arrayBuffer()));
88
295
  }
89
296
 
90
297
  res.end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.339",
3
+ "version": "1.0.0-next.341",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -52,11 +52,11 @@
52
52
  "./node": {
53
53
  "import": "./dist/node.js"
54
54
  },
55
+ "./node/polyfills": {
56
+ "import": "./dist/node/polyfills.js"
57
+ },
55
58
  "./hooks": {
56
59
  "import": "./dist/hooks.js"
57
- },
58
- "./install-fetch": {
59
- "import": "./dist/install-fetch.js"
60
60
  }
61
61
  },
62
62
  "types": "types/index.d.ts",
@@ -88,7 +88,7 @@ declare module '$app/env' {
88
88
  */
89
89
  declare module '$app/navigation' {
90
90
  /**
91
- * If called when the page is being updated following a navigation (in `onMount` or an action, for example), this disables SvelteKit's built-in scroll handling.
91
+ * If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling.
92
92
  * This is generally discouraged, since it breaks user expectations.
93
93
  */
94
94
  export function disableScrollHandling(): void;
@@ -283,11 +283,16 @@ declare module '@sveltejs/kit/hooks' {
283
283
  /**
284
284
  * A polyfill for `fetch` and its related interfaces, used by adapters for environments that don't provide a native implementation.
285
285
  */
286
- declare module '@sveltejs/kit/install-fetch' {
286
+ declare module '@sveltejs/kit/node/polyfills' {
287
287
  /**
288
- * Make `fetch`, `Headers`, `Request` and `Response` available as globals, via `node-fetch`
288
+ * Make various web APIs available as globals:
289
+ * - `crypto`
290
+ * - `fetch`
291
+ * - `Headers`
292
+ * - `Request`
293
+ * - `Response`
289
294
  */
290
- export function installFetch(): void;
295
+ export function installPolyfills(): void;
291
296
  }
292
297
 
293
298
  /**
package/types/index.d.ts CHANGED
@@ -93,6 +93,7 @@ export interface Config {
93
93
  extensions?: string[];
94
94
  kit?: {
95
95
  adapter?: Adapter;
96
+ alias?: Record<string, string>;
96
97
  appDir?: string;
97
98
  browser?: {
98
99
  hydrate?: boolean;
@@ -172,7 +173,7 @@ export interface HandleError {
172
173
  }
173
174
 
174
175
  /**
175
- * The `(input: LoadInput) => LoadOutput` `load` function exported from `<script context="module">` in a page or layout.
176
+ * The `(event: LoadEvent) => LoadOutput` `load` function exported from `<script context="module">` in a page or layout.
176
177
  *
177
178
  * Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the Params generic argument.
178
179
  */
@@ -181,10 +182,10 @@ export interface Load<
181
182
  InputProps extends Record<string, any> = Record<string, any>,
182
183
  OutputProps extends Record<string, any> = InputProps
183
184
  > {
184
- (input: LoadInput<Params, InputProps>): MaybePromise<LoadOutput<OutputProps>>;
185
+ (event: LoadEvent<Params, InputProps>): MaybePromise<LoadOutput<OutputProps>>;
185
186
  }
186
187
 
187
- export interface LoadInput<
188
+ export interface LoadEvent<
188
189
  Params extends Record<string, string> = Record<string, string>,
189
190
  Props extends Record<string, any> = Record<string, any>
190
191
  > {
@@ -94,7 +94,7 @@ export class InternalServer extends Server {
94
94
  respond(
95
95
  request: Request,
96
96
  options: RequestOptions & {
97
- prerender?: PrerenderOptions;
97
+ prerendering?: PrerenderOptions;
98
98
  }
99
99
  ): Promise<Response>;
100
100
  }
@@ -147,7 +147,6 @@ export interface PrerenderDependency {
147
147
 
148
148
  export interface PrerenderOptions {
149
149
  fallback?: boolean;
150
- default: boolean;
151
150
  dependencies: Map<string, PrerenderDependency>;
152
151
  }
153
152
 
@@ -254,7 +253,10 @@ export interface SSROptions {
254
253
  assets: string;
255
254
  };
256
255
  prefix: string;
257
- prerender: boolean;
256
+ prerender: {
257
+ default: boolean;
258
+ enabled: boolean;
259
+ };
258
260
  read(file: string): Buffer;
259
261
  root: SSRComponent['default'];
260
262
  router: boolean;
@@ -308,7 +310,7 @@ export interface SSRState {
308
310
  getClientAddress: () => string;
309
311
  initiator?: SSRPage | null;
310
312
  platform?: any;
311
- prerender?: PrerenderOptions;
313
+ prerendering?: PrerenderOptions;
312
314
  }
313
315
 
314
316
  export type StrictBody = string | Uint8Array;