@sveltejs/kit 2.23.0 → 2.25.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "2.23.0",
3
+ "version": "2.25.0",
4
4
  "description": "SvelteKit is the fastest way to build Svelte apps",
5
5
  "keywords": [
6
6
  "framework",
@@ -35,7 +35,7 @@
35
35
  "@playwright/test": "^1.51.1",
36
36
  "@sveltejs/vite-plugin-svelte": "^6.0.0-next.3",
37
37
  "@types/connect": "^3.4.38",
38
- "@types/node": "^18.19.48",
38
+ "@types/node": "^18.19.119",
39
39
  "@types/set-cookie-parser": "^2.4.7",
40
40
  "dts-buddy": "^0.6.1",
41
41
  "rollup": "^4.14.2",
@@ -67,6 +67,9 @@ export async function load_config({ cwd = process.cwd() } = {}) {
67
67
  .filter((f) => fs.existsSync(f));
68
68
 
69
69
  if (config_files.length === 0) {
70
+ console.log(
71
+ `No Svelte config file found in ${cwd} - using SvelteKit's default configuration without an adapter.`
72
+ );
70
73
  return process_config({}, { cwd });
71
74
  }
72
75
  const config_file = config_files[0];
@@ -36,25 +36,25 @@ export function write_root(manifest_data, output) {
36
36
  isSvelte5Plus()
37
37
  ? dedent`{@const Pyramid_${l} = constructors[${l}]}
38
38
  <!-- svelte-ignore binding_property_non_reactive -->
39
- <Pyramid_${l} bind:this={components[${l}]} data={data_${l}} {form}>
39
+ <Pyramid_${l} bind:this={components[${l}]} data={data_${l}} {form} params={page.params}>
40
40
  ${pyramid}
41
41
  </Pyramid_${l}>`
42
- : dedent`<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}}>
42
+ : dedent`<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} params={page.params}>
43
43
  ${pyramid}
44
44
  </svelte:component>`
45
45
  }
46
-
46
+
47
47
  {:else}
48
48
  ${
49
49
  isSvelte5Plus()
50
50
  ? dedent`
51
51
  {@const Pyramid_${l} = constructors[${l}]}
52
52
  <!-- svelte-ignore binding_property_non_reactive -->
53
- <Pyramid_${l} bind:this={components[${l}]} data={data_${l}} {form} />
53
+ <Pyramid_${l} bind:this={components[${l}]} data={data_${l}} {form} params={page.params} />
54
54
  `
55
- : dedent`<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} {form} />`
55
+ : dedent`<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} {form} params={page.params} />`
56
56
  }
57
-
57
+
58
58
  {/if}
59
59
  `;
60
60
  }
@@ -272,9 +272,11 @@ function update_types(config, routes, route, to_delete = new Set()) {
272
272
  }
273
273
 
274
274
  if (route.leaf.server) {
275
- exports.push('export type PageProps = { data: PageData; form: ActionData }');
275
+ exports.push(
276
+ 'export type PageProps = { params: RouteParams; data: PageData; form: ActionData }'
277
+ );
276
278
  } else {
277
- exports.push('export type PageProps = { data: PageData }');
279
+ exports.push('export type PageProps = { params: RouteParams; data: PageData }');
278
280
  }
279
281
  }
280
282
 
@@ -341,7 +343,7 @@ function update_types(config, routes, route, to_delete = new Set()) {
341
343
  if (proxies.universal?.modified) to_delete.delete(proxies.universal.file_name);
342
344
 
343
345
  exports.push(
344
- 'export type LayoutProps = { data: LayoutData; children: import("svelte").Snippet }'
346
+ 'export type LayoutProps = { params: LayoutParams; data: LayoutData; children: import("svelte").Snippet }'
345
347
  );
346
348
  }
347
349
 
@@ -1302,7 +1302,7 @@ export interface ServerInitOptions {
1302
1302
  /** A map of environment variables. */
1303
1303
  env: Record<string, string>;
1304
1304
  /** A function that turns an asset filename into a `ReadableStream`. Required for the `read` export from `$app/server` to work. */
1305
- read?: (file: string) => ReadableStream;
1305
+ read?: (file: string) => MaybePromise<ReadableStream | null>;
1306
1306
  }
1307
1307
 
1308
1308
  export interface SSRManifest {
@@ -3,6 +3,7 @@
3
3
  * @param {string} key
4
4
  * @param {(value: string) => any} parse
5
5
  */
6
+ /*@__NO_SIDE_EFFECTS__*/
6
7
  export function get(key, parse = JSON.parse) {
7
8
  try {
8
9
  return parse(sessionStorage[key]);
@@ -36,10 +36,7 @@ export class Server {
36
36
  }
37
37
 
38
38
  /**
39
- * @param {{
40
- * env: Record<string, string>;
41
- * read?: (file: string) => ReadableStream;
42
- * }} opts
39
+ * @param {import('@sveltejs/kit').ServerInitOptions} opts
43
40
  */
44
41
  async init({ env, read }) {
45
42
  // Take care: Some adapters may have to call `Server.init` per-request to set env vars,
@@ -64,7 +61,41 @@ export class Server {
64
61
  set_safe_public_env(public_env);
65
62
 
66
63
  if (read) {
67
- set_read_implementation(read);
64
+ // Wrap the read function to handle MaybePromise<ReadableStream>
65
+ // and ensure the public API stays synchronous
66
+ /** @param {string} file */
67
+ const wrapped_read = (file) => {
68
+ const result = read(file);
69
+ if (result instanceof ReadableStream) {
70
+ return result;
71
+ } else {
72
+ return new ReadableStream({
73
+ async start(controller) {
74
+ try {
75
+ const stream = await Promise.resolve(result);
76
+ if (!stream) {
77
+ controller.close();
78
+ return;
79
+ }
80
+
81
+ const reader = stream.getReader();
82
+
83
+ while (true) {
84
+ const { done, value } = await reader.read();
85
+ if (done) break;
86
+ controller.enqueue(value);
87
+ }
88
+
89
+ controller.close();
90
+ } catch (error) {
91
+ controller.error(error);
92
+ }
93
+ }
94
+ });
95
+ }
96
+ };
97
+
98
+ set_read_implementation(wrapped_read);
68
99
  }
69
100
 
70
101
  // During DEV and for some adapters this function might be called in quick succession,
@@ -133,7 +133,10 @@ export function redirect_response(status, location) {
133
133
  */
134
134
  export function clarify_devalue_error(event, error) {
135
135
  if (error.path) {
136
- return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path})`;
136
+ return (
137
+ `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path}). ` +
138
+ `If you need to serialize/deserialize custom types, use transport hooks: https://svelte.dev/docs/kit/hooks#Universal-hooks-transport.`
139
+ );
137
140
  }
138
141
 
139
142
  if (error.path === '') {
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // generated during release, do not modify
2
2
 
3
3
  /** @type {string} */
4
- export const VERSION = '2.23.0';
4
+ export const VERSION = '2.25.0';
package/types/index.d.ts CHANGED
@@ -1284,7 +1284,7 @@ declare module '@sveltejs/kit' {
1284
1284
  /** A map of environment variables. */
1285
1285
  env: Record<string, string>;
1286
1286
  /** A function that turns an asset filename into a `ReadableStream`. Required for the `read` export from `$app/server` to work. */
1287
- read?: (file: string) => ReadableStream;
1287
+ read?: (file: string) => MaybePromise<ReadableStream | null>;
1288
1288
  }
1289
1289
 
1290
1290
  export interface SSRManifest {