@sveltejs/kit 1.0.0-next.244 → 1.0.0-next.245

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.
@@ -2187,7 +2187,8 @@ async function respond(request, options, state = {}) {
2187
2187
  request,
2188
2188
  url,
2189
2189
  params: {},
2190
- locals: {}
2190
+ locals: {},
2191
+ platform: state.platform
2191
2192
  };
2192
2193
 
2193
2194
  // TODO remove this for 1.0
@@ -2081,7 +2081,8 @@ async function respond(request, options, state = {}) {
2081
2081
  request,
2082
2082
  url,
2083
2083
  params: {},
2084
- locals: {}
2084
+ locals: {},
2085
+ platform: state.platform
2085
2086
  };
2086
2087
 
2087
2088
  // TODO remove this for 1.0
@@ -2383,7 +2384,6 @@ async function create_plugin(config, cwd) {
2383
2384
  vite.middlewares.use(async (req, res) => {
2384
2385
  try {
2385
2386
  if (!req.url || !req.method) throw new Error('Incomplete request');
2386
- if (req.url === '/favicon.ico') return not_found(res);
2387
2387
 
2388
2388
  const base = `${vite.config.server.https ? 'https' : 'http'}://${req.headers.host}`;
2389
2389
 
@@ -2400,6 +2400,8 @@ async function create_plugin(config, cwd) {
2400
2400
  }
2401
2401
  }
2402
2402
 
2403
+ if (req.url === '/favicon.ico') return not_found(res);
2404
+
2403
2405
  if (!decoded.startsWith(config.kit.paths.base)) return not_found(res);
2404
2406
 
2405
2407
  /** @type {Partial<import('types/internal').Hooks>} */
@@ -326,14 +326,12 @@ export class App {
326
326
  };
327
327
  }
328
328
 
329
- render(request, {
330
- prerender
331
- } = {}) {
329
+ render(request, options = {}) {
332
330
  if (!(request instanceof Request)) {
333
331
  throw new Error('The first argument to app.render must be a Request object. See https://github.com/sveltejs/kit/pull/3384 for details');
334
332
  }
335
333
 
336
- return respond(request, this.options, { prerender });
334
+ return respond(request, this.options, options);
337
335
  }
338
336
  }
339
337
  `;
@@ -402,7 +400,6 @@ async function build_server(
402
400
  return relative_file[0] === '.' ? relative_file : `./${relative_file}`;
403
401
  };
404
402
 
405
- // prettier-ignore
406
403
  fs__default.writeFileSync(
407
404
  input.app,
408
405
  app_template({
package/dist/cli.js CHANGED
@@ -986,7 +986,7 @@ async function launch(port, https) {
986
986
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
987
987
  }
988
988
 
989
- const prog = sade('svelte-kit').version('1.0.0-next.244');
989
+ const prog = sade('svelte-kit').version('1.0.0-next.245');
990
990
 
991
991
  prog
992
992
  .command('dev')
@@ -1138,7 +1138,7 @@ async function check_port(port) {
1138
1138
  function welcome({ port, host, https, open, loose, allow, cwd }) {
1139
1139
  if (open) launch(port, https);
1140
1140
 
1141
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.244'}\n`));
1141
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.245'}\n`));
1142
1142
 
1143
1143
  const protocol = https ? 'https:' : 'http:';
1144
1144
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.244",
3
+ "version": "1.0.0-next.245",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
package/types/app.d.ts CHANGED
@@ -1,15 +1,19 @@
1
1
  import { PrerenderOptions, SSRNodeLoader, SSRRoute } from './internal';
2
2
 
3
+ export interface RequestOptions<Platform = Record<string, any>> {
4
+ platform?: Platform;
5
+ }
6
+
3
7
  export class App {
4
8
  constructor(manifest: SSRManifest);
5
- render(request: Request): Promise<Response>;
9
+ render(request: Request, options?: RequestOptions): Promise<Response>;
6
10
  }
7
11
 
8
12
  export class InternalApp extends App {
9
13
  render(
10
14
  request: Request,
11
- options?: {
12
- prerender: PrerenderOptions;
15
+ options?: RequestOptions & {
16
+ prerender?: PrerenderOptions;
13
17
  }
14
18
  ): Promise<Response>;
15
19
  }
@@ -13,8 +13,12 @@ export interface Fallthrough {
13
13
  fallthrough: true;
14
14
  }
15
15
 
16
- export interface RequestHandler<Locals = Record<string, any>, Output extends Body = Body> {
17
- (event: RequestEvent<Locals>): MaybePromise<
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<
18
22
  Either<Response | EndpointOutput<Output>, Fallthrough>
19
23
  >;
20
24
  }
package/types/hooks.d.ts CHANGED
@@ -2,25 +2,30 @@ import { MaybePromise } from './helper';
2
2
 
3
3
  export type StrictBody = string | Uint8Array;
4
4
 
5
- export interface RequestEvent<Locals = Record<string, any>> {
5
+ export interface RequestEvent<Locals = Record<string, any>, Platform = Record<string, any>> {
6
6
  request: Request;
7
7
  url: URL;
8
8
  params: Record<string, string>;
9
9
  locals: Locals;
10
+ platform: Readonly<Platform>;
10
11
  }
11
12
 
12
- export interface GetSession<Locals = Record<string, any>, Session = any> {
13
- (event: RequestEvent<Locals>): MaybePromise<Session>;
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>;
14
19
  }
15
20
 
16
21
  export interface ResolveOpts {
17
22
  ssr?: boolean;
18
23
  }
19
24
 
20
- export interface Handle<Locals = Record<string, any>> {
25
+ export interface Handle<Locals = Record<string, any>, Platform = Record<string, any>> {
21
26
  (input: {
22
- event: RequestEvent<Locals>;
23
- resolve(event: RequestEvent<Locals>, opts?: ResolveOpts): MaybePromise<Response>;
27
+ event: RequestEvent<Locals, Platform>;
28
+ resolve(event: RequestEvent<Locals, Platform>, opts?: ResolveOpts): MaybePromise<Response>;
24
29
  }): MaybePromise<Response>;
25
30
  }
26
31
 
@@ -159,6 +159,7 @@ export interface SSRRenderOptions {
159
159
  export interface SSRRenderState {
160
160
  fetched?: string;
161
161
  initiator?: SSRPage | null;
162
+ platform?: any;
162
163
  prerender?: PrerenderOptions;
163
164
  fallback?: string;
164
165
  }