@sveltejs/kit 1.0.0-next.215 → 1.0.0-next.216

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.
package/assets/kit.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @param {Record<string, string | string[]>} headers
2
+ * @param {Record<string, string | string[] | undefined>} headers
3
3
  * @param {string} key
4
4
  * @returns {string | undefined}
5
5
  * @throws {Error}
@@ -12,7 +12,7 @@ import 'querystring';
12
12
  import { URL } from 'url';
13
13
  import require$$10 from 'vm';
14
14
  import vite from 'vite';
15
- import { r as resolve_entry, $, g as get_mime_lookup, a as rimraf, c as copy_assets, p as print_config_conflicts } from '../cli.js';
15
+ import { r as resolve_entry, $, l as load_template, g as get_mime_lookup, a as rimraf, c as copy_assets, p as print_config_conflicts } from '../cli.js';
16
16
  import { c as create_manifest_data, a as create_app, d as deep_merge } from './index2.js';
17
17
  import { S as SVELTE_KIT, a as SVELTE_KIT_ASSETS } from './constants.js';
18
18
  import { respond } from '../ssr.js';
@@ -4407,8 +4407,7 @@ function create_plugin(config, output, cwd, amp) {
4407
4407
  ssr: config.kit.ssr,
4408
4408
  target: config.kit.target,
4409
4409
  template: ({ head, body }) => {
4410
- let rendered = fs__default
4411
- .readFileSync(config.kit.files.template, 'utf8')
4410
+ let rendered = load_template(cwd, config)
4412
4411
  .replace('%svelte.head%', () => head)
4413
4412
  .replace('%svelte.body%', () => body);
4414
4413
 
@@ -1,6 +1,6 @@
1
1
  import fs__default from 'fs';
2
2
  import path__default from 'path';
3
- import { p as print_config_conflicts, c as copy_assets, b as posixify, r as resolve_entry, m as mkdirp, a as rimraf } from '../cli.js';
3
+ import { p as print_config_conflicts, c as copy_assets, b as posixify, r as resolve_entry, l as load_template, m as mkdirp, a as rimraf } from '../cli.js';
4
4
  import { d as deep_merge, a as create_app, c as create_manifest_data } from './index2.js';
5
5
  import { S as SVELTE_KIT } from './constants.js';
6
6
  import { g as generate_manifest } from './index4.js';
@@ -247,21 +247,22 @@ async function build_client({
247
247
 
248
248
  /**
249
249
  * @param {{
250
- * runtime: string,
251
- * hooks: string,
252
- * config: import('types/config').ValidatedConfig,
253
- * has_service_worker: boolean
250
+ * cwd: string;
251
+ * runtime: string;
252
+ * hooks: string;
253
+ * config: import('types/config').ValidatedConfig;
254
+ * has_service_worker: boolean;
254
255
  * }} opts
255
256
  * @returns
256
257
  */
257
- const template = ({ config, hooks, runtime, has_service_worker }) => `
258
+ const template = ({ cwd, config, hooks, runtime, has_service_worker }) => `
258
259
  import { respond } from '${runtime}';
259
260
  import root from './generated/root.svelte';
260
261
  import { set_paths, assets, base } from './runtime/paths.js';
261
262
  import { set_prerendering } from './runtime/env.js';
262
263
  import * as user_hooks from ${s(hooks)};
263
264
 
264
- const template = ({ head, body }) => ${s(fs__default.readFileSync(config.kit.files.template, 'utf-8'))
265
+ const template = ({ head, body }) => ${s(load_template(cwd, config))
265
266
  .replace('%svelte.head%', '" + head + "')
266
267
  .replace('%svelte.body%', '" + body + "')};
267
268
 
@@ -415,6 +416,7 @@ async function build_server(
415
416
  fs__default.writeFileSync(
416
417
  input.app,
417
418
  template({
419
+ cwd,
418
420
  config,
419
421
  hooks: app_relative(hooks_file),
420
422
  runtime,
@@ -1,4 +1,4 @@
1
- import { m as mkdirp, a as rimraf, d as copy, $, l as logger } from '../cli.js';
1
+ import { m as mkdirp, a as rimraf, d as copy, $, e as logger } from '../cli.js';
2
2
  import { S as SVELTE_KIT } from './constants.js';
3
3
  import { readFileSync, writeFileSync } from 'fs';
4
4
  import { resolve, join, dirname } from 'path';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @param {Record<string, string | string[]>} headers
2
+ * @param {Record<string, string | string[] | undefined>} headers
3
3
  * @param {string} key
4
4
  * @returns {string | undefined}
5
5
  * @throws {Error}
package/dist/cli.js CHANGED
@@ -740,10 +740,10 @@ function assert_string(input, keypath) {
740
740
 
741
741
  /**
742
742
  * @param {string} cwd
743
- * @param {import('types/config').ValidatedConfig} validated
743
+ * @param {import('types/config').ValidatedConfig} config
744
744
  */
745
- function validate_template(cwd, validated) {
746
- const { template } = validated.kit.files;
745
+ function load_template(cwd, config) {
746
+ const { template } = config.kit.files;
747
747
  const relative = path__default.relative(cwd, template);
748
748
 
749
749
  if (fs__default.existsSync(template)) {
@@ -757,6 +757,8 @@ function validate_template(cwd, validated) {
757
757
  } else {
758
758
  throw new Error(`${relative} does not exist`);
759
759
  }
760
+
761
+ return fs__default.readFileSync(template, 'utf-8');
760
762
  }
761
763
 
762
764
  async function load_config({ cwd = process.cwd() } = {}) {
@@ -775,10 +777,6 @@ async function load_config({ cwd = process.cwd() } = {}) {
775
777
  validated.kit.files.serviceWorker = path__default.resolve(cwd, validated.kit.files.serviceWorker);
776
778
  validated.kit.files.template = path__default.resolve(cwd, validated.kit.files.template);
777
779
 
778
- validate_template(cwd, validated);
779
-
780
- // TODO check all the `files` exist when the config is loaded?
781
-
782
780
  return validated;
783
781
  }
784
782
 
@@ -887,7 +885,7 @@ async function launch(port, https) {
887
885
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
888
886
  }
889
887
 
890
- const prog = sade('svelte-kit').version('1.0.0-next.215');
888
+ const prog = sade('svelte-kit').version('1.0.0-next.216');
891
889
 
892
890
  prog
893
891
  .command('dev')
@@ -1039,7 +1037,7 @@ async function check_port(port) {
1039
1037
  function welcome({ port, host, https, open, loose, allow, cwd }) {
1040
1038
  if (open) launch(port, https);
1041
1039
 
1042
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.215'}\n`));
1040
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.216'}\n`));
1043
1041
 
1044
1042
  const protocol = https ? 'https:' : 'http:';
1045
1043
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
@@ -1076,4 +1074,4 @@ function welcome({ port, host, https, open, loose, allow, cwd }) {
1076
1074
  console.log('\n');
1077
1075
  }
1078
1076
 
1079
- export { $, rimraf as a, posixify as b, copy_assets as c, copy as d, get_mime_lookup as g, logger as l, mkdirp as m, print_config_conflicts as p, resolve_entry as r, walk as w };
1077
+ export { $, rimraf as a, posixify as b, copy_assets as c, copy as d, logger as e, get_mime_lookup as g, load_template as l, mkdirp as m, print_config_conflicts as p, resolve_entry as r, walk as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.215",
3
+ "version": "1.0.0-next.216",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -5,7 +5,7 @@ type DefaultBody = JSONString | Uint8Array;
5
5
 
6
6
  export interface EndpointOutput<Body extends DefaultBody = DefaultBody> {
7
7
  status?: number;
8
- headers?: ResponseHeaders;
8
+ headers?: Partial<ResponseHeaders>;
9
9
  body?: Body;
10
10
  }
11
11
 
package/types/hooks.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface ServerRequest<Locals = Record<string, any>, Body = unknown> {
15
15
 
16
16
  export interface ServerResponse {
17
17
  status: number;
18
- headers: ResponseHeaders;
18
+ headers: Partial<ResponseHeaders>;
19
19
  body?: StrictBody;
20
20
  }
21
21