@sveltejs/kit 3.0.0-next.1 → 3.0.0-next.11

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 (144) hide show
  1. package/package.json +33 -21
  2. package/src/constants.js +2 -0
  3. package/src/core/adapt/builder.js +32 -49
  4. package/src/core/adapt/index.js +1 -4
  5. package/src/core/config/index.js +137 -71
  6. package/src/core/config/options.js +236 -244
  7. package/src/core/config/types.d.ts +1 -1
  8. package/src/core/env.js +121 -5
  9. package/src/core/generate_manifest/index.js +12 -15
  10. package/src/core/postbuild/analyse.js +7 -19
  11. package/src/core/postbuild/crawl.js +22 -6
  12. package/src/core/postbuild/fallback.js +2 -1
  13. package/src/core/postbuild/prerender.js +114 -48
  14. package/src/core/postbuild/queue.js +2 -1
  15. package/src/core/sync/create_manifest_data/index.js +53 -50
  16. package/src/core/sync/sync.js +0 -2
  17. package/src/core/sync/write_client_manifest.js +8 -15
  18. package/src/core/sync/write_env.js +2 -1
  19. package/src/core/sync/write_non_ambient.js +12 -9
  20. package/src/core/sync/write_server.js +14 -15
  21. package/src/core/sync/write_tsconfig.js +16 -8
  22. package/src/core/sync/write_tsconfig_test/package.json +7 -0
  23. package/src/core/sync/write_types/index.js +28 -24
  24. package/src/core/utils.js +30 -5
  25. package/src/exports/env/index.js +77 -0
  26. package/src/exports/hooks/index.js +3 -9
  27. package/src/exports/hooks/sequence.js +3 -2
  28. package/src/exports/index.js +35 -13
  29. package/src/exports/internal/client.js +5 -0
  30. package/src/exports/internal/env.js +8 -5
  31. package/src/exports/internal/index.js +1 -90
  32. package/src/exports/internal/{event.js → server/event.js} +1 -2
  33. package/src/exports/internal/server/index.js +33 -0
  34. package/src/exports/internal/shared.js +89 -0
  35. package/src/exports/node/index.js +62 -15
  36. package/src/exports/params.js +68 -0
  37. package/src/exports/public.d.ts +363 -189
  38. package/src/exports/url.js +86 -0
  39. package/src/exports/vite/build/build_server.js +53 -59
  40. package/src/exports/vite/build/remote.js +18 -11
  41. package/src/exports/vite/build/utils.js +0 -8
  42. package/src/exports/vite/dev/index.js +92 -50
  43. package/src/exports/vite/index.js +903 -681
  44. package/src/exports/vite/module_ids.js +0 -2
  45. package/src/exports/vite/preview/index.js +32 -24
  46. package/src/exports/vite/static_analysis/index.js +2 -4
  47. package/src/exports/vite/static_analysis/types.d.ts +14 -0
  48. package/src/exports/vite/utils.js +40 -35
  49. package/src/runtime/app/env/internal.js +4 -4
  50. package/src/runtime/app/env/types.d.ts +1 -1
  51. package/src/runtime/app/environment/index.js +3 -3
  52. package/src/runtime/app/forms.js +24 -7
  53. package/src/runtime/app/paths/client.js +4 -10
  54. package/src/runtime/app/paths/internal/client.js +4 -2
  55. package/src/runtime/app/paths/internal/server.js +2 -23
  56. package/src/runtime/app/paths/public.d.ts +0 -28
  57. package/src/runtime/app/paths/server.js +10 -6
  58. package/src/runtime/app/server/index.js +1 -1
  59. package/src/runtime/app/server/remote/command.js +0 -3
  60. package/src/runtime/app/server/remote/form.js +27 -15
  61. package/src/runtime/app/server/remote/prerender.js +29 -36
  62. package/src/runtime/app/server/remote/query.js +101 -99
  63. package/src/runtime/app/server/remote/requested.js +22 -14
  64. package/src/runtime/app/server/remote/shared.js +30 -26
  65. package/src/runtime/app/state/client.js +1 -2
  66. package/src/runtime/app/stores.js +13 -76
  67. package/src/runtime/client/bundle.js +1 -1
  68. package/src/runtime/client/client-entry.js +3 -0
  69. package/src/runtime/client/client.js +411 -318
  70. package/src/runtime/client/entry.js +24 -3
  71. package/src/runtime/client/fetcher.js +3 -2
  72. package/src/runtime/client/ndjson.js +6 -33
  73. package/src/runtime/client/payload.js +17 -0
  74. package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
  75. package/src/runtime/client/remote-functions/command.svelte.js +7 -32
  76. package/src/runtime/client/remote-functions/form.svelte.js +183 -112
  77. package/src/runtime/client/remote-functions/prerender.svelte.js +29 -8
  78. package/src/runtime/client/remote-functions/query/index.js +7 -14
  79. package/src/runtime/client/remote-functions/query/instance.svelte.js +63 -18
  80. package/src/runtime/client/remote-functions/query/proxy.js +3 -3
  81. package/src/runtime/client/remote-functions/query-batch.svelte.js +60 -68
  82. package/src/runtime/client/remote-functions/query-live/instance.svelte.js +60 -18
  83. package/src/runtime/client/remote-functions/query-live/iterator.js +36 -55
  84. package/src/runtime/client/remote-functions/shared.svelte.js +88 -62
  85. package/src/runtime/client/sse.js +32 -0
  86. package/src/runtime/client/state.svelte.js +65 -49
  87. package/src/runtime/client/stream.js +39 -0
  88. package/src/runtime/client/types.d.ts +11 -7
  89. package/src/runtime/client/utils.js +0 -96
  90. package/src/runtime/components/root.svelte +66 -0
  91. package/src/runtime/env/dynamic/private.js +7 -0
  92. package/src/runtime/env/dynamic/public.js +7 -0
  93. package/src/runtime/env/static/private.js +6 -0
  94. package/src/runtime/env/static/public.js +6 -0
  95. package/src/runtime/form-utils.js +100 -22
  96. package/src/runtime/server/cookie.js +69 -52
  97. package/src/runtime/server/csrf.js +65 -0
  98. package/src/runtime/server/data/index.js +15 -19
  99. package/src/runtime/server/env_module.js +0 -5
  100. package/src/runtime/server/errors.js +135 -0
  101. package/src/runtime/server/fetch.js +1 -1
  102. package/src/runtime/server/index.js +22 -12
  103. package/src/runtime/server/internal.js +25 -0
  104. package/src/runtime/server/page/actions.js +43 -27
  105. package/src/runtime/server/page/data_serializer.js +10 -10
  106. package/src/runtime/server/page/index.js +12 -17
  107. package/src/runtime/server/page/load_data.js +2 -2
  108. package/src/runtime/server/page/render.js +114 -193
  109. package/src/runtime/server/page/respond_with_error.js +11 -11
  110. package/src/runtime/server/page/server_routing.js +27 -18
  111. package/src/runtime/server/remote-functions.js +596 -0
  112. package/src/runtime/server/respond.js +100 -68
  113. package/src/runtime/server/sourcemaps.js +183 -0
  114. package/src/runtime/server/utils.js +2 -134
  115. package/src/runtime/shared.js +83 -13
  116. package/src/runtime/telemetry/otel.js +1 -1
  117. package/src/runtime/types.d.ts +8 -0
  118. package/src/types/ambient-private.d.ts +2 -0
  119. package/src/types/ambient.d.ts +10 -5
  120. package/src/types/global-private.d.ts +13 -25
  121. package/src/types/internal.d.ts +95 -80
  122. package/src/types/private.d.ts +41 -1
  123. package/src/utils/error.js +24 -4
  124. package/src/utils/escape.js +9 -25
  125. package/src/utils/features.js +1 -1
  126. package/src/utils/fork.js +7 -2
  127. package/src/utils/import.js +6 -1
  128. package/src/utils/imports.js +83 -0
  129. package/src/utils/mime.js +9 -0
  130. package/src/utils/page_nodes.js +3 -5
  131. package/src/utils/params.js +66 -0
  132. package/src/utils/routing.js +90 -44
  133. package/src/utils/shared-iterator.js +5 -0
  134. package/src/utils/streaming.js +14 -4
  135. package/src/utils/url.js +20 -2
  136. package/src/version.js +1 -1
  137. package/types/index.d.ts +537 -557
  138. package/types/index.d.ts.map +24 -39
  139. package/src/core/sync/write_root.js +0 -148
  140. package/src/exports/internal/server.js +0 -22
  141. package/src/runtime/server/remote.js +0 -457
  142. package/src/runtime/shared-server.js +0 -7
  143. package/src/types/synthetic/$lib.md +0 -5
  144. /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
