@sveltejs/kit 1.0.0-next.23 → 1.0.0-next.230

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.
Files changed (83) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +20 -0
  3. package/assets/app/navigation.js +81 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/{runtime/app → app}/stores.js +19 -15
  6. package/assets/chunks/utils.js +13 -0
  7. package/assets/client/singletons.js +18 -0
  8. package/assets/client/start.js +1382 -0
  9. package/assets/components/error.svelte +19 -3
  10. package/assets/env.js +8 -0
  11. package/assets/paths.js +13 -0
  12. package/assets/server/index.js +1998 -0
  13. package/dist/chunks/cert.js +28154 -0
  14. package/dist/chunks/index.js +2391 -0
  15. package/dist/chunks/index2.js +807 -0
  16. package/dist/chunks/index3.js +648 -0
  17. package/dist/chunks/index4.js +109 -0
  18. package/dist/chunks/index5.js +754 -0
  19. package/dist/chunks/index6.js +830 -0
  20. package/dist/chunks/index7.js +15574 -0
  21. package/dist/chunks/index8.js +4207 -0
  22. package/dist/chunks/misc.js +3 -0
  23. package/dist/chunks/multipart-parser.js +449 -0
  24. package/dist/chunks/url.js +62 -0
  25. package/dist/cli.js +1039 -84
  26. package/dist/hooks.js +28 -0
  27. package/dist/install-fetch.js +6514 -0
  28. package/dist/node.js +51 -0
  29. package/package.json +93 -54
  30. package/svelte-kit.js +2 -0
  31. package/types/ambient-modules.d.ts +204 -0
  32. package/types/app.d.ts +45 -0
  33. package/types/config.d.ts +169 -0
  34. package/types/endpoint.d.ts +20 -0
  35. package/types/helper.d.ts +53 -0
  36. package/types/hooks.d.ts +55 -0
  37. package/types/index.d.ts +18 -0
  38. package/types/internal.d.ts +237 -0
  39. package/types/page.d.ts +73 -0
  40. package/CHANGELOG.md +0 -294
  41. package/assets/runtime/app/navigation.js +0 -23
  42. package/assets/runtime/app/navigation.js.map +0 -1
  43. package/assets/runtime/app/paths.js +0 -2
  44. package/assets/runtime/app/paths.js.map +0 -1
  45. package/assets/runtime/app/stores.js.map +0 -1
  46. package/assets/runtime/internal/singletons.js +0 -15
  47. package/assets/runtime/internal/singletons.js.map +0 -1
  48. package/assets/runtime/internal/start.js +0 -591
  49. package/assets/runtime/internal/start.js.map +0 -1
  50. package/assets/runtime/utils-85ebcc60.js +0 -18
  51. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  52. package/dist/api.js +0 -44
  53. package/dist/api.js.map +0 -1
  54. package/dist/build.js +0 -246
  55. package/dist/build.js.map +0 -1
  56. package/dist/cli.js.map +0 -1
  57. package/dist/colors.js +0 -37
  58. package/dist/colors.js.map +0 -1
  59. package/dist/create_app.js +0 -578
  60. package/dist/create_app.js.map +0 -1
  61. package/dist/index.js +0 -367
  62. package/dist/index.js.map +0 -1
  63. package/dist/index2.js +0 -12044
  64. package/dist/index2.js.map +0 -1
  65. package/dist/index3.js +0 -547
  66. package/dist/index3.js.map +0 -1
  67. package/dist/index4.js +0 -73
  68. package/dist/index4.js.map +0 -1
  69. package/dist/index5.js +0 -464
  70. package/dist/index5.js.map +0 -1
  71. package/dist/index6.js +0 -729
  72. package/dist/index6.js.map +0 -1
  73. package/dist/logging.js +0 -43
  74. package/dist/logging.js.map +0 -1
  75. package/dist/package.js +0 -432
  76. package/dist/package.js.map +0 -1
  77. package/dist/renderer.js +0 -2391
  78. package/dist/renderer.js.map +0 -1
  79. package/dist/standard.js +0 -101
  80. package/dist/standard.js.map +0 -1
  81. package/dist/utils.js +0 -54
  82. package/dist/utils.js.map +0 -1
  83. package/svelte-kit +0 -3
