@sveltejs/kit 3.0.0-next.6 → 3.0.0-next.8

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