@sveltejs/kit 1.17.1 → 1.18.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 +1 -1
- package/src/core/config/options.js +5 -0
- package/src/core/sync/write_server.js +1 -0
- package/src/runtime/server/data/index.js +2 -1
- package/src/runtime/server/page/index.js +2 -1
- package/src/runtime/server/page/load_data.js +13 -2
- package/src/runtime/server/page/respond_with_error.js +2 -1
- package/types/index.d.ts +10 -0
- package/types/internal.d.ts +1 -0
package/package.json
CHANGED
|
@@ -34,6 +34,7 @@ export const options = {
|
|
|
34
34
|
app_template_contains_nonce: ${template.includes('%sveltekit.nonce%')},
|
|
35
35
|
csp: ${s(config.kit.csp)},
|
|
36
36
|
csrf_check_origin: ${s(config.kit.csrf.checkOrigin)},
|
|
37
|
+
track_server_fetches: ${s(config.kit.dangerZone.trackServerFetches)},
|
|
37
38
|
embedded: ${config.kit.embedded},
|
|
38
39
|
env_public_prefix: '${config.kit.env.publicPrefix}',
|
|
39
40
|
hooks: null, // added lazily, via \`get_hooks\`
|
|
@@ -150,7 +150,8 @@ export async function render_page(event, page, options, manifest, state, resolve
|
|
|
150
150
|
if (parent) Object.assign(data, await parent.data);
|
|
151
151
|
}
|
|
152
152
|
return data;
|
|
153
|
-
}
|
|
153
|
+
},
|
|
154
|
+
track_server_fetches: options.track_server_fetches
|
|
154
155
|
});
|
|
155
156
|
} catch (e) {
|
|
156
157
|
load_error = /** @type {Error} */ (e);
|
|
@@ -10,10 +10,18 @@ import { validate_depends } from '../../shared.js';
|
|
|
10
10
|
* state: import('types').SSRState;
|
|
11
11
|
* node: import('types').SSRNode | undefined;
|
|
12
12
|
* parent: () => Promise<Record<string, any>>;
|
|
13
|
+
* track_server_fetches: boolean;
|
|
13
14
|
* }} opts
|
|
14
15
|
* @returns {Promise<import('types').ServerDataNode | null>}
|
|
15
16
|
*/
|
|
16
|
-
export async function load_server_data({
|
|
17
|
+
export async function load_server_data({
|
|
18
|
+
event,
|
|
19
|
+
state,
|
|
20
|
+
node,
|
|
21
|
+
parent,
|
|
22
|
+
// TODO 2.0: Remove this
|
|
23
|
+
track_server_fetches
|
|
24
|
+
}) {
|
|
17
25
|
if (!node?.server) return null;
|
|
18
26
|
|
|
19
27
|
let done = false;
|
|
@@ -51,7 +59,10 @@ export async function load_server_data({ event, state, node, parent }) {
|
|
|
51
59
|
);
|
|
52
60
|
}
|
|
53
61
|
|
|
54
|
-
|
|
62
|
+
// TODO 2.0: Remove this
|
|
63
|
+
if (track_server_fetches) {
|
|
64
|
+
uses.dependencies.add(url.href);
|
|
65
|
+
}
|
|
55
66
|
|
|
56
67
|
return event.fetch(info, init);
|
|
57
68
|
},
|
|
@@ -44,7 +44,8 @@ export async function respond_with_error({
|
|
|
44
44
|
event,
|
|
45
45
|
state,
|
|
46
46
|
node: default_layout,
|
|
47
|
-
parent: async () => ({})
|
|
47
|
+
parent: async () => ({}),
|
|
48
|
+
track_server_fetches: options.track_server_fetches
|
|
48
49
|
});
|
|
49
50
|
|
|
50
51
|
const server_data = await server_data_promise;
|
package/types/index.d.ts
CHANGED
|
@@ -343,6 +343,16 @@ export interface KitConfig {
|
|
|
343
343
|
*/
|
|
344
344
|
checkOrigin?: boolean;
|
|
345
345
|
};
|
|
346
|
+
/**
|
|
347
|
+
* Here be dragons. Enable at your peril.
|
|
348
|
+
*/
|
|
349
|
+
dangerZone?: {
|
|
350
|
+
/**
|
|
351
|
+
* Automatically add server-side `fetch`ed URLs to the `dependencies` map of `load` functions. This will expose secrets
|
|
352
|
+
* to the client if your URL contains them.
|
|
353
|
+
*/
|
|
354
|
+
trackServerFetches?: boolean;
|
|
355
|
+
};
|
|
346
356
|
/**
|
|
347
357
|
* Whether or not the app is embedded inside a larger app. If `true`, SvelteKit will add its event listeners related to navigation etc on the parent of `%sveltekit.body%` instead of `window`, and will pass `params` from the server rather than inferring them from `location.pathname`.
|
|
348
358
|
* @default false
|
package/types/internal.d.ts
CHANGED
|
@@ -333,6 +333,7 @@ export interface SSROptions {
|
|
|
333
333
|
app_template_contains_nonce: boolean;
|
|
334
334
|
csp: ValidatedConfig['kit']['csp'];
|
|
335
335
|
csrf_check_origin: boolean;
|
|
336
|
+
track_server_fetches: boolean;
|
|
336
337
|
embedded: boolean;
|
|
337
338
|
env_public_prefix: string;
|
|
338
339
|
hooks: ServerHooks;
|