@sveltejs/kit 1.0.0-next.393 → 1.0.0-next.396

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.393",
3
+ "version": "1.0.0-next.396",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -9,13 +9,17 @@
9
9
  *
10
10
  * interface Platform {}
11
11
  *
12
+ * interface PrivateEnv {}
13
+ *
14
+ * interface PublicEnv {}
15
+ *
12
16
  * interface Session {}
13
17
  *
14
18
  * interface Stuff {}
15
19
  * }
16
20
  * ```
17
21
  *
18
- * By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, `session` and `stuff`.
22
+ * By populating these interfaces, you will gain type safety when using `env`, `event.locals`, `event.platform`, `session` and `stuff`.
19
23
  *
20
24
  * Note that since it's an ambient declaration file, you have to be careful when using `import` statements. Once you add an `import`
21
25
  * at the top level, the declaration file is no longer considered ambient and you lose access to these typings in other files.
@@ -43,22 +47,32 @@
43
47
  */
44
48
  declare namespace App {
45
49
  /**
46
- * The interface that defines `event.locals`, which can be accessed in [hooks](/docs/hooks) (`handle`, `handleError` and `getSession`) and [endpoints](/docs/routing#endpoints).
50
+ * The interface that defines `event.locals`, which can be accessed in [hooks](https://kit.svelte.dev/docs/hooks) (`handle`, `handleError` and `getSession`) and [endpoints](https://kit.svelte.dev/docs/routing#endpoints).
47
51
  */
48
52
  export interface Locals {}
49
53
 
50
54
  /**
51
- * If your adapter provides [platform-specific context](/docs/adapters#supported-environments-platform-specific-context) via `event.platform`, you can specify it here.
55
+ * If your adapter provides [platform-specific context](https://kit.svelte.dev/docs/adapters#supported-environments-platform-specific-context) via `event.platform`, you can specify it here.
52
56
  */
53
57
  export interface Platform {}
54
58
 
55
59
  /**
56
- * The interface that defines `session`, both as an argument to [`load`](/docs/loading) functions and the value of the [session store](/docs/modules#$app-stores).
60
+ * The interface that defines the dynamic environment variables exported from '$env/dynamic/private'.
61
+ */
62
+ export interface PrivateEnv extends Record<string, string> {}
63
+
64
+ /**
65
+ * The interface that defines the dynamic environment variables exported from '$env/dynamic/public'.
66
+ */
67
+ export interface PublicEnv extends Record<string, string> {}
68
+
69
+ /**
70
+ * The interface that defines `session`, both as an argument to [`load`](https://kit.svelte.dev/docs/loading) functions and the value of the [session store](https://kit.svelte.dev/docs/modules#$app-stores).
57
71
  */
58
72
  export interface Session {}
59
73
 
60
74
  /**
61
- * The interface that defines `stuff`, as input or output to [`load`](/docs/loading) or as the value of the `stuff` property of the [page store](/docs/modules#$app-stores).
75
+ * The interface that defines `stuff`, as input or output to [`load`](https://kit.svelte.dev/docs/loading) or as the value of the `stuff` property of the [page store](https://kit.svelte.dev/docs/modules#$app-stores).
62
76
  */
63
77
  export interface Stuff {}
64
78
  }
@@ -85,6 +99,39 @@ declare module '$app/env' {
85
99
  export const prerendering: boolean;
86
100
  }
87
101
 
102
+ /**
103
+ * This module provides access to runtime environment variables, as defined by the platform you're running on. For example
104
+ * if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/master/packages/adapter-node) (or running
105
+ * [`vite preview`](https://kit.svelte.dev/docs/cli)), this is equivalent to `process.env`. This module only includes
106
+ * variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#kit-env-publicprefix).
107
+ *
108
+ * This module cannot be imported into client-side code.
109
+ *
110
+ * ```ts
111
+ * import { env } from '$env/dynamic/private';
112
+ * console.log(env.DEPLOYMENT_SPECIFIC_VARIABLE);
113
+ * ```
114
+ */
115
+ declare module '$env/dynamic/private' {
116
+ export let env: App.PrivateEnv;
117
+ }
118
+
119
+ /**
120
+ * Similar to [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), but only includes
121
+ * variables that begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#kit-env-publicprefix)
122
+ * (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code
123
+ *
124
+ * Note that public dynamic environment variables must all be sent from the server to the client, causing larger network requests — when possible, use `$env/static/public` instead.
125
+ *
126
+ * ```ts
127
+ * import { env } from '$env/dynamic/public';
128
+ * console.log(env.PUBLIC_DEPLOYMENT_SPECIFIC_VARIABLE);
129
+ * ```
130
+ */
131
+ declare module '$env/dynamic/public' {
132
+ export let env: App.PublicEnv;
133
+ }
134
+
88
135
  /**
89
136
  * ```ts