@@ -1,7 +1,7 @@
1
+ /** @import { SvelteConfig } from '@sveltejs/vite-plugin-svelte' */
2
+ /** @import { ValidatedKitConfig } from 'types' */
1
3
  /** @import { Validator } from './types.js' */
2
4
 
3
- import process from 'node:process';
4
-
5
5
  const directives = object({
6
6
  'child-src': string_array(),
7
7
  'default-src': string_array(),
@@ -36,8 +36,8 @@ const directives = object({
36
36
  referrer: string_array()
37
37
  });
38
38
 
39
- /** @type {Validator} */
40
- const options = object(
39
+ /** @type {Validator<{ extensions: string[] } & SvelteConfig>} */
40
+ export const validate_svelte_options = object(
41
41
  {
42
42
  extensions: validate(['.svelte'], (input, keypath) => {
43
43
  if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {
@@ -55,260 +55,241 @@ const options = object(
55
55
  });
56
56
 
57
57
  return input;
58
- }),
58
+ })
59
+ },
60
+ true
61
+ );
59
62
 
60
- kit: object({
61
- adapter: validate(undefined, (input, keypath) => {
62
- if (typeof input !== 'object' || !input.adapt) {
63
- const message = `The SvelteKit Vite plugin ${keypath} should be an object with an \`adapt\` method`;
64
- throw new Error(`${message}. See https://svelte.dev/docs/kit/adapters`);
65
- }
63
+ const prerender_handler = validate(undefined, (input, keypath) => {
64
+ if (typeof input === 'function') return input;
65
+ if (['fail', 'warn', 'ignore'].includes(input)) return input;
66
+ throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`);
67
+ });
66
68
 
67
- return input;
68
- }),
69
+ /** @type {Validator<ValidatedKitConfig>} */
70
+ export const validate_kit_options = object({
71
+ adapter: validate(undefined, (input, keypath) => {
72
+ if (typeof input !== 'object' || !input.adapt) {
73
+ const message = `The SvelteKit Vite plugin ${keypath} should be an object with an \`adapt\` method`;
74
+ throw new Error(`${message}. See https://svelte.dev/docs/kit/adapters`);
75
+ }
69
76
 
70
- alias: validate({}, (input, keypath) => {
71
- if (typeof input !== 'object') {
72
- throw new Error(`${keypath} should be an object`);
73
- }
77
+ return input;
78
+ }),
74
79
 
75
- for (const key in input) {
76
- assert_string(input[key], `${keypath}.${key}`);
77
- }
80
+ alias: validate({}, (input, keypath) => {
81
+ if (typeof input !== 'object') {
82
+ throw new Error(`${keypath} should be an object`);
83
+ }
84
+
85
+ for (const key in input) {
86
+ assert_string(input[key], `${keypath}.${key}`);
87
+ }
78
88
 
79
- return input;
80
- }),
89
+ return input;
90
+ }),
81
91
 
82
- appDir: validate('_app', (input, keypath) => {
83
- assert_string(input, keypath);
92
+ appDir: validate('_app', (input, keypath) => {
93
+ assert_string(input, keypath);
84
94
 
85
- if (input) {
86
- if (input.startsWith('/') || input.endsWith('/')) {
87
- throw new Error(
88
- "config.kit.appDir cannot start or end with '/'. See https://svelte.dev/docs/kit/configuration"
89
- );
90
- }
91
- } else {
92
- throw new Error(`${keypath} cannot be empty`);
95
+ if (input) {
96
+ if (input.startsWith('/') || input.endsWith('/')) {
97
+ throw new Error(
98
+ `${keypath} cannot start or end with '/'. See https://svelte.dev/docs/kit/configuration`
99
+ );
100
+ }
101
+ } else {
102
+ throw new Error(`${keypath} cannot be empty`);
103
+ }
104
+
105
+ return input;
106
+ }),
107
+
108
+ csp: object({
109
+ mode: list(['auto', 'hash', 'nonce']),
110
+ directives,
111
+ reportOnly: directives
112
+ }),
113
+
114
+ csrf: object({
115
+ checkOrigin: removed(
116
+ (keypath) => `\`${keypath}\` has been removed in favour of \`csrf.trustedOrigins\``
117
+ ),
118
+ trustedOrigins: string_array([])
119
+ }),
120
+
121
+ embedded: boolean(false),
122
+
123
+ env: object({
124
+ dir: string('')
125
+ }),
126
+
127
+ experimental: object({
128
+ tracing: removed(
129
+ (keypath) =>
130
+ `\`${keypath}\` has been removed. Server-side tracing is now configured via \`tracing.server\``
131
+ ),
132
+ instrumentation: removed(
133
+ (keypath) =>
134
+ `\`${keypath}\` has been removed. \`src/instrumentation.server.js\` is now included in the build automatically when it exists; no opt-in is required`
135
+ ),
136
+ remoteFunctions: boolean(false),
137
+ forkPreloads: boolean(false),
138
+ handleRenderingErrors: removed()
139
+ }),
140
+
141
+ files: object({
142
+ src: string('src'),
143
+ assets: string('static'),
144
+ hooks: object({
145
+ client: string(null),
146
+ server: string(null),
147
+ universal: string(null)
148
+ }),
149
+ lib: removed(
150
+ (keypath) =>
151
+ `\`${keypath}\` has been removed. Use #lib instead of $lib: https://svelte.dev/docs/kit/$lib`
152
+ ),
153
+ params: string(null),
154
+ routes: string(null),
155
+ serviceWorker: string(null),
156
+ appTemplate: string(null),
157
+ errorTemplate: string(null)
158
+ }),
159
+
160
+ inlineStyleThreshold: number(0),
161
+
162
+ moduleExtensions: string_array(['.js', '.ts']),
163
+
164
+ outDir: string('.svelte-kit'),
165
+
166
+ output: object({
167
+ linkHeaderPreload: boolean(false),
168
+ preloadStrategy: removed(
169
+ (keypath) => `\`${keypath}\` has been removed. modulepreload will always be used`
170
+ ),
171
+ bundleStrategy: list(['split', 'single', 'inline'])
172
+ }),
173
+
174
+ paths: object({
175
+ base: validate('', (input, keypath) => {
176
+ assert_string(input, keypath);
177
+
178
+ if (input !== '' && (input.endsWith('/') || !input.startsWith('/'))) {
179
+ throw new Error(
180
+ `${keypath} option must either be the empty string or a root-relative path that starts but doesn't end with '/'. See https://svelte.dev/docs/kit/configuration#paths`
181
+ );
182
+ }
183
+
184
+ return input;
185
+ }),
186
+ assets: validate('', (input, keypath) => {
187
+ assert_string(input, keypath);
188
+
189
+ if (input) {
190
+ if (!/^[a-z]+:\/\//.test(input)) {
191
+ throw new Error(
192
+ `${keypath} option must be an absolute path, if specified. See https://svelte.dev/docs/kit/configuration#paths`
193
+ );
93
194
  }
94
195
 
95
- return input;
96
- }),
97
-
98
- csp: object({
99
- mode: list(['auto', 'hash', 'nonce']),
100
- directives,
101
- reportOnly: directives
102
- }),
103
-
104
- csrf: object({
105
- checkOrigin: removed(
106
- (keypath) => `\`${keypath}\` has been removed in favour of \`csrf.trustedOrigins\``
107
- ),
108
- trustedOrigins: string_array([])
109
- }),
110
-
111
- embedded: boolean(false),
112
-
113
- env: object({
114
- dir: string(process.cwd())
115
- }),
116
-
117
- experimental: object({
118
- tracing: object({
119
- server: boolean(false)
120
- }),
121
- instrumentation: object({
122
- server: boolean(false)
123
- }),
124
- remoteFunctions: boolean(false),
125
- forkPreloads: boolean(false),
126
- handleRenderingErrors: boolean(false)
127
- }),
128
-
129
- files: object({
130
- src: string('src'),
131
- assets: string('static'),
132
- hooks: object({
133
- client: string(null),
134
- server: string(null),
135
- universal: string(null)
136
- }),
137
- lib: string(null),
138
- params: string(null),
139
- routes: string(null),
140
- serviceWorker: string(null),
141
- appTemplate: string(null),
142
- errorTemplate: string(null)
143
- }),
144
-
145
- inlineStyleThreshold: number(0),
146
-
147
- moduleExtensions: string_array(['.js', '.ts']),
148
-
149
- outDir: string('.svelte-kit'),
150
-
151
- output: object({
152
- linkHeaderPreload: boolean(false),
153
- preloadStrategy: removed(
154
- (keypath) => `\`${keypath}\` has been removed. modulepreload will always be used`
155
- ),
156
- bundleStrategy: list(['split', 'single', 'inline'])
157
- }),
158
-
159
- paths: object({
160
- base: validate('', (input, keypath) => {
161
- assert_string(input, keypath);
162
-
163
- if (input !== '' && (input.endsWith('/') || !input.startsWith('/'))) {
164
- throw new Error(
165
- `${keypath} option must either be the empty string or a root-relative path that starts but doesn't end with '/'. See https://svelte.dev/docs/kit/configuration#paths`
166
- );
167
- }
196
+ if (input.endsWith('/')) {
197
+ throw new Error(
198
+ `${keypath} option must not end with '/'. See https://svelte.dev/docs/kit/configuration#paths`
199
+ );
200
+ }
201
+ }
168
202
 
169
- return input;
170
- }),
171
- assets: validate('', (input, keypath) => {
172
- assert_string(input, keypath);
173
-
174
- if (input) {
175
- if (!/^[a-z]+:\/\//.test(input)) {
176
- throw new Error(
177
- `${keypath} option must be an absolute path, if specified. See https://svelte.dev/docs/kit/configuration#paths`
178
- );
179
- }
180
-
181
- if (input.endsWith('/')) {
182
- throw new Error(
183
- `${keypath} option must not end with '/'. See https://svelte.dev/docs/kit/configuration#paths`
184
- );
185
- }
186
- }
203
+ return input;
204
+ }),
205
+ origin: validate(undefined, (input, keypath) => {
206
+ assert_string(input, keypath);
187
207
 
188
- return input;
189
- }),
190
- relative: boolean(true)
191
- }),
192
-
193
- prerender: object({
194
- concurrency: number(1),
195
- crawl: boolean(true),
196
- entries: validate(['*'], (input, keypath) => {
197
- if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {
198
- throw new Error(`${keypath} must be an array of strings`);
199
- }
208
+ let url;
200
209
 
201
- input.forEach((page) => {
202
- if (page !== '*' && page[0] !== '/') {
203
- throw new Error(
204
- `Each member of ${keypath} must be either '*' or an absolute path beginning with '/' — saw '${page}'`
205
- );
206
- }
207
- });
208
-
209
- return input;
210
- }),
211
-
212
- handleHttpError: validate(
213
- (/** @type {any} */ { message }) => {
214
- throw new Error(
215
- message +
216
- '\nTo suppress or handle this error, implement `handleHttpError` in https://svelte.dev/docs/kit/configuration#prerender'
217
- );
218
- },
219
- (input, keypath) => {
220
- if (typeof input === 'function') return input;
221
- if (['fail', 'warn', 'ignore'].includes(input)) return input;
222
- throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`);
223
- }
224
- ),
225
-
226
- handleMissingId: validate(
227
- (/** @type {any} */ { message }) => {
228
- throw new Error(
229
- message +
230
- '\nTo suppress or handle this error, implement `handleMissingId` in https://svelte.dev/docs/kit/configuration#prerender'
231
- );
232
- },
233
- (input, keypath) => {
234
- if (typeof input === 'function') return input;
235
- if (['fail', 'warn', 'ignore'].includes(input)) return input;
236
- throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`);
237
- }
238
- ),
239
-
240
- handleEntryGeneratorMismatch: validate(
241
- (/** @type {any} */ { message }) => {
242
- throw new Error(
243
- message +
244
- '\nTo suppress or handle this error, implement `handleEntryGeneratorMismatch` in https://svelte.dev/docs/kit/configuration#prerender'
245
- );
246
- },
247
- (input, keypath) => {
248
- if (typeof input === 'function') return input;
249
- if (['fail', 'warn', 'ignore'].includes(input)) return input;
250
- throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`);
251
- }
252
- ),
253
-
254
- handleUnseenRoutes: validate(
255
- (/** @type {any} */ { message }) => {
256
- throw new Error(
257
- message +
258
- '\nTo suppress or handle this error, implement `handleUnseenRoutes` in https://svelte.dev/docs/kit/configuration#prerender'
259
- );
260
- },
261
- (input, keypath) => {
262
- if (typeof input === 'function') return input;
263
- if (['fail', 'warn', 'ignore'].includes(input)) return input;
264
- throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`);
265
- }
266
- ),
210
+ try {
211
+ url = new URL(input);
212
+ } catch {
213
+ throw new Error(
214
+ `${keypath} must be a valid origin (e.g. 'https://my-site.com'). '${input}' could not be parsed as a URL`
215
+ );
216
+ }
267
217
 
268
- origin: validate('http://sveltekit-prerender', (input, keypath) => {
269
- assert_string(input, keypath);
218
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
219
+ throw new Error(
220
+ `${keypath} must be a valid origin — only 'http' and 'https' protocols are supported, received '${url.protocol}'`
221
+ );
222
+ }
270
223
 
271
- let origin;
224
+ const origin = url.origin;
272
225
 
273
- try {
274
- origin = new URL(input).origin;
275
- } catch {
276
- throw new Error(`${keypath} must be a valid origin`);
277
- }
226
+ if (input !== origin) {
227
+ throw new Error(
228
+ `${keypath} must be a valid origin — received '${input}' which contains a path, query, or hash. Use the bare origin '${origin}' instead`
229
+ );
230
+ }
278
231
 
279
- if (input !== origin) {
280
- throw new Error(`${keypath} must be a valid origin (${origin} rather than ${input})`);
281
- }
232
+ return origin;
233
+ }),
234
+ relative: boolean(true)
235
+ }),
282
236
 
283
- return origin;
284
- })
285
- }),
286
-
287
- router: object({
288
- type: list(['pathname', 'hash']),
289
- resolution: list(['client', 'server'])
290
- }),
291
-
292
- serviceWorker: object({
293
- register: boolean(true),
294
- // options could be undefined but if it is defined we only validate that
295
- // it's an object since the type comes from the browser itself
296
- options: validate(undefined, object({}, true)),
297
- files: fun((filename) => !/\.DS_Store/.test(filename))
298
- }),
299
-
300
- typescript: object({
301
- config: fun((config) => config)
302
- }),
303
-
304
- version: object({
305
- name: string(Date.now().toString()),
306
- pollInterval: number(0)
307
- })
308
- })
309
- },
310
- true
311
- );
237
+ prerender: object({
238
+ concurrency: number(1),
239
+ crawl: boolean(true),
240
+ entries: validate(['*'], (input, keypath) => {
241
+ if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {
242
+ throw new Error(`${keypath} must be an array of strings`);
243
+ }
244
+
245
+ input.forEach((page) => {
246
+ if (page !== '*' && page[0] !== '/') {
247
+ throw new Error(
248
+ `Each member of ${keypath} must be either '*' or an absolute path beginning with '/' — saw '${page}'`
249
+ );
250
+ }
251
+ });
252
+
253
+ return input;
254
+ }),
255
+
256
+ handleHttpError: prerender_handler,
257
+ handleMissingId: prerender_handler,
258
+ handleEntryGeneratorMismatch: prerender_handler,
259
+ handleUnseenRoutes: prerender_handler,
260
+ handleInvalidUrl: prerender_handler,
261
+
262
+ origin: removed(
263
+ (keypath) => `\`${keypath}\` has been removed in favour of \`config.paths.origin\``
264
+ )
265
+ }),
266
+
267
+ router: object({
268
+ type: list(['pathname', 'hash']),
269
+ resolution: list(['client', 'server'])
270
+ }),
271
+
272
+ serviceWorker: object({
273
+ register: boolean(true),
274
+ // options could be undefined but if it is defined we only validate that
275
+ // it's an object since the type comes from the browser itself
276
+ options: validate(undefined, object({}, true)),
277
+ files: fun((filename) => !/\.DS_Store/.test(filename))
278
+ }),
279
+
280
+ tracing: object({
281
+ server: boolean(false)
282
+ }),
283
+
284
+ typescript: object({
285
+ config: fun((config) => config)
286
+ }),
287
+
288
+ version: object({
289
+ name: string(Date.now().toString()),
290
+ pollInterval: number(0)
291
+ })
292
+ });
312
293
 