@@ -0,0 +1,53 @@
1
+ interface ReadOnlyFormData {
2
+ get(key: string): string | null;
3
+ getAll(key: string): string[];
4
+ has(key: string): boolean;
5
+ entries(): Generator<[string, string], void>;
6
+ keys(): Generator<string, void>;
7
+ values(): Generator<string, void>;
8
+ [Symbol.iterator](): Generator<[string, string], void>;
9
+ }
10
+
11
+ type ToJSON = { toJSON(...args: any[]): JSONValue };
12
+ type JSONValue = Exclude<JSONString, ToJSON>;
13
+ export type JSONString =
14
+ | string
15
+ | number
16
+ | boolean
17
+ | null
18
+ | ToJSON
19
+ | JSONString[]
20
+ | { [key: string]: JSONString };
21
+
22
+ /** `string[]` is only for set-cookie, everything else must be type of `string` */
23
+ export type ResponseHeaders = Record<string, string | string[]>;
24
+ export type RequestHeaders = Record<string, string>;
25
+
26
+ // Utility Types
27
+ export type InferValue<T, Key extends keyof T, Default> = T extends Record<Key, infer Val>
28
+ ? Val
29
+ : Default;
30
+ export type MaybePromise<T> = T | Promise<T>;
31
+ export type Rec<T = any> = Record<string, T>;
32
+ export type RecursiveRequired<T> = {
33
+ // Recursive implementation of TypeScript's Required utility type.
34
+ // Will recursively continue until it reaches primitive or union
35
+ // with a Function in it, except those commented below
36
+ [K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
37
+ ? RecursiveRequired<T[K]> // recursively continue through.
38
+ : K extends 'vite' // If it reaches the 'vite' key
39
+ ? Extract<T[K], Function> // only take the Function type.
40
+ : T[K]; // Use the exact type for everything else
41
+ };
42
+
43
+ type Only<T, U> = {
44
+ [P in keyof T]: T[P];
45
+ } & {
46
+ [P in keyof U]?: never;
47
+ };
48
+
49
+ export type Either<T, U> = Only<T, U> | Only<U, T>;
50
+
51
+ export interface Fallthrough {
52
+ fallthrough: true;
53
+ }
@@ -0,0 +1,55 @@
1
+ import { ParameterizedBody, RawBody } from './app';
2
+ import { MaybePromise, RequestHeaders, ResponseHeaders } from './helper';
3
+
4
+ export type StrictBody = string | Uint8Array;
5
+
6
+ export interface ServerRequest<Locals = Record<string, any>, Body = unknown> {
7
+ url: URL;
8
+ method: string;
9
+ headers: RequestHeaders;
10
+ rawBody: RawBody;
11
+ params: Record<string, string>;
12
+ body: ParameterizedBody<Body>;
13
+ locals: Locals;
14
+ }
15
+
16
+ export interface ServerResponse {
17
+ status: number;
18
+ headers: Partial<ResponseHeaders>;
19
+ body?: StrictBody;
20
+ }
21
+
22
+ export interface GetSession<Locals = Record<string, any>, Body = unknown, Session = any> {
23
+ (request: ServerRequest<Locals, Body>): MaybePromise<Session>;
24
+ }
25
+
26
+ export interface ResolveOpts {
27
+ ssr?: boolean;
28
+ }
29
+
30
+ export interface Handle<Locals = Record<string, any>, Body = unknown> {
31
+ (input: {
32
+ request: ServerRequest<Locals, Body>;
33
+ resolve(request: ServerRequest<Locals, Body>, opts?: ResolveOpts): MaybePromise<ServerResponse>;
34
+ }): MaybePromise<ServerResponse>;
35
+ }
36
+
37
+ // internally, `resolve` could return `undefined`, so we differentiate InternalHandle
38
+ // from the public Handle type
39
+ export interface InternalHandle<Locals = Record<string, any>, Body = unknown> {
40
+ (input: {
41
+ request: ServerRequest<Locals, Body>;
42
+ resolve(
43
+ request: ServerRequest<Locals, Body>,
44
+ opts?: ResolveOpts
45
+ ): MaybePromise<ServerResponse | undefined>;
46
+ }): MaybePromise<ServerResponse | undefined>;
47
+ }
48
+
49
+ export interface HandleError<Locals = Record<string, any>, Body = unknown> {
50
+ (input: { error: Error & { frame?: string }; request: ServerRequest<Locals, Body> }): void;
51
+ }
52
+
53
+ export interface ExternalFetch {
54
+ (req: Request): Promise<Response>;
55
+ }
@@ -0,0 +1,18 @@
1
+ /// <reference types="svelte" />
2
+ /// <reference types="vite/client" />
3
+
4
+ import './ambient-modules';
5
+
6
+ export { App, IncomingRequest, RawBody, 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 {
11
+ ExternalFetch,
12
+ GetSession,
13
+ Handle,
14
+ HandleError,
15
+ ServerRequest as Request,
16
+ ServerResponse as Response,
17
+ ResolveOpts
18
+ } from './hooks';
@@ -0,0 +1,237 @@
1
+ import { OutputAsset, OutputChunk } from 'rollup';
2
+ import { RequestHandler } from './endpoint';
3
+ import { InternalApp, SSRManifest } from './app';
4
+ import {
5
+ ExternalFetch,
6
+ GetSession,
7
+ HandleError,
8
+ InternalHandle,
9
+ ServerRequest,
10
+ ServerResponse
11
+ } from './hooks';
12
+ import { Load } from './page';
13
+ import { Either, Fallthrough } from './helper';
14
+
15
+ type PageId = string;
16
+
17
+ export interface PrerenderOptions {
18
+ fallback?: string;
19
+ all: boolean;
20
+ dependencies: Map<string, ServerResponse>;
21
+ }
22
+
23
+ export interface AppModule {
24
+ App: typeof InternalApp;
25
+
26
+ override(options: {
27
+ paths: {
28
+ base: string;
29
+ assets: string;
30
+ };
31
+ prerendering: boolean;
32
+ protocol?: 'http' | 'https';
33
+ read(file: string): Buffer;
34
+ }): void;
35
+ }
36
+
37
+ export interface Logger {
38
+ (msg: string): void;
39
+ success(msg: string): void;
40
+ error(msg: string): void;
41
+ warn(msg: string): void;
42
+ minor(msg: string): void;
43
+ info(msg: string): void;
44
+ }
45
+
46
+ export interface SSRComponent {
47
+ router?: boolean;
48
+ hydrate?: boolean;
49
+ prerender?: boolean;
50
+ load: Load;
51
+ default: {
52
+ render(props: Record<string, any>): {
53
+ html: string;
54
+ head: string;
55
+ css: {
56
+ code: string;
57
+ map: any; // TODO
58
+ };
59
+ };
60
+ };
61
+ }
62
+
63
+ export type SSRComponentLoader = () => Promise<SSRComponent>;
64
+
65
+ export type CSRComponent = any; // TODO
66
+
67
+ export type CSRComponentLoader = () => Promise<CSRComponent>;
68
+
69
+ export interface SSRPagePart {
70
+ id: string;
71
+ load: SSRComponentLoader;
72
+ }
73
+
74
+ export type GetParams = (match: RegExpExecArray) => Record<string, string>;
75
+
76
+ export interface SSRPage {
77
+ type: 'page';
78
+ pattern: RegExp;
79
+ params: GetParams;
80
+ /**
81
+ * plan a is to render 1 or more layout components followed by a leaf component.
82
+ */
83
+ a: number[];
84
+ /**
85
+ * plan b — if one of them components fails in `load` we backtrack until we find
86
+ * the nearest error component.
87
+ */
88
+ b: number[];
89
+ }
90
+
91
+ export interface SSREndpoint {
92
+ type: 'endpoint';
93
+ pattern: RegExp;
94
+ params: GetParams;
95
+ load(): Promise<{
96
+ [method: string]: RequestHandler;
97
+ }>;
98
+ }
99
+
100
+ export type SSRRoute = SSREndpoint | SSRPage;
101
+
102
+ export type CSRRoute = [RegExp, CSRComponentLoader[], CSRComponentLoader[], GetParams?];
103
+
104
+ export type SSRNodeLoader = () => Promise<SSRNode>;
105
+
106
+ export interface Hooks {
107
+ externalFetch: ExternalFetch;
108
+ getSession: GetSession;
109
+ handle: InternalHandle;
110
+ handleError: HandleError;
111
+ }
112
+
113
+ export interface SSRNode {
114
+ module: SSRComponent;
115
+ /** client-side module URL for this component */
116
+ entry: string;
117
+ /** external CSS files */
118
+ css: string[];
119
+ /** external JS files */
120
+ js: string[];
121
+ /** inlined styles */
122
+ styles?: Record<string, string>;
123
+ }
124
+
125
+ export interface SSRRenderOptions {
126
+ amp: boolean;
127
+ dev: boolean;
128
+ floc: boolean;
129
+ get_stack: (error: Error) => string | undefined;
130
+ handle_error(error: Error & { frame?: string }, request: ServerRequest<any>): void;
131
+ hooks: Hooks;
132
+ hydrate: boolean;
133
+ manifest: SSRManifest;
134
+ method_override: MethodOverride;
135
+ paths: {
136
+ base: string;
137
+ assets: string;
138
+ };
139
+ prefix: string;
140
+ prerender: boolean;
141
+ read(file: string): Buffer;
142
+ root: SSRComponent['default'];
143
+ router: boolean;
144
+ service_worker?: string;
145
+ target: string;
146
+ template({ head, body, assets }: { head: string; body: string; assets: string }): string;
147
+ trailing_slash: TrailingSlash;
148
+ }
149
+
150
+ export interface SSRRenderState {
151
+ fetched?: string;
152
+ initiator?: SSRPage | null;
153
+ prerender?: PrerenderOptions;
154
+ fallback?: string;
155
+ }
156
+
157
+ export interface Asset {
158
+ file: string;
159
+ size: number;
160
+ type: string | null;
161
+ }
162
+
163
+ export interface RouteSegment {
164
+ content: string;
165
+ dynamic: boolean;
166
+ rest: boolean;
167
+ }
168
+
169
+ export type HttpMethod = 'get' | 'head' | 'post' | 'put' | 'delete' | 'patch';
170
+
171
+ export interface PageData {
172
+ type: 'page';
173
+ segments: RouteSegment[];
174
+ pattern: RegExp;
175
+ params: string[];
176
+ path: string;
177
+ a: string[];
178
+ b: string[];
179
+ }
180
+
181
+ export interface EndpointData {
182
+ type: 'endpoint';
183
+ segments: RouteSegment[];
184
+ pattern: RegExp;
185
+ params: string[];
186
+ file: string;
187
+ }
188
+
189
+ export type RouteData = PageData | EndpointData;
190
+
191
+ export interface ManifestData {
192
+ assets: Asset[];
193
+ layout: string;
194
+ error: string;
195
+ components: string[];
196
+ routes: RouteData[];
197
+ }
198
+
199
+ export interface BuildData {
200
+ app_dir: string;
201
+ manifest_data: ManifestData;
202
+ client: {
203
+ assets: OutputAsset[];
204
+ chunks: OutputChunk[];
205
+ entry: {
206
+ file: string;
207
+ js: string[];
208
+ css: string[];
209
+ };
210
+ vite_manifest: import('vite').Manifest;
211
+ };
212
+ server: {
213
+ chunks: OutputChunk[];
214
+ methods: Record<string, HttpMethod[]>;
215
+ vite_manifest: import('vite').Manifest;
216
+ };
217
+ static: string[];
218
+ entries: string[];
219
+ }
220
+
221
+ export type NormalizedLoadOutput = Either<
222
+ {
223
+ status: number;
224
+ error?: Error;
225
+ redirect?: string;
226
+ props?: Record<string, any> | Promise<Record<string, any>>;
227
+ stuff?: Record<string, any>;
228
+ maxage?: number;
229
+ },
230
+ Fallthrough
231
+ >;
232
+
233
+ export type TrailingSlash = 'never' | 'always' | 'ignore';
234
+ export interface MethodOverride {
235
+ parameter: string;
236
+ allowed: string[];
237
+ }
@@ -0,0 +1,73 @@
1
+ import { InferValue, MaybePromise, Rec, Either, Fallthrough } from './helper';
2
+
3
+ export interface LoadInput<
4
+ PageParams extends Rec<string> = Rec<string>,
5
+ Stuff extends Rec = Rec,
6
+ Session = any
7
+ > {
8
+ url: URL;
9
+ params: PageParams;
10
+ fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
11
+ session: Session;
12
+ stuff: Stuff;
13
+ }
14
+
15
+ export interface ErrorLoadInput<
16
+ PageParams extends Rec<string> = Rec<string>,
17
+ Stuff extends Rec = Rec,
18
+ Session = any
19
+ > extends LoadInput<PageParams, Stuff, Session> {
20
+ status?: number;
21
+ error?: Error;
22
+ }
23
+
24
+ export interface LoadOutput<Props extends Rec = Rec, Stuff extends Rec = Rec> {
25
+ status?: number;
26
+ error?: string | Error;
27
+ redirect?: string;
28
+ props?: Props;
29
+ stuff?: Stuff;
30
+ maxage?: number;
31
+ }
32
+
33
+ interface LoadInputExtends {
34
+ stuff?: Rec;
35
+ pageParams?: Rec<string>;
36
+ session?: any;
37
+ }
38
+
39
+ interface LoadOutputExtends {
40
+ stuff?: Rec;
41
+ props?: Rec;
42
+ }
43
+
44
+ export interface Load<
45
+ Input extends LoadInputExtends = Required<LoadInputExtends>,
46
+ Output extends LoadOutputExtends = Required<LoadOutputExtends>
47
+ > {
48
+ (
49
+ input: LoadInput<
50
+ InferValue<Input, 'pageParams', Rec<string>>,
51
+ InferValue<Input, 'stuff', Rec>,
52
+ InferValue<Input, 'session', any>
53
+ >
54
+ ): MaybePromise<
55
+ Either<
56
+ LoadOutput<InferValue<Output, 'props', Rec>, InferValue<Output, 'stuff', Rec>>,
57
+ Fallthrough
58
+ >
59
+ >;
60
+ }
61
+
62
+ export interface ErrorLoad<
63
+ Input extends LoadInputExtends = Required<LoadInputExtends>,
64
+ Output extends LoadOutputExtends = Required<LoadOutputExtends>
65
+ > {
66
+ (
67
+ input: ErrorLoadInput<
68
+ InferValue<Input, 'pageParams', Rec<string>>,
69
+ InferValue<Input, 'stuff', Rec>,
70
+ InferValue<Input, 'session', any>
71
+ >
72
+ ): MaybePromise<LoadOutput<InferValue<Output, 'props', Rec>, InferValue<Output, 'stuff', Rec>>>;
73
+ }