@sveltejs/kit 1.30.3 → 2.0.0

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.
Files changed (57) hide show
  1. package/package.json +24 -24
  2. package/src/core/adapt/builder.js +8 -1
  3. package/src/core/config/index.js +9 -1
  4. package/src/core/config/options.js +1 -12
  5. package/src/core/postbuild/analyse.js +98 -80
  6. package/src/core/postbuild/prerender.js +11 -9
  7. package/src/core/sync/sync.js +2 -0
  8. package/src/core/sync/write_non_ambient.js +42 -0
  9. package/src/core/sync/write_server.js +3 -3
  10. package/src/core/sync/write_tsconfig.js +27 -78
  11. package/src/core/sync/write_types/index.js +1 -1
  12. package/src/exports/hooks/sequence.js +1 -1
  13. package/src/exports/index.js +88 -71
  14. package/src/exports/node/index.js +21 -24
  15. package/src/exports/node/polyfills.js +5 -34
  16. package/src/exports/public.d.ts +82 -61
  17. package/src/exports/vite/dev/index.js +11 -19
  18. package/src/exports/vite/graph_analysis/index.js +2 -4
  19. package/src/exports/vite/index.js +73 -14
  20. package/src/exports/vite/module_ids.js +7 -0
  21. package/src/exports/vite/preview/index.js +56 -130
  22. package/src/runtime/app/forms.js +2 -35
  23. package/src/runtime/app/navigation.js +28 -15
  24. package/src/runtime/app/paths.js +2 -29
  25. package/src/runtime/client/client.js +449 -199
  26. package/src/runtime/client/constants.js +5 -1
  27. package/src/runtime/client/session-storage.js +7 -5
  28. package/src/runtime/client/singletons.js +7 -1
  29. package/src/runtime/client/types.d.ts +6 -2
  30. package/src/runtime/client/utils.js +12 -10
  31. package/src/runtime/control.js +16 -8
  32. package/src/runtime/server/cookie.js +38 -61
  33. package/src/runtime/server/data/index.js +6 -4
  34. package/src/runtime/server/env_module.js +29 -0
  35. package/src/runtime/server/fetch.js +7 -6
  36. package/src/runtime/server/index.js +23 -20
  37. package/src/runtime/server/page/actions.js +24 -15
  38. package/src/runtime/server/page/index.js +6 -8
  39. package/src/runtime/server/page/load_data.js +58 -40
  40. package/src/runtime/server/page/render.js +12 -7
  41. package/src/runtime/server/page/respond_with_error.js +4 -4
  42. package/src/runtime/server/page/types.d.ts +1 -1
  43. package/src/runtime/server/respond.js +14 -12
  44. package/src/runtime/server/utils.js +11 -8
  45. package/src/runtime/shared-server.js +19 -2
  46. package/src/types/ambient.d.ts +7 -1
  47. package/src/types/internal.d.ts +4 -1
  48. package/src/types/synthetic/$env+dynamic+private.md +2 -0
  49. package/src/types/synthetic/$env+dynamic+public.md +2 -0
  50. package/src/utils/error.js +17 -1
  51. package/src/utils/routing.js +47 -1
  52. package/src/utils/url.js +45 -27
  53. package/src/version.js +1 -1
  54. package/types/index.d.ts +166 -115
  55. package/types/index.d.ts.map +9 -5
  56. package/src/utils/platform.js +0 -1
  57. package/src/utils/promises.js +0 -61
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.30.3",
3
+ "version": "2.0.0",
4
4
  "description": "The fastest way to build Svelte apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,37 +11,37 @@
11
11
  "homepage": "https://kit.svelte.dev",
12
12
  "type": "module",
13
13
  "dependencies": {
14
- "@sveltejs/vite-plugin-svelte": "^2.5.0",
15
- "@types/cookie": "^0.5.1",
16
- "cookie": "^0.5.0",
17
- "devalue": "^4.3.1",
14
+ "@types/cookie": "^0.6.0",
15
+ "cookie": "^0.6.0",
16
+ "devalue": "^4.3.2",
18
17
  "esm-env": "^1.0.0",
19
18
  "kleur": "^4.1.5",
20
- "magic-string": "^0.30.0",
19
+ "magic-string": "^0.30.5",
21
20
  "mrmime": "^1.0.1",
22
21
  "sade": "^1.8.1",
23
22
  "set-cookie-parser": "^2.6.0",
24
- "sirv": "^2.0.2",
25
- "tiny-glob": "^0.2.9",
26
- "undici": "~5.26.2"
23
+ "sirv": "^2.0.3",
24
+ "tiny-glob": "^0.2.9"
27
25
  },
