@sveltejs/kit 1.0.0-next.295 → 1.0.0-next.296

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.
@@ -1685,7 +1685,7 @@ async function load_node({
1685
1685
 
1686
1686
  if (options.read) {
1687
1687
  const type = is_asset
1688
- ? options.manifest._.mime[filename.slice(filename.lastIndexOf('.'))]
1688
+ ? options.manifest.mimeTypes[filename.slice(filename.lastIndexOf('.'))]
1689
1689
  : 'text/html';
1690
1690
 
1691
1691
  response = new Response(options.read(file), {
@@ -61,8 +61,8 @@ async function create_plugin(config, cwd) {
61
61
  manifest = {
62
62
  appDir: config.kit.appDir,
63
63
  assets: new Set(manifest_data.assets.map((asset) => asset.file)),
64
+ mimeTypes: get_mime_lookup(manifest_data),
64
65
  _: {
65
- mime: get_mime_lookup(manifest_data),
66
66
  entry: {
67
67
  file: `/@fs${runtime}/client/start.js`,
68
68
  css: [],
@@ -306,15 +306,6 @@ let read = null;
306
306
 
307
307
  set_paths(${s(config.kit.paths)});
308
308
 
309
- // this looks redundant, but the indirection allows us to access
310
- // named imports without triggering Rollup's missing import detection
311
- const get_hooks = hooks => ({
312
- getSession: hooks.getSession || (() => ({})),
313
- handle: hooks.handle || (({ event, resolve }) => resolve(event)),
314
- handleError: hooks.handleError || (({ error }) => console.error(error.stack)),
315
- externalFetch: hooks.externalFetch || fetch
316
- });
317
-
318
309
  let default_protocol = 'https';
319
310
 
320
311
  // allow paths to be globally overridden
@@ -328,8 +319,6 @@ export function override(settings) {
328
319
 
329
320
  export class Server {
330
321
  constructor(manifest) {
331
- const hooks = get_hooks(user_hooks);
332
-
333
322
  this.options = {
334
323
  amp: ${config.kit.amp},
335
324
  csp: ${s(config.kit.csp)},
@@ -337,7 +326,7 @@ export class Server {
337
326
  floc: ${config.kit.floc},
338
327
  get_stack: error => String(error), // for security
339
328
  handle_error: (error, event) => {
340
- hooks.handleError({
329
+ this.options.hooks.handleError({
341
330
  error,
342
331
  event,
343
332
 
@@ -349,7 +338,7 @@ export class Server {
349
338
  });
350
339
  error.stack = this.options.get_stack(error);
351
340
  },
352
- hooks,
341
+ hooks: null,
353
342
  hydrate: ${s(config.kit.browser.hydrate)},
354
343
  manifest,
355
344
  method_override: ${s(config.kit.methodOverride)},
@@ -366,11 +355,21 @@ export class Server {
366
355
  };
367
356
  }
368
357
 
369
- respond(request, options = {}) {
358
+ async respond(request, options = {}) {
370
359
  if (!(request instanceof Request)) {
371
360
  throw new Error('The first argument to server.respond must be a Request object. See https://github.com/sveltejs/kit/pull/3384 for details');
372
361
  }
373
362
 
363
+ if (!this.options.hooks) {
364
+ const module = await import(${s(hooks)});
365
+ this.options.hooks = {
366
+ getSession: module.getSession || (() => ({})),
367
+ handle: module.handle || (({ event, resolve }) => resolve(event)),
368
+ handleError: module.handleError || (({ error }) => console.error(error.stack)),
369
+ externalFetch: module.externalFetch || fetch
370
+ };
371
+ }
372
+
374
373
  return respond(request, this.options, options);
375
374
  }
376
375
  }
@@ -58,8 +58,8 @@ function generate_manifest({ build_data, relative_path, routes, format = 'esm' }
58
58
  return `{
59
59
  appDir: ${s(build_data.app_dir)},
60
60
  assets: new Set(${s(assets)}),
61
+ mimeTypes: ${s(get_mime_lookup(build_data.manifest_data))},
61
62
  _: {
62
- mime: ${s(get_mime_lookup(build_data.manifest_data))},
63
63
  entry: ${s(build_data.client.entry)},
64
64
  nodes: [
65
65
  ${Array.from(bundled_nodes.values()).map(node => importer(node.path)).join(',\n\t\t\t\t')}
package/dist/cli.js CHANGED
@@ -870,7 +870,7 @@ async function launch(port, https) {
870
870
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
871
871
  }
872
872
 
873
- const prog = sade('svelte-kit').version('1.0.0-next.295');
873
+ const prog = sade('svelte-kit').version('1.0.0-next.296');
874
874
 
875
875
  prog
876
876
  .command('dev')
@@ -1043,7 +1043,7 @@ async function check_port(port) {
1043
1043
  function welcome({ port, host, https, open, loose, allow, cwd }) {
1044
1044
  if (open) launch(port, https);
1045
1045
 
1046
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.295'}\n`));
1046
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.296'}\n`));
1047
1047
 
1048
1048
  const protocol = https ? 'https:' : 'http:';
1049
1049
  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.295",
3
+ "version": "1.0.0-next.296",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
package/types/index.d.ts CHANGED
@@ -28,7 +28,7 @@ import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal';
28
28
 
29
29
  export interface Adapter {
30
30
  name: string;
31
- adapt(builder: Builder): Promise<void>;
31
+ adapt(builder: Builder): MaybePromise<void>;
32
32
  }
33
33
 
34
34
  export interface Builder {
@@ -241,9 +241,10 @@ export class Server {
241
241
  export interface SSRManifest {
242
242
  appDir: string;
243
243
  assets: Set<string>;
244
+ mimeTypes: Record<string, string>;
245
+
244
246
  /** private fields */
245
247
  _: {
246
- mime: Record<string, string>;
247
248
  entry: {
248
249
  file: string;
249
250
  js: string[];