@sveltejs/kit 1.0.0-next.50 → 1.0.0-next.501
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/README.md +12 -9
- package/package.json +94 -67
- package/postinstall.js +38 -0
- package/scripts/special-types/$env+dynamic+private.md +10 -0
- package/scripts/special-types/$env+dynamic+public.md +8 -0
- package/scripts/special-types/$env+static+private.md +19 -0
- package/scripts/special-types/$env+static+public.md +7 -0
- package/scripts/special-types/$lib.md +5 -0
- package/src/cli.js +108 -0
- package/src/constants.js +7 -0
- package/src/core/adapt/builder.js +206 -0
- package/src/core/adapt/index.js +31 -0
- package/src/core/config/default-error.html +56 -0
- package/src/core/config/index.js +110 -0
- package/src/core/config/options.js +504 -0
- package/src/core/config/types.d.ts +1 -0
- package/src/core/env.js +121 -0
- package/src/core/generate_manifest/index.js +93 -0
- package/src/core/prerender/crawl.js +198 -0
- package/src/core/prerender/entities.js +2252 -0
- package/src/core/prerender/prerender.js +431 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/index.js +488 -0
- package/src/core/sync/create_manifest_data/types.d.ts +37 -0
- package/src/core/sync/sync.js +70 -0
- package/src/core/sync/utils.js +33 -0
- package/src/core/sync/write_ambient.js +53 -0
- package/src/core/sync/write_client_manifest.js +106 -0
- package/src/core/sync/write_matchers.js +25 -0
- package/src/core/sync/write_root.js +91 -0
- package/src/core/sync/write_tsconfig.js +195 -0
- package/src/core/sync/write_types/index.js +678 -0
- package/src/core/utils.js +70 -0
- package/src/exports/hooks/index.js +1 -0
- package/src/exports/hooks/sequence.js +44 -0
- package/src/exports/index.js +45 -0
- package/src/exports/node/index.js +173 -0
- package/src/exports/node/polyfills.js +41 -0
- package/src/exports/vite/build/build_server.js +378 -0
- package/src/exports/vite/build/build_service_worker.js +90 -0
- package/src/exports/vite/build/utils.js +180 -0
- package/src/exports/vite/dev/index.js +577 -0
- package/src/exports/vite/graph_analysis/index.js +277 -0
- package/src/exports/vite/graph_analysis/types.d.ts +5 -0
- package/src/exports/vite/graph_analysis/utils.js +30 -0
- package/src/exports/vite/index.js +598 -0
- package/src/exports/vite/preview/index.js +189 -0
- package/src/exports/vite/types.d.ts +3 -0
- package/src/exports/vite/utils.js +157 -0
- package/src/runtime/app/env.js +1 -0
- package/src/runtime/app/environment.js +11 -0
- package/src/runtime/app/forms.js +114 -0
- package/src/runtime/app/navigation.js +23 -0
- package/src/runtime/app/paths.js +1 -0
- package/src/runtime/app/stores.js +102 -0
- package/src/runtime/client/ambient.d.ts +30 -0
- package/src/runtime/client/client.js +1585 -0
- package/src/runtime/client/fetcher.js +107 -0
- package/src/runtime/client/parse.js +60 -0
- package/src/runtime/client/singletons.js +21 -0
- package/src/runtime/client/start.js +37 -0
- package/src/runtime/client/types.d.ts +84 -0
- package/src/runtime/client/utils.js +159 -0
- package/src/runtime/components/error.svelte +16 -0
- package/{assets → src/runtime}/components/layout.svelte +0 -0
- package/src/runtime/control.js +98 -0
- package/src/runtime/env/dynamic/private.js +1 -0
- package/src/runtime/env/dynamic/public.js +1 -0
- package/src/runtime/env-private.js +6 -0
- package/src/runtime/env-public.js +6 -0
- package/src/runtime/env.js +6 -0
- package/src/runtime/hash.js +16 -0
- package/src/runtime/paths.js +11 -0
- package/src/runtime/server/cookie.js +127 -0
- package/src/runtime/server/data/index.js +136 -0
- package/src/runtime/server/endpoint.js +90 -0
- package/src/runtime/server/index.js +340 -0
- package/src/runtime/server/page/actions.js +243 -0
- package/src/runtime/server/page/crypto.js +239 -0
- package/src/runtime/server/page/csp.js +250 -0
- package/src/runtime/server/page/fetch.js +301 -0
- package/src/runtime/server/page/index.js +304 -0
- package/src/runtime/server/page/load_data.js +112 -0
- package/src/runtime/server/page/render.js +342 -0
- package/src/runtime/server/page/respond_with_error.js +104 -0
- package/src/runtime/server/page/serialize_data.js +87 -0
- package/src/runtime/server/page/types.d.ts +41 -0
- package/src/runtime/server/utils.js +179 -0
- package/src/utils/array.js +9 -0
- package/src/utils/error.js +22 -0
- package/src/utils/escape.js +46 -0
- package/src/utils/filesystem.js +137 -0
- package/src/utils/functions.js +16 -0
- package/src/utils/http.js +55 -0
- package/src/utils/misc.js +1 -0
- package/src/utils/promises.js +17 -0
- package/src/utils/routing.js +117 -0
- package/src/utils/unit_test.js +11 -0
- package/src/utils/url.js +142 -0
- package/svelte-kit.js +1 -1
- package/types/ambient.d.ts +426 -0
- package/types/index.d.ts +444 -0
- package/types/internal.d.ts +378 -0
- package/types/private.d.ts +224 -0
- package/CHANGELOG.md +0 -484
- package/assets/components/error.svelte +0 -13
- package/assets/runtime/app/env.js +0 -5
- package/assets/runtime/app/navigation.js +0 -44
- package/assets/runtime/app/paths.js +0 -1
- package/assets/runtime/app/stores.js +0 -93
- package/assets/runtime/chunks/utils.js +0 -22
- package/assets/runtime/internal/singletons.js +0 -23
- package/assets/runtime/internal/start.js +0 -779
- package/assets/runtime/paths.js +0 -12
- package/dist/chunks/index.js +0 -3516
- package/dist/chunks/index2.js +0 -587
- package/dist/chunks/index3.js +0 -246
- package/dist/chunks/index4.js +0 -528
- package/dist/chunks/index5.js +0 -763
- package/dist/chunks/index6.js +0 -322
- package/dist/chunks/standard.js +0 -99
- package/dist/chunks/utils.js +0 -83
- package/dist/cli.js +0 -550
- package/dist/ssr.js +0 -2588
- package/types.d.ts +0 -89
- package/types.internal.d.ts +0 -191
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { devalue } from 'devalue';
|
|
2
|
+
import { DATA_SUFFIX } from '../../../constants.js';
|
|
3
|
+
import { compact } from '../../../utils/array.js';
|
|
4
|
+
import { normalize_error } from '../../../utils/error.js';
|
|
5
|
+
import { HttpError, Redirect } from '../../control.js';
|
|
6
|
+
import {
|
|
7
|
+
get_option,
|
|
8
|
+
redirect_response,
|
|
9
|
+
static_error_page,
|
|
10
|
+
handle_error_and_jsonify
|
|
11
|
+
} from '../utils.js';
|
|
12
|
+
import {
|
|
13
|
+
handle_action_json_request,
|
|
14
|
+
handle_action_request,
|
|
15
|
+
is_action_json_request,
|
|
16
|
+
is_action_request
|
|
17
|
+
} from './actions.js';
|
|
18
|
+
import { create_fetch } from './fetch.js';
|
|
19
|
+
import { load_data, load_server_data } from './load_data.js';
|
|
20
|
+
import { render_response } from './render.js';
|
|
21
|
+
import { respond_with_error } from './respond_with_error.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {import('types').RequestEvent} event
|
|
25
|
+
* @param {import('types').SSRRoute} route
|
|
26
|
+
* @param {import('types').PageNodeIndexes} page
|
|
27
|
+
* @param {import('types').SSROptions} options
|
|
28
|
+
* @param {import('types').SSRState} state
|
|
29
|
+
* @param {import('types').RequiredResolveOptions} resolve_opts
|
|
30
|
+
* @returns {Promise<Response>}
|
|
31
|
+
*/
|
|
32
|
+
export async function render_page(event, route, page, options, state, resolve_opts) {
|
|
33
|
+
if (state.initiator === route) {
|
|
34
|
+
// infinite request cycle detected
|
|
35
|
+
return new Response(`Not found: ${event.url.pathname}`, {
|
|
36
|
+
status: 404
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (is_action_json_request(event)) {
|
|
41
|
+
const node = await options.manifest._.nodes[page.leaf]();
|
|
42
|
+
if (node.server) {
|
|
43
|
+
return handle_action_json_request(event, options, node.server);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const nodes = await Promise.all([
|
|
49
|
+
// we use == here rather than === because [undefined] serializes as "[null]"
|
|
50
|
+
...page.layouts.map((n) => (n == undefined ? n : options.manifest._.nodes[n]())),
|
|
51
|
+
options.manifest._.nodes[page.leaf]()
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
const leaf_node = /** @type {import('types').SSRNode} */ (nodes.at(-1));
|
|
55
|
+
|
|
56
|
+
let status = 200;
|
|
57
|
+
|
|
58
|
+
/** @type {import('types').ActionResult | undefined} */
|
|
59
|
+
let action_result = undefined;
|
|
60
|
+
|
|
61
|
+
if (is_action_request(event, leaf_node)) {
|
|
62
|
+
// for action requests, first call handler in +page.server.js
|
|
63
|
+
// (this also determines status code)
|
|
64
|
+
action_result = await handle_action_request(event, leaf_node.server);
|
|
65
|
+
if (action_result?.type === 'redirect') {
|
|
66
|
+
return redirect_response(303, action_result.location);
|
|
67
|
+
}
|
|
68
|
+
if (action_result?.type === 'error') {
|
|
69
|
+
const error = action_result.error;
|
|
70
|
+
status = error instanceof HttpError ? error.status : 500;
|
|
71
|
+
}
|
|
72
|
+
if (action_result?.type === 'invalid') {
|
|
73
|
+
status = action_result.status;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const should_prerender_data = nodes.some((node) => node?.server);
|
|
78
|
+
const data_pathname = event.url.pathname.replace(/\/$/, '') + DATA_SUFFIX;
|
|
79
|
+
|
|
80
|
+
// it's crucial that we do this before returning the non-SSR response, otherwise
|
|
81
|
+
// SvelteKit will erroneously believe that the path has been prerendered,
|
|
82
|
+
// causing functions to be omitted from the manifesst generated later
|
|
83
|
+
const should_prerender = get_option(nodes, 'prerender') ?? false;
|
|
84
|
+
if (should_prerender) {
|
|
85
|
+
const mod = leaf_node.server;
|
|
86
|
+
if (mod && mod.actions) {
|
|
87
|
+
throw new Error('Cannot prerender pages with actions');
|
|
88
|
+
}
|
|
89
|
+
} else if (state.prerendering) {
|
|
90
|
+
// if the page isn't marked as prerenderable, then bail out at this point
|
|
91
|
+
return new Response(undefined, {
|
|
92
|
+
status: 204
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const { fetcher, fetched, cookies } = create_fetch({
|
|
97
|
+
event,
|
|
98
|
+
options,
|
|
99
|
+
state,
|
|
100
|
+
route,
|
|
101
|
+
prerender_default: should_prerender,
|
|
102
|
+
resolve_opts
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
if (get_option(nodes, 'ssr') === false) {
|
|
106
|
+
return await render_response({
|
|
107
|
+
branch: [],
|
|
108
|
+
fetched,
|
|
109
|
+
cookies,
|
|
110
|
+
page_config: {
|
|
111
|
+
ssr: false,
|
|
112
|
+
csr: get_option(nodes, 'csr') ?? true
|
|
113
|
+
},
|
|
114
|
+
status,
|
|
115
|
+
error: null,
|
|
116
|
+
event,
|
|
117
|
+
options,
|
|
118
|
+
state,
|
|
119
|
+
resolve_opts
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** @type {Array<import('./types.js').Loaded | null>} */
|
|
124
|
+
let branch = [];
|
|
125
|
+
|
|
126
|
+
/** @type {Error | null} */
|
|
127
|
+
let load_error = null;
|
|
128
|
+
|
|
129
|
+
/** @type {Array<Promise<import('types').ServerDataNode | null>>} */
|
|
130
|
+
const server_promises = nodes.map((node, i) => {
|
|
131
|
+
if (load_error) {
|
|
132
|
+
// if an error happens immediately, don't bother with the rest of the nodes
|
|
133
|
+
throw load_error;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return Promise.resolve().then(async () => {
|
|
137
|
+
try {
|
|
138
|
+
if (node === leaf_node && action_result?.type === 'error') {
|
|
139
|
+
// we wait until here to throw the error so that we can use
|
|
140
|
+
// any nested +error.svelte components that were defined
|
|
141
|
+
throw action_result.error;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return await load_server_data({
|
|
145
|
+
event,
|
|
146
|
+
state,
|
|
147
|
+
node,
|
|
148
|
+
parent: async () => {
|
|
149
|
+
/** @type {Record<string, any>} */
|
|
150
|
+
const data = {};
|
|
151
|
+
for (let j = 0; j < i; j += 1) {
|
|
152
|
+
const parent = await server_promises[j];
|
|
153
|
+
if (parent) Object.assign(data, await parent.data);
|
|
154
|
+
}
|
|
155
|
+
return data;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
} catch (e) {
|
|
159
|
+
load_error = /** @type {Error} */ (e);
|
|
160
|
+
throw load_error;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
/** @type {Array<Promise<Record<string, any> | null>>} */
|
|
166
|
+
const load_promises = nodes.map((node, i) => {
|
|
167
|
+
if (load_error) throw load_error;
|
|
168
|
+
return Promise.resolve().then(async () => {
|
|
169
|
+
try {
|
|
170
|
+
return await load_data({
|
|
171
|
+
event,
|
|
172
|
+
fetcher,
|
|
173
|
+
node,
|
|
174
|
+
parent: async () => {
|
|
175
|
+
const data = {};
|
|
176
|
+
for (let j = 0; j < i; j += 1) {
|
|
177
|
+
Object.assign(data, await load_promises[j]);
|
|
178
|
+
}
|
|
179
|
+
return data;
|
|
180
|
+
},
|
|
181
|
+
server_data_promise: server_promises[i],
|
|
182
|
+
state
|
|
183
|
+
});
|
|
184
|
+
} catch (e) {
|
|
185
|
+
load_error = /** @type {Error} */ (e);
|
|
186
|
+
throw load_error;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// if we don't do this, rejections will be unhandled
|
|
192
|
+
for (const p of server_promises) p.catch(() => {});
|
|
193
|
+
for (const p of load_promises) p.catch(() => {});
|
|
194
|
+
|
|
195
|
+
for (let i = 0; i < nodes.length; i += 1) {
|
|
196
|
+
const node = nodes[i];
|
|
197
|
+
|
|
198
|
+
if (node) {
|
|
199
|
+
try {
|
|
200
|
+
const server_data = await server_promises[i];
|
|
201
|
+
const data = await load_promises[i];
|
|
202
|
+
|
|
203
|
+
branch.push({ node, server_data, data });
|
|
204
|
+
} catch (e) {
|
|
205
|
+
const err = normalize_error(e);
|
|
206
|
+
|
|
207
|
+
if (err instanceof Redirect) {
|
|
208
|
+
if (state.prerendering && should_prerender_data) {
|
|
209
|
+
const body = `window.__sveltekit_data = ${JSON.stringify({
|
|
210
|
+
type: 'redirect',
|
|
211
|
+
location: err.location
|
|
212
|
+
})}`;
|
|
213
|
+
|
|
214
|
+
state.prerendering.dependencies.set(data_pathname, {
|
|
215
|
+
response: new Response(body),
|
|
216
|
+
body
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return redirect_response(err.status, err.location, cookies);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const status = err instanceof HttpError ? err.status : 500;
|
|
224
|
+
const error = handle_error_and_jsonify(event, options, err);
|
|
225
|
+
|
|
226
|
+
while (i--) {
|
|
227
|
+
if (page.errors[i]) {
|
|
228
|
+
const index = /** @type {number} */ (page.errors[i]);
|
|
229
|
+
const node = await options.manifest._.nodes[index]();
|
|
230
|
+
|
|
231
|
+
let j = i;
|
|
232
|
+
while (!branch[j]) j -= 1;
|
|
233
|
+
|
|
234
|
+
return await render_response({
|
|
235
|
+
event,
|
|
236
|
+
options,
|
|
237
|
+
state,
|
|
238
|
+
resolve_opts,
|
|
239
|
+
page_config: { ssr: true, csr: true },
|
|
240
|
+
status,
|
|
241
|
+
error,
|
|
242
|
+
branch: compact(branch.slice(0, j + 1)).concat({
|
|
243
|
+
node,
|
|
244
|
+
data: null,
|
|
245
|
+
server_data: null
|
|
246
|
+
}),
|
|
247
|
+
fetched,
|
|
248
|
+
cookies
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// if we're still here, it means the error happened in the root layout,
|
|
254
|
+
// which means we have to fall back to error.html
|
|
255
|
+
return static_error_page(options, status, error.message);
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
// push an empty slot so we can rewind past gaps to the
|
|
259
|
+
// layout that corresponds with an +error.svelte page
|
|
260
|
+
branch.push(null);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (state.prerendering && should_prerender_data) {
|
|
265
|
+
const body = `window.__sveltekit_data = ${devalue({
|
|
266
|
+
type: 'data',
|
|
267
|
+
nodes: branch.map((branch_node) => branch_node?.server_data)
|
|
268
|
+
})}`;
|
|
269
|
+
|
|
270
|
+
state.prerendering.dependencies.set(data_pathname, {
|
|
271
|
+
response: new Response(body),
|
|
272
|
+
body
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return await render_response({
|
|
277
|
+
event,
|
|
278
|
+
options,
|
|
279
|
+
state,
|
|
280
|
+
resolve_opts,
|
|
281
|
+
page_config: {
|
|
282
|
+
csr: get_option(nodes, 'csr') ?? true,
|
|
283
|
+
ssr: true
|
|
284
|
+
},
|
|
285
|
+
status,
|
|
286
|
+
error: null,
|
|
287
|
+
branch: compact(branch),
|
|
288
|
+
action_result,
|
|
289
|
+
fetched,
|
|
290
|
+
cookies
|
|
291
|
+
});
|
|
292
|
+
} catch (error) {
|
|
293
|
+
// if we end up here, it means the data loaded successfull
|
|
294
|
+
// but the page failed to render, or that a prerendering error occurred
|
|
295
|
+
return await respond_with_error({
|
|
296
|
+
event,
|
|
297
|
+
options,
|
|
298
|
+
state,
|
|
299
|
+
status: 500,
|
|
300
|
+
error,
|
|
301
|
+
resolve_opts
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { disable_search, make_trackable } from '../../../utils/url.js';
|
|
2
|
+
import { unwrap_promises } from '../../../utils/promises.js';
|
|
3
|
+
/**
|
|
4
|
+
* Calls the user's `load` function.
|
|
5
|
+
* @param {{
|
|
6
|
+
* event: import('types').RequestEvent;
|
|
7
|
+
* state: import('types').SSRState;
|
|
8
|
+
* node: import('types').SSRNode | undefined;
|
|
9
|
+
* parent: () => Promise<Record<string, any>>;
|
|
10
|
+
* }} opts
|
|
11
|
+
* @returns {Promise<import('types').ServerDataNode | null>}
|
|
12
|
+
*/
|
|
13
|
+
export async function load_server_data({ event, state, node, parent }) {
|
|
14
|
+
if (!node?.server) return null;
|
|
15
|
+
|
|
16
|
+
const uses = {
|
|
17
|
+
dependencies: new Set(),
|
|
18
|
+
params: new Set(),
|
|
19
|
+
parent: false,
|
|
20
|
+
url: false
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const url = make_trackable(event.url, () => {
|
|
24
|
+
uses.url = true;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (state.prerendering) {
|
|
28
|
+
disable_search(url);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const result = await node.server.load?.call(null, {
|
|
32
|
+
...event,
|
|
33
|
+
/** @param {string[]} deps */
|
|
34
|
+
depends: (...deps) => {
|
|
35
|
+
for (const dep of deps) {
|
|
36
|
+
const { href } = new URL(dep, event.url);
|
|
37
|
+
uses.dependencies.add(href);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
params: new Proxy(event.params, {
|
|
41
|
+
get: (target, key) => {
|
|
42
|
+
uses.params.add(key);
|
|
43
|
+
return target[/** @type {string} */ (key)];
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
parent: async () => {
|
|
47
|
+
uses.parent = true;
|
|
48
|
+
return parent();
|
|
49
|
+
},
|
|
50
|
+
url
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const data = result ? await unwrap_promises(result) : null;
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
type: 'data',
|
|
57
|
+
data,
|
|
58
|
+
uses: {
|
|
59
|
+
dependencies: uses.dependencies.size > 0 ? Array.from(uses.dependencies) : undefined,
|
|
60
|
+
params: uses.params.size > 0 ? Array.from(uses.params) : undefined,
|
|
61
|
+
parent: uses.parent ? 1 : undefined,
|
|
62
|
+
url: uses.url ? 1 : undefined
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Calls the user's `load` function.
|
|
69
|
+
* @param {{
|
|
70
|
+
* event: import('types').RequestEvent;
|
|
71
|
+
* fetcher: typeof fetch;
|
|
72
|
+
* node: import('types').SSRNode | undefined;
|
|
73
|
+
* parent: () => Promise<Record<string, any>>;
|
|
74
|
+
* server_data_promise: Promise<import('types').ServerDataNode | null>;
|
|
75
|
+
* state: import('types').SSRState;
|
|
76
|
+
* }} opts
|
|
77
|
+
* @returns {Promise<Record<string, any> | null>}
|
|
78
|
+
*/
|
|
79
|
+
export async function load_data({ event, fetcher, node, parent, server_data_promise }) {
|
|
80
|
+
const server_data_node = await server_data_promise;
|
|
81
|
+
|
|
82
|
+
if (!node?.shared?.load) {
|
|
83
|
+
return server_data_node?.data ?? null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const load_event = {
|
|
87
|
+
url: event.url,
|
|
88
|
+
params: event.params,
|
|
89
|
+
data: server_data_node?.data ?? null,
|
|
90
|
+
routeId: event.routeId,
|
|
91
|
+
fetch: fetcher,
|
|
92
|
+
setHeaders: event.setHeaders,
|
|
93
|
+
depends: () => {},
|
|
94
|
+
parent
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// TODO remove this for 1.0
|
|
98
|
+
Object.defineProperties(load_event, {
|
|
99
|
+
session: {
|
|
100
|
+
get() {
|
|
101
|
+
throw new Error(
|
|
102
|
+
'session is no longer available. See https://github.com/sveltejs/kit/discussions/5883'
|
|
103
|
+
);
|
|
104
|
+
},
|
|
105
|
+
enumerable: false
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const data = await node.shared.load.call(null, load_event);
|
|
110
|
+
|
|
111
|
+
return data ? unwrap_promises(data) : null;
|
|
112
|
+
}
|