28
26
  "devDependencies": {
29
27
  "@playwright/test": "1.30.0",
30
- "@types/connect": "^3.4.35",
31
- "@types/node": "^16.18.6",
32
- "@types/sade": "^1.7.4",
33
- "@types/set-cookie-parser": "^2.4.2",
34
- "dts-buddy": "^0.2.4",
35
- "rollup": "^3.29.4",
36
- "svelte": "^4.2.7",
37
- "svelte-preprocess": "^5.1.1",
38
- "typescript": "^4.9.4",
39
- "vite": "^4.4.9",
40
- "vitest": "^0.34.5"
28
+ "@sveltejs/vite-plugin-svelte": "^3.0.1",
29
+ "@types/connect": "^3.4.38",
30
+ "@types/node": "^18.19.3",
31
+ "@types/sade": "^1.7.8",
32
+ "@types/set-cookie-parser": "^2.4.7",
33
+ "dts-buddy": "^0.4.3",
34
+ "rollup": "^4.8.0",
35
+ "svelte": "^4.2.8",
36
+ "svelte-preprocess": "^5.1.2",
37
+ "typescript": "^5.3.3",
38
+ "vite": "^5.0.8",
39
+ "vitest": "^1.0.4"
41
40
  },
42
41
  "peerDependencies": {
43
- "svelte": "^3.54.0 || ^4.0.0-next.0 || ^5.0.0-next.0",
44
- "vite": "^4.0.0"
42
+ "@sveltejs/vite-plugin-svelte": "^3.0.0",
43
+ "svelte": "^4.0.0 || ^5.0.0-next.0",
44
+ "vite": "^5.0.3"
45
45
  },
46
46
  "bin": {
47
47
  "svelte-kit": "svelte-kit.js"
@@ -80,11 +80,11 @@
80
80
  },
81
81
  "types": "types/index.d.ts",
82
82
  "engines": {
83
- "node": "^16.14 || >=18"
83
+ "node": ">=18.13"
84
84
  },