90
137
  * import {
@@ -167,11 +214,11 @@ declare module '$app/navigation' {
167
214
  */
168
215
  declare module '$app/paths' {
169
216
  /**
170
- * A string that matches [`config.kit.paths.base`](/docs/configuration#paths). It must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string.
217
+ * A string that matches [`config.kit.paths.base`](https://kit.svelte.dev/docs/configuration#paths). It must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string.
171
218
  */
172
219
  export const base: `/${string}`;
173
220
  /**
174
- * An absolute path that matches [`config.kit.paths.assets`](/docs/configuration#paths).
221
+ * An absolute path that matches [`config.kit.paths.assets`](https://kit.svelte.dev/docs/configuration#paths).
175
222
  *
176
223
  * > If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during `vite dev` or `vite preview`, since the assets don't yet live at their eventual URL.
177
224
  */
@@ -213,12 +260,12 @@ declare module '$app/stores' {
213
260
  */
214
261
  export const navigating: Readable<Navigation | null>;
215
262
  /**
216
- * A writable store whose initial value is whatever was returned from [`getSession`](/docs/hooks#getsession).
263
+ * A writable store whose initial value is whatever was returned from [`getSession`](https://kit.svelte.dev/docs/hooks#getsession).
217
264
  * It can be written to, but this will not cause changes to persist on the server — this is something you must implement yourself.
218
265
  */
219
266
  export const session: Writable<App.Session>;
220
267
  /**
221
- * A readable store whose initial value is `false`. If [`version.pollInterval`](/docs/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.
268
+ * A readable store whose initial value is `false`. If [`version.pollInterval`](https://kit.svelte.dev/docs/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.
222
269
  */
223
270
  export const updated: Readable<boolean> & { check: () => boolean };
224
271
  }
@@ -228,7 +275,7 @@ declare module '$app/stores' {
228
275
  * import { build, files, prerendered, version } from '$service-worker';
229
276
  * ```
230
277
  *
231
- * This module is only available to [service workers](/docs/service-workers).
278
+ * This module is only available to [service workers](https://kit.svelte.dev/docs/service-workers).
232
279
  */
233
280
  declare module '$service-worker' {
234
281
  /**
@@ -236,7 +283,7 @@ declare module '$service-worker' {
236
283
  */
237
284
  export const build: string[];
238
285
  /**
239
- * An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](/docs/configuration)
286
+ * An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://kit.svelte.dev/docs/configuration)
240
287
  */
241
288
  export const files: string[];
242
289
  /**
@@ -244,7 +291,7 @@ declare module '$service-worker' {
244
291
  */
245
292
  export const prerendered: string[];
246
293
  /**
247
- * See [`config.kit.version`](/docs/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
294
+ * See [`config.kit.version`](https://kit.svelte.dev/docs/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
248
295
  */
249
296
  export const version: string;
250
297
  }
package/types/index.d.ts CHANGED
@@ -102,6 +102,9 @@ export interface KitConfig {
102
102
  directives?: CspDirectives;
103
103
  reportOnly?: CspDirectives;
104
104
  };
105
+ env?: {
106
+ publicPrefix: string;
107
+ };
105
108
  moduleExtensions?: string[];
106
109
  files?: {
107
110
  assets?: string;
@@ -268,9 +271,14 @@ export type ResponseBody = JSONValue | Uint8Array | ReadableStream | Error;
268
271
 
269
272
  export class Server {
270
273
  constructor(manifest: SSRManifest);
274
+ init(options: ServerInitOptions): void;
271
275
  respond(request: Request, options: RequestOptions): Promise<Response>;
272
276
  }
273
277
 
278
+ export interface ServerInitOptions {
279
+ env: Record<string, string>;
280
+ }
281
+
274
282
  export interface SSRManifest {
275
283
  appDir: string;
276
284
  assets: Set<string>;
@@ -11,6 +11,7 @@ import {
11
11
  RequestHandler,
12
12
  ResolveOptions,
13
13
  Server,
14
+ ServerInitOptions,
14
15
  SSRManifest
15
16
  } from './index.js';
16
17
  import {
@@ -91,7 +92,13 @@ export interface Hooks {
91
92
  handleError: HandleError;
92
93
  }
93
94
 
95
+ export interface ImportNode {
96
+ name: string;
97
+ dynamic: boolean;
98
+ }
99
+
94
100
  export class InternalServer extends Server {
101
+ init(options: ServerInitOptions): void;
95
102
  respond(
96
103
  request: Request,
97
104
  options: RequestOptions & {
@@ -249,6 +256,7 @@ export interface SSROptions {
249
256
  default: boolean;
250
257
  enabled: boolean;
251
258
  };
259
+ public_env: Record<string, string>;
252
260
  read(file: string): Buffer;
253
261
  root: SSRComponent['default'];
254
262
  router: boolean;