@sveltejs/kit 1.0.0-next.255 → 1.0.0-next.259
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/assets/server/index.js +31 -22
- package/dist/chunks/index.js +1 -1
- package/dist/chunks/index3.js +0 -1
- package/dist/chunks/index5.js +6 -6
- package/dist/cli.js +4 -3
- package/package.json +1 -1
- package/types/ambient-modules.d.ts +11 -4
- package/types/config.d.ts +0 -1
- package/types/endpoint.d.ts +4 -10
- package/types/helper.d.ts +5 -8
- package/types/hooks.d.ts +10 -14
- package/types/internal.d.ts +3 -4
- package/types/page.d.ts +12 -65
package/assets/server/index.js
CHANGED
|
@@ -1033,8 +1033,8 @@ const updated = {
|
|
|
1033
1033
|
/**
|
|
1034
1034
|
* @param {{
|
|
1035
1035
|
* branch: Array<import('./types').Loaded>;
|
|
1036
|
-
* options: import('types/internal').
|
|
1037
|
-
* state: import('types/internal').
|
|
1036
|
+
* options: import('types/internal').SSROptions;
|
|
1037
|
+
* state: import('types/internal').SSRState;
|
|
1038
1038
|
* $session: any;
|
|
1039
1039
|
* page_config: { hydrate: boolean, router: boolean };
|
|
1040
1040
|
* status: number;
|
|
@@ -1168,11 +1168,13 @@ async function render_response({
|
|
|
1168
1168
|
needs_nonce: options.template_contains_nonce
|
|
1169
1169
|
});
|
|
1170
1170
|
|
|
1171
|
+
const target = hash(body);
|
|
1172
|
+
|
|
1171
1173
|
// prettier-ignore
|
|
1172
1174
|
const init_app = `
|
|
1173
1175
|
import { start } from ${s(options.prefix + options.manifest._.entry.file)};
|
|
1174
1176
|
start({
|
|
1175
|
-
target:
|
|
1177
|
+
target: document.querySelector('[data-hydrate="${target}"]').parentNode,
|
|
1176
1178
|
paths: ${s(options.paths)},
|
|
1177
1179
|
session: ${try_serialize($session, (error) => {
|
|
1178
1180
|
throw new Error(`Failed to serialize session data: ${error.message}`);
|
|
@@ -1250,7 +1252,7 @@ async function render_response({
|
|
|
1250
1252
|
.map((dep) => `\n\t<link rel="modulepreload" href="${options.prefix + dep}">`)
|
|
1251
1253
|
.join('');
|
|
1252
1254
|
|
|
1253
|
-
const attributes = ['type="module"'];
|
|
1255
|
+
const attributes = ['type="module"', `data-hydrate="${target}"`];
|
|
1254
1256
|
|
|
1255
1257
|
csp.add_script(init_app);
|
|
1256
1258
|
|
|
@@ -1258,7 +1260,7 @@ async function render_response({
|
|
|
1258
1260
|
attributes.push(`nonce="${csp.nonce}"`);
|
|
1259
1261
|
}
|
|
1260
1262
|
|
|
1261
|
-
|
|
1263
|
+
body += `\n\t\t<script ${attributes.join(' ')}>${init_app}</script>`;
|
|
1262
1264
|
|
|
1263
1265
|
// prettier-ignore
|
|
1264
1266
|
body += serialized_data
|
|
@@ -1268,7 +1270,7 @@ async function render_response({
|
|
|
1268
1270
|
|
|
1269
1271
|
return `<script ${attributes}>${json}</script>`;
|
|
1270
1272
|
})
|
|
1271
|
-
.join('\n\
|
|
1273
|
+
.join('\n\t');
|
|
1272
1274
|
}
|
|
1273
1275
|
|
|
1274
1276
|
if (options.service_worker) {
|
|
@@ -1465,8 +1467,8 @@ function is_root_relative(path) {
|
|
|
1465
1467
|
/**
|
|
1466
1468
|
* @param {{
|
|
1467
1469
|
* event: import('types/hooks').RequestEvent;
|
|
1468
|
-
* options: import('types/internal').
|
|
1469
|
-
* state: import('types/internal').
|
|
1470
|
+
* options: import('types/internal').SSROptions;
|
|
1471
|
+
* state: import('types/internal').SSRState;
|
|
1470
1472
|
* route: import('types/internal').SSRPage | null;
|
|
1471
1473
|
* url: URL;
|
|
1472
1474
|
* params: Record<string, string>;
|
|
@@ -1553,9 +1555,15 @@ async function load_node({
|
|
|
1553
1555
|
|
|
1554
1556
|
// merge headers from request
|
|
1555
1557
|
for (const [key, value] of event.request.headers) {
|
|
1556
|
-
if (
|
|
1557
|
-
|
|
1558
|
-
|
|
1558
|
+
if (
|
|
1559
|
+
key !== 'authorization' &&
|
|
1560
|
+
key !== 'cookie' &&
|
|
1561
|
+
key !== 'host' &&
|
|
1562
|
+
key !== 'if-none-match' &&
|
|
1563
|
+
!opts.headers.has(key)
|
|
1564
|
+
) {
|
|
1565
|
+
opts.headers.set(key, value);
|
|
1566
|
+
}
|
|
1559
1567
|
}
|
|
1560
1568
|
|
|
1561
1569
|
opts.headers.set('referer', event.url.href);
|
|
@@ -1763,15 +1771,15 @@ async function load_node({
|
|
|
1763
1771
|
|
|
1764
1772
|
/**
|
|
1765
1773
|
* @typedef {import('./types.js').Loaded} Loaded
|
|
1766
|
-
* @typedef {import('types/internal').
|
|
1767
|
-
* @typedef {import('types/internal').
|
|
1774
|
+
* @typedef {import('types/internal').SSROptions} SSROptions
|
|
1775
|
+
* @typedef {import('types/internal').SSRState} SSRState
|
|
1768
1776
|
*/
|
|
1769
1777
|
|
|
1770
1778
|
/**
|
|
1771
1779
|
* @param {{
|
|
1772
1780
|
* event: import('types/hooks').RequestEvent;
|
|
1773
|
-
* options:
|
|
1774
|
-
* state:
|
|
1781
|
+
* options: SSROptions;
|
|
1782
|
+
* state: SSRState;
|
|
1775
1783
|
* $session: any;
|
|
1776
1784
|
* status: number;
|
|
1777
1785
|
* error: Error;
|
|
@@ -1848,15 +1856,15 @@ async function respond_with_error({ event, options, state, $session, status, err
|
|
|
1848
1856
|
/**
|
|
1849
1857
|
* @typedef {import('./types.js').Loaded} Loaded
|
|
1850
1858
|
* @typedef {import('types/internal').SSRNode} SSRNode
|
|
1851
|
-
* @typedef {import('types/internal').
|
|
1852
|
-
* @typedef {import('types/internal').
|
|
1859
|
+
* @typedef {import('types/internal').SSROptions} SSROptions
|
|
1860
|
+
* @typedef {import('types/internal').SSRState} SSRState
|
|
1853
1861
|
*/
|
|
1854
1862
|
|
|
1855
1863
|
/**
|
|
1856
1864
|
* @param {{
|
|
1857
1865
|
* event: import('types/hooks').RequestEvent;
|
|
1858
|
-
* options:
|
|
1859
|
-
* state:
|
|
1866
|
+
* options: SSROptions;
|
|
1867
|
+
* state: SSRState;
|
|
1860
1868
|
* $session: any;
|
|
1861
1869
|
* route: import('types/internal').SSRPage;
|
|
1862
1870
|
* params: Record<string, string>;
|
|
@@ -2081,7 +2089,7 @@ async function respond$1(opts) {
|
|
|
2081
2089
|
|
|
2082
2090
|
/**
|
|
2083
2091
|
* @param {import('types/internal').SSRComponent} leaf
|
|
2084
|
-
* @param {
|
|
2092
|
+
* @param {SSROptions} options
|
|
2085
2093
|
*/
|
|
2086
2094
|
function get_page_config(leaf, options) {
|
|
2087
2095
|
// TODO remove for 1.0
|
|
@@ -2114,8 +2122,8 @@ function with_cookies(response, set_cookie_headers) {
|
|
|
2114
2122
|
* @param {import('types/hooks').RequestEvent} event
|
|
2115
2123
|
* @param {import('types/internal').SSRPage} route
|
|
2116
2124
|
* @param {RegExpExecArray} match
|
|
2117
|
-
* @param {import('types/internal').
|
|
2118
|
-
* @param {import('types/internal').
|
|
2125
|
+
* @param {import('types/internal').SSROptions} options
|
|
2126
|
+
* @param {import('types/internal').SSRState} state
|
|
2119
2127
|
* @param {boolean} ssr
|
|
2120
2128
|
* @returns {Promise<Response | undefined>}
|
|
2121
2129
|
*/
|
|
@@ -2212,6 +2220,7 @@ async function respond(request, options, state = {}) {
|
|
|
2212
2220
|
request,
|
|
2213
2221
|
url,
|
|
2214
2222
|
params: {},
|
|
2223
|
+
// @ts-expect-error this picks up types that belong to the tests
|
|
2215
2224
|
locals: {},
|
|
2216
2225
|
platform: state.platform
|
|
2217
2226
|
};
|
package/dist/chunks/index.js
CHANGED
|
@@ -185,6 +185,7 @@ async function create_plugin(config, cwd) {
|
|
|
185
185
|
|
|
186
186
|
/** @type {import('types/internal').Hooks} */
|
|
187
187
|
const hooks = {
|
|
188
|
+
// @ts-expect-error this picks up types that belong to the tests
|
|
188
189
|
getSession: user_hooks.getSession || (() => ({})),
|
|
189
190
|
handle: amp ? sequence(amp, handle) : handle,
|
|
190
191
|
handleError:
|
|
@@ -271,7 +272,6 @@ async function create_plugin(config, cwd) {
|
|
|
271
272
|
read: (file) => fs__default.readFileSync(path__default.join(config.kit.files.assets, file)),
|
|
272
273
|
root,
|
|
273
274
|
router: config.kit.browser.router,
|
|
274
|
-
target: config.kit.target,
|
|
275
275
|
template: ({ head, body, assets, nonce }) => {
|
|
276
276
|
return (
|
|
277
277
|
template
|
package/dist/chunks/index3.js
CHANGED
|
@@ -328,7 +328,6 @@ export class App {
|
|
|
328
328
|
root,
|
|
329
329
|
service_worker: ${has_service_worker ? "base + '/service-worker.js'" : 'null'},
|
|
330
330
|
router: ${s(config.kit.browser.router)},
|
|
331
|
-
target: ${s(config.kit.target)},
|
|
332
331
|
template,
|
|
333
332
|
template_contains_nonce: ${template.includes('%svelte.nonce%')},
|
|
334
333
|
trailing_slash: ${s(config.kit.trailingSlash)}
|
package/dist/chunks/index5.js
CHANGED
|
@@ -161,7 +161,7 @@ function crawl(html) {
|
|
|
161
161
|
if (html[i + 1] === '!') {
|
|
162
162
|
i += 2;
|
|
163
163
|
|
|
164
|
-
if (html.
|
|
164
|
+
if (html.substr(i, DOCTYPE.length).toUpperCase() === DOCTYPE) {
|
|
165
165
|
i += DOCTYPE.length;
|
|
166
166
|
while (i < html.length) {
|
|
167
167
|
if (html[i++] === '>') {
|
|
@@ -171,10 +171,10 @@ function crawl(html) {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
// skip cdata
|
|
174
|
-
if (html.
|
|
174
|
+
if (html.substr(i, CDATA_OPEN.length) === CDATA_OPEN) {
|
|
175
175
|
i += CDATA_OPEN.length;
|
|
176
176
|
while (i < html.length) {
|
|
177
|
-
if (html.
|
|
177
|
+
if (html.substr(i, CDATA_CLOSE.length) === CDATA_CLOSE) {
|
|
178
178
|
i += CDATA_CLOSE.length;
|
|
179
179
|
continue main;
|
|
180
180
|
}
|
|
@@ -184,10 +184,10 @@ function crawl(html) {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
// skip comments
|
|
187
|
-
if (html.
|
|
187
|
+
if (html.substr(i, COMMENT_OPEN.length) === COMMENT_OPEN) {
|
|
188
188
|
i += COMMENT_OPEN.length;
|
|
189
189
|
while (i < html.length) {
|
|
190
|
-
if (html.
|
|
190
|
+
if (html.substr(i, COMMENT_CLOSE.length) === COMMENT_CLOSE) {
|
|
191
191
|
i += COMMENT_CLOSE.length;
|
|
192
192
|
continue main;
|
|
193
193
|
}
|
|
@@ -215,7 +215,7 @@ function crawl(html) {
|
|
|
215
215
|
if (
|
|
216
216
|
html[i] === '<' &&
|
|
217
217
|
html[i + 1] === '/' &&
|
|
218
|
-
html.
|
|
218
|
+
html.substr(i + 2, tag.length).toUpperCase() === tag
|
|
219
219
|
) {
|
|
220
220
|
continue main;
|
|
221
221
|
}
|
package/dist/cli.js
CHANGED
|
@@ -684,7 +684,8 @@ const options = object(
|
|
|
684
684
|
`${keypath} has been removed — use the handle hook instead: https://kit.svelte.dev/docs#hooks-handle'`
|
|
685
685
|
),
|
|
686
686
|
|
|
687
|
-
|
|
687
|
+
// TODO remove this for 1.0
|
|
688
|
+
target: error((keypath) => `${keypath} is no longer required, and should be removed`),
|
|
688
689
|
|
|
689
690
|
trailingSlash: list(['never', 'always', 'ignore']),
|
|
690
691
|
|
|
@@ -994,7 +995,7 @@ async function launch(port, https) {
|
|
|
994
995
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
995
996
|
}
|
|
996
997
|
|
|
997
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
998
|
+
const prog = sade('svelte-kit').version('1.0.0-next.259');
|
|
998
999
|
|
|
999
1000
|
prog
|
|
1000
1001
|
.command('dev')
|
|
@@ -1152,7 +1153,7 @@ async function check_port(port) {
|
|
|
1152
1153
|
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
1153
1154
|
if (open) launch(port, https);
|
|
1154
1155
|
|
|
1155
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1156
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.259'}\n`));
|
|
1156
1157
|
|
|
1157
1158
|
const protocol = https ? 'https:' : 'http:';
|
|
1158
1159
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
package/package.json
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/* eslint-disable import/no-duplicates */
|
|
2
2
|
|
|
3
|
+
declare namespace App {
|
|
4
|
+
interface Locals {}
|
|
5
|
+
interface Platform {}
|
|
6
|
+
interface Session {}
|
|
7
|
+
interface Stuff {}
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
declare module '$app/env' {
|
|
4
11
|
/**
|
|
5
12
|
* Whether or not app is in AMP mode.
|
|
@@ -106,10 +113,10 @@ declare module '$app/stores' {
|
|
|
106
113
|
* A convenience function around `getContext` that returns `{ navigating, page, session }`.
|
|
107
114
|
* Most of the time, you won't need to use it.
|
|
108
115
|
*/
|
|
109
|
-
export function getStores
|
|
116
|
+
export function getStores(): {
|
|
110
117
|
navigating: typeof navigating;
|
|
111
118
|
page: typeof page;
|
|
112
|
-
session: Writable<Session>;
|
|
119
|
+
session: Writable<App.Session>;
|
|
113
120
|
updated: typeof updated;
|
|
114
121
|
};
|
|
115
122
|
/**
|
|
@@ -118,7 +125,7 @@ declare module '$app/stores' {
|
|
|
118
125
|
export const page: Readable<{
|
|
119
126
|
url: URL;
|
|
120
127
|
params: Record<string, string>;
|
|
121
|
-
stuff:
|
|
128
|
+
stuff: App.Stuff;
|
|
122
129
|
status: number;
|
|
123
130
|
error: Error | null;
|
|
124
131
|
}>;
|
|
@@ -132,7 +139,7 @@ declare module '$app/stores' {
|
|
|
132
139
|
* A writable store whose initial value is whatever was returned from `getSession`.
|
|
133
140
|
* It can be written to, but this will not cause changes to persist on the server — this is something you must implement yourself.
|
|
134
141
|
*/
|
|
135
|
-
export const session: Writable<
|
|
142
|
+
export const session: Writable<App.Session>;
|
|
136
143
|
/**
|
|
137
144
|
* A writable store indicating if the site was updated since the store was created.
|
|
138
145
|
* It can be written to when custom logic is required to detect updates.
|
package/types/config.d.ts
CHANGED
package/types/endpoint.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RequestEvent } from './hooks';
|
|
2
|
-
import { Either,
|
|
2
|
+
import { Either, JSONValue, MaybePromise, ResponseHeaders } from './helper';
|
|
3
3
|
|
|
4
|
-
type Body =
|
|
4
|
+
type Body = JSONValue | Uint8Array | ReadableStream | import('stream').Readable;
|
|
5
5
|
|
|
6
6
|
export interface EndpointOutput<Output extends Body = Body> {
|
|
7
7
|
status?: number;
|
|
@@ -13,12 +13,6 @@ export interface Fallthrough {
|
|
|
13
13
|
fallthrough: true;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export interface RequestHandler<
|
|
17
|
-
|
|
18
|
-
Platform = Record<string, any>,
|
|
19
|
-
Output extends Body = Body
|
|
20
|
-
> {
|
|
21
|
-
(event: RequestEvent<Locals, Platform>): MaybePromise<
|
|
22
|
-
Either<Response | EndpointOutput<Output>, Fallthrough>
|
|
23
|
-
>;
|
|
16
|
+
export interface RequestHandler<Output extends Body = Body> {
|
|
17
|
+
(event: RequestEvent): MaybePromise<Either<Response | EndpointOutput<Output>, Fallthrough>>;
|
|
24
18
|
}
|
package/types/helper.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
type ToJSON = { toJSON(...args: any[]): JSONValue };
|
|
2
|
-
|
|
3
|
-
export type
|
|
1
|
+
type ToJSON = { toJSON(...args: any[]): Exclude<JSONValue, ToJSON> };
|
|
2
|
+
|
|
3
|
+
export type JSONValue =
|
|
4
4
|
| string
|
|
5
5
|
| number
|
|
6
6
|
| boolean
|
|
7
7
|
| null
|
|
8
8
|
| ToJSON
|
|
9
|
-
|
|
|
10
|
-
| { [key: string]:
|
|
9
|
+
| JSONValue[]
|
|
10
|
+
| { [key: string]: JSONValue };
|
|
11
11
|
|
|
12
12
|
/** `string[]` is only for set-cookie, everything else must be type of `string` */
|
|
13
13
|
export type ResponseHeaders = Record<string, string | string[]>;
|
|
@@ -16,9 +16,6 @@ export type ResponseHeaders = Record<string, string | string[]>;
|
|
|
16
16
|
type Only<T, U> = { [P in keyof T]: T[P] } & { [P in Exclude<keyof U, keyof T>]?: never };
|
|
17
17
|
|
|
18
18
|
export type Either<T, U> = Only<T, U> | Only<U, T>;
|
|
19
|
-
export type InferValue<T, Key extends keyof T, Default> = T extends Record<Key, infer Val>
|
|
20
|
-
? Val
|
|
21
|
-
: Default;
|
|
22
19
|
export type MaybePromise<T> = T | Promise<T>;
|
|
23
20
|
export type RecursiveRequired<T> = {
|
|
24
21
|
// Recursive implementation of TypeScript's Required utility type.
|
package/types/hooks.d.ts
CHANGED
|
@@ -2,35 +2,31 @@ import { MaybePromise } from './helper';
|
|
|
2
2
|
|
|
3
3
|
export type StrictBody = string | Uint8Array;
|
|
4
4
|
|
|
5
|
-
export interface RequestEvent
|
|
5
|
+
export interface RequestEvent {
|
|
6
6
|
request: Request;
|
|
7
7
|
url: URL;
|
|
8
8
|
params: Record<string, string>;
|
|
9
|
-
locals: Locals;
|
|
10
|
-
platform: Readonly<Platform>;
|
|
9
|
+
locals: App.Locals;
|
|
10
|
+
platform: Readonly<App.Platform>;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export interface GetSession
|
|
14
|
-
|
|
15
|
-
Platform = Record<string, any>,
|
|
16
|
-
Session = any
|
|
17
|
-
> {
|
|
18
|
-
(event: RequestEvent<Locals, Platform>): MaybePromise<Session>;
|
|
13
|
+
export interface GetSession {
|
|
14
|
+
(event: RequestEvent): MaybePromise<App.Session>;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
export interface ResolveOpts {
|
|
22
18
|
ssr?: boolean;
|
|
23
19
|
}
|
|
24
20
|
|
|
25
|
-
export interface Handle
|
|
21
|
+
export interface Handle {
|
|
26
22
|
(input: {
|
|
27
|
-
event: RequestEvent
|
|
28
|
-
resolve(event: RequestEvent
|
|
23
|
+
event: RequestEvent;
|
|
24
|
+
resolve(event: RequestEvent, opts?: ResolveOpts): MaybePromise<Response>;
|
|
29
25
|
}): MaybePromise<Response>;
|
|
30
26
|
}
|
|
31
27
|
|
|
32
|
-
export interface HandleError
|
|
33
|
-
(input: { error: Error & { frame?: string }; event: RequestEvent
|
|
28
|
+
export interface HandleError {
|
|
29
|
+
(input: { error: Error & { frame?: string }; event: RequestEvent }): void;
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
export interface ExternalFetch {
|
package/types/internal.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ export interface SSRNode {
|
|
|
119
119
|
styles?: Record<string, string>;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
export interface
|
|
122
|
+
export interface SSROptions {
|
|
123
123
|
amp: boolean;
|
|
124
124
|
csp: ValidatedConfig['kit']['csp'];
|
|
125
125
|
dev: boolean;
|
|
@@ -140,7 +140,6 @@ export interface SSRRenderOptions {
|
|
|
140
140
|
root: SSRComponent['default'];
|
|
141
141
|
router: boolean;
|
|
142
142
|
service_worker?: string;
|
|
143
|
-
target: string;
|
|
144
143
|
template({
|
|
145
144
|
head,
|
|
146
145
|
body,
|
|
@@ -156,7 +155,7 @@ export interface SSRRenderOptions {
|
|
|
156
155
|
trailing_slash: TrailingSlash;
|
|
157
156
|
}
|
|
158
157
|
|
|
159
|
-
export interface
|
|
158
|
+
export interface SSRState {
|
|
160
159
|
fetched?: string;
|
|
161
160
|
initiator?: SSRPage | null;
|
|
162
161
|
platform?: any;
|
|
@@ -248,5 +247,5 @@ export interface MethodOverride {
|
|
|
248
247
|
}
|
|
249
248
|
|
|
250
249
|
export interface Respond {
|
|
251
|
-
(request: Request, options:
|
|
250
|
+
(request: Request, options: SSROptions, state?: SSRState): Promise<Response>;
|
|
252
251
|
}
|
package/types/page.d.ts
CHANGED
|
@@ -1,85 +1,32 @@
|
|
|
1
1
|
import { Fallthrough } from './endpoint';
|
|
2
|
-
import { Either,
|
|
2
|
+
import { Either, MaybePromise } from './helper';
|
|
3
3
|
|
|
4
|
-
export interface LoadInput<
|
|
5
|
-
PageParams extends Record<string, string> = Record<string, string>,
|
|
6
|
-
Stuff extends Record<string, any> = Record<string, any>,
|
|
7
|
-
Session = any
|
|
8
|
-
> {
|
|
4
|
+
export interface LoadInput<Params = Record<string, string>> {
|
|
9
5
|
url: URL;
|
|
10
|
-
params:
|
|
6
|
+
params: Params;
|
|
11
7
|
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
12
|
-
session: Session;
|
|
13
|
-
stuff: Stuff
|
|
8
|
+
session: App.Session;
|
|
9
|
+
stuff: Partial<App.Stuff>;
|
|
14
10
|
}
|
|
15
11
|
|
|
16
|
-
export interface ErrorLoadInput<
|
|
17
|
-
PageParams extends Record<string, string> = Record<string, string>,
|
|
18
|
-
Stuff extends Record<string, any> = Record<string, any>,
|
|
19
|
-
Session = any
|
|
20
|
-
> extends LoadInput<PageParams, Stuff, Session> {
|
|
12
|
+
export interface ErrorLoadInput<Params = Record<string, string>> extends LoadInput<Params> {
|
|
21
13
|
status?: number;
|
|
22
14
|
error?: Error;
|
|
23
15
|
}
|
|
24
16
|
|
|
25
|
-
export interface LoadOutput<
|
|
26
|
-
Props extends Record<string, any> = Record<string, any>,
|
|
27
|
-
Stuff extends Record<string, any> = Record<string, any>
|
|
28
|
-
> {
|
|
17
|
+
export interface LoadOutput<Props = Record<string, any>> {
|
|
29
18
|
status?: number;
|
|
30
19
|
error?: string | Error;
|
|
31
20
|
redirect?: string;
|
|
32
21
|
props?: Props;
|
|
33
|
-
stuff?: Stuff
|
|
22
|
+
stuff?: Partial<App.Stuff>;
|
|
34
23
|
maxage?: number;
|
|
35
24
|
}
|
|
36
25
|
|
|
37
|
-
interface
|
|
38
|
-
|
|
39
|
-
pageParams?: Record<string, string>;
|
|
40
|
-
session?: any;
|
|
26
|
+
export interface Load<Params = Record<string, string>, Props = Record<string, any>> {
|
|
27
|
+
(input: LoadInput<Params>): MaybePromise<Either<Fallthrough, LoadOutput<Props>>>;
|
|
41
28
|
}
|
|
42
29
|
|
|
43
|
-
interface
|
|
44
|
-
|
|
45
|
-
props?: Record<string, any>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface Load<
|
|
49
|
-
Input extends LoadInputExtends = Required<LoadInputExtends>,
|
|
50
|
-
Output extends LoadOutputExtends = Required<LoadOutputExtends>
|
|
51
|
-
> {
|
|
52
|
-
(
|
|
53
|
-
input: LoadInput<
|
|
54
|
-
InferValue<Input, 'pageParams', Record<string, string>>,
|
|
55
|
-
InferValue<Input, 'stuff', Record<string, any>>,
|
|
56
|
-
InferValue<Input, 'session', any>
|
|
57
|
-
>
|
|
58
|
-
): MaybePromise<
|
|
59
|
-
Either<
|
|
60
|
-
Fallthrough,
|
|
61
|
-
LoadOutput<
|
|
62
|
-
InferValue<Output, 'props', Record<string, any>>,
|
|
63
|
-
InferValue<Output, 'stuff', Record<string, any>>
|
|
64
|
-
>
|
|
65
|
-
>
|
|
66
|
-
>;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface ErrorLoad<
|
|
70
|
-
Input extends LoadInputExtends = Required<LoadInputExtends>,
|
|
71
|
-
Output extends LoadOutputExtends = Required<LoadOutputExtends>
|
|
72
|
-
> {
|
|
73
|
-
(
|
|
74
|
-
input: ErrorLoadInput<
|
|
75
|
-
InferValue<Input, 'pageParams', Record<string, string>>,
|
|
76
|
-
InferValue<Input, 'stuff', Record<string, any>>,
|
|
77
|
-
InferValue<Input, 'session', any>
|
|
78
|
-
>
|
|
79
|
-
): MaybePromise<
|
|
80
|
-
LoadOutput<
|
|
81
|
-
InferValue<Output, 'props', Record<string, any>>,
|
|
82
|
-
InferValue<Output, 'stuff', Record<string, any>>
|
|
83
|
-
>
|
|
84
|
-
>;
|
|
30
|
+
export interface ErrorLoad<Params = Record<string, string>, Props = Record<string, any>> {
|
|
31
|
+
(input: ErrorLoadInput<Params>): MaybePromise<LoadOutput<Props>>;
|
|
85
32
|
}
|