@sveltejs/kit 1.0.0-next.353 → 1.0.0-next.356

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/dist/vite.js CHANGED
@@ -11,18 +11,32 @@ import { pathToFileURL, URL as URL$1 } from 'url';
11
11
  import { installPolyfills } from './node/polyfills.js';
12
12
  import * as qs from 'querystring';
13
13
  import { getRequest, setResponse } from './node.js';
14
+ import 'assert';
15
+ import 'net';
16
+ import 'http';
17
+ import 'stream';
18
+ import 'buffer';
19
+ import 'util';
20
+ import 'stream/web';
21
+ import 'perf_hooks';
22
+ import 'util/types';
23
+ import 'events';
24
+ import 'tls';
25
+ import './chunks/_commonjsHelpers.js';
26
+ import 'async_hooks';
27
+ import 'console';
28
+ import 'zlib';
29
+ import 'crypto';
14
30
  import 'node:http';
15
31
  import 'node:https';
16
32
  import 'node:zlib';
17
33
  import 'node:stream';
18
34
  import 'node:buffer';
19
- import 'node:util';
20
35
  import 'node:url';
36
+ import 'node:util';
21
37
  import 'node:net';
22
38
  import 'node:fs';
23
39
  import 'node:path';
24
- import 'crypto';
25
- import 'stream';
26
40
 
27
41
  /**
28
42
  * @param {...import('vite').UserConfig} configs
@@ -2725,11 +2739,13 @@ function kit() {
2725
2739
  /** @type {import('types').ManifestData} */
2726
2740
  let manifest_data;
2727
2741
 
2728
- /** @type {{
2742
+ /**
2743
+ * @type {{
2729
2744
  * build_dir: string;
2730
2745
  * output_dir: string;
2731
2746
  * client_out_dir: string;
2732
- * }} */
2747
+ * }}
2748
+ */
2733
2749
  let paths;
2734
2750
 
2735
2751
  return {
@@ -2798,13 +2814,12 @@ function kit() {
2798
2814
  }
2799
2815
  },
2800
2816
  preview: {
2801
- port: 3000,
2802
- strictPort: true
2817
+ port: config.preview?.port ?? 3000,
2818
+ strictPort: config.preview?.strictPort ?? true
2803
2819
  },
2804
2820
  resolve: {
2805
2821
  alias: get_aliases(svelte_config.kit)
2806
2822
  },
2807
- root: cwd,
2808
2823
  server: {
2809
2824
  fs: {
2810
2825
  allow: [
@@ -2818,16 +2833,15 @@ function kit() {
2818
2833
  ])
2819
2834
  ]
2820
2835
  },
2821
- port: 3000,
2822
- strictPort: true,
2836
+ port: config.server?.port ?? 3000,
2837
+ strictPort: config.server?.strictPort ?? true,
2823
2838
  watch: {
2824
2839
  ignored: [
2825
2840
  // Ignore all siblings of config.kit.outDir/generated
2826
2841
  `${posixify(svelte_config.kit.outDir)}/!(generated)`
2827
2842
  ]
2828
2843
  }
2829
- },
2830
- spa: false
2844
+ }
2831
2845
  };
2832
2846
  },
2833
2847
 
