@sveltejs/kit 1.0.0-next.31 → 1.0.0-next.310
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/assets/app/env.js +20 -0
- package/assets/app/navigation.js +24 -0
- package/assets/app/paths.js +1 -0
- package/assets/app/stores.js +97 -0
- package/assets/client/singletons.js +13 -0
- package/assets/client/start.js +1655 -0
- package/assets/components/error.svelte +18 -2
- package/assets/env.js +8 -0
- package/assets/paths.js +13 -0
- package/assets/server/index.js +2862 -0
- package/dist/chunks/amp_hook.js +56 -0
- package/dist/chunks/cert.js +28154 -0
- package/dist/chunks/constants.js +663 -0
- package/dist/chunks/filesystem.js +110 -0
- package/dist/chunks/index.js +515 -0
- package/dist/chunks/index2.js +1326 -0
- package/dist/chunks/index3.js +118 -0
- package/dist/chunks/index4.js +185 -0
- package/dist/chunks/index5.js +251 -0
- package/dist/chunks/index6.js +15585 -0
- package/dist/chunks/index7.js +4207 -0
- package/dist/chunks/misc.js +78 -0
- package/dist/chunks/multipart-parser.js +449 -0
- package/dist/chunks/object.js +83 -0
- package/dist/chunks/sync.js +983 -0
- package/dist/chunks/url.js +56 -0
- package/dist/cli.js +1023 -91
- package/dist/hooks.js +28 -0
- package/dist/install-fetch.js +6518 -0
- package/dist/node.js +94 -0
- package/package.json +92 -54
- package/svelte-kit.js +2 -0
- package/types/ambient.d.ts +298 -0
- package/types/index.d.ts +258 -0
- package/types/internal.d.ts +314 -0
- package/types/private.d.ts +269 -0
- package/CHANGELOG.md +0 -344
- package/assets/runtime/app/navigation.js +0 -23
- package/assets/runtime/app/navigation.js.map +0 -1
- package/assets/runtime/app/paths.js +0 -2
- package/assets/runtime/app/paths.js.map +0 -1
- package/assets/runtime/app/stores.js +0 -78
- package/assets/runtime/app/stores.js.map +0 -1
- package/assets/runtime/internal/singletons.js +0 -15
- package/assets/runtime/internal/singletons.js.map +0 -1
- package/assets/runtime/internal/start.js +0 -591
- package/assets/runtime/internal/start.js.map +0 -1
- package/assets/runtime/utils-85ebcc60.js +0 -18
- package/assets/runtime/utils-85ebcc60.js.map +0 -1
- package/dist/api.js +0 -44
- package/dist/api.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/create_app.js +0 -580
- package/dist/create_app.js.map +0 -1
- package/dist/index.js +0 -375
- package/dist/index.js.map +0 -1
- package/dist/index2.js +0 -12205
- package/dist/index2.js.map +0 -1
- package/dist/index3.js +0 -549
- package/dist/index3.js.map +0 -1
- package/dist/index4.js +0 -74
- package/dist/index4.js.map +0 -1
- package/dist/index5.js +0 -468
- package/dist/index5.js.map +0 -1
- package/dist/index6.js +0 -735
- package/dist/index6.js.map +0 -1
- package/dist/renderer.js +0 -2425
- package/dist/renderer.js.map +0 -1
- package/dist/standard.js +0 -103
- package/dist/standard.js.map +0 -1
- package/dist/utils.js +0 -58
- package/dist/utils.js.map +0 -1
- package/svelte-kit +0 -3
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
/// <reference types="vite/client" />
|
|
3
|
+
|
|
4
|
+
import './ambient';
|
|
5
|
+
|
|
6
|
+
import { CompileOptions } from 'svelte/types/compiler/interfaces';
|
|
7
|
+
import {
|
|
8
|
+
AdapterEntry,
|
|
9
|
+
CspDirectives,
|
|
10
|
+
ErrorLoadInput,
|
|
11
|
+
JSONValue,
|
|
12
|
+
LoadInput,
|
|
13
|
+
LoadOutput,
|
|
14
|
+
Logger,
|
|
15
|
+
MaybePromise,
|
|
16
|
+
Prerendered,
|
|
17
|
+
PrerenderOnErrorValue,
|
|
18
|
+
RequestEvent,
|
|
19
|
+
RequestOptions,
|
|
20
|
+
ResolveOptions,
|
|
21
|
+
ResponseHeaders,
|
|
22
|
+
RouteDefinition,
|
|
23
|
+
TrailingSlash
|
|
24
|
+
} from './private';
|
|
25
|
+
import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal';
|
|
26
|
+
|
|
27
|
+
export interface Adapter {
|
|
28
|
+
name: string;
|
|
29
|
+
adapt(builder: Builder): MaybePromise<void>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface Builder {
|
|
33
|
+
log: Logger;
|
|
34
|
+
rimraf(dir: string): void;
|
|
35
|
+
mkdirp(dir: string): void;
|
|
36
|
+
|
|
37
|
+
config: ValidatedConfig;
|
|
38
|
+
prerendered: Prerendered;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create entry points that map to individual functions
|
|
42
|
+
* @param fn A function that groups a set of routes into an entry point
|
|
43
|
+
*/
|
|
44
|
+
createEntries(fn: (route: RouteDefinition) => AdapterEntry): void;
|
|
45
|
+
|
|
46
|
+
generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
|
|
47
|
+
|
|
48
|
+
getBuildDirectory(name: string): string;
|
|
49
|
+
getClientDirectory(): string;
|
|
50
|
+
getServerDirectory(): string;
|
|
51
|
+
getStaticDirectory(): string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param dest the destination folder to which files should be copied
|
|
55
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
56
|
+
*/
|
|
57
|
+
writeClient(dest: string): string[];
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param dest
|
|
61
|
+
*/
|
|
62
|
+
writePrerendered(
|
|
63
|
+
dest: string,
|
|
64
|
+
opts?: {
|
|
65
|
+
fallback?: string;
|
|
66
|
+
}
|
|
67
|
+
): string[];
|
|
68
|
+
/**
|
|
69
|
+
* @param dest the destination folder to which files should be copied
|
|
70
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
71
|
+
*/
|
|
72
|
+
writeServer(dest: string): string[];
|
|
73
|
+
/**
|
|
74
|
+
* @param dest the destination folder to which files should be copied
|
|
75
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
76
|
+
*/
|
|
77
|
+
writeStatic(dest: string): string[];
|
|
78
|
+
/**
|
|
79
|
+
* @param from the source file or folder
|
|
80
|
+
* @param to the destination file or folder
|
|
81
|
+
* @param opts.filter a function to determine whether a file or folder should be copied
|
|
82
|
+
* @param opts.replace a map of strings to replace
|
|
83
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
84
|
+
*/
|
|
85
|
+
copy(
|
|
86
|
+
from: string,
|
|
87
|
+
to: string,
|
|
88
|
+
opts?: {
|
|
89
|
+
filter?: (basename: string) => boolean;
|
|
90
|
+
replace?: Record<string, string>;
|
|
91
|
+
}
|
|
92
|
+
): string[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface Config {
|
|
96
|
+
compilerOptions?: CompileOptions;
|
|
97
|
+
extensions?: string[];
|
|
98
|
+
kit?: {
|
|
99
|
+
adapter?: Adapter;
|
|
100
|
+
amp?: boolean;
|
|
101
|
+
appDir?: string;
|
|
102
|
+
browser?: {
|
|
103
|
+
hydrate?: boolean;
|
|
104
|
+
router?: boolean;
|
|
105
|
+
};
|
|
106
|
+
csp?: {
|
|
107
|
+
mode?: 'hash' | 'nonce' | 'auto';
|
|
108
|
+
directives?: CspDirectives;
|
|
109
|
+
};
|
|
110
|
+
endpointExtensions?: string[];
|
|
111
|
+
files?: {
|
|
112
|
+
assets?: string;
|
|
113
|
+
hooks?: string;
|
|
114
|
+
lib?: string;
|
|
115
|
+
params?: string;
|
|
116
|
+
routes?: string;
|
|
117
|
+
serviceWorker?: string;
|
|
118
|
+
template?: string;
|
|
119
|
+
};
|
|
120
|
+
floc?: boolean;
|
|
121
|
+
inlineStyleThreshold?: number;
|
|
122
|
+
methodOverride?: {
|
|
123
|
+
parameter?: string;
|
|
124
|
+
allowed?: string[];
|
|
125
|
+
};
|
|
126
|
+
outDir?: string;
|
|
127
|
+
package?: {
|
|
128
|
+
dir?: string;
|
|
129
|
+
emitTypes?: boolean;
|
|
130
|
+
exports?(filepath: string): boolean;
|
|
131
|
+
files?(filepath: string): boolean;
|
|
132
|
+
};
|
|
133
|
+
paths?: {
|
|
134
|
+
assets?: string;
|
|
135
|
+
base?: string;
|
|
136
|
+
};
|
|
137
|
+
prerender?: {
|
|
138
|
+
concurrency?: number;
|
|
139
|
+
crawl?: boolean;
|
|
140
|
+
default?: boolean;
|
|
141
|
+
enabled?: boolean;
|
|
142
|
+
entries?: string[];
|
|
143
|
+
onError?: PrerenderOnErrorValue;
|
|
144
|
+
};
|
|
145
|
+
routes?: (filepath: string) => boolean;
|
|
146
|
+
serviceWorker?: {
|
|
147
|
+
register?: boolean;
|
|
148
|
+
files?: (filepath: string) => boolean;
|
|
149
|
+
};
|
|
150
|
+
trailingSlash?: TrailingSlash;
|
|
151
|
+
version?: {
|
|
152
|
+
name?: string;
|
|
153
|
+
pollInterval?: number;
|
|
154
|
+
};
|
|
155
|
+
vite?: import('vite').UserConfig | (() => MaybePromise<import('vite').UserConfig>);
|
|
156
|
+
};
|
|
157
|
+
preprocess?: any;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface ErrorLoad<
|
|
161
|
+
Params extends Record<string, string> = Record<string, string>,
|
|
162
|
+
Props extends Record<string, any> = Record<string, any>
|
|
163
|
+
> {
|
|
164
|
+
(input: ErrorLoadInput<Params>): MaybePromise<LoadOutput<Props>>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface ExternalFetch {
|
|
168
|
+
(req: Request): Promise<Response>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface GetSession {
|
|
172
|
+
(event: RequestEvent): MaybePromise<App.Session>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface Handle {
|
|
176
|
+
(input: {
|
|
177
|
+
event: RequestEvent;
|
|
178
|
+
resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise<Response>;
|
|
179
|
+
}): MaybePromise<Response>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface HandleError {
|
|
183
|
+
(input: { error: Error & { frame?: string }; event: RequestEvent }): void;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The `(input: LoadInput) => LoadOutput` `load` function exported from `<script context="module">` in a page or layout.
|
|
188
|
+
*
|
|
189
|
+
* Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the Params generic argument.
|
|
190
|
+
*/
|
|
191
|
+
export interface Load<
|
|
192
|
+
Params extends Record<string, string> = Record<string, string>,
|
|
193
|
+
InputProps extends Record<string, any> = Record<string, any>,
|
|
194
|
+
OutputProps extends Record<string, any> = InputProps
|
|
195
|
+
> {
|
|
196
|
+
(input: LoadInput<Params, InputProps>): MaybePromise<LoadOutput<OutputProps>>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface Navigation {
|
|
200
|
+
from: URL;
|
|
201
|
+
to: URL;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface Page<Params extends Record<string, string> = Record<string, string>> {
|
|
205
|
+
url: URL;
|
|
206
|
+
params: Params;
|
|
207
|
+
routeId: string | null;
|
|
208
|
+
stuff: App.Stuff;
|
|
209
|
+
status: number;
|
|
210
|
+
error: Error | null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface ParamMatcher {
|
|
214
|
+
(param: string): boolean;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* A `(event: RequestEvent) => RequestHandlerOutput` function exported from an endpoint that corresponds to an HTTP verb (`get`, `put`, `patch`, etc) and handles requests with that method. Note that since 'delete' is a reserved word in JavaScript, delete handles are called `del` instead.
|
|
219
|
+
*
|
|
220
|
+
* Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the `Params` generic argument.
|
|
221
|
+
*/
|
|
222
|
+
export interface RequestHandler<
|
|
223
|
+
Params extends Record<string, string> = Record<string, string>,
|
|
224
|
+
Output extends ResponseBody = ResponseBody
|
|
225
|
+
> {
|
|
226
|
+
(event: RequestEvent<Params>): MaybePromise<RequestHandlerOutput<Output>>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface RequestHandlerOutput<Output extends ResponseBody = ResponseBody> {
|
|
230
|
+
status?: number;
|
|
231
|
+
headers?: Headers | Partial<ResponseHeaders>;
|
|
232
|
+
body?: Output;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export type ResponseBody = JSONValue | Uint8Array | ReadableStream | import('stream').Readable;
|
|
236
|
+
|
|
237
|
+
export class Server {
|
|
238
|
+
constructor(manifest: SSRManifest);
|
|
239
|
+
respond(request: Request, options: RequestOptions): Promise<Response>;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface SSRManifest {
|
|
243
|
+
appDir: string;
|
|
244
|
+
assets: Set<string>;
|
|
245
|
+
mimeTypes: Record<string, string>;
|
|
246
|
+
|
|
247
|
+
/** private fields */
|
|
248
|
+
_: {
|
|
249
|
+
entry: {
|
|
250
|
+
file: string;
|
|
251
|
+
js: string[];
|
|
252
|
+
css: string[];
|
|
253
|
+
};
|
|
254
|
+
nodes: SSRNodeLoader[];
|
|
255
|
+
routes: SSRRoute[];
|
|
256
|
+
matchers: () => Promise<Record<string, ParamMatcher>>;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { OutputAsset, OutputChunk } from 'rollup';
|
|
2
|
+
import {
|
|
3
|
+
Config,
|
|
4
|
+
ExternalFetch,
|
|
5
|
+
GetSession,
|
|
6
|
+
Handle,
|
|
7
|
+
HandleError,
|
|
8
|
+
Load,
|
|
9
|
+
RequestHandler,
|
|
10
|
+
Server,
|
|
11
|
+
SSRManifest
|
|
12
|
+
} from './index';
|
|
13
|
+
import {
|
|
14
|
+
HttpMethod,
|
|
15
|
+
JSONObject,
|
|
16
|
+
MaybePromise,
|
|
17
|
+
RequestEvent,
|
|
18
|
+
RequestOptions,
|
|
19
|
+
ResolveOptions,
|
|
20
|
+
ResponseHeaders,
|
|
21
|
+
TrailingSlash
|
|
22
|
+
} from './private';
|
|
23
|
+
|
|
24
|
+
export interface ServerModule {
|
|
25
|
+
Server: typeof InternalServer;
|
|
26
|
+
|
|
27
|
+
override(options: {
|
|
28
|
+
paths: {
|
|
29
|
+
base: string;
|
|
30
|
+
assets: string;
|
|
31
|
+
};
|
|
32
|
+
prerendering: boolean;
|
|
33
|
+
protocol?: 'http' | 'https';
|
|
34
|
+
read(file: string): Buffer;
|
|
35
|
+
}): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Asset {
|
|
39
|
+
file: string;
|
|
40
|
+
size: number;
|
|
41
|
+
type: string | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface BuildData {
|
|
45
|
+
app_dir: string;
|
|
46
|
+
manifest_data: ManifestData;
|
|
47
|
+
service_worker: string | null;
|
|
48
|
+
client: {
|
|
49
|
+
assets: OutputAsset[];
|
|
50
|
+
chunks: OutputChunk[];
|
|
51
|
+
entry: {
|
|
52
|
+
file: string;
|
|
53
|
+
js: string[];
|
|
54
|
+
css: string[];
|
|
55
|
+
};
|
|
56
|
+
vite_manifest: import('vite').Manifest;
|
|
57
|
+
};
|
|
58
|
+
server: {
|
|
59
|
+
chunks: OutputChunk[];
|
|
60
|
+
methods: Record<string, HttpMethod[]>;
|
|
61
|
+
vite_manifest: import('vite').Manifest;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type CSRComponent = any; // TODO
|
|
66
|
+
|
|
67
|
+
export type CSRComponentLoader = () => Promise<CSRComponent>;
|
|
68
|
+
|
|
69
|
+
export type CSRRoute = {
|
|
70
|
+
id: string;
|
|
71
|
+
exec: (path: string) => undefined | Record<string, string>;
|
|
72
|
+
a: CSRComponentLoader[];
|
|
73
|
+
b: CSRComponentLoader[];
|
|
74
|
+
has_shadow: boolean;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export interface EndpointData {
|
|
78
|
+
type: 'endpoint';
|
|
79
|
+
id: string;
|
|
80
|
+
pattern: RegExp;
|
|
81
|
+
file: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type GetParams = (match: RegExpExecArray) => Record<string, string>;
|
|
85
|
+
|
|
86
|
+
export interface Hooks {
|
|
87
|
+
externalFetch: ExternalFetch;
|
|
88
|
+
getSession: GetSession;
|
|
89
|
+
handle: Handle;
|
|
90
|
+
handleError: HandleError;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class InternalServer extends Server {
|
|
94
|
+
respond(
|
|
95
|
+
request: Request,
|
|
96
|
+
options: RequestOptions & {
|
|
97
|
+
prerender?: PrerenderOptions;
|
|
98
|
+
}
|
|
99
|
+
): Promise<Response>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface ManifestData {
|
|
103
|
+
assets: Asset[];
|
|
104
|
+
components: string[];
|
|
105
|
+
routes: RouteData[];
|
|
106
|
+
matchers: Record<string, string>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface MethodOverride {
|
|
110
|
+
parameter: string;
|
|
111
|
+
allowed: string[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export type NormalizedLoadOutput = {
|
|
115
|
+
status: number;
|
|
116
|
+
error?: Error;
|
|
117
|
+
redirect?: string;
|
|
118
|
+
props?: Record<string, any> | Promise<Record<string, any>>;
|
|
119
|
+
stuff?: Record<string, any>;
|
|
120
|
+
maxage?: number;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export interface PageData {
|
|
124
|
+
type: 'page';
|
|
125
|
+
id: string;
|
|
126
|
+
shadow: string | null;
|
|
127
|
+
pattern: RegExp;
|
|
128
|
+
path: string;
|
|
129
|
+
a: Array<string | undefined>;
|
|
130
|
+
b: Array<string | undefined>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type PayloadScriptAttributes =
|
|
134
|
+
| { type: 'data'; url: string; body?: string }
|
|
135
|
+
| { type: 'props' };
|
|
136
|
+
|
|
137
|
+
export interface PrerenderDependency {
|
|
138
|
+
response: Response;
|
|
139
|
+
body: null | string | Uint8Array;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface PrerenderOptions {
|
|
143
|
+
fallback?: boolean;
|
|
144
|
+
default: boolean;
|
|
145
|
+
dependencies: Map<string, PrerenderDependency>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export type RecursiveRequired<T> = {
|
|
149
|
+
// Recursive implementation of TypeScript's Required utility type.
|
|
150
|
+
// Will recursively continue until it reaches primitive or union
|
|
151
|
+
// with a Function in it, except those commented below
|
|
152
|
+
[K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
|
|
153
|
+
? RecursiveRequired<T[K]> // recursively continue through.
|
|
154
|
+
: K extends 'vite' // If it reaches the 'vite' key
|
|
155
|
+
? Extract<T[K], Function> // only take the Function type.
|
|
156
|
+
: T[K]; // Use the exact type for everything else
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export type RequiredResolveOptions = Required<ResolveOptions>;
|
|
160
|
+
|
|
161
|
+
export interface Respond {
|
|
162
|
+
(request: Request, options: SSROptions, state: SSRState): Promise<Response>;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export type RouteData = PageData | EndpointData;
|
|
166
|
+
|
|
167
|
+
export interface ShadowEndpointOutput<Output extends JSONObject = JSONObject> {
|
|
168
|
+
status?: number;
|
|
169
|
+
headers?: Partial<ResponseHeaders>;
|
|
170
|
+
body?: Output;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The route key of a page with a matching endpoint — used to ensure the
|
|
175
|
+
* client loads data from the right endpoint during client-side navigation
|
|
176
|
+
* rather than a different route that happens to match the path
|
|
177
|
+
*/
|
|
178
|
+
type ShadowKey = string;
|
|
179
|
+
|
|
180
|
+
export interface ShadowRequestHandler<Output extends JSONObject = JSONObject> {
|
|
181
|
+
(event: RequestEvent): MaybePromise<ShadowEndpointOutput<Output>>;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface ShadowData {
|
|
185
|
+
status?: number;
|
|
186
|
+
error?: Error;
|
|
187
|
+
redirect?: string;
|
|
188
|
+
cookies?: string[];
|
|
189
|
+
body?: JSONObject;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface SSRComponent {
|
|
193
|
+
router?: boolean;
|
|
194
|
+
hydrate?: boolean;
|
|
195
|
+
prerender?: boolean;
|
|
196
|
+
load: Load;
|
|
197
|
+
default: {
|
|
198
|
+
render(props: Record<string, any>): {
|
|
199
|
+
html: string;
|
|
200
|
+
head: string;
|
|
201
|
+
css: {
|
|
202
|
+
code: string;
|
|
203
|
+
map: any; // TODO
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export type SSRComponentLoader = () => Promise<SSRComponent>;
|
|
210
|
+
|
|
211
|
+
export interface SSREndpoint {
|
|
212
|
+
type: 'endpoint';
|
|
213
|
+
id: string;
|
|
214
|
+
pattern: RegExp;
|
|
215
|
+
names: string[];
|
|
216
|
+
types: string[];
|
|
217
|
+
load(): Promise<{
|
|
218
|
+
[method: string]: RequestHandler;
|
|
219
|
+
}>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface SSRNode {
|
|
223
|
+
module: SSRComponent;
|
|
224
|
+
/** client-side module URL for this component */
|
|
225
|
+
entry: string;
|
|
226
|
+
/** external CSS files */
|
|
227
|
+
css: string[];
|
|
228
|
+
/** external JS files */
|
|
229
|
+
js: string[];
|
|
230
|
+
/** inlined styles */
|
|
231
|
+
styles?: Record<string, string>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export type SSRNodeLoader = () => Promise<SSRNode>;
|
|
235
|
+
|
|
236
|
+
export interface SSROptions {
|
|
237
|
+
amp: boolean;
|
|
238
|
+
csp: ValidatedConfig['kit']['csp'];
|
|
239
|
+
dev: boolean;
|
|
240
|
+
floc: boolean;
|
|
241
|
+
get_stack: (error: Error) => string | undefined;
|
|
242
|
+
handle_error(error: Error & { frame?: string }, event: RequestEvent): void;
|
|
243
|
+
hooks: Hooks;
|
|
244
|
+
hydrate: boolean;
|
|
245
|
+
manifest: SSRManifest;
|
|
246
|
+
method_override: MethodOverride;
|
|
247
|
+
paths: {
|
|
248
|
+
base: string;
|
|
249
|
+
assets: string;
|
|
250
|
+
};
|
|
251
|
+
prefix: string;
|
|
252
|
+
prerender: boolean;
|
|
253
|
+
read(file: string): Buffer;
|
|
254
|
+
root: SSRComponent['default'];
|
|
255
|
+
router: boolean;
|
|
256
|
+
service_worker?: string;
|
|
257
|
+
template({
|
|
258
|
+
head,
|
|
259
|
+
body,
|
|
260
|
+
assets,
|
|
261
|
+
nonce
|
|
262
|
+
}: {
|
|
263
|
+
head: string;
|
|
264
|
+
body: string;
|
|
265
|
+
assets: string;
|
|
266
|
+
nonce: string;
|
|
267
|
+
}): string;
|
|
268
|
+
template_contains_nonce: boolean;
|
|
269
|
+
trailing_slash: TrailingSlash;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface SSRPage {
|
|
273
|
+
type: 'page';
|
|
274
|
+
id: string;
|
|
275
|
+
pattern: RegExp;
|
|
276
|
+
names: string[];
|
|
277
|
+
types: string[];
|
|
278
|
+
shadow:
|
|
279
|
+
| null
|
|
280
|
+
| (() => Promise<{
|
|
281
|
+
[method: string]: ShadowRequestHandler;
|
|
282
|
+
}>);
|
|
283
|
+
/**
|
|
284
|
+
* plan a is to render 1 or more layout components followed by a leaf component.
|
|
285
|
+
*/
|
|
286
|
+
a: Array<number | undefined>;
|
|
287
|
+
/**
|
|
288
|
+
* plan b — if one of them components fails in `load` we backtrack until we find
|
|
289
|
+
* the nearest error component.
|
|
290
|
+
*/
|
|
291
|
+
b: Array<number | undefined>;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export interface SSRPagePart {
|
|
295
|
+
id: string;
|
|
296
|
+
load: SSRComponentLoader;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export type SSRRoute = SSREndpoint | SSRPage;
|
|
300
|
+
|
|
301
|
+
export interface SSRState {
|
|
302
|
+
fallback?: string;
|
|
303
|
+
getClientAddress: () => string;
|
|
304
|
+
initiator?: SSRPage | null;
|
|
305
|
+
platform?: any;
|
|
306
|
+
prerender?: PrerenderOptions;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export type StrictBody = string | Uint8Array;
|
|
310
|
+
|
|
311
|
+
export type ValidatedConfig = RecursiveRequired<Config>;
|
|
312
|
+
|
|
313
|
+
export * from './index';
|
|
314
|
+
export * from './private';
|