313
294
  // /**
314
295
  // * @param {Validator} fn
@@ -321,6 +302,8 @@ const options = object(
321
302
  // `The \`${keypath}\` option is deprecated, and will be removed in a future version`
322
303
  // ) {
323
304
  // return (input, keypath) => {
305
+ // keypath = remove_kit_prefix(keypath);
306
+ //
324
307
  // if (input !== undefined) {
325
308
  // console.warn(styleText(['bold', 'yellow'], get_message(keypath)));
326
309
  // }
@@ -329,6 +312,17 @@ const options = object(
329
312
  // };
330
313
  // }
331
314
 
315
+ // Derive the names of SvelteKit's own config options from the schema, so they
316
+ // stay in sync automatically. These are used to separate Kit's options from
317
+ // `vite-plugin-svelte`'s options when config is passed via the Vite plugin.
318
+ const kit_defaults = validate_kit_options({}, 'config');
319
+
320
+ /** The names of the options that live under the `kit` namespace */
321
+ export const kit_options = Object.keys(kit_defaults);
322
+
323
+ /** The names of the options that live under the `kit.experimental` namespace */
324
+ export const kit_experimental_options = Object.keys(kit_defaults.experimental);
325
+
332
326
  /**
333
327
  * @param {(keypath: string) => string} get_message
334
328
  * @returns {Validator}
@@ -366,7 +360,7 @@ export function object(children, allow_unknown = false) {
366
360
  let message = `Unexpected option ${keypath}.${key}`;
367
361
 
368
362
  // special case
369
- if (keypath === 'config.kit' && key in options) {
363
+ if (keypath === 'config.kit' && key in kit_options) {
370
364
  message += ` (did you mean config.${key}?)`;
371
365
  }
372
366
 
@@ -492,5 +486,3 @@ function assert_string(input, keypath) {
492
486
  throw new Error(`${keypath} should be a string, if specified`);
493
487
  }
494
488
  }
495
-
496
- export default options;
@@ -1 +1 @@
1
- export type Validator<T = any> = (input: T, keypath: string) => T;
1
+ export type Validator<T = any> = (input: any, keypath: string) => T;