@sveltejs/kit 2.20.3 → 2.20.5
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
|
@@ -392,32 +392,6 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
392
392
|
}
|
|
393
393
|
});
|
|
394
394
|
|
|
395
|
-
async function align_exports() {
|
|
396
|
-
// This shameful hack allows us to load runtime server code via Vite
|
|
397
|
-
// while apps load `HttpError` and `Redirect` in Node, without
|
|
398
|
-
// causing `instanceof` checks to fail
|
|
399
|
-
const control_module_node = await import('../../../runtime/control.js');
|
|
400
|
-
const control_module_vite = await vite.ssrLoadModule(`${runtime_base}/control.js`);
|
|
401
|
-
|
|
402
|
-
control_module_node.replace_implementations({
|
|
403
|
-
ActionFailure: control_module_vite.ActionFailure,
|
|
404
|
-
HttpError: control_module_vite.HttpError,
|
|
405
|
-
Redirect: control_module_vite.Redirect,
|
|
406
|
-
SvelteKitError: control_module_vite.SvelteKitError
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
await align_exports();
|
|
410
|
-
const ws_send = vite.ws.send;
|
|
411
|
-
/** @param {any} args */
|
|
412
|
-
vite.ws.send = function (...args) {
|
|
413
|
-
// We need to reapply the patch after Vite did dependency optimizations
|
|
414
|
-
// because that clears the module resolutions
|
|
415
|
-
if (args[0]?.type === 'full-reload' && args[0].path === '*') {
|
|
416
|
-
void align_exports();
|
|
417
|
-
}
|
|
418
|
-
return ws_send.apply(vite.ws, args);
|
|
419
|
-
};
|
|
420
|
-
|
|
421
395
|
vite.middlewares.use((req, res, next) => {
|
|
422
396
|
const base = `${vite.config.server.https ? 'https' : 'http'}://${
|
|
423
397
|
req.headers[':authority'] || req.headers.host
|
|
@@ -678,7 +678,19 @@ Tips:
|
|
|
678
678
|
manualChunks: split ? undefined : () => 'bundle',
|
|
679
679
|
inlineDynamicImports: false
|
|
680
680
|
},
|
|
681
|
-
preserveEntrySignatures: 'strict'
|
|
681
|
+
preserveEntrySignatures: 'strict',
|
|
682
|
+
onwarn(warning, handler) {
|
|
683
|
+
if (
|
|
684
|
+
warning.code === 'MISSING_EXPORT' &&
|
|
685
|
+
warning.id === `${kit.outDir}/generated/client-optimized/app.js`
|
|
686
|
+
) {
|
|
687
|
+
// ignore e.g. undefined `handleError` hook when
|
|
688
|
+
// referencing `client_hooks.handleError`
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
handler(warning);
|
|
693
|
+
}
|
|
682
694
|
},
|
|
683
695
|
ssrEmitAssets: true,
|
|
684
696
|
target: ssr ? 'node18.13' : undefined
|
|
@@ -15,7 +15,7 @@ import('node:async_hooks')
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Returns the current `RequestEvent`. Can be used inside
|
|
18
|
+
* Returns the current `RequestEvent`. Can be used inside server hooks, server `load` functions, actions, and endpoints (and functions called by them).
|
|
19
19
|
*
|
|
20
20
|
* In environments without [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).
|
|
21
21
|
* @since 2.20.0
|
|
@@ -25,7 +25,7 @@ export function getRequestEvent() {
|
|
|
25
25
|
|
|
26
26
|
if (!event) {
|
|
27
27
|
let message =
|
|
28
|
-
'Can only read the current request event inside functions invoked during `handle`, such as server `load` functions, actions, and server
|
|
28
|
+
'Can only read the current request event inside functions invoked during `handle`, such as server `load` functions, actions, endpoints, and other server hooks.';
|
|
29
29
|
|
|
30
30
|
if (!als) {
|
|
31
31
|
message +=
|
package/src/runtime/control.js
CHANGED
|
@@ -61,27 +61,3 @@ export class ActionFailure {
|
|
|
61
61
|
this.data = data;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* This is a grotesque hack that, in dev, allows us to replace the implementations
|
|
67
|
-
* of these classes that you'd get by importing them from `@sveltejs/kit` with the
|
|
68
|
-
* ones that are imported via Vite and loaded internally, so that instanceof
|
|
69
|
-
* checks work even though SvelteKit imports this module via Vite and consumers
|
|
70
|
-
* import it via Node
|
|
71
|
-
* @param {{
|
|
72
|
-
* ActionFailure: typeof ActionFailure;
|
|
73
|
-
* HttpError: typeof HttpError;
|
|
74
|
-
* Redirect: typeof Redirect;
|
|
75
|
-
* SvelteKitError: typeof SvelteKitError;
|
|
76
|
-
* }} implementations
|
|
77
|
-
*/
|
|
78
|
-
export function replace_implementations(implementations) {
|
|
79
|
-
// @ts-expect-error
|
|
80
|
-
ActionFailure = implementations.ActionFailure; // eslint-disable-line no-class-assign
|
|
81
|
-
// @ts-expect-error
|
|
82
|
-
HttpError = implementations.HttpError; // eslint-disable-line no-class-assign
|
|
83
|
-
// @ts-expect-error
|
|
84
|
-
Redirect = implementations.Redirect; // eslint-disable-line no-class-assign
|
|
85
|
-
// @ts-expect-error
|
|
86
|
-
SvelteKitError = implementations.SvelteKitError; // eslint-disable-line no-class-assign
|
|
87
|
-
}
|
|
@@ -6,6 +6,7 @@ import { HttpError } from '../control.js';
|
|
|
6
6
|
import { fix_stack_trace } from '../shared-server.js';
|
|
7
7
|
import { ENDPOINT_METHODS } from '../../constants.js';
|
|
8
8
|
import { escape_html } from '../../utils/escape.js';
|
|
9
|
+
import { with_event } from '../app/server/event.js';
|
|
9
10
|
|
|
10
11
|
/** @param {any} body */
|
|
11
12
|
export function is_pojo(body) {
|
|
@@ -107,7 +108,11 @@ export async function handle_error_and_jsonify(event, options, error) {
|
|
|
107
108
|
const status = get_status(error);
|
|
108
109
|
const message = get_message(error);
|
|
109
110
|
|
|
110
|
-
return (
|
|
111
|
+
return (
|
|
112
|
+
(await with_event(event, () =>
|
|
113
|
+
options.hooks.handleError({ error, event, status, message })
|
|
114
|
+
)) ?? { message }
|
|
115
|
+
);
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
/**
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -2417,7 +2417,7 @@ declare module '$app/server' {
|
|
|
2417
2417
|
*/
|
|
2418
2418
|
export function read(asset: string): Response;
|
|
2419
2419
|
/**
|
|
2420
|
-
* Returns the current `RequestEvent`. Can be used inside
|
|
2420
|
+
* Returns the current `RequestEvent`. Can be used inside server hooks, server `load` functions, actions, and endpoints (and functions called by them).
|
|
2421
2421
|
*
|
|
2422
2422
|
* In environments without [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).
|
|
2423
2423
|
* @since 2.20.0
|