85
85
  "scripts": {
86
86
  "lint": "prettier --config ../../.prettierrc --check .",
87
- "check": "tsc",
87
+ "check": "tsc && cd ./test/types && tsc",
88
88
  "check:all": "tsc && pnpm -r --filter=\"./**\" check",
89
89
  "format": "prettier --config ../../.prettierrc --write .",
90
90
  "test": "pnpm test:unit && pnpm test:integration",
@@ -156,6 +156,13 @@ export function create_builder({
156
156
  write(dest, fallback);
157
157
  },
158
158
 
159
+ generateEnvModule() {
160
+ const dest = `${config.kit.outDir}/output/prerendered/dependencies/${config.kit.appDir}/env.js`;
161
+ const env = get_env(config.kit.env, vite_config.mode);
162
+
163
+ write(dest, `export const env=${JSON.stringify(env.public)}`);
164
+ },
165
+
159
166
  generateManifest({ relativePath, routes: subset }) {
160
167
  return generate_manifest({
161
168
  build_data,
@@ -213,7 +220,7 @@ async function compress_file(file, format = 'gz') {
213
220
  [zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
214
221
  [zlib.constants.BROTLI_PARAM_SIZE_HINT]: statSync(file).size
215
222
  }
216
- })
223
+ })
217
224
  : zlib.createGzip({ level: zlib.constants.Z_BEST_COMPRESSION });
218
225
 
219
226
  const source = createReadStream(file);
@@ -69,7 +69,15 @@ export async function load_config({ cwd = process.cwd() } = {}) {
69
69
 
70
70
  const config = await import(`${url.pathToFileURL(config_file).href}?ts=${Date.now()}`);
71
71
 
72
- return process_config(config.default, { cwd });
72
+ try {
73
+ return process_config(config.default, { cwd });
74
+ } catch (e) {
75
+ const error = /** @type {Error} */ (e);
76
+
77
+ // redact the stack trace — it's not helpful to users
78
+ error.stack = `Could not load svelte.config.js: ${error.message}\n`;
79
+ throw error;
80
+ }
73
81
  }
74
82
 
75
83
  /**
@@ -111,11 +111,6 @@ const options = object(
111
111
  checkOrigin: boolean(true)
112
112
  }),
113
113
 
114
- dangerZone: object({
115
- // TODO 2.0: Remove this
116
- trackServerFetches: boolean(false)
117
- }),
118
-
119
114
  embedded: boolean(false),
120
115
 
121
116
  env: object({
@@ -179,13 +174,7 @@ const options = object(
179
174
 
180
175
  return input;
181
176
  }),
182
- relative: validate(undefined, (input, keypath) => {
183
- if (typeof input !== 'boolean') {
184
- throw new Error(`${keypath} option must be a boolean or undefined`);
185
- }
186
-
187
- return input;
188
- })
177
+ relative: boolean(true)
189
178
  }),
190
179
 
191
180
  prerender: object({
@@ -10,11 +10,10 @@ import {
10
10
  } from '../../utils/exports.js';
11
11
  import { load_config } from '../config/index.js';
12
12
  import { forked } from '../../utils/fork.js';
13
- import { should_polyfill } from '../../utils/platform.js';
14
13
  import { installPolyfills } from '../../exports/node/polyfills.js';
15
- import { resolvePath } from '../../exports/index.js';
16
14
  import { ENDPOINT_METHODS } from '../../constants.js';
17
15
  import { filter_private_env, filter_public_env } from '../../utils/env.js';
16
+ import { resolve_route } from '../../utils/routing.js';
18
17
 
19
18
  export default forked(import.meta.url, analyse);
20
19
 
@@ -36,9 +35,7 @@ async function analyse({ manifest_path, env }) {
36
35
  /** @type {import('types').ServerInternalModule} */
37
36
  const internal = await import(pathToFileURL(`${server_root}/server/internal.js`).href);
38
37
 
39
- if (should_polyfill) {
40
- installPolyfills();
41
- }
38
+ installPolyfills();
42
39
 
43
40
  // configure `import { building } from '$app/environment'` —
44
41
  // essential we do this before analysing the code
@@ -46,8 +43,11 @@ async function analyse({ manifest_path, env }) {
46
43
 
47
44
  // set env, in case it's used in initialisation
48
45
  const { publicPrefix: public_prefix, privatePrefix: private_prefix } = config.env;
49
- internal.set_private_env(filter_private_env(env, { public_prefix, private_prefix }));
50
- internal.set_public_env(filter_public_env(env, { public_prefix, private_prefix }));
46
+ const private_env = filter_private_env(env, { public_prefix, private_prefix });
47
+ const public_env = filter_public_env(env, { public_prefix, private_prefix });
48
+ internal.set_private_env(private_env);
49
+ internal.set_public_env(public_env);
50
+ internal.set_safe_public_env(public_env);
51
51
 
52
52
  /** @type {import('types').ServerMetadata} */
53
53
  const metadata = {
@@ -55,10 +55,10 @@ async function analyse({ manifest_path, env }) {
55
55
  routes: new Map()
56
56
  };
57
57
 
58
- // analyse nodes
59
- for (const loader of manifest._.nodes) {
60
- const node = await loader();
58
+ const nodes = await Promise.all(manifest._.nodes.map((loader) => loader()));
61
59
 
60
+ // analyse nodes
61
+ for (const node of nodes) {
62
62
  metadata.nodes[node.index] = {
63
63
  has_server_load: node.server?.load !== undefined || node.server?.trailingSlash !== undefined
64
64
  };
@@ -66,78 +66,35 @@ async function analyse({ manifest_path, env }) {
66
66
 
67
67
  // analyse routes
68
68
  for (const route of manifest._.routes) {
69
- /** @type {Array<'GET' | 'POST'>} */
70
- const page_methods = [];
71
-
72
- /** @type {(import('types').HttpMethod | '*')[]} */
73
- const api_methods = [];
69
+ const page =
70
+ route.page &&
71
+ analyse_page(
72
+ route.page.layouts.map((n) => (n === undefined ? n : nodes[n])),
73
+ nodes[route.page.leaf]
74
+ );
74
75
 
75
- /** @type {import('types').PrerenderOption | undefined} */
76
- let prerender = undefined;
77
- /** @type {any} */
78
- let config = undefined;
79
- /** @type {import('types').PrerenderEntryGenerator | undefined} */
80
- let entries = undefined;
76
+ const endpoint = route.endpoint && analyse_endpoint(route, await route.endpoint());
81
77
 
82
- if (route.endpoint) {
83
- const mod = await route.endpoint();
84
- if (mod.prerender !== undefined) {
85
- validate_server_exports(mod, route.id);
78
+ if (page?.prerender && endpoint?.prerender) {
79
+ throw new Error(`Cannot prerender a route with both +page and +server files (${route.id})`);
80
+ }
86
81
 
87
- if (mod.prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) {
82
+ if (page?.config && endpoint?.config) {
83
+ for (const key in { ...page.config, ...endpoint.config }) {
84
+ if (JSON.stringify(page.config[key]) !== JSON.stringify(endpoint.config[key])) {
88
85
  throw new Error(
89
- `Cannot prerender a +server file with POST, PATCH, PUT, or DELETE (${route.id})`
86
+ `Mismatched route config for ${route.id} — the +page and +server files must export the same config, if any`
90
87
  );
91
88
  }
92
-
93
- prerender = mod.prerender;
94
- }
95
-
96
- for (const method of /** @type {import('types').HttpMethod[]} */ (ENDPOINT_METHODS)) {
97
- if (mod[method]) api_methods.push(method);
98
89
  }
99
-
100
- if (mod.fallback) {
101
- api_methods.push('*');
102
- }
103
-
104
- config = mod.config;
105
- entries = mod.entries;
106
90
  }
107
91
 
108
- if (route.page) {
109
- const nodes = await Promise.all(
110
- [...route.page.layouts, route.page.leaf].map((n) => {
111
- if (n !== undefined) return manifest._.nodes[n]();
112
- })
113
- );
114
-
115
- const layouts = nodes.slice(0, -1);
116
- const page = nodes.at(-1);
117
-
118
- for (const layout of layouts) {
119
- if (layout) {
120
- validate_layout_server_exports(layout.server, layout.server_id);
121
- validate_layout_exports(layout.universal, layout.universal_id);
122
- }
123
- }
124
-
125
- if (page) {
126
- page_methods.push('GET');
127
- if (page.server?.actions) page_methods.push('POST');
128
-
129
- validate_page_server_exports(page.server, page.server_id);
130
- validate_page_exports(page.universal, page.universal_id);
131
- }
132
-
133
- prerender = get_option(nodes, 'prerender') ?? false;
134
-
135
- config = get_config(nodes);
136
- entries ??= get_option(nodes, 'entries');
137
- }
92
+ const page_methods = page?.methods ?? [];
93
+ const api_methods = endpoint?.methods ?? [];
94
+ const entries = page?.entries ?? endpoint?.entries;
138
95
 
139
96
  metadata.routes.set(route.id, {
140
- config,
97
+ config: page?.config ?? endpoint?.config,
141
98
  methods: Array.from(new Set([...page_methods, ...api_methods])),
142
99
  page: {
143
100
  methods: page_methods
@@ -145,29 +102,90 @@ async function analyse({ manifest_path, env }) {
145
102
  api: {
146
103
  methods: api_methods
147
104
  },
148
- prerender,
105
+ prerender: page?.prerender ?? endpoint?.prerender,
149
106
  entries:
150
- entries && (await entries()).map((entry_object) => resolvePath(route.id, entry_object))
107
+ entries && (await entries()).map((entry_object) => resolve_route(route.id, entry_object))
151
108
  });
152
109
  }
153
110
 
154
111
  return metadata;
155
112
  }
156
113
 
114
+ /**
115
+ * @param {import('types').SSRRoute} route
116
+ * @param {import('types').SSREndpoint} mod
117
+ */
118
+ function analyse_endpoint(route, mod) {
119
+ validate_server_exports(mod, route.id);
120
+
121
+ if (mod.prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) {
122
+ throw new Error(
123
+ `Cannot prerender a +server file with POST, PATCH, PUT, or DELETE (${route.id})`
124
+ );
125
+ }
126
+
127
+ /** @type {Array<import('types').HttpMethod | '*'>} */
128
+ const methods = [];
129
+
130
+ for (const method of /** @type {import('types').HttpMethod[]} */ (ENDPOINT_METHODS)) {
131
+ if (mod[method]) methods.push(method);
132
+ }
133
+
134
+ if (mod.fallback) {
135
+ methods.push('*');
136
+ }
137
+
138
+ return {
139
+ config: mod.config,
140
+ entries: mod.entries,
141
+ methods,
142
+ prerender: mod.prerender ?? false
143
+ };
144
+ }
145
+
146
+ /**
147
+ * @param {Array<import('types').SSRNode | undefined>} layouts
148
+ * @param {import('types').SSRNode} leaf
149
+ */
150
+ function analyse_page(layouts, leaf) {
151
+ for (const layout of layouts) {
152
+ if (layout) {
153
+ validate_layout_server_exports(layout.server, layout.server_id);
154
+ validate_layout_exports(layout.universal, layout.universal_id);
155
+ }
156
+ }
157
+
158
+ /** @type {Array<'GET' | 'POST'>} */
159
+ const methods = ['GET'];
160
+ if (leaf.server?.actions) methods.push('POST');
161
+
162
+ validate_page_server_exports(leaf.server, leaf.server_id);
163
+ validate_page_exports(leaf.universal, leaf.universal_id);
164
+
165
+ return {
166
+ config: get_config([...layouts, leaf]),
167
+ entries: leaf.universal?.entries ?? leaf.server?.entries,
168
+ methods,
169
+ prerender: get_option([...layouts, leaf], 'prerender') ?? false
170
+ };
171
+ }
172
+
157
173
  /**
158
174
  * Do a shallow merge (first level) of the config object
159
175
  * @param {Array<import('types').SSRNode | undefined>} nodes
160
176
  */
161
177
  function get_config(nodes) {
178
+ /** @type {any} */
162
179
  let current = {};
180
+
163
181
  for (const node of nodes) {
164
- const config = node?.universal?.config ?? node?.server?.config;
165
- if (config) {
166
- current = {
167
- ...current,
168
- ...config
169
- };
170
- }
182
+ if (!node?.universal?.config && !node?.server?.config) continue;
183
+
184
+ current = {
185
+ ...current,
186
+ ...node?.universal?.config,
187
+ ...node?.server?.config
188
+ };
171
189
  }
172
190
 
173
191
  return Object.keys(current).length ? current : undefined;
@@ -3,7 +3,6 @@ import { dirname, join } from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { installPolyfills } from '../../exports/node/polyfills.js';
5
5
  import { mkdirp, posixify, walk } from '../../utils/filesystem.js';
6
- import { should_polyfill } from '../../utils/platform.js';
7
6
  import { decode_uri, is_root_relative, resolve } from '../../utils/url.js';
8
7
  import { escape_html_attr } from '../../utils/escape.js';
9
8
  import { logger } from '../utils.js';
@@ -94,9 +93,7 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
94
93
  /** @type {import('types').Logger} */
95
94
  const log = logger({ verbose });
96
95
 
97
- if (should_polyfill) {
98
- installPolyfills();
99
- }
96
+ installPolyfills();
100
97
 
101
98
  /** @type {Map<string, string>} */
102
99
  const saved = new Map();
@@ -153,6 +150,7 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
153
150
  }
154
151
 
155
152
  const files = new Set(walk(`${out}/client`).map(posixify));
153
+ files.add(`${config.appDir}/env.js`);
156
154
 
157
155
  const immutable = `${config.appDir}/immutable`;
158
156
  if (existsSync(`${out}/server/${immutable}`)) {
@@ -429,8 +427,12 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
429
427
  if (entry === '*') {
430
428
  for (const [id, prerender] of prerender_map) {
431
429
  if (prerender) {
432
- if (id.includes('[')) continue;
433
- const path = `/${get_route_segments(id).join('/')}`;
430
+ // remove optional parameters from the route
431
+ const segments = get_route_segments(id).filter((segment) => !segment.startsWith('[['));
432
+ const processed_id = '/' + segments.join('/');
433
+
434
+ if (processed_id.includes('[')) continue;
435
+ const path = `/${get_route_segments(processed_id).join('/')}`;
434
436
  enqueue(null, config.paths.base + path);
435
437
  }
436
438
  }
@@ -472,10 +474,10 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
472
474
  }
473
475
 
474
476
  if (not_prerendered.length > 0) {
477
+ const list = not_prerendered.map((id) => ` - ${id}`).join('\n');
478
+
475
479
  throw new Error(
476
- `The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app:\n${not_prerendered.map(
477
- (id) => ` - ${id}`
478
- )}\n\nSee https://kit.svelte.dev/docs/page-options#prerender-troubleshooting for info on how to solve this`
480
+ `The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app:\n${list}\n\nSee https://kit.svelte.dev/docs/page-options#prerender-troubleshooting for info on how to solve this`
479
481
  );
480
482
  }
481
483
 
@@ -5,6 +5,7 @@ import { write_root } from './write_root.js';
5
5
  import { write_tsconfig } from './write_tsconfig.js';
6
6
  import { write_types, write_all_types } from './write_types/index.js';
7
7
  import { write_ambient } from './write_ambient.js';
8
+ import { write_non_ambient } from './write_non_ambient.js';
8
9
  import { write_server } from './write_server.js';
9
10
 
10
11
  /**
@@ -15,6 +16,7 @@ import { write_server } from './write_server.js';
15
16
  export function init(config, mode) {
16
17
  write_tsconfig(config.kit);
17
18
  write_ambient(config.kit, mode);
19
+ write_non_ambient(config.kit);
18
20
  }
19
21
 
20
22
  /**
@@ -0,0 +1,42 @@
1
+ import path from 'node:path';
2
+ import { GENERATED_COMMENT } from '../../constants.js';
3
+ import { write_if_changed } from './utils.js';
4
+
5
+ // `declare module "svelte/elements"` needs to happen in a non-ambient module, and dts-buddy generates one big ambient module,
6
+ // so we can't add it there - therefore generate the typings ourselves here.
7
+ // We're not using the `declare namespace svelteHTML` variant because that one doesn't augment the HTMLAttributes interface
8
+ // people could use to type their own components.
9
+ // The T generic is needed or else there's a "all declarations must have identical type parameters" error.
10
+ const template = `
11
+ ${GENERATED_COMMENT}
12
+
13
+ declare module "svelte/elements" {
14
+ export interface HTMLAttributes<T> {
15
+ 'data-sveltekit-keepfocus'?: true | '' | 'off' | undefined | null;
16
+ 'data-sveltekit-noscroll'?: true | '' | 'off' | undefined | null;
17
+ 'data-sveltekit-preload-code'?:
18
+ | true
19
+ | ''
20
+ | 'eager'
21
+ | 'viewport'
22
+ | 'hover'
23
+ | 'tap'
24
+ | 'off'
25
+ | undefined
26
+ | null;
27
+ 'data-sveltekit-preload-data'?: true | '' | 'hover' | 'tap' | 'off' | undefined | null;
28
+ 'data-sveltekit-reload'?: true | '' | 'off' | undefined | null;
29
+ 'data-sveltekit-replacestate'?: true | '' | 'off' | undefined | null;
30
+ }
31
+ }
32
+
33
+ export {};
34
+ `;
35
+
36
+ /**
37
+ * Writes non-ambient declarations to the output directory
38
+ * @param {import('types').ValidatedKitConfig} config
39
+ */
40
+ export function write_non_ambient(config) {
41
+ write_if_changed(path.join(config.outDir, 'non-ambient.d.ts'), template);
42
+ }
@@ -28,13 +28,13 @@ const server_template = ({
28
28
  import root from '../root.${isSvelte5Plus() ? 'js' : 'svelte'}';
29
29
  import { set_building } from '__sveltekit/environment';
30
30
  import { set_assets } from '__sveltekit/paths';
31
- import { set_private_env, set_public_env } from '${runtime_directory}/shared-server.js';
31
+ import { set_private_env, set_public_env, set_safe_public_env } from '${runtime_directory}/shared-server.js';
32
32
 
33
33
  export const options = {
34
+ app_dir: ${s(config.kit.appDir)},
34
35
  app_template_contains_nonce: ${template.includes('%sveltekit.nonce%')},
35
36
  csp: ${s(config.kit.csp)},
36
37
  csrf_check_origin: ${s(config.kit.csrf.checkOrigin)},
37
- track_server_fetches: ${s(config.kit.dangerZone.trackServerFetches)},
38
38
  embedded: ${config.kit.embedded},
39
39
  env_public_prefix: '${config.kit.env.publicPrefix}',
40
40
  env_private_prefix: '${config.kit.env.privatePrefix}',
@@ -63,7 +63,7 @@ export function get_hooks() {
63
63
  return ${hooks ? `import(${s(hooks)})` : '{}'};
64
64
  }
65
65
 
66
- export { set_assets, set_building, set_private_env, set_public_env };
66
+ export { set_assets, set_building, set_private_env, set_public_env, set_safe_public_env };
67
67
  `;
68
68
 
69
69
  // TODO need to re-run this whenever src/app.html or src/error.html are