@sveltejs/kit 1.0.0-next.298 → 1.0.0-next.299

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.
@@ -11,8 +11,6 @@ import {
11
11
  SSRManifest
12
12
  } from './index';
13
13
  import {
14
- Either,
15
- Fallthrough,
16
14
  HttpMethod,
17
15
  JSONObject,
18
16
  MaybePromise,
@@ -69,11 +67,17 @@ export type CSRComponent = any; // TODO
69
67
 
70
68
  export type CSRComponentLoader = () => Promise<CSRComponent>;
71
69
 
72
- export type CSRRoute = [RegExp, CSRComponentLoader[], CSRComponentLoader[], GetParams?, ShadowKey?];
70
+ export type CSRRoute = {
71
+ id: string;
72
+ exec: (path: string) => undefined | Record<string, string>;
73
+ a: CSRComponentLoader[];
74
+ b: CSRComponentLoader[];
75
+ has_shadow: boolean;
76
+ };
73
77
 
74
78
  export interface EndpointData {
75
79
  type: 'endpoint';
76
- key: string;
80
+ id: string;
77
81
  segments: RouteSegment[];
78
82
  pattern: RegExp;
79
83
  params: string[];
@@ -104,6 +108,7 @@ export interface ManifestData {
104
108
  error: string;
105
109
  components: string[];
106
110
  routes: RouteData[];
111
+ validators: Record<string, string>;
107
112
  }
108
113
 
109
114
  export interface MethodOverride {
@@ -111,21 +116,18 @@ export interface MethodOverride {
111
116
  allowed: string[];
112
117
  }
113
118
 
114
- export type NormalizedLoadOutput = Either<
115
- {
116
- status: number;
117
- error?: Error;
118
- redirect?: string;
119
- props?: Record<string, any> | Promise<Record<string, any>>;
120
- stuff?: Record<string, any>;
121
- maxage?: number;
122
- },
123
- Fallthrough
124
- >;
119
+ export type NormalizedLoadOutput = {
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
+ };
125
127
 
126
128
  export interface PageData {
127
129
  type: 'page';
128
- key: string;
130
+ id: string;
129
131
  shadow: string | null;
130
132
  segments: RouteSegment[];
131
133
  pattern: RegExp;
@@ -183,11 +185,10 @@ export interface ShadowEndpointOutput<Output extends JSONObject = JSONObject> {
183
185
  type ShadowKey = string;
184
186
 
185
187
  export interface ShadowRequestHandler<Output extends JSONObject = JSONObject> {
186
- (event: RequestEvent): MaybePromise<Either<ShadowEndpointOutput<Output>, Fallthrough>>;
188
+ (event: RequestEvent): MaybePromise<ShadowEndpointOutput<Output>>;
187
189
  }
188
190
 
189
191
  export interface ShadowData {
190
- fallthrough?: boolean;
191
192
  status?: number;
192
193
  error?: Error;
193
194
  redirect?: string;
@@ -216,8 +217,10 @@ export type SSRComponentLoader = () => Promise<SSRComponent>;
216
217
 
217
218
  export interface SSREndpoint {
218
219
  type: 'endpoint';
220
+ id: string;
219
221
  pattern: RegExp;
220
- params: GetParams;
222
+ names: string[];
223
+ types: string[];
221
224
  load(): Promise<{
222
225
  [method: string]: RequestHandler;
223
226
  }>;
@@ -275,9 +278,10 @@ export interface SSROptions {
275
278
 
276
279
  export interface SSRPage {
277
280
  type: 'page';
278
- key: string;
281
+ id: string;
279
282
  pattern: RegExp;
280
- params: GetParams;
283
+ names: string[];
284
+ types: string[];
281
285
  shadow:
282
286
  | null
283
287
  | (() => Promise<{
@@ -303,7 +307,6 @@ export type SSRRoute = SSREndpoint | SSRPage;
303
307
 
304
308
  export interface SSRState {
305
309
  fallback?: string;
306
- fetched?: string;
307
310
  getClientAddress: () => string;
308
311
  initiator?: SSRPage | null;
309
312
  platform?: any;
@@ -136,18 +136,12 @@ export interface CspDirectives {
136
136
  >;
137
137
  }
138
138
 
139
- export type Either<T, U> = Only<T, U> | Only<U, T>;
140
-
141
139
  export interface ErrorLoadInput<Params extends Record<string, string> = Record<string, string>>
142
140
  extends LoadInput<Params> {
143
141
  status?: number;
144
142
  error?: Error;
145
143
  }
146
144
 
147
- export interface Fallthrough {
148
- fallthrough: true;
149
- }
150
-
151
145
  export type HttpMethod = 'get' | 'head' | 'post' | 'put' | 'delete' | 'patch';
152
146
 
153
147
  export interface JSONObject {
@@ -168,12 +162,13 @@ export interface LoadInput<
168
162
  Params extends Record<string, string> = Record<string, string>,
169
163
  Props extends Record<string, any> = Record<string, any>
170
164
  > {
171
- url: URL;
165
+ fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
172
166
  params: Params;
173
167
  props: Props;
174
- fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
168
+ routeId: string | null;
175
169
  session: App.Session;
176
170
  stuff: Partial<App.Stuff>;
171
+ url: URL;
177
172
  }
178
173
 
179
174
  export interface LoadOutput<Props extends Record<string, any> = Record<string, any>> {
@@ -241,6 +236,7 @@ export interface RequestEvent<Params extends Record<string, string> = Record<str
241
236
  params: Params;
242
237
  platform: Readonly<App.Platform>;
243
238
  request: Request;
239
+ routeId: string | null;
244
240
  url: URL;
245
241
  }
246
242