@sveltejs/kit 2.20.5 → 2.20.7
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
|
@@ -2,7 +2,7 @@ import { HttpError, SvelteKitError, Redirect } from '../../control.js';
|
|
|
2
2
|
import { normalize_error } from '../../../utils/error.js';
|
|
3
3
|
import { once } from '../../../utils/functions.js';
|
|
4
4
|
import { load_server_data } from '../page/load_data.js';
|
|
5
|
-
import { clarify_devalue_error, handle_error_and_jsonify,
|
|
5
|
+
import { clarify_devalue_error, handle_error_and_jsonify, serialize_uses } from '../utils.js';
|
|
6
6
|
import { normalize_path } from '../../../utils/url.js';
|
|
7
7
|
import { text } from '../../../exports/index.js';
|
|
8
8
|
import * as devalue from 'devalue';
|
|
@@ -253,8 +253,8 @@ export function get_data_json(event, options, nodes) {
|
|
|
253
253
|
return JSON.stringify(node);
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
return `{"type":"data","data":${devalue.stringify(node.data, reducers)}
|
|
257
|
-
node
|
|
256
|
+
return `{"type":"data","data":${devalue.stringify(node.data, reducers)},"uses":${JSON.stringify(
|
|
257
|
+
serialize_uses(node)
|
|
258
258
|
)}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ''}}`;
|
|
259
259
|
});
|
|
260
260
|
|
|
@@ -263,6 +263,8 @@ export function get_data_json(event, options, nodes) {
|
|
|
263
263
|
chunks: count > 0 ? iterator : null
|
|
264
264
|
};
|
|
265
265
|
} catch (e) {
|
|
266
|
+
// @ts-expect-error
|
|
267
|
+
e.path = 'data' + e.path;
|
|
266
268
|
throw new Error(clarify_devalue_error(event, /** @type {any} */ (e)));
|
|
267
269
|
}
|
|
268
270
|
}
|
|
@@ -7,7 +7,7 @@ import { serialize_data } from './serialize_data.js';
|
|
|
7
7
|
import { s } from '../../../utils/misc.js';
|
|
8
8
|
import { Csp } from './csp.js';
|
|
9
9
|
import { uneval_action_response } from './actions.js';
|
|
10
|
-
import { clarify_devalue_error,
|
|
10
|
+
import { clarify_devalue_error, handle_error_and_jsonify, serialize_uses } from '../utils.js';
|
|
11
11
|
import { public_env, safe_public_env } from '../../shared-server.js';
|
|
12
12
|
import { text } from '../../../exports/index.js';
|
|
13
13
|
import { create_async_iterator } from '../../../utils/streaming.js';
|
|
@@ -646,9 +646,11 @@ function get_data(event, options, nodes, csp, global) {
|
|
|
646
646
|
const strings = nodes.map((node) => {
|
|
647
647
|
if (!node) return 'null';
|
|
648
648
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
649
|
+
/** @type {any} */
|
|
650
|
+
const payload = { type: 'data', data: node.data, uses: serialize_uses(node) };
|
|
651
|
+
if (node.slash) payload.slash = node.slash;
|
|
652
|
+
|
|
653
|
+
return devalue.uneval(payload, replacer);
|
|
652
654
|
});
|
|
653
655
|
|
|
654
656
|
return {
|
|
@@ -656,6 +658,8 @@ function get_data(event, options, nodes, csp, global) {
|
|
|
656
658
|
chunks: count > 0 ? iterator : null
|
|
657
659
|
};
|
|
658
660
|
} catch (e) {
|
|
661
|
+
// @ts-expect-error
|
|
662
|
+
e.path = e.path.slice(1);
|
|
659
663
|
throw new Error(clarify_devalue_error(event, /** @type {any} */ (e)));
|
|
660
664
|
}
|
|
661
665
|
}
|
|
@@ -133,7 +133,7 @@ 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} (
|
|
136
|
+
return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path})`;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
if (error.path === '') {
|
|
@@ -147,26 +147,26 @@ export function clarify_devalue_error(event, error) {
|
|
|
147
147
|
/**
|
|
148
148
|
* @param {import('types').ServerDataNode} node
|
|
149
149
|
*/
|
|
150
|
-
export function
|
|
151
|
-
const uses =
|
|
150
|
+
export function serialize_uses(node) {
|
|
151
|
+
const uses = {};
|
|
152
152
|
|
|
153
153
|
if (node.uses && node.uses.dependencies.size > 0) {
|
|
154
|
-
uses.
|
|
154
|
+
uses.dependencies = Array.from(node.uses.dependencies);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
if (node.uses && node.uses.search_params.size > 0) {
|
|
158
|
-
uses.
|
|
158
|
+
uses.search_params = Array.from(node.uses.search_params);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
if (node.uses && node.uses.params.size > 0) {
|
|
162
|
-
uses.
|
|
162
|
+
uses.params = Array.from(node.uses.params);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
if (node.uses?.parent) uses.
|
|
166
|
-
if (node.uses?.route) uses.
|
|
167
|
-
if (node.uses?.url) uses.
|
|
165
|
+
if (node.uses?.parent) uses.parent = 1;
|
|
166
|
+
if (node.uses?.route) uses.route = 1;
|
|
167
|
+
if (node.uses?.url) uses.url = 1;
|
|
168
168
|
|
|
169
|
-
return
|
|
169
|
+
return uses;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
package/src/version.js
CHANGED