@sveltejs/kit 1.0.0-next.29 → 1.0.0-next.290

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