@sveltejs/kit 1.12.0 → 1.14.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": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -38,7 +38,7 @@
38
38
  "svelte-preprocess": "^5.0.0",
39
39
  "typescript": "^4.9.4",
40
40
  "uvu": "^0.5.6",
41
- "vite": "^4.1.1"
41
+ "vite": "^4.2.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "svelte": "^3.54.0",
@@ -6,6 +6,11 @@
6
6
 
7
7
  <style>
8
8
  body {
9
+ --bg: white;
10
+ --fg: #222;
11
+ --divider: #ccc;
12
+ background: var(--bg);
13
+ color: var(--fg);
9
14
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
10
15
  Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
11
16
  display: flex;
@@ -30,7 +35,7 @@
30
35
  }
31
36
 
32
37
  .message {
33
- border-left: 1px solid #ccc;
38
+ border-left: 1px solid var(--divider);
34
39
  padding: 0 0 0 1rem;
35
40
  margin: 0 0 0 1rem;
36
41
  min-height: 2.5rem;
@@ -43,6 +48,14 @@
43
48
  font-size: 1em;
44
49
  margin: 0;
45
50
  }
51
+
52
+ @media (prefers-color-scheme: dark) {
53
+ body {
54
+ --bg: #222;
55
+ --fg: #ddd;
56
+ --divider: #666;
57
+ }
58
+ }
46
59
  </style>
47
60
  </head>
48
61
  <body>
@@ -35,6 +35,8 @@ import { validate_common_exports } from '../../utils/exports.js';
35
35
  import { compact } from '../../utils/array.js';
36
36
  import { validate_depends } from '../shared.js';
37
37
 
38
+ let errored = false;
39
+
38
40
  // We track the scroll position associated with each history entry in sessionStorage,
39
41
  // rather than on history.state itself, because when navigation is driven by
40
42
  // popstate it's too late to update the scroll position associated with the
@@ -1193,7 +1195,7 @@ export function create_client(app, target) {
1193
1195
  });
1194
1196
  }
1195
1197
 
1196
- if (__SVELTEKIT_DEV__ && status !== 404) {
1198
+ if (DEV && status !== 404) {
1197
1199
  console.error(
1198
1200
  'An error occurred while loading the page. This will cause a full page reload. (This message will only appear during development.)'
1199
1201
  );
@@ -1273,7 +1275,7 @@ export function create_client(app, target) {
1273
1275
  if (priority <= options.preload_data) {
1274
1276
  const intent = get_navigation_intent(/** @type {URL} */ (url), false);
1275
1277
  if (intent) {
1276
- if (__SVELTEKIT_DEV__) {
1278
+ if (DEV) {
1277
1279
  preload_data(intent).then((result) => {
1278
1280
  if (result.type === 'loaded' && result.state.error) {
1279
1281
  console.warn(
@@ -1327,6 +1329,12 @@ export function create_client(app, target) {
1327
1329
  if (error instanceof HttpError) {
1328
1330
  return error.body;
1329
1331
  }
1332
+
1333
+ if (DEV) {
1334
+ errored = true;
1335
+ console.warn('The next HMR update will cause the page to reload');
1336
+ }
1337
+
1330
1338
  return (
1331
1339
  app.hooks.handleError({ error, event }) ??
1332
1340
  /** @type {any} */ ({ message: event.route.id != null ? 'Internal Error' : 'Not Found' })
@@ -1947,4 +1955,12 @@ if (DEV) {
1947
1955
  }
1948
1956
  console_warn(...args);
1949
1957
  };
1958
+
1959
+ if (import.meta.hot) {
1960
+ import.meta.hot.on('vite:beforeUpdate', () => {
1961
+ if (errored) {
1962
+ location.reload();
1963
+ }
1964
+ });
1965
+ }
1950
1966
  }
@@ -1,3 +1,4 @@
1
+ import { DEV } from 'esm-env';
1
2
  import { json, text } from '../../exports/index.js';
2
3
  import { coalesce_to_error } from '../../utils/error.js';
3
4
  import { negotiate } from '../../utils/http.js';
@@ -52,7 +53,14 @@ export function allowed_methods(mod) {
52
53
  * @param {string} message
53
54
  */
54
55
  export function static_error_page(options, status, message) {
55
- return text(options.templates.error({ status, message }), {
56
+ let page = options.templates.error({ status, message });
57
+
58
+ if (DEV) {
59
+ // inject Vite HMR client, for easier debugging
60
+ page = page.replace('</head>', '<script type="module" src="/@vite/client"></script></head>');
61
+ }
62
+
63
+ return text(page, {
56
64
  headers: { 'content-type': 'text/html; charset=utf-8' },
57
65
  status
58
66
  });
package/types/index.d.ts CHANGED
@@ -87,7 +87,7 @@ export interface Builder {
87
87
  config: ValidatedConfig;
88
88
  /** Information about prerendered pages and assets, if any. */
89
89
  prerendered: Prerendered;
90
- /** An array of dynamic (not prerendered) routes */
90
+ /** An array of all routes (including prerendered) */
91
91
  routes: RouteDefinition[];
92
92
 
93
93
  /**
@@ -1264,6 +1264,7 @@ export interface SubmitFunction<
1264
1264
  data: FormData;
1265
1265
  form: HTMLFormElement;
1266
1266
  controller: AbortController;
1267
+ submitter: HTMLElement | null;
1267
1268
  cancel(): void;
1268
1269
  }): MaybePromise<
1269
1270
  | void