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

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