@sveltejs/kit 1.0.0-next.405 → 1.0.0-next.408
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 +23 -25
- package/{dist → src}/cli.js +19 -18
- package/{dist/chunks/index3.js → src/core/adapt/builder.js} +6 -59
- package/src/core/adapt/index.js +19 -0
- package/src/core/config/index.js +86 -0
- package/{dist/chunks/index.js → src/core/config/options.js} +7 -194
- package/src/core/config/types.d.ts +1 -0
- package/src/core/constants.js +3 -0
- package/src/core/generate_manifest/index.js +99 -0
- package/src/core/prerender/crawl.js +194 -0
- package/src/core/prerender/prerender.js +378 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/index.js +492 -0
- package/src/core/sync/create_manifest_data/types.d.ts +40 -0
- package/src/core/sync/sync.js +59 -0
- package/src/core/sync/utils.js +97 -0
- package/src/core/sync/write_ambient.js +87 -0
- package/src/core/sync/write_client_manifest.js +82 -0
- package/src/core/sync/write_matchers.js +25 -0
- package/src/core/sync/write_root.js +88 -0
- package/{dist/chunks → src/core/sync}/write_tsconfig.js +24 -108
- package/src/core/sync/write_types.js +738 -0
- package/src/core/utils.js +58 -0
- package/{dist → src}/hooks.js +1 -3
- package/src/index/index.js +45 -0
- package/src/index/private.js +33 -0
- package/src/node/index.js +145 -0
- package/src/node/polyfills.js +40 -0
- package/src/packaging/index.js +218 -0
- package/src/packaging/types.d.ts +8 -0
- package/src/packaging/typescript.js +150 -0
- package/src/packaging/utils.js +143 -0
- package/{assets → src/runtime}/app/env.js +3 -5
- package/src/runtime/app/navigation.js +22 -0
- package/src/runtime/app/paths.js +1 -0
- package/{assets → src/runtime}/app/stores.js +6 -9
- package/src/runtime/client/ambient.d.ts +17 -0
- package/{assets/client/start.js → src/runtime/client/client.js} +302 -878
- package/src/runtime/client/fetcher.js +60 -0
- package/src/runtime/client/parse.js +36 -0
- package/{assets → src/runtime}/client/singletons.js +2 -4
- package/src/runtime/client/start.js +48 -0
- package/src/runtime/client/types.d.ts +106 -0
- package/src/runtime/client/utils.js +113 -0
- package/src/runtime/components/error.svelte +16 -0
- package/{assets → src/runtime}/components/layout.svelte +0 -0
- package/{assets → src/runtime}/env/dynamic/private.js +0 -0
- package/{assets → src/runtime}/env/dynamic/public.js +0 -0
- package/{assets → src/runtime}/env-private.js +2 -4
- package/{assets → src/runtime}/env-public.js +2 -4
- package/src/runtime/env.js +6 -0
- package/src/runtime/hash.js +16 -0
- package/{assets → src/runtime}/paths.js +3 -5
- package/src/runtime/server/endpoint.js +42 -0
- package/src/runtime/server/index.js +434 -0
- package/src/runtime/server/page/cookie.js +25 -0
- package/src/runtime/server/page/crypto.js +239 -0
- package/src/runtime/server/page/csp.js +249 -0
- package/src/runtime/server/page/fetch.js +265 -0
- package/src/runtime/server/page/index.js +418 -0
- package/src/runtime/server/page/load_data.js +94 -0
- package/src/runtime/server/page/render.js +357 -0
- package/src/runtime/server/page/respond_with_error.js +105 -0
- package/src/runtime/server/page/types.d.ts +44 -0
- package/src/runtime/server/utils.js +116 -0
- package/src/utils/error.js +22 -0
- package/src/utils/escape.js +104 -0
- package/{dist/chunks → src/utils}/filesystem.js +22 -24
- package/src/utils/http.js +55 -0
- package/src/utils/misc.js +1 -0
- package/src/utils/routing.js +107 -0
- package/src/utils/url.js +97 -0
- package/src/vite/build/build_server.js +335 -0
- package/src/vite/build/build_service_worker.js +90 -0
- package/src/vite/build/utils.js +153 -0
- package/src/vite/dev/index.js +565 -0
- package/src/vite/index.js +540 -0
- package/src/vite/preview/index.js +186 -0
- package/src/vite/types.d.ts +3 -0
- package/src/vite/utils.js +335 -0
- package/svelte-kit.js +1 -10
- package/types/ambient.d.ts +5 -12
- package/types/index.d.ts +86 -44
- package/types/internal.d.ts +50 -72
- package/types/private.d.ts +2 -1
- package/assets/app/navigation.js +0 -24
- package/assets/app/paths.js +0 -1
- package/assets/components/error.svelte +0 -29
- package/assets/env.js +0 -8
- package/assets/server/index.js +0 -3589
- package/dist/chunks/error.js +0 -12
- package/dist/chunks/index2.js +0 -15745
- package/dist/chunks/multipart-parser.js +0 -458
- package/dist/chunks/sync.js +0 -1366
- package/dist/chunks/utils.js +0 -66
- package/dist/node/polyfills.js +0 -17928
- package/dist/node.js +0 -348
- package/dist/prerender.js +0 -788
- package/dist/vite.js +0 -2513
package/types/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import './ambient.js';
|
|
|
6
6
|
import { CompileOptions } from 'svelte/types/compiler/interfaces';
|
|
7
7
|
import {
|
|
8
8
|
AdapterEntry,
|
|
9
|
-
BodyValidator,
|
|
10
9
|
CspDirectives,
|
|
10
|
+
JSONObject,
|
|
11
11
|
JSONValue,
|
|
12
12
|
Logger,
|
|
13
13
|
MaybePromise,
|
|
@@ -19,12 +19,29 @@ import {
|
|
|
19
19
|
TrailingSlash
|
|
20
20
|
} from './private.js';
|
|
21
21
|
import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js';
|
|
22
|
+
import { HttpError, Redirect } from '../src/index/private.js';
|
|
22
23
|
|
|
23
24
|
export interface Adapter {
|
|
24
25
|
name: string;
|
|
25
26
|
adapt(builder: Builder): MaybePromise<void>;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
export type AwaitedProperties<input extends Record<string, any> | void> = input extends void
|
|
30
|
+
? undefined // needs to be undefined, because void will break intellisense
|
|
31
|
+
: input extends Record<string, any>
|
|
32
|
+
? {
|
|
33
|
+
[key in keyof input]: Awaited<input[key]>;
|
|
34
|
+
}
|
|
35
|
+
: {} extends input // handles the any case
|
|
36
|
+
? input
|
|
37
|
+
: unknown;
|
|
38
|
+
|
|
39
|
+
export type AwaitedErrors<T extends (...args: any) => any> = Awaited<ReturnType<T>> extends {
|
|
40
|
+
errors?: any;
|
|
41
|
+
}
|
|
42
|
+
? Awaited<ReturnType<T>>['errors']
|
|
43
|
+
: undefined;
|
|
44
|
+
|
|
28
45
|
export interface Builder {
|
|
29
46
|
log: Logger;
|
|
30
47
|
rimraf(dir: string): void;
|
|
@@ -145,7 +162,6 @@ export interface KitConfig {
|
|
|
145
162
|
onError?: PrerenderOnErrorValue;
|
|
146
163
|
origin?: string;
|
|
147
164
|
};
|
|
148
|
-
routes?: (filepath: string) => boolean;
|
|
149
165
|
serviceWorker?: {
|
|
150
166
|
register?: boolean;
|
|
151
167
|
files?: (filepath: string) => boolean;
|
|
@@ -177,46 +193,32 @@ export interface HandleError {
|
|
|
177
193
|
}
|
|
178
194
|
|
|
179
195
|
/**
|
|
180
|
-
* The
|
|
181
|
-
*
|
|
182
|
-
* Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the Params generic argument.
|
|
196
|
+
* The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types))
|
|
197
|
+
* rather than using `Load` directly.
|
|
183
198
|
*/
|
|
184
199
|
export interface Load<
|
|
185
200
|
Params extends Record<string, string> = Record<string, string>,
|
|
186
|
-
|
|
187
|
-
|
|
201
|
+
InputData extends JSONObject | null = JSONObject | null,
|
|
202
|
+
ParentData extends Record<string, any> | null = Record<string, any> | null,
|
|
203
|
+
OutputData extends Record<string, any> = Record<string, any>
|
|
188
204
|
> {
|
|
189
|
-
(event: LoadEvent<Params,
|
|
205
|
+
(event: LoadEvent<Params, InputData, ParentData>): MaybePromise<OutputData | void>;
|
|
190
206
|
}
|
|
191
207
|
|
|
192
208
|
export interface LoadEvent<
|
|
193
209
|
Params extends Record<string, string> = Record<string, string>,
|
|
194
|
-
|
|
210
|
+
Data extends JSONObject | null = JSONObject | null,
|
|
211
|
+
ParentData extends Record<string, any> | null = Record<string, any> | null
|
|
195
212
|
> {
|
|
196
213
|
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
197
214
|
params: Params;
|
|
198
|
-
|
|
215
|
+
data: Data;
|
|
199
216
|
routeId: string | null;
|
|
200
217
|
session: App.Session;
|
|
201
|
-
|
|
218
|
+
setHeaders: (headers: ResponseHeaders) => void;
|
|
202
219
|
url: URL;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export interface LoadOutput<Props extends Record<string, any> = Record<string, any>> {
|
|
208
|
-
status?: number;
|
|
209
|
-
error?: string | Error;
|
|
210
|
-
redirect?: string;
|
|
211
|
-
props?: Props;
|
|
212
|
-
stuff?: Partial<App.Stuff>;
|
|
213
|
-
cache?: LoadOutputCache;
|
|
214
|
-
dependencies?: string[];
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export interface LoadOutputCache {
|
|
218
|
-
maxage: number;
|
|
219
|
-
private?: boolean;
|
|
220
|
+
parent: () => Promise<ParentData>;
|
|
221
|
+
depends: (...deps: string[]) => void;
|
|
220
222
|
}
|
|
221
223
|
|
|
222
224
|
export interface Navigation {
|
|
@@ -228,9 +230,9 @@ export interface Page<Params extends Record<string, string> = Record<string, str
|
|
|
228
230
|
url: URL;
|
|
229
231
|
params: Params;
|
|
230
232
|
routeId: string | null;
|
|
231
|
-
stuff: App.Stuff;
|
|
232
233
|
status: number;
|
|
233
|
-
error: Error | null;
|
|
234
|
+
error: HttpError | Error | null;
|
|
235
|
+
data: Record<string, any>;
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
export interface ParamMatcher {
|
|
@@ -244,27 +246,17 @@ export interface RequestEvent<Params extends Record<string, string> = Record<str
|
|
|
244
246
|
platform: Readonly<App.Platform>;
|
|
245
247
|
request: Request;
|
|
246
248
|
routeId: string | null;
|
|
249
|
+
setHeaders: (headers: ResponseHeaders) => void;
|
|
247
250
|
url: URL;
|
|
248
251
|
}
|
|
249
252
|
|
|
250
253
|
/**
|
|
251
|
-
* A `(event: RequestEvent) =>
|
|
254
|
+
* A `(event: RequestEvent) => Response` function exported from a +server.js file that corresponds to an HTTP verb (`GET`, `PUT`, `PATCH`, etc) and handles requests with that method.
|
|
252
255
|
*
|
|
253
256
|
* It receives `Params` as the first generic argument, which you can skip by using [generated types](/docs/types#generated-types) instead.
|
|
254
|
-
*
|
|
255
|
-
* The next generic argument `Output` is used to validate the returned `body` from your functions by passing it through `BodyValidator`, which will make sure the variable in the `body` matches what with you assign here. It defaults to `ResponseBody`, which will error when `body` receives a [custom object type](https://www.typescriptlang.org/docs/handbook/2/objects.html).
|
|
256
257
|
*/
|
|
257
|
-
export interface RequestHandler<
|
|
258
|
-
|
|
259
|
-
Output = ResponseBody
|
|
260
|
-
> {
|
|
261
|
-
(event: RequestEvent<Params>): MaybePromise<RequestHandlerOutput<Output>>;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export interface RequestHandlerOutput<Output = ResponseBody> {
|
|
265
|
-
status?: number;
|
|
266
|
-
headers?: Headers | Partial<ResponseHeaders>;
|
|
267
|
-
body?: Output extends ResponseBody ? Output : BodyValidator<Output>;
|
|
258
|
+
export interface RequestHandler<Params extends Record<string, string> = Record<string, string>> {
|
|
259
|
+
(event: RequestEvent<Params>): MaybePromise<Response>;
|
|
268
260
|
}
|
|
269
261
|
|
|
270
262
|
export interface ResolveOptions {
|
|
@@ -301,3 +293,53 @@ export interface SSRManifest {
|
|
|
301
293
|
matchers: () => Promise<Record<string, ParamMatcher>>;
|
|
302
294
|
};
|
|
303
295
|
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* The generic form of `PageServerLoad` and `LayoutServerLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types))
|
|
299
|
+
* rather than using `ServerLoad` directly.
|
|
300
|
+
*/
|
|
301
|
+
export interface ServerLoad<
|
|
302
|
+
Params extends Record<string, string> = Record<string, string>,
|
|
303
|
+
ParentData extends JSONObject | null = JSONObject | null,
|
|
304
|
+
OutputData extends JSONObject | void = JSONObject | void
|
|
305
|
+
> {
|
|
306
|
+
(event: ServerLoadEvent<Params, ParentData>): MaybePromise<OutputData | void>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export interface ServerLoadEvent<
|
|
310
|
+
Params extends Record<string, string> = Record<string, string>,
|
|
311
|
+
ParentData extends JSONObject | null = JSONObject | null
|
|
312
|
+
> extends RequestEvent<Params> {
|
|
313
|
+
parent: () => Promise<ParentData>;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface Action<Params extends Record<string, string> = Record<string, string>> {
|
|
317
|
+
(event: RequestEvent<Params>): MaybePromise<
|
|
318
|
+
| { status?: number; errors: Record<string, string>; location?: never }
|
|
319
|
+
| { status?: never; errors?: never; location: string }
|
|
320
|
+
| void
|
|
321
|
+
>;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// TODO figure out how to just re-export from '../src/index/index.js' without
|
|
325
|
+
// breaking the site
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Creates an `HttpError` object with an HTTP status code and an optional message.
|
|
329
|
+
* This object, if thrown during request handling, will cause SvelteKit to
|
|
330
|
+
* return an error response without invoking `handleError`
|
|
331
|
+
* @param {number} status
|
|
332
|
+
* @param {string | undefined} [message]
|
|
333
|
+
*/
|
|
334
|
+
export function error(status: number, message?: string | undefined): HttpError;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Creates a `Redirect` object. If thrown during request handling, SvelteKit will
|
|
338
|
+
* return a redirect response.
|
|
339
|
+
*/
|
|
340
|
+
export function redirect(status: number, location: string): Redirect;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Generates a JSON `Response` object from the supplied data.
|
|
344
|
+
*/
|
|
345
|
+
export function json(data: any, init?: ResponseInit): Response;
|
package/types/internal.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { OutputAsset, OutputChunk } from 'rollup';
|
|
2
|
+
import { SvelteComponent } from 'svelte/internal';
|
|
2
3
|
import {
|
|
4
|
+
Action,
|
|
3
5
|
Config,
|
|
4
6
|
ExternalFetch,
|
|
7
|
+
ServerLoad,
|
|
5
8
|
GetSession,
|
|
6
9
|
Handle,
|
|
7
10
|
HandleError,
|
|
@@ -14,14 +17,7 @@ import {
|
|
|
14
17
|
ServerInitOptions,
|
|
15
18
|
SSRManifest
|
|
16
19
|
} from './index.js';
|
|
17
|
-
import {
|
|
18
|
-
HttpMethod,
|
|
19
|
-
JSONObject,
|
|
20
|
-
MaybePromise,
|
|
21
|
-
RequestOptions,
|
|
22
|
-
ResponseHeaders,
|
|
23
|
-
TrailingSlash
|
|
24
|
-
} from './private.js';
|
|
20
|
+
import { HttpMethod, MaybePromise, RequestOptions, TrailingSlash } from './private.js';
|
|
25
21
|
|
|
26
22
|
export interface ServerModule {
|
|
27
23
|
Server: typeof InternalServer;
|
|
@@ -64,16 +60,25 @@ export interface BuildData {
|
|
|
64
60
|
};
|
|
65
61
|
}
|
|
66
62
|
|
|
67
|
-
export
|
|
63
|
+
export interface CSRPageNode {
|
|
64
|
+
component: typeof SvelteComponent;
|
|
65
|
+
shared: {
|
|
66
|
+
load: Load;
|
|
67
|
+
hydrate: boolean;
|
|
68
|
+
router: boolean;
|
|
69
|
+
};
|
|
70
|
+
server: boolean;
|
|
71
|
+
}
|
|
68
72
|
|
|
69
|
-
export type
|
|
73
|
+
export type CSRPageNodeLoader = () => Promise<CSRPageNode>;
|
|
70
74
|
|
|
71
75
|
export type CSRRoute = {
|
|
72
76
|
id: string;
|
|
73
77
|
exec: (path: string) => undefined | Record<string, string>;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
errors: CSRPageNodeLoader[];
|
|
79
|
+
layouts: CSRPageNodeLoader[];
|
|
80
|
+
leaf: CSRPageNodeLoader;
|
|
81
|
+
uses_server_data: boolean;
|
|
77
82
|
};
|
|
78
83
|
|
|
79
84
|
export interface EndpointData {
|
|
@@ -109,7 +114,7 @@ export class InternalServer extends Server {
|
|
|
109
114
|
|
|
110
115
|
export interface ManifestData {
|
|
111
116
|
assets: Asset[];
|
|
112
|
-
|
|
117
|
+
nodes: PageNode[];
|
|
113
118
|
routes: RouteData[];
|
|
114
119
|
matchers: Record<string, string>;
|
|
115
120
|
}
|
|
@@ -119,34 +124,24 @@ export interface MethodOverride {
|
|
|
119
124
|
allowed: string[];
|
|
120
125
|
}
|
|
121
126
|
|
|
122
|
-
export
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
props?: Record<string, any> | Promise<Record<string, any>>;
|
|
127
|
-
stuff?: Record<string, any>;
|
|
128
|
-
cache?: NormalizedLoadOutputCache;
|
|
129
|
-
dependencies?: string[];
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export interface NormalizedLoadOutputCache {
|
|
133
|
-
maxage: number;
|
|
134
|
-
private?: boolean;
|
|
127
|
+
export interface PageNode {
|
|
128
|
+
component?: string; // TODO supply default component if it's missing (bit of an edge case)
|
|
129
|
+
shared?: string;
|
|
130
|
+
server?: string;
|
|
135
131
|
}
|
|
136
132
|
|
|
137
133
|
export interface PageData {
|
|
138
134
|
type: 'page';
|
|
139
135
|
id: string;
|
|
140
|
-
shadow: string | null;
|
|
141
136
|
pattern: RegExp;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
errors: Array<PageNode | undefined>;
|
|
138
|
+
layouts: Array<PageNode | undefined>;
|
|
139
|
+
leaf: PageNode;
|
|
145
140
|
}
|
|
146
141
|
|
|
147
142
|
export type PayloadScriptAttributes =
|
|
148
143
|
| { type: 'data'; url: string; body?: string }
|
|
149
|
-
| { type: '
|
|
144
|
+
| { type: 'server_data' };
|
|
150
145
|
|
|
151
146
|
export interface PrerenderDependency {
|
|
152
147
|
response: Response;
|
|
@@ -154,6 +149,7 @@ export interface PrerenderDependency {
|
|
|
154
149
|
}
|
|
155
150
|
|
|
156
151
|
export interface PrerenderOptions {
|
|
152
|
+
cache?: string; // including this here is a bit of a hack, but it makes it easy to add <meta http-equiv>
|
|
157
153
|
fallback?: boolean;
|
|
158
154
|
dependencies: Map<string, PrerenderDependency>;
|
|
159
155
|
}
|
|
@@ -174,29 +170,7 @@ export interface Respond {
|
|
|
174
170
|
|
|
175
171
|
export type RouteData = PageData | EndpointData;
|
|
176
172
|
|
|
177
|
-
export interface ShadowEndpointOutput<Output extends JSONObject = JSONObject> {
|
|
178
|
-
status?: number;
|
|
179
|
-
headers?: Partial<ResponseHeaders>;
|
|
180
|
-
body?: Output;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export interface ShadowRequestHandler<Output extends JSONObject = JSONObject> {
|
|
184
|
-
(event: RequestEvent): MaybePromise<ShadowEndpointOutput<Output>>;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export interface ShadowData {
|
|
188
|
-
status?: number;
|
|
189
|
-
error?: Error;
|
|
190
|
-
redirect?: string;
|
|
191
|
-
cookies?: string[];
|
|
192
|
-
body?: JSONObject;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
173
|
export interface SSRComponent {
|
|
196
|
-
router?: boolean;
|
|
197
|
-
hydrate?: boolean;
|
|
198
|
-
prerender?: boolean;
|
|
199
|
-
load: Load;
|
|
200
174
|
default: {
|
|
201
175
|
render(props: Record<string, any>): {
|
|
202
176
|
html: string;
|
|
@@ -217,13 +191,11 @@ export interface SSREndpoint {
|
|
|
217
191
|
pattern: RegExp;
|
|
218
192
|
names: string[];
|
|
219
193
|
types: string[];
|
|
220
|
-
load(): Promise<
|
|
221
|
-
[method: string]: RequestHandler;
|
|
222
|
-
}>;
|
|
194
|
+
load(): Promise<Partial<Record<HttpMethod, RequestHandler>>>;
|
|
223
195
|
}
|
|
224
196
|
|
|
225
197
|
export interface SSRNode {
|
|
226
|
-
|
|
198
|
+
component: SSRComponent;
|
|
227
199
|
/** index into the `components` array in client-manifest.js */
|
|
228
200
|
index: number;
|
|
229
201
|
/** client-side module URL for this component */
|
|
@@ -234,6 +206,23 @@ export interface SSRNode {
|
|
|
234
206
|
stylesheets: string[];
|
|
235
207
|
/** inlined styles */
|
|
236
208
|
inline_styles?: () => MaybePromise<Record<string, string>>;
|
|
209
|
+
|
|
210
|
+
shared: {
|
|
211
|
+
load?: Load;
|
|
212
|
+
hydrate?: boolean;
|
|
213
|
+
prerender?: boolean;
|
|
214
|
+
router?: boolean;
|
|
215
|
+
ssr?: boolean;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
server: {
|
|
219
|
+
load?: ServerLoad;
|
|
220
|
+
HEAD?: ServerLoad;
|
|
221
|
+
POST?: Action;
|
|
222
|
+
PATCH?: Action;
|
|
223
|
+
PUT?: Action;
|
|
224
|
+
DELETE?: Action;
|
|
225
|
+
};
|
|
237
226
|
}
|
|
238
227
|
|
|
239
228
|
export type SSRNodeLoader = () => Promise<SSRNode>;
|
|
@@ -282,20 +271,9 @@ export interface SSRPage {
|
|
|
282
271
|
pattern: RegExp;
|
|
283
272
|
names: string[];
|
|
284
273
|
types: string[];
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
[method: string]: ShadowRequestHandler;
|
|
289
|
-
}>);
|
|
290
|
-
/**
|
|
291
|
-
* plan a is to render 1 or more layout components followed by a leaf component.
|
|
292
|
-
*/
|
|
293
|
-
a: Array<number | undefined>;
|
|
294
|
-
/**
|
|
295
|
-
* plan b — if one of them components fails in `load` we backtrack until we find
|
|
296
|
-
* the nearest error component.
|
|
297
|
-
*/
|
|
298
|
-
b: Array<number | undefined>;
|
|
274
|
+
errors: Array<number | undefined>;
|
|
275
|
+
layouts: Array<number | undefined>;
|
|
276
|
+
leaf: number;
|
|
299
277
|
}
|
|
300
278
|
|
|
301
279
|
export interface SSRErrorPage {
|
package/types/private.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface AdapterEntry {
|
|
|
26
26
|
}) => MaybePromise<void>;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// TODO is this still used?
|
|
29
30
|
export type BodyValidator<T> = {
|
|
30
31
|
[P in keyof T]: T[P] extends { [k: string]: unknown }
|
|
31
32
|
? BodyValidator<T[P]> // recurse when T[P] is an object
|
|
@@ -212,7 +213,7 @@ export interface RequestOptions {
|
|
|
212
213
|
}
|
|
213
214
|
|
|
214
215
|
/** `string[]` is only for set-cookie, everything else must be type of `string` */
|
|
215
|
-
export type ResponseHeaders = Record<string, string | number | string[]>;
|
|
216
|
+
export type ResponseHeaders = Record<string, string | number | string[] | null>;
|
|
216
217
|
|
|
217
218
|
export interface RouteDefinition {
|
|
218
219
|
id: string;
|
package/assets/app/navigation.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { client } from '../client/singletons.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {string} name
|
|
5
|
-
*/
|
|
6
|
-
function guard(name) {
|
|
7
|
-
return () => {
|
|
8
|
-
throw new Error(`Cannot call ${name}(...) on the server`);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const ssr = import.meta.env.SSR;
|
|
13
|
-
|
|
14
|
-
const disableScrollHandling = ssr
|
|
15
|
-
? guard('disableScrollHandling')
|
|
16
|
-
: client.disable_scroll_handling;
|
|
17
|
-
const goto = ssr ? guard('goto') : client.goto;
|
|
18
|
-
const invalidate = ssr ? guard('invalidate') : client.invalidate;
|
|
19
|
-
const prefetch = ssr ? guard('prefetch') : client.prefetch;
|
|
20
|
-
const prefetchRoutes = ssr ? guard('prefetchRoutes') : client.prefetch_routes;
|
|
21
|
-
const beforeNavigate = ssr ? () => {} : client.before_navigate;
|
|
22
|
-
const afterNavigate = ssr ? () => {} : client.after_navigate;
|
|
23
|
-
|
|
24
|
-
export { afterNavigate, beforeNavigate, disableScrollHandling, goto, invalidate, prefetch, prefetchRoutes };
|
package/assets/app/paths.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { assets, base } from '../paths.js';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script context="module">
|
|
2
|
-
/** @type {import('@sveltejs/kit').Load} */
|
|
3
|
-
export function load({ error, status }) {
|
|
4
|
-
return {
|
|
5
|
-
props: { error, status }
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<script>
|
|
11
|
-
/** @type {number} */
|
|
12
|
-
export let status;
|
|
13
|
-
|
|
14
|
-
/** @type {Error & {frame?: string} & {loc?: object}} */
|
|
15
|
-
export let error;
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<h1>{status}</h1>
|
|
19
|
-
|
|
20
|
-
<pre>{error.message}</pre>
|
|
21
|
-
|
|
22
|
-
<!-- TODO figure out what to do with frames/stacktraces in prod -->
|
|
23
|
-
<!-- frame is populated by Svelte in its CompileError and is a Rollup/Vite convention -->
|
|
24
|
-
{#if error.frame}
|
|
25
|
-
<pre>{error.frame}</pre>
|
|
26
|
-
{/if}
|
|
27
|
-
{#if error.stack}
|
|
28
|
-
<pre>{error.stack}</pre>
|
|
29
|
-
{/if}
|