@@ -2984,8 +2998,8 @@ function kit() {
2984
2998
  /**
2985
2999
  * @param {Record<string, any>} config
2986
3000
  * @param {Record<string, any>} enforced_config
2987
- * @param {string} path
2988
- * @param {string[]} out
3001
+ * @param {string} [path]
3002
+ * @param {string[]} [out] used locally to compute the return value
2989
3003
  */
2990
3004
  function find_overridden_config(config, enforced_config, path = '', out = []) {
2991
3005
  for (const key in enforced_config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.353",
3
+ "version": "1.0.0-next.356",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -45,6 +45,7 @@
45
45
  "svelte2tsx": "~0.5.10",
46
46
  "tiny-glob": "^0.2.9",
47
47
  "typescript": "^4.7.2",
48
+ "undici": "^5.4.0",
48
49
  "uvu": "^0.5.3"
49
50
  },
50
51
  "peerDependencies": {
@@ -17,13 +17,29 @@
17
17
  *
18
18
  * By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, `session` and `stuff`.
19
19
  *
20
- * Note that since it's an ambient declaration file, you can't use `import` statements instead, use the `import(...)` function:
20
+ * Note that since it's an ambient declaration file, you have to be careful when using `import` statements. Once you add an `import`
21
+ * at the top level, the declaration file is no longer considered ambient and you lose access to these typings in other files.
22
+ * To avoid this, either use the `import(...)` function:
21
23
  *
22
24
  * ```ts
23
25
  * interface Locals {
24
26
  * user: import('$lib/types').User;
25
27
  * }
26
28
  * ```
29
+ * Or wrap the namespace with `declare global`:
30
+ * ```ts
31
+ * import { User } from '$lib/types';
32
+ *
33
+ * declare global {
34
+ * namespace App {
35
+ * interface Locals {
36
+ * user: User;
37
+ * }
38
+ * // ...
39
+ * }
40
+ * }
41
+ * ```
42
+ *
27
43
  */
28
44
  declare namespace App {
29
45
  /**
@@ -49,28 +65,41 @@ declare namespace App {
49
65
 
50
66
  /**
51
67
  * ```ts
52
- * import { browser, dev, mode, prerendering } from '$app/env';
68
+ * import { browser, dev, mode, prerendering, prod, server } from '$app/env';
53
69
  * ```
54
70
  */
55
71
  declare module '$app/env' {
56
72
  /**
57
- * Whether the app is running in the browser or on the server.
73
+ * `true` if the app is running in the browser.
58
74
  */
59
75
  export const browser: boolean;
76
+
60
77
  /**
61
78
  * `true` in development mode, `false` in production.
62
79
  */
63
80
  export const dev: boolean;
64
- /**
65
- * `true` when prerendering, `false` otherwise.
66
- */
67
- export const prerendering: boolean;
81
+
68
82
  /**
69
83
  * The Vite.js mode the app is running in. Configure in `config.kit.vite.mode`.
70
84
  * Vite.js loads the dotenv file associated with the provided mode, `.env.[mode]` or `.env.[mode].local`.
71
85
  * By default, `svelte-kit dev` runs with `mode=development` and `svelte-kit build` runs with `mode=production`.
72
86
  */
73
87
  export const mode: string;
88
+
89
+ /**
90
+ * `true` when prerendering, `false` otherwise.
91
+ */
92
+ export const prerendering: boolean;
93
+
94
+ /**
95
+ * `true` in production mode, `false` in development.
96
+ */
97
+ export const prod: boolean;
98
+
99
+ /**
100
+ * `true` if the app is running on the server.
101
+ */
102
+ export const server: boolean;
74
103
  }
75
104
 
76
105
  /**
@@ -93,16 +122,16 @@ declare module '$app/navigation' {
93
122
  */
94
123
  export function disableScrollHandling(): void;
95
124
  /**
96
- * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `href`.
125
+ * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
97
126
  *
98
- * @param href Where to navigate to
127
+ * @param url Where to navigate to
99
128
  * @param opts.replaceState If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
100
129
  * @param opts.noscroll If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
101
130
  * @param opts.keepfocus If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
102
131
  * @param opts.state The state of the new/updated history entry
103
132
  */
104
133
  export function goto(
105
- href: string,
134
+ url: string | URL,
106
135
  opts?: { replaceState?: boolean; noscroll?: boolean; keepfocus?: boolean; state?: any }
107
136
  ): Promise<void>;
108
137
  /**
@@ -305,3 +334,12 @@ declare module '@sveltejs/kit/node' {
305
334
  ): Promise<Request>;
306
335
  export function setResponse(res: import('http').ServerResponse, response: Response): void;
307
336
  }
337
+
338
+ declare module '@sveltejs/kit/experimental/vite' {
339
+ import { Plugin } from 'vite';
340
+
341
+ /**
342
+ * Returns the SvelteKit Vite plugins.
343
+ */
344
+ export function sveltekit(): Plugin[];
345
+ }
package/types/index.d.ts CHANGED
@@ -268,7 +268,7 @@ export interface ResolveOptions {
268
268
  transformPage?: ({ html }: { html: string }) => MaybePromise<string>;
269
269
  }
270
270
 
271
- export type ResponseBody = JSONValue | Uint8Array | ReadableStream | import('stream').Readable;
271
+ export type ResponseBody = JSONValue | Uint8Array | ReadableStream;
272
272
 
273
273
  export class Server {
274
274
  constructor(manifest: SSRManifest);