@sveltejs/kit 1.0.0-next.25 → 1.0.0-next.253
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 +79 -0
- package/assets/app/paths.js +1 -0
- package/assets/{runtime/app → app}/stores.js +19 -15
- package/assets/chunks/utils.js +13 -0
- package/assets/client/singletons.js +21 -0
- package/assets/client/start.js +1382 -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 +2374 -0
- package/dist/chunks/amp_hook.js +56 -0
- package/dist/chunks/build.js +658 -0
- package/dist/chunks/cert.js +28154 -0
- package/dist/chunks/index.js +459 -0
- package/dist/chunks/index2.js +806 -0
- package/dist/chunks/index3.js +644 -0
- package/dist/chunks/index4.js +114 -0
- package/dist/chunks/index5.js +858 -0
- package/dist/chunks/index6.js +170 -0
- package/dist/chunks/index7.js +15582 -0
- package/dist/chunks/index8.js +4207 -0
- package/dist/chunks/misc.js +3 -0
- package/dist/chunks/multipart-parser.js +449 -0
- package/dist/cli.js +1122 -84
- package/dist/hooks.js +28 -0
- package/dist/install-fetch.js +6518 -0
- package/dist/node.js +95 -0
- package/package.json +95 -54
- package/svelte-kit.js +2 -0
- package/types/ambient-modules.d.ts +195 -0
- package/types/app.d.ts +35 -0
- package/types/config.d.ts +173 -0
- package/types/csp.d.ts +115 -0
- package/types/endpoint.d.ts +24 -0
- package/types/helper.d.ts +32 -0
- package/types/hooks.d.ts +38 -0
- package/types/index.d.ts +10 -0
- package/types/internal.d.ts +252 -0
- package/types/page.d.ts +85 -0
- package/CHANGELOG.md +0 -306
- 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.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/build.js +0 -246
- package/dist/build.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/colors.js +0 -37
- package/dist/colors.js.map +0 -1
- package/dist/create_app.js +0 -578
- package/dist/create_app.js.map +0 -1
- package/dist/index.js +0 -367
- package/dist/index.js.map +0 -1
- package/dist/index2.js +0 -12043
- package/dist/index2.js.map +0 -1
- package/dist/index3.js +0 -550
- 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 -464
- package/dist/index5.js.map +0 -1
- package/dist/index6.js +0 -727
- package/dist/index6.js.map +0 -1
- package/dist/logging.js +0 -43
- package/dist/logging.js.map +0 -1
- package/dist/package.js +0 -432
- package/dist/package.js.map +0 -1
- package/dist/renderer.js +0 -2403
- package/dist/renderer.js.map +0 -1
- package/dist/standard.js +0 -101
- package/dist/standard.js.map +0 -1
- package/dist/utils.js +0 -54
- package/dist/utils.js.map +0 -1
- package/svelte-kit +0 -3
package/types/csp.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2021-present, Joshua Hemphill
|
|
7
|
+
* Copyright (c) 2021, Tecnico Corporation
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
type SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:';
|
|
28
|
+
|
|
29
|
+
type HostProtocolSchemes = `${string}://` | '';
|
|
30
|
+
type PortScheme = `:${number}` | '' | ':*';
|
|
31
|
+
/** Can actually be any string, but typed more explicitly to
|
|
32
|
+
* restrict the combined optional types of Source from collapsing to just bing `string` */
|
|
33
|
+
type HostNameScheme = `${string}.${string}` | `localhost`;
|
|
34
|
+
type HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`;
|
|
35
|
+
|
|
36
|
+
type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;
|
|
37
|
+
|
|
38
|
+
type BaseSource = 'self' | 'unsafe-eval' | 'unsafe-hashes' | 'unsafe-inline' | 'none';
|
|
39
|
+
|
|
40
|
+
export type Source = HostSource | SchemeSource | CryptoSource | BaseSource;
|
|
41
|
+
type Sources = Source[];
|
|
42
|
+
|
|
43
|
+
type ActionSource = 'strict-dynamic' | 'report-sample';
|
|
44
|
+
|
|
45
|
+
type FrameSource = HostSource | SchemeSource | 'self' | 'none';
|
|
46
|
+
|
|
47
|
+
type HttpDelineator = '/' | '?' | '#' | '\\';
|
|
48
|
+
type UriPath = `${HttpDelineator}${string}`;
|
|
49
|
+
|
|
50
|
+
export type CspDirectives = {
|
|
51
|
+
'child-src'?: Sources;
|
|
52
|
+
'default-src'?: Array<Source | ActionSource>;
|
|
53
|
+
'frame-src'?: Sources;
|
|
54
|
+
'worker-src'?: Sources;
|
|
55
|
+
'connect-src'?: Sources;
|
|
56
|
+
'font-src'?: Sources;
|
|
57
|
+
'img-src'?: Sources;
|
|
58
|
+
'manifest-src'?: Sources;
|
|
59
|
+
'media-src'?: Sources;
|
|
60
|
+
'object-src'?: Sources;
|
|
61
|
+
'prefetch-src'?: Sources;
|
|
62
|
+
'script-src'?: Array<Source | ActionSource>;
|
|
63
|
+
'script-src-elem'?: Sources;
|
|
64
|
+
'script-src-attr'?: Sources;
|
|
65
|
+
'style-src'?: Array<Source | ActionSource>;
|
|
66
|
+
'style-src-elem'?: Sources;
|
|
67
|
+
'style-src-attr'?: Sources;
|
|
68
|
+
'base-uri'?: Array<Source | ActionSource>;
|
|
69
|
+
sandbox?: Array<
|
|
70
|
+
| 'allow-downloads-without-user-activation'
|
|
71
|
+
| 'allow-forms'
|
|
72
|
+
| 'allow-modals'
|
|
73
|
+
| 'allow-orientation-lock'
|
|
74
|
+
| 'allow-pointer-lock'
|
|
75
|
+
| 'allow-popups'
|
|
76
|
+
| 'allow-popups-to-escape-sandbox'
|
|
77
|
+
| 'allow-presentation'
|
|
78
|
+
| 'allow-same-origin'
|
|
79
|
+
| 'allow-scripts'
|
|
80
|
+
| 'allow-storage-access-by-user-activation'
|
|
81
|
+
| 'allow-top-navigation'
|
|
82
|
+
| 'allow-top-navigation-by-user-activation'
|
|
83
|
+
>;
|
|
84
|
+
'form-action'?: Array<Source | ActionSource>;
|
|
85
|
+
'frame-ancestors'?: Array<HostSource | SchemeSource | FrameSource>;
|
|
86
|
+
'navigate-to'?: Array<Source | ActionSource>;
|
|
87
|
+
'report-uri'?: UriPath[];
|
|
88
|
+
'report-to'?: string[];
|
|
89
|
+
|
|
90
|
+
'require-trusted-types-for'?: Array<'script'>;
|
|
91
|
+
'trusted-types'?: Array<'none' | 'allow-duplicates' | '*' | string>;
|
|
92
|
+
'upgrade-insecure-requests'?: boolean;
|
|
93
|
+
|
|
94
|
+
/** @deprecated */
|
|
95
|
+
'require-sri-for'?: Array<'script' | 'style' | 'script style'>;
|
|
96
|
+
|
|
97
|
+
/** @deprecated */
|
|
98
|
+
'block-all-mixed-content'?: boolean;
|
|
99
|
+
|
|
100
|
+
/** @deprecated */
|
|
101
|
+
'plugin-types'?: Array<`${string}/${string}` | 'none'>;
|
|
102
|
+
|
|
103
|
+
/** @deprecated */
|
|
104
|
+
referrer?: Array<
|
|
105
|
+
| 'no-referrer'
|
|
106
|
+
| 'no-referrer-when-downgrade'
|
|
107
|
+
| 'origin'
|
|
108
|
+
| 'origin-when-cross-origin'
|
|
109
|
+
| 'same-origin'
|
|
110
|
+
| 'strict-origin'
|
|
111
|
+
| 'strict-origin-when-cross-origin'
|
|
112
|
+
| 'unsafe-url'
|
|
113
|
+
| 'none'
|
|
114
|
+
>;
|
|
115
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RequestEvent } from './hooks';
|
|
2
|
+
import { Either, JSONString, MaybePromise, ResponseHeaders } from './helper';
|
|
3
|
+
|
|
4
|
+
type Body = JSONString | Uint8Array | ReadableStream | import('stream').Readable;
|
|
5
|
+
|
|
6
|
+
export interface EndpointOutput<Output extends Body = Body> {
|
|
7
|
+
status?: number;
|
|
8
|
+
headers?: Headers | Partial<ResponseHeaders>;
|
|
9
|
+
body?: Output;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Fallthrough {
|
|
13
|
+
fallthrough: true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface RequestHandler<
|
|
17
|
+
Locals = Record<string, any>,
|
|
18
|
+
Platform = Record<string, any>,
|
|
19
|
+
Output extends Body = Body
|
|
20
|
+
> {
|
|
21
|
+
(event: RequestEvent<Locals, Platform>): MaybePromise<
|
|
22
|
+
Either<Response | EndpointOutput<Output>, Fallthrough>
|
|
23
|
+
>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type ToJSON = { toJSON(...args: any[]): JSONValue };
|
|
2
|
+
type JSONValue = Exclude<JSONString, ToJSON>;
|
|
3
|
+
export type JSONString =
|
|
4
|
+
| string
|
|
5
|
+
| number
|
|
6
|
+
| boolean
|
|
7
|
+
| null
|
|
8
|
+
| ToJSON
|
|
9
|
+
| JSONString[]
|
|
10
|
+
| { [key: string]: JSONString };
|
|
11
|
+
|
|
12
|
+
/** `string[]` is only for set-cookie, everything else must be type of `string` */
|
|
13
|
+
export type ResponseHeaders = Record<string, string | string[]>;
|
|
14
|
+
|
|
15
|
+
// <-- Utility Types -->
|
|
16
|
+
type Only<T, U> = { [P in keyof T]: T[P] } & { [P in Exclude<keyof U, keyof T>]?: never };
|
|
17
|
+
|
|
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
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
23
|
+
export type RecursiveRequired<T> = {
|
|
24
|
+
// Recursive implementation of TypeScript's Required utility type.
|
|
25
|
+
// Will recursively continue until it reaches primitive or union
|
|
26
|
+
// with a Function in it, except those commented below
|
|
27
|
+
[K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
|
|
28
|
+
? RecursiveRequired<T[K]> // recursively continue through.
|
|
29
|
+
: K extends 'vite' // If it reaches the 'vite' key
|
|
30
|
+
? Extract<T[K], Function> // only take the Function type.
|
|
31
|
+
: T[K]; // Use the exact type for everything else
|
|
32
|
+
};
|
package/types/hooks.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MaybePromise } from './helper';
|
|
2
|
+
|
|
3
|
+
export type StrictBody = string | Uint8Array;
|
|
4
|
+
|
|
5
|
+
export interface RequestEvent<Locals = Record<string, any>, Platform = Record<string, any>> {
|
|
6
|
+
request: Request;
|
|
7
|
+
url: URL;
|
|
8
|
+
params: Record<string, string>;
|
|
9
|
+
locals: Locals;
|
|
10
|
+
platform: Readonly<Platform>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface GetSession<
|
|
14
|
+
Locals = Record<string, any>,
|
|
15
|
+
Platform = Record<string, any>,
|
|
16
|
+
Session = any
|
|
17
|
+
> {
|
|
18
|
+
(event: RequestEvent<Locals, Platform>): MaybePromise<Session>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ResolveOpts {
|
|
22
|
+
ssr?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Handle<Locals = Record<string, any>, Platform = Record<string, any>> {
|
|
26
|
+
(input: {
|
|
27
|
+
event: RequestEvent<Locals, Platform>;
|
|
28
|
+
resolve(event: RequestEvent<Locals, Platform>, opts?: ResolveOpts): MaybePromise<Response>;
|
|
29
|
+
}): MaybePromise<Response>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface HandleError<Locals = Record<string, any>> {
|
|
33
|
+
(input: { error: Error & { frame?: string }; event: RequestEvent<Locals> }): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ExternalFetch {
|
|
37
|
+
(req: Request): Promise<Response>;
|
|
38
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
/// <reference types="vite/client" />
|
|
3
|
+
|
|
4
|
+
import './ambient-modules';
|
|
5
|
+
|
|
6
|
+
export { App, SSRManifest } from './app';
|
|
7
|
+
export { Adapter, Builder, Config, PrerenderErrorHandler, ValidatedConfig } from './config';
|
|
8
|
+
export { EndpointOutput, RequestHandler } from './endpoint';
|
|
9
|
+
export { ErrorLoad, ErrorLoadInput, Load, LoadInput, LoadOutput } from './page';
|
|
10
|
+
export { ExternalFetch, GetSession, Handle, HandleError, RequestEvent, ResolveOpts } from './hooks';
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { OutputAsset, OutputChunk } from 'rollup';
|
|
2
|
+
import { ValidatedConfig } from './config';
|
|
3
|
+
import { InternalApp, SSRManifest } from './app';
|
|
4
|
+
import { Fallthrough, RequestHandler } from './endpoint';
|
|
5
|
+
import { Either } from './helper';
|
|
6
|
+
import { ExternalFetch, GetSession, Handle, HandleError, RequestEvent } from './hooks';
|
|
7
|
+
import { Load } from './page';
|
|
8
|
+
|
|
9
|
+
export interface PrerenderDependency {
|
|
10
|
+
response: Response;
|
|
11
|
+
body: null | string | Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface PrerenderOptions {
|
|
15
|
+
fallback?: string;
|
|
16
|
+
all: boolean;
|
|
17
|
+
dependencies: Map<string, PrerenderDependency>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AppModule {
|
|
21
|
+
App: typeof InternalApp;
|
|
22
|
+
|
|
23
|
+
override(options: {
|
|
24
|
+
paths: {
|
|
25
|
+
base: string;
|
|
26
|
+
assets: string;
|
|
27
|
+
};
|
|
28
|
+
prerendering: boolean;
|
|
29
|
+
protocol?: 'http' | 'https';
|
|
30
|
+
read(file: string): Buffer;
|
|
31
|
+
}): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Logger {
|
|
35
|
+
(msg: string): void;
|
|
36
|
+
success(msg: string): void;
|
|
37
|
+
error(msg: string): void;
|
|
38
|
+
warn(msg: string): void;
|
|
39
|
+
minor(msg: string): void;
|
|
40
|
+
info(msg: string): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface SSRComponent {
|
|
44
|
+
router?: boolean;
|
|
45
|
+
hydrate?: boolean;
|
|
46
|
+
prerender?: boolean;
|
|
47
|
+
load: Load;
|
|
48
|
+
default: {
|
|
49
|
+
render(props: Record<string, any>): {
|
|
50
|
+
html: string;
|
|
51
|
+
head: string;
|
|
52
|
+
css: {
|
|
53
|
+
code: string;
|
|
54
|
+
map: any; // TODO
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type SSRComponentLoader = () => Promise<SSRComponent>;
|
|
61
|
+
|
|
62
|
+
export type CSRComponent = any; // TODO
|
|
63
|
+
|
|
64
|
+
export type CSRComponentLoader = () => Promise<CSRComponent>;
|
|
65
|
+
|
|
66
|
+
export interface SSRPagePart {
|
|
67
|
+
id: string;
|
|
68
|
+
load: SSRComponentLoader;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type GetParams = (match: RegExpExecArray) => Record<string, string>;
|
|
72
|
+
|
|
73
|
+
export interface SSRPage {
|
|
74
|
+
type: 'page';
|
|
75
|
+
pattern: RegExp;
|
|
76
|
+
params: GetParams;
|
|
77
|
+
/**
|
|
78
|
+
* plan a is to render 1 or more layout components followed by a leaf component.
|
|
79
|
+
*/
|
|
80
|
+
a: number[];
|
|
81
|
+
/**
|
|
82
|
+
* plan b — if one of them components fails in `load` we backtrack until we find
|
|
83
|
+
* the nearest error component.
|
|
84
|
+
*/
|
|
85
|
+
b: number[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface SSREndpoint {
|
|
89
|
+
type: 'endpoint';
|
|
90
|
+
pattern: RegExp;
|
|
91
|
+
params: GetParams;
|
|
92
|
+
load(): Promise<{
|
|
93
|
+
[method: string]: RequestHandler;
|
|
94
|
+
}>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type SSRRoute = SSREndpoint | SSRPage;
|
|
98
|
+
|
|
99
|
+
export type CSRRoute = [RegExp, CSRComponentLoader[], CSRComponentLoader[], GetParams?];
|
|
100
|
+
|
|
101
|
+
export type SSRNodeLoader = () => Promise<SSRNode>;
|
|
102
|
+
|
|
103
|
+
export interface Hooks {
|
|
104
|
+
externalFetch: ExternalFetch;
|
|
105
|
+
getSession: GetSession;
|
|
106
|
+
handle: Handle;
|
|
107
|
+
handleError: HandleError;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface SSRNode {
|
|
111
|
+
module: SSRComponent;
|
|
112
|
+
/** client-side module URL for this component */
|
|
113
|
+
entry: string;
|
|
114
|
+
/** external CSS files */
|
|
115
|
+
css: string[];
|
|
116
|
+
/** external JS files */
|
|
117
|
+
js: string[];
|
|
118
|
+
/** inlined styles */
|
|
119
|
+
styles?: Record<string, string>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface SSRRenderOptions {
|
|
123
|
+
amp: boolean;
|
|
124
|
+
csp: ValidatedConfig['kit']['csp'];
|
|
125
|
+
dev: boolean;
|
|
126
|
+
floc: boolean;
|
|
127
|
+
get_stack: (error: Error) => string | undefined;
|
|
128
|
+
handle_error(error: Error & { frame?: string }, event: RequestEvent): void;
|
|
129
|
+
hooks: Hooks;
|
|
130
|
+
hydrate: boolean;
|
|
131
|
+
manifest: SSRManifest;
|
|
132
|
+
method_override: MethodOverride;
|
|
133
|
+
paths: {
|
|
134
|
+
base: string;
|
|
135
|
+
assets: string;
|
|
136
|
+
};
|
|
137
|
+
prefix: string;
|
|
138
|
+
prerender: boolean;
|
|
139
|
+
read(file: string): Buffer;
|
|
140
|
+
root: SSRComponent['default'];
|
|
141
|
+
router: boolean;
|
|
142
|
+
service_worker?: string;
|
|
143
|
+
target: string;
|
|
144
|
+
template({
|
|
145
|
+
head,
|
|
146
|
+
body,
|
|
147
|
+
assets,
|
|
148
|
+
nonce
|
|
149
|
+
}: {
|
|
150
|
+
head: string;
|
|
151
|
+
body: string;
|
|
152
|
+
assets: string;
|
|
153
|
+
nonce: string;
|
|
154
|
+
}): string;
|
|
155
|
+
template_contains_nonce: boolean;
|
|
156
|
+
trailing_slash: TrailingSlash;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface SSRRenderState {
|
|
160
|
+
fetched?: string;
|
|
161
|
+
initiator?: SSRPage | null;
|
|
162
|
+
platform?: any;
|
|
163
|
+
prerender?: PrerenderOptions;
|
|
164
|
+
fallback?: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface Asset {
|
|
168
|
+
file: string;
|
|
169
|
+
size: number;
|
|
170
|
+
type: string | null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface RouteSegment {
|
|
174
|
+
content: string;
|
|
175
|
+
dynamic: boolean;
|
|
176
|
+
rest: boolean;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export type HttpMethod = 'get' | 'head' | 'post' | 'put' | 'delete' | 'patch';
|
|
180
|
+
|
|
181
|
+
export interface PageData {
|
|
182
|
+
type: 'page';
|
|
183
|
+
segments: RouteSegment[];
|
|
184
|
+
pattern: RegExp;
|
|
185
|
+
params: string[];
|
|
186
|
+
path: string;
|
|
187
|
+
a: string[];
|
|
188
|
+
b: string[];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface EndpointData {
|
|
192
|
+
type: 'endpoint';
|
|
193
|
+
segments: RouteSegment[];
|
|
194
|
+
pattern: RegExp;
|
|
195
|
+
params: string[];
|
|
196
|
+
file: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export type RouteData = PageData | EndpointData;
|
|
200
|
+
|
|
201
|
+
export interface ManifestData {
|
|
202
|
+
assets: Asset[];
|
|
203
|
+
layout: string;
|
|
204
|
+
error: string;
|
|
205
|
+
components: string[];
|
|
206
|
+
routes: RouteData[];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface BuildData {
|
|
210
|
+
app_dir: string;
|
|
211
|
+
manifest_data: ManifestData;
|
|
212
|
+
service_worker: string | null;
|
|
213
|
+
client: {
|
|
214
|
+
assets: OutputAsset[];
|
|
215
|
+
chunks: OutputChunk[];
|
|
216
|
+
entry: {
|
|
217
|
+
file: string;
|
|
218
|
+
js: string[];
|
|
219
|
+
css: string[];
|
|
220
|
+
};
|
|
221
|
+
vite_manifest: import('vite').Manifest;
|
|
222
|
+
};
|
|
223
|
+
server: {
|
|
224
|
+
chunks: OutputChunk[];
|
|
225
|
+
methods: Record<string, HttpMethod[]>;
|
|
226
|
+
vite_manifest: import('vite').Manifest;
|
|
227
|
+
};
|
|
228
|
+
static: string[];
|
|
229
|
+
entries: string[];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export type NormalizedLoadOutput = Either<
|
|
233
|
+
{
|
|
234
|
+
status: number;
|
|
235
|
+
error?: Error;
|
|
236
|
+
redirect?: string;
|
|
237
|
+
props?: Record<string, any> | Promise<Record<string, any>>;
|
|
238
|
+
stuff?: Record<string, any>;
|
|
239
|
+
maxage?: number;
|
|
240
|
+
},
|
|
241
|
+
Fallthrough
|
|
242
|
+
>;
|
|
243
|
+
|
|
244
|
+
export type TrailingSlash = 'never' | 'always' | 'ignore';
|
|
245
|
+
export interface MethodOverride {
|
|
246
|
+
parameter: string;
|
|
247
|
+
allowed: string[];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface Respond {
|
|
251
|
+
(request: Request, options: SSRRenderOptions, state?: SSRRenderState): Promise<Response>;
|
|
252
|
+
}
|
package/types/page.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Fallthrough } from './endpoint';
|
|
2
|
+
import { Either, InferValue, MaybePromise } from './helper';
|
|
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
|
+
> {
|
|
9
|
+
url: URL;
|
|
10
|
+
params: PageParams;
|
|
11
|
+
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
12
|
+
session: Session;
|
|
13
|
+
stuff: Stuff;
|
|
14
|
+
}
|
|
15
|
+
|
|
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> {
|
|
21
|
+
status?: number;
|
|
22
|
+
error?: Error;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface LoadOutput<
|
|
26
|
+
Props extends Record<string, any> = Record<string, any>,
|
|
27
|
+
Stuff extends Record<string, any> = Record<string, any>
|
|
28
|
+
> {
|
|
29
|
+
status?: number;
|
|
30
|
+
error?: string | Error;
|
|
31
|
+
redirect?: string;
|
|
32
|
+
props?: Props;
|
|
33
|
+
stuff?: Stuff;
|
|
34
|
+
maxage?: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface LoadInputExtends {
|
|
38
|
+
stuff?: Record<string, any>;
|
|
39
|
+
pageParams?: Record<string, string>;
|
|
40
|
+
session?: any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface LoadOutputExtends {
|
|
44
|
+
stuff?: Record<string, any>;
|
|
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
|
+
>;
|
|
85
|
+
}
|