@sveltejs/kit 1.27.5 → 1.27.6

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": "1.27.5",
3
+ "version": "1.27.6",
4
4
  "description": "The fastest way to build Svelte apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,7 +32,6 @@
32
32
  "@types/sade": "^1.7.4",
33
33
  "@types/set-cookie-parser": "^2.4.2",
34
34
  "dts-buddy": "^0.2.4",
35
- "marked": "^9.0.0",
36
35
  "rollup": "^3.29.4",
37
36
  "svelte": "^4.2.2",
38
37
  "svelte-preprocess": "^5.0.4",
@@ -84,10 +83,10 @@
84
83
  "node": "^16.14 || >=18"
85
84
  },
86
85
  "scripts": {
87
- "lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
86
+ "lint": "prettier --config ../../.prettierrc --check .",
88
87
  "check": "tsc",
89
88
  "check:all": "tsc && pnpm -r --filter=\"./**\" check",
90
- "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
89
+ "format": "prettier --config ../../.prettierrc --write .",
91
90
  "test": "pnpm test:unit && pnpm test:integration",
92
91
  "test:integration": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test",
93
92
  "test:cross-platform:dev": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform:dev",
@@ -1,4 +1,4 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -11,8 +11,18 @@
11
11
  --divider: #ccc;
12
12
  background: var(--bg);
13
13
  color: var(--fg);
14
- font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
15
- Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
14
+ font-family:
15
+ system-ui,
16
+ -apple-system,
17
+ BlinkMacSystemFont,
18
+ 'Segoe UI',
19
+ Roboto,
20
+ Oxygen,
21
+ Ubuntu,
22
+ Cantarell,
23
+ 'Open Sans',
24
+ 'Helvetica Neue',
25
+ sans-serif;
16
26
  display: flex;
17
27
  align-items: center;
18
28
  justify-content: center;
@@ -40,28 +40,57 @@ export function write_root(manifest_data, output) {
40
40
  dedent`
41
41
  <!-- This file is generated by @sveltejs/kit — do not edit it! -->
42
42
  <script>
43
- import { setContext, afterUpdate, onMount, tick } from 'svelte';
43
+ import { setContext, ${isSvelte5Plus() ? '' : 'afterUpdate, '}onMount, tick } from 'svelte';
44
44
  import { browser } from '$app/environment';
45
45
 
46
46
  // stores
47
- export let stores;
48
- export let page;
49
-
50
- export let constructors;
51
- export let components = [];
52
- export let form;
53
- ${levels.map((l) => `export let data_${l} = null;`).join('\n')}
47
+ ${
48
+ isSvelte5Plus()
49
+ ? dedent`
50
+ let { stores, page, constructors, components = [], form, ${levels
51
+ .map((l) => `data_${l} = null`)
52
+ .join(', ')} } = $props();
53
+ `
54
+ : dedent`
55
+ export let stores;
56
+ export let page;
57
+
58
+ export let constructors;
59
+ export let components = [];
60
+ export let form;
61
+ ${levels.map((l) => `export let data_${l} = null;`).join('\n')}
62
+ `
63
+ }
54
64
 
55
65
  if (!browser) {
56
66
  setContext('__svelte__', stores);
57
67
  }
58
68
 
59
- $: stores.page.set(page);
60
- afterUpdate(stores.page.notify);
69
+ ${
70
+ isSvelte5Plus()
71
+ ? dedent`
72
+ if (browser) {
73
+ $effect.pre(() => stores.page.set(page));
74
+ } else {
75
+ stores.page.set(page);
76
+ }
77
+ `
78
+ : '$: stores.page.set(page);'
79
+ }
80
+ ${
81
+ isSvelte5Plus()
82
+ ? dedent`
83
+ $effect(() => {
84
+ stores;page;constructors;components;form;${levels.map((l) => `data_${l}`).join(';')};
85
+ stores.page.notify();
86
+ });
87
+ `
88
+ : 'afterUpdate(stores.page.notify);'
89
+ }
61
90
 
62
- let mounted = false;
63
- let navigated = false;
64
- let title = null;
91
+ let mounted = ${isSvelte5Plus() ? '$state(false)' : 'false'};
92
+ let navigated = ${isSvelte5Plus() ? '$state(false)' : 'false'};
93
+ let title = ${isSvelte5Plus() ? '$state(null)' : 'null'};
65
94
 
66
95
  onMount(() => {
67
96
  const unsubscribe = stores.page.subscribe(() => {
@@ -139,8 +139,9 @@ export function get_tsconfig(kit, include_base_url) {
139
139
  // This is required for svelte-package to work as expected
140
140
  // Can be overwritten
141
141
  lib: ['esnext', 'DOM', 'DOM.Iterable'],
142
- moduleResolution: 'node',
142
+ moduleResolution: 'node', // TODO change to "bundler" in SvelteKit v2
143
143
  module: 'esnext',
144
+ noEmit: true, // prevent tsconfig error "overwriting input files" - Vite handles the build and ignores this
144
145
  target: 'esnext',
145
146
 
146
147
  // TODO(v2): use the new flag verbatimModuleSyntax instead (requires support by Vite/Esbuild)
@@ -181,8 +182,8 @@ function validate_user_config(kit, cwd, out, config) {
181
182
  typeof extend === 'string'
182
183
  ? path.resolve(cwd, extend) === out
183
184
  : Array.isArray(extend)
184
- ? extend.some((e) => path.resolve(cwd, e) === out)
185
- : false;
185
+ ? extend.some((e) => path.resolve(cwd, e) === out)
186
+ : false;
186
187
 
187
188
  const options = config.options.compilerOptions || {};
188
189
 
@@ -42,12 +42,12 @@ export interface Adapter {
42
42
  type AwaitedPropertiesUnion<input extends Record<string, any> | void> = input extends void
43
43
  ? undefined // needs to be undefined, because void will break intellisense
44
44
  : input extends Record<string, any>
45
- ? {
46
- [key in keyof input]: Awaited<input[key]>;
47
- }
48
- : {} extends input // handles the any case
49
- ? input
50
- : unknown;
45
+ ? {
46
+ [key in keyof input]: Awaited<input[key]>;
47
+ }
48
+ : {} extends input // handles the any case
49
+ ? input
50
+ : unknown;
51
51
 
52
52
  export type AwaitedProperties<input extends Record<string, any> | void> =
53
53
  AwaitedPropertiesUnion<input> extends Record<string, any>
@@ -70,8 +70,8 @@ type OptionalUnion<
70
70
  type UnpackValidationError<T> = T extends ActionFailure<infer X>
71
71
  ? X
72
72
  : T extends void
73
- ? undefined // needs to be undefined, because void will corrupt union type
74
- : T;
73
+ ? undefined // needs to be undefined, because void will corrupt union type
74
+ : T;
75
75
 
76
76
  /**
77
77
  * This object is passed to the `adapt` function of adapters.
@@ -55,6 +55,17 @@ function update_scroll_positions(index) {
55
55
  scroll_positions[index] = scroll_state();
56
56
  }
57
57
 
58
+ /**
59
+ * Loads `href` the old-fashioned way, with a full page reload.
60
+ * Returns a `Promise` that never resolves (to prevent any
61
+ * subsequent work, e.g. history manipulation, from happening)
62
+ * @param {URL} url
63
+ */
64
+ function native_navigation(url) {
65
+ location.href = url.href;
66
+ return new Promise(() => {});
67
+ }
68
+
58
69
  /**
59
70
  * @param {import('./types.js').SvelteKitApp} app
60
71
  * @param {HTMLElement} target
@@ -535,10 +546,10 @@ export function create_client(app, target) {
535
546
  typeof data !== 'object'
536
547
  ? `a ${typeof data}`
537
548
  : data instanceof Response
538
- ? 'a Response object'
539
- : Array.isArray(data)
540
- ? 'an array'
541
- : 'a non-plain object'
549
+ ? 'a Response object'
550
+ : Array.isArray(data)
551
+ ? 'an array'
552
+ : 'a non-plain object'
542
553
  }, but must return a plain object at the top level (i.e. \`return {...}\`)`
543
554
  );
544
555
  }
@@ -1196,17 +1207,6 @@ export function create_client(app, target) {
1196
1207
  return await native_navigation(url);
1197
1208
  }
1198
1209
 
1199
- /**
1200
- * Loads `href` the old-fashioned way, with a full page reload.
1201
- * Returns a `Promise` that never resolves (to prevent any
1202
- * subsequent work, e.g. history manipulation, from happening)
1203
- * @param {URL} url
1204
- */
1205
- function native_navigation(url) {
1206
- location.href = url.href;
1207
- return new Promise(() => {});
1208
- }
1209
-
1210
1210
  if (import.meta.hot) {
1211
1211
  import.meta.hot.on('vite:beforeUpdate', () => {
1212
1212
  if (current.error) location.reload();
@@ -1842,7 +1842,7 @@ export function create_client(app, target) {
1842
1842
  /**
1843
1843
  * @param {URL} url
1844
1844
  * @param {boolean[]} invalid
1845
- * @returns {Promise<import('types').ServerNodesResponse |import('types').ServerRedirectNode>}
1845
+ * @returns {Promise<import('types').ServerNodesResponse | import('types').ServerRedirectNode>}
1846
1846
  */
1847
1847
  async function load_data(url, invalid) {
1848
1848
  const data_url = new URL(url);
@@ -1857,13 +1857,19 @@ async function load_data(url, invalid) {
1857
1857
 
1858
1858
  const res = await native_fetch(data_url.href);
1859
1859
 
1860
+ // if `__data.json` doesn't exist or the server has an internal error,
1861
+ // fallback to native navigation so we avoid parsing the HTML error page as a JSON
1862
+ if (res.headers.get('content-type')?.includes('text/html')) {
1863
+ await native_navigation(url);
1864
+ }
1865
+
1860
1866
  if (!res.ok) {
1861
1867
  // error message is a JSON-stringified string which devalue can't handle at the top level
1862
1868
  // turn it into a HttpError to not call handleError on the client again (was already handled on the server)
1863
1869
  throw new HttpError(res.status, await res.json());
1864
1870
  }
1865
1871
 
1866
- // TODO: fix eslint error
1872
+ // TODO: fix eslint error / figure out if it actually applies to our situation
1867
1873
  // eslint-disable-next-line
1868
1874
  return new Promise(async (resolve) => {
1869
1875
  /**
@@ -1 +1 @@
1
- <slot></slot>
1
+ <slot />
@@ -291,7 +291,7 @@ export async function render_page(event, page, options, manifest, state, resolve
291
291
  resolve_opts,
292
292
  page_config: {
293
293
  csr: get_option(nodes, 'csr') ?? true,
294
- ssr: true
294
+ ssr: get_option(nodes, 'ssr') ?? true
295
295
  },
296
296
  status,
297
297
  error: null,
@@ -359,10 +359,10 @@ function validate_load_response(data, routeId) {
359
359
  typeof data !== 'object'
360
360
  ? `a ${typeof data}`
361
361
  : data instanceof Response
362
- ? 'a Response object'
363
- : Array.isArray(data)
364
- ? 'an array'
365
- : 'a non-plain object'
362
+ ? 'a Response object'
363
+ : Array.isArray(data)
364
+ ? 'an array'
365
+ : 'a non-plain object'
366
366
  }, but must return a plain object at the top level (i.e. \`return {...}\`)`
367
367
  );
368
368
  }
@@ -341,8 +341,8 @@ export async function respond(request, options, manifest, state) {
341
341
  const response = is_data_request
342
342
  ? redirect_json_response(e)
343
343
  : route?.page && is_action_json_request(event)
344
- ? action_json_redirect(e)
345
- : redirect_response(e.status, e.location);
344
+ ? action_json_redirect(e)
345
+ : redirect_response(e.status, e.location);
346
346
  add_cookies_to_headers(response.headers, Object.values(cookies_to_add));
347
347
  return response;
348
348
  }
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 = '1.27.5';
4
+ export const VERSION = '1.27.6';
package/types/index.d.ts CHANGED
@@ -22,12 +22,12 @@ declare module '@sveltejs/kit' {
22
22
  type AwaitedPropertiesUnion<input extends Record<string, any> | void> = input extends void
23
23
  ? undefined // needs to be undefined, because void will break intellisense
24
24
  : input extends Record<string, any>
25
- ? {
26
- [key in keyof input]: Awaited<input[key]>;
27
- }
28
- : {} extends input // handles the any case
29
- ? input
30
- : unknown;
25
+ ? {
26
+ [key in keyof input]: Awaited<input[key]>;
27
+ }
28
+ : {} extends input // handles the any case
29
+ ? input
30
+ : unknown;
31
31
 
32
32
  export type AwaitedProperties<input extends Record<string, any> | void> =
33
33
  AwaitedPropertiesUnion<input> extends Record<string, any>
@@ -50,8 +50,8 @@ declare module '@sveltejs/kit' {
50
50
  type UnpackValidationError<T> = T extends ActionFailure<infer X>
51
51
  ? X
52
52
  : T extends void
53
- ? undefined // needs to be undefined, because void will corrupt union type
54
- : T;
53
+ ? undefined // needs to be undefined, because void will corrupt union type
54
+ : T;
55
55
 
56
56
  /**
57
57
  * This object is passed to the `adapt` function of adapters.