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

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 (127) hide show
  1. package/package.json +33 -21
  2. package/src/core/adapt/builder.js +29 -43
  3. package/src/core/adapt/index.js +1 -4
  4. package/src/core/config/index.js +132 -71
  5. package/src/core/config/options.js +294 -244
  6. package/src/core/config/types.d.ts +1 -1
  7. package/src/core/env.js +121 -5
  8. package/src/core/generate_manifest/index.js +12 -15
  9. package/src/core/postbuild/analyse.js +7 -19
  10. package/src/core/postbuild/crawl.js +22 -6
  11. package/src/core/postbuild/prerender.js +42 -23
  12. package/src/core/sync/create_manifest_data/index.js +53 -50
  13. package/src/core/sync/sync.js +0 -2
  14. package/src/core/sync/write_client_manifest.js +8 -15
  15. package/src/core/sync/write_env.js +2 -1
  16. package/src/core/sync/write_non_ambient.js +12 -9
  17. package/src/core/sync/write_server.js +13 -14
  18. package/src/core/sync/write_tsconfig.js +16 -8
  19. package/src/core/sync/write_tsconfig_test/package.json +7 -0
  20. package/src/core/sync/write_types/index.js +28 -24
  21. package/src/core/utils.js +2 -2
  22. package/src/exports/env/index.js +12 -0
  23. package/src/exports/hooks/index.js +3 -9
  24. package/src/exports/hooks/sequence.js +3 -2
  25. package/src/exports/index.js +35 -13
  26. package/src/exports/internal/client.js +5 -0
  27. package/src/exports/internal/env.js +2 -2
  28. package/src/exports/internal/index.js +1 -90
  29. package/src/exports/internal/{event.js → server/event.js} +1 -2
  30. package/src/exports/internal/server/index.js +33 -0
  31. package/src/exports/internal/shared.js +89 -0
  32. package/src/exports/node/index.js +62 -15
  33. package/src/exports/params.js +63 -0
  34. package/src/exports/public.d.ts +323 -170
  35. package/src/exports/url.js +86 -0
  36. package/src/exports/vite/build/build_server.js +53 -59
  37. package/src/exports/vite/build/remote.js +18 -11
  38. package/src/exports/vite/build/utils.js +0 -8
  39. package/src/exports/vite/dev/index.js +42 -44
  40. package/src/exports/vite/index.js +810 -593
  41. package/src/exports/vite/preview/index.js +29 -22
  42. package/src/exports/vite/static_analysis/index.js +2 -4
  43. package/src/exports/vite/static_analysis/types.d.ts +14 -0
  44. package/src/exports/vite/utils.js +21 -36
  45. package/src/runtime/app/env/internal.js +4 -4
  46. package/src/runtime/app/env/types.d.ts +1 -1
  47. package/src/runtime/app/environment/index.js +3 -3
  48. package/src/runtime/app/forms.js +24 -7
  49. package/src/runtime/app/paths/client.js +4 -10
  50. package/src/runtime/app/paths/internal/client.js +4 -2
  51. package/src/runtime/app/paths/internal/server.js +2 -23
  52. package/src/runtime/app/paths/public.d.ts +0 -28
  53. package/src/runtime/app/paths/server.js +9 -5
  54. package/src/runtime/app/server/remote/command.js +0 -3
  55. package/src/runtime/app/server/remote/form.js +27 -15
  56. package/src/runtime/app/server/remote/prerender.js +29 -36
  57. package/src/runtime/app/server/remote/query.js +101 -99
  58. package/src/runtime/app/server/remote/requested.js +22 -14
  59. package/src/runtime/app/server/remote/shared.js +30 -26
  60. package/src/runtime/app/state/client.js +1 -2
  61. package/src/runtime/app/stores.js +13 -76
  62. package/src/runtime/client/bundle.js +1 -1
  63. package/src/runtime/client/client-entry.js +3 -0
  64. package/src/runtime/client/client.js +411 -318
  65. package/src/runtime/client/entry.js +24 -3
  66. package/src/runtime/client/fetcher.js +3 -2
  67. package/src/runtime/client/ndjson.js +6 -33
  68. package/src/runtime/client/payload.js +17 -0
  69. package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
  70. package/src/runtime/client/remote-functions/command.svelte.js +7 -32
  71. package/src/runtime/client/remote-functions/form.svelte.js +183 -112
  72. package/src/runtime/client/remote-functions/prerender.svelte.js +29 -8
  73. package/src/runtime/client/remote-functions/query/index.js +7 -14
  74. package/src/runtime/client/remote-functions/query/instance.svelte.js +63 -18
  75. package/src/runtime/client/remote-functions/query/proxy.js +3 -3
  76. package/src/runtime/client/remote-functions/query-batch.svelte.js +60 -68
  77. package/src/runtime/client/remote-functions/query-live/instance.svelte.js +60 -18
  78. package/src/runtime/client/remote-functions/query-live/iterator.js +36 -55
  79. package/src/runtime/client/remote-functions/shared.svelte.js +88 -62
  80. package/src/runtime/client/sse.js +32 -0
  81. package/src/runtime/client/state.svelte.js +65 -49
  82. package/src/runtime/client/stream.js +38 -0
  83. package/src/runtime/client/types.d.ts +11 -7
  84. package/src/runtime/client/utils.js +0 -96
  85. package/src/runtime/components/root.svelte +66 -0
  86. package/src/runtime/env/dynamic/private.js +7 -0
  87. package/src/runtime/env/dynamic/public.js +7 -0
  88. package/src/runtime/env/static/private.js +6 -0
  89. package/src/runtime/env/static/public.js +6 -0
  90. package/src/runtime/form-utils.js +100 -22
  91. package/src/runtime/server/cookie.js +69 -52
  92. package/src/runtime/server/csrf.js +65 -0
  93. package/src/runtime/server/data/index.js +14 -18
  94. package/src/runtime/server/env_module.js +0 -5
  95. package/src/runtime/server/index.js +2 -2
  96. package/src/runtime/server/page/actions.js +41 -26
  97. package/src/runtime/server/page/index.js +9 -15
  98. package/src/runtime/server/page/load_data.js +1 -1
  99. package/src/runtime/server/page/render.js +112 -187
  100. package/src/runtime/server/page/respond_with_error.js +7 -8
  101. package/src/runtime/server/page/server_routing.js +27 -18
  102. package/src/runtime/server/remote.js +355 -216
  103. package/src/runtime/server/respond.js +97 -61
  104. package/src/runtime/server/utils.js +32 -9
  105. package/src/runtime/shared.js +83 -13
  106. package/src/runtime/telemetry/otel.js +1 -1
  107. package/src/runtime/types.d.ts +8 -0
  108. package/src/types/ambient.d.ts +10 -5
  109. package/src/types/global-private.d.ts +15 -22
  110. package/src/types/internal.d.ts +89 -74
  111. package/src/types/private.d.ts +33 -1
  112. package/src/utils/error.js +24 -4
  113. package/src/utils/import.js +6 -1
  114. package/src/utils/imports.js +83 -0
  115. package/src/utils/mime.js +9 -0
  116. package/src/utils/params.js +66 -0
  117. package/src/utils/routing.js +90 -44
  118. package/src/utils/shared-iterator.js +5 -0
  119. package/src/utils/streaming.js +14 -4
  120. package/src/utils/url.js +20 -2
  121. package/src/version.js +1 -1
  122. package/types/index.d.ts +467 -537
  123. package/types/index.d.ts.map +22 -39
  124. package/src/core/sync/write_root.js +0 -148
  125. package/src/exports/internal/server.js +0 -22
  126. package/src/types/synthetic/$lib.md +0 -5
  127. /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
@@ -8,7 +8,7 @@ import { is_endpoint_request, render_endpoint } from './endpoint.js';
8
8
  import { render_page } from './page/index.js';
9
9
  import { render_response } from './page/render.js';
10
10
  import { respond_with_error } from './page/respond_with_error.js';
11
- import { is_form_content_type } from '../../utils/http.js';
11
+ import { get_self_origin, is_csrf_forbidden, is_remote_forbidden } from './csrf.js';
12
12
  import {
13
13
  handle_fatal_error,
14
14
  has_prerendered_path,
@@ -70,23 +70,28 @@ export async function internal_respond(request, options, manifest, state) {
70
70
  const is_data_request = has_data_suffix(url.pathname);
71
71
  const remote_id = get_remote_id(url);
72
72
 
73
- if (!DEV) {
73
+ if (!__SVELTEKIT_DEV__) {
74
74
  const request_origin = request.headers.get('origin');
75
+ const self_origin = get_self_origin(options.paths_origin, url.origin);
75
76
 
76
77
  if (remote_id) {
77
- if (request.method !== 'GET' && request_origin !== url.origin) {
78
+ if (
79
+ is_remote_forbidden({
80
+ request,
81
+ request_origin,
82
+ self_origin
83
+ })
84
+ ) {
78
85
  const message = 'Cross-site remote requests are forbidden';
79
86
  return json({ message }, { status: 403 });
80
87
  }
81
88
  } else if (options.csrf_check_origin) {
82
- const forbidden =
83
- is_form_content_type(request) &&
84
- (request.method === 'POST' ||
85
- request.method === 'PUT' ||
86
- request.method === 'PATCH' ||
87
- request.method === 'DELETE') &&
88
- request_origin !== url.origin &&
89
- (!request_origin || !options.csrf_trusted_origins.includes(request_origin));
89
+ const forbidden = is_csrf_forbidden({
90
+ request,
91
+ request_origin,
92
+ self_origin,
93
+ trusted_origins: options.csrf_trusted_origins
94
+ });
90
95
 
91
96
  if (forbidden) {
92
97
  const message = `Cross-site ${request.method} form submissions are forbidden`;
@@ -147,14 +152,16 @@ export async function internal_respond(request, options, manifest, state) {
147
152
  },
148
153
  remote: {
149
154
  data: null,
155
+ explicit: null,
156
+ implicit: null,
150
157
  forms: null,
151
- refreshes: null,
152
158
  requested: null,
153
- reconnects: null,
154
159
  batches: null,
155
160
  live_iterators: null
156
161
  },
157
162
  is_in_remote_function: false,
163
+ is_in_remote_form_or_command: false,
164
+ is_in_remote_query: false,
158
165
  is_in_render: false,
159
166
  is_in_universal_load: false
160
167
  };
@@ -317,7 +324,7 @@ export async function internal_respond(request, options, manifest, state) {
317
324
  return resolve_route(resolved_path, new URL(request.url), manifest);
318
325
  }
319
326
 
320
- if (resolved_path === `/${app_dir}/env.js` || resolved_path === `/${app_dir}/env.script.js`) {
327
+ if (resolved_path === `/${app_dir}/env.js`) {
321
328
  return get_public_env(request);
322
329
  }
323
330
 
@@ -329,14 +336,17 @@ export async function internal_respond(request, options, manifest, state) {
329
336
  }
330
337
 
331
338
  if (!state.prerendering?.fallback) {
332
- // TODO this could theoretically break — should probably be inside a try-catch
333
- const matchers = await manifest._.matchers();
334
- const result = find_route(resolved_path, manifest._.routes, matchers);
335
-
336
- if (result) {
337
- route = result.route;
338
- event.route = { id: route.id };
339
- event.params = result.params;
339
+ try {
340
+ const matchers = await manifest._.matchers();
341
+ const result = find_route(resolved_path, manifest._.routes, matchers);
342
+
343
+ if (result) {
344
+ route = result.route;
345
+ event.route = { id: route.id };
346
+ event.params = result.params;
347
+ }
348
+ } catch (e) {
349
+ return await handle_fatal_error(event, event_state, options, e);
340
350
  }
341
351
  }
342
352
 
@@ -617,54 +627,80 @@ export async function internal_respond(request, options, manifest, state) {
617
627
  invalidated_data_nodes,
618
628
  trailing_slash
619
629
  );
620
- } else if (route.endpoint && (!route.page || is_endpoint_request(event))) {
621
- response = await render_endpoint(event, event_state, await route.endpoint(), state);
622
- } else if (route.page) {
623
- if (!page_nodes) {
624
- throw new Error('page_nodes not found. This should never happen');
625
- } else if (page_methods.has(method)) {
626
- response = await render_page(
627
- event,
628
- event_state,
629
- route.page,
630
- options,
631
- manifest,
632
- state,
633
- page_nodes,
634
- resolve_opts
635
- );
636
- } else {
637
- const allowed_methods = new Set(allowed_page_methods);
638
- const node = await manifest._.nodes[route.page.leaf]();
639
- if (node?.server?.actions) {
640
- allowed_methods.add('POST');
630
+ } else {
631
+ let endpoint;
632
+ if (
633
+ route.endpoint &&
634
+ (!route.page || (!state.prerendering && is_endpoint_request(event)))
635
+ ) {
636
+ endpoint = await route.endpoint();
637
+
638
+ // Prefer rendering the page if the endpoint can't handle this GET or HEAD request
639
+ if (route.page && (method === 'GET' || method === 'HEAD')) {
640
+ const endpoint_can_handle = !!(
641
+ endpoint.GET ||
642
+ endpoint.fallback ||
643
+ (method === 'HEAD' && endpoint.HEAD)
644
+ );
645
+ if (!endpoint_can_handle) {
646
+ endpoint = undefined;
647
+ }
641
648
  }
649
+ }
642
650
 
643
- if (method === 'OPTIONS') {
644
- // This will deny CORS preflight requests implicitly because we don't
645
- // add the required CORS headers to the response.
646
- response = new Response(null, {
647
- status: 204,
648
- headers: {
649
- allow: Array.from(allowed_methods.values()).join(', ')
650
- }
651
- });
651
+ if (endpoint) {
652
+ response = await render_endpoint(event, event_state, endpoint, state);
653
+ } else if (route.page) {
654
+ if (!page_nodes) {
655
+ throw new Error('page_nodes not found. This should never happen');
656
+ } else if (page_methods.has(method)) {
657
+ response = await render_page(
658
+ event,
659
+ event_state,
660
+ route.page,
661
+ options,
662
+ manifest,
663
+ state,
664
+ page_nodes,
665
+ resolve_opts
666
+ );
652
667
  } else {
653
- const mod = [...allowed_methods].reduce((acc, curr) => {
654
- acc[curr] = true;
655
- return acc;
656
- }, /** @type {Record<string, any>} */ ({}));
657
- response = method_not_allowed(mod, method);
668
+ const allowed_methods = new Set(allowed_page_methods);
669
+ const node = await manifest._.nodes[route.page.leaf]();
670
+ if (node?.server?.actions) {
671
+ allowed_methods.add('POST');
672
+ }
673
+
674
+ if (method === 'OPTIONS') {
675
+ // This will deny CORS preflight requests implicitly because we don't
676
+ // add the required CORS headers to the response.
677
+ response = new Response(null, {
678
+ status: 204,
679
+ headers: {
680
+ allow: Array.from(allowed_methods.values()).join(', ')
681
+ }
682
+ });
683
+ } else {
684
+ const mod = [...allowed_methods].reduce((acc, curr) => {
685
+ acc[curr] = true;
686
+ return acc;
687
+ }, /** @type {Record<string, any>} */ ({}));
688
+ response = method_not_allowed(mod, method);
689
+ }
658
690
  }
691
+ } else {
692
+ // a route will always have a page or an endpoint, but TypeScript doesn't know that
693
+ throw new Error('Route is neither page nor endpoint. This should never happen');
659
694
  }
660
- } else {
661
- // a route will always have a page or an endpoint, but TypeScript doesn't know that
662
- throw new Error('Route is neither page nor endpoint. This should never happen');
663
695
  }
664
696
 
665
697
  // If the route contains a page and an endpoint, we need to add a
666
698
  // `Vary: Accept` header to the response because of browser caching
667
- if (request.method === 'GET' && route.page && route.endpoint) {
699
+ if (
700
+ (request.method === 'GET' || request.method === 'HEAD') &&
701
+ route.page &&
702
+ route.endpoint
703
+ ) {
668
704
  const vary = response.headers
669
705
  .get('vary')
670
706
  ?.split(',')
@@ -75,8 +75,8 @@ export function static_error_page(options, status, message) {
75
75
  */
76
76
  export async function handle_fatal_error(event, state, options, error) {
77
77
  error = error instanceof HttpError ? error : coalesce_to_error(error);
78
- const status = get_status(error);
79
78
  const body = await handle_error_and_jsonify(event, state, options, error);
79
+ const status = body.status;
80
80
 
81
81
  // ideally we'd use sec-fetch-dest instead, but Safari — quelle surprise — doesn't support it
82
82
  const type = negotiate(event.request.headers.get('accept') || 'text/html', [
@@ -98,9 +98,9 @@ export async function handle_fatal_error(event, state, options, error) {
98
98
  * @param {import('types').RequestState} state
99
99
  * @param {import('types').SSROptions} options
100
100
  * @param {any} error
101
- * @returns {Promise<App.Error>}
101
+ * @returns {App.Error | Promise<App.Error>}
102
102
  */
103
- export async function handle_error_and_jsonify(event, state, options, error) {
103
+ export function handle_error_and_jsonify(event, state, options, error) {
104
104
  if (error instanceof HttpError) {
105
105
  // @ts-expect-error custom user errors may not have a message field if App.Error is overwritten
106
106
  return { message: 'Unknown Error', ...error.body };
@@ -113,11 +113,34 @@ export async function handle_error_and_jsonify(event, state, options, error) {
113
113
  const status = get_status(error);
114
114
  const message = get_message(error);
115
115
 
116
- return (
117
- (await with_request_store({ event, state }, () =>
118
- options.hooks.handleError({ error, event, status, message })
119
- )) ?? { message }
120
- );
116
+ // TODO 4.0 await this, rather than handling the non-Promise case
117
+ const result = with_request_store({ event, state }, () =>
118
+ options.hooks.handleError({ error, event, status, message })
119
+ ) ?? { status, message };
120
+
121
+ if (result instanceof Promise) {
122
+ if (!__SVELTEKIT_SUPPORTS_ASYNC__ && state.is_in_render) {
123
+ console.warn(
124
+ `To use an async \`handleError\` hook to handle errors that occur during rendering, you must enable \`compilerOptions.experimental.async\` in the SvelteKit plugin of your Vite config. The returned error has been replaced with a generic object`
125
+ );
126
+
127
+ // we're discarding the result, but we still need to prevent an unhandled
128
+ // rejection if the user's async `handleError` hook rejects
129
+ result.catch(() => {});
130
+
131
+ return {
132
+ status,
133
+ message: 'Internal Error'
134
+ };
135
+ }
136
+
137
+ return result.then((body) => {
138
+ body ??= { status, message };
139
+ return { ...body, status: get_status(body, error) };
140
+ });
141
+ }
142
+
143
+ return { ...result, status: get_status(result, error) };
121
144
  }
122
145
 
123
146
  /**
@@ -228,7 +251,7 @@ export function clean_up_stack_trace(error) {
228
251
  return line.replace(/\((.+)(:\d+:\d+)\)$/, (_, file, loc) => `(${relative(file)}${loc})`);
229
252
  });
230
253
 
231
- // progressive enhancement for people who haven't configured kit.files.src to something else
254
+ // progressive enhancement for people who haven't configured files.src to something else
232
255
  const last_line_from_src_code = stack_trace.findLastIndex((line) => /\(src[\\/]/.test(line));
233
256
 
234
257
  if (last_line_from_src_code === -1) {
@@ -96,6 +96,8 @@ function to_sorted(value, clones) {
96
96
  const remote_object = '__skrao';
97
97
  const remote_map = '__skram';
98
98
  const remote_set = '__skras';
99
+ const remote_file = '__skraf';
100
+ const remote_promise_guard = '__skrap';
99
101
  const remote_regex_guard = '__skrag';
100
102
  const remote_arg_marker = Symbol(remote_object);
101
103
 
@@ -107,13 +109,12 @@ const remote_arg_marker = Symbol(remote_object);
107
109
  function create_remote_arg_reducers(transport, sort, remote_arg_clones) {
108
110
  /** @type {Record<string, (value: unknown) => unknown>} */
109
111
  const remote_fns_reducers = {
110
- [remote_regex_guard]:
111
- /** @type {(value: unknown) => void} */
112
- (value) => {
113
- if (value instanceof RegExp) {
114
- throw new Error('Regular expressions are not valid remote function arguments');
115
- }
112
+ /** @param {unknown} value */
113
+ [remote_regex_guard]: (value) => {
114
+ if (value instanceof RegExp) {
115
+ throw new Error('Regular expressions are not valid remote function arguments');
116
116
  }
117
+ }
117
118
  };
118
119
 
119
120
  if (sort) {
@@ -229,6 +230,24 @@ function create_remote_arg_revivers(transport) {
229
230
  }
230
231
 
231
232
  return set;
233
+ },
234
+ /** @type {(value: any) => File} */
235
+ [remote_file]: (value) => {
236
+ if (
237
+ !value ||
238
+ typeof value !== 'object' ||
239
+ typeof value.name !== 'string' ||
240
+ typeof value.type !== 'string' ||
241
+ typeof value.size !== 'number' ||
242
+ typeof value.lastModified !== 'number' ||
243
+ !(value.data instanceof ArrayBuffer)
244
+ ) {
245
+ throw new Error('Invalid data for File reviver');
246
+ }
247
+
248
+ const { data, name, ...meta } = value;
249
+
250
+ return new File([data], name, meta);
232
251
  }
233
252
  };
234
253
 
@@ -249,18 +268,69 @@ function create_remote_arg_revivers(transport) {
249
268
  * it is both a valid URL and a valid file name (necessary for prerendering).
250
269
  * @param {any} value
251
270
  * @param {Transport} transport
252
- * @param {boolean} [sort]
253
271
  */
254
- export function stringify_remote_arg(value, transport, sort = true) {
272
+ export function stringify_remote_arg(value, transport) {
255
273
  if (value === undefined) return '';
256
274
 
257
275
  // If people hit file/url size limits, we can look into using something like compress_and_encode_text from svelte.dev beyond a certain size
258
- const json_string = devalue.stringify(
259
- value,
260
- create_remote_arg_reducers(transport, sort, new Map())
261
- );
276
+ const json = devalue.stringify(value, create_remote_arg_reducers(transport, true, new Map()));
277
+
278
+ return url_friendly_base64_encode(json);
279
+ }
280
+
281
+ /**
282
+ * Stringifies command arguments, including `File` objects.
283
+ * @param {any} value
284
+ * @param {Transport} transport
285
+ */
286
+ export async function stringify_command_arg(value, transport) {
287
+ if (value === undefined) return '';
288
+
289
+ const reducers = create_remote_arg_reducers(transport, false, new Map());
262
290
 
263
- const bytes = text_encoder.encode(json_string);
291
+ /** @type {Set<Promise<any>>} */
292
+ const allowed_promises = new Set();
293
+
294
+ /** @param {any} value */
295
+ reducers[remote_file] = (value) => {
296
+ if (value instanceof File) {
297
+ const promise = value.arrayBuffer().then((data) => ({
298
+ data,
299
+ lastModified: value.lastModified,
300
+ name: value.name,
301
+ size: value.size,
302
+ type: value.type
303
+ }));
304
+
305
+ allowed_promises.add(promise);
306
+
307
+ return promise;
308
+ }
309
+ };
310
+
311
+ // we don't want to allow arbitrary promises, because they won't
312
+ // show up as promises on the other side. this is something
313
+ // we could potentially change in future. stringifyAsync
314
+ // will await them, so we need to explicitly deny them
315
+ /** @param {unknown} value */
316
+ reducers[remote_promise_guard] = (value) => {
317
+ if (value instanceof Promise && !allowed_promises.has(value)) {
318
+ throw new Error('Promises are not valid remote function arguments');
319
+ }
320
+ };
321
+
322
+ const json = await devalue.stringifyAsync(value, reducers);
323
+
324
+ return url_friendly_base64_encode(json);
325
+ }
326
+
327
+ /**
328
+ * Base64-encodes `string` in such a way that the result is safe to use
329
+ * as both a URI component and a filename
330
+ * @param {string} string
331
+ */
332
+ function url_friendly_base64_encode(string) {
333
+ const bytes = text_encoder.encode(string);
264
334
  return base64_encode(bytes).replaceAll('=', '').replaceAll('+', '-').replaceAll('/', '_');
265
335
  }
266
336
 
@@ -15,7 +15,7 @@ if (__SVELTEKIT_SERVER_TRACING_ENABLED__) {
15
15
  })
16
16
  .catch(() => {
17
17
  throw new Error(
18
- 'Tracing is enabled (see `config.kit.experimental.instrumentation.server` in your svelte.config.js), but `@opentelemetry/api` is not available. This error will likely resolve itself when you set up your tracing instrumentation in `instrumentation.server.js`. For more information, see https://svelte.dev/docs/kit/observability#opentelemetry-api'
18
+ 'Tracing is enabled (see the SvelteKit plugin `tracing.server` option in your vite.config.js), but `@opentelemetry/api` is not available. This error will likely resolve itself when you set up your tracing instrumentation in `instrumentation.server.js`. For more information, see https://svelte.dev/docs/kit/observability#opentelemetry-api'
19
19
  );
20
20
  });
21
21
  }
@@ -0,0 +1,8 @@
1
+ import { Component } from 'svelte';
2
+
3
+ export interface RenderNode {
4
+ component: Component;
5
+ error: Component;
6
+ data: Record<string, any>;
7
+ child?: RenderNode;
8
+ }
@@ -25,29 +25,34 @@ declare namespace App {
25
25
  * Defines the common shape of expected and unexpected errors. Expected errors are thrown using the `error` function. Unexpected errors are handled by the `handleError` hooks which should return this shape.
26
26
  */
27
27
  export interface Error {
28
+ status: number;
28
29
  message: string;
29
30
  }
30
31
 
31
32
  /**
32
33
  * The interface that defines `event.locals`, which can be accessed in server [hooks](https://svelte.dev/docs/kit/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files.
33
34
  */
35
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
34
36
  export interface Locals {}
35
37
 
36
38
  /**
37
- * Defines the common shape of the [page.data state](https://svelte.dev/docs/kit/$app-state#page) and [$page.data store](https://svelte.dev/docs/kit/$app-stores#page) - that is, the data that is shared between all pages.
39
+ * Defines the common shape of the [page.data state](https://svelte.dev/docs/kit/$app-state#page) - that is, the data that is shared between all pages.
38
40
  * The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.
39
41
  * Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).
40
42
  */
43
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
41
44
  export interface PageData {}
42
45
 
43
46
  /**
44
47
  * The shape of the `page.state` object, which can be manipulated using the [`pushState`](https://svelte.dev/docs/kit/$app-navigation#pushState) and [`replaceState`](https://svelte.dev/docs/kit/$app-navigation#replaceState) functions from `$app/navigation`.
45
48
  */
49
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
46
50
  export interface PageState {}
47
51
 
48
52
  /**
49
53
  * If your adapter provides [platform-specific context](https://svelte.dev/docs/kit/adapters#Platform-specific-context) via `event.platform`, you can specify it here.
50
54
  */
55
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
51
56
  export interface Platform {}
52
57
  }
53
58
 
@@ -56,8 +61,8 @@ declare namespace App {
56
61
  */
57
62
  declare module '$service-worker' {
58
63
  /**
59
- * The `base` path of the deployment. Typically this is equivalent to `config.kit.paths.base`, but it is calculated from `location.pathname` meaning that it will continue to work correctly if the site is deployed to a subdirectory.
60
- * Note that there is a `base` but no `assets`, since service workers cannot be used if `config.kit.paths.assets` is specified.
64
+ * The `base` path of the deployment. Typically this is equivalent to `config.paths.base`, but it is calculated from `location.pathname` meaning that it will continue to work correctly if the site is deployed to a subdirectory.
65
+ * Note that there is a `base` but no `assets`, since service workers cannot be used if `config.paths.assets` is specified.
61
66
  */
62
67
  export const base: string;
63
68
  /**
@@ -66,7 +71,7 @@ declare module '$service-worker' {
66
71
  */
67
72
  export const build: string[];
68
73
  /**
69
- * 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://svelte.dev/docs/kit/configuration#serviceWorker)
74
+ * An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.files.assets`. You can customize which files are included from `static` directory using [`config.serviceWorker.files`](https://svelte.dev/docs/kit/configuration#serviceWorker)
70
75
  */
71
76
  export const files: string[];
72
77
  /**
@@ -75,7 +80,7 @@ declare module '$service-worker' {
75
80
  */
76
81
  export const prerendered: string[];
77
82
  /**
78
- * See [`config.kit.version`](https://svelte.dev/docs/kit/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.
83
+ * See [`config.version`](https://svelte.dev/docs/kit/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.
79
84
  */
80
85
  export const version: string;
81
86
  }
@@ -1,3 +1,5 @@
1
+ import { SvelteKitPayload } from 'types';
2
+
1
3
  declare global {
2
4
  const __SVELTEKIT_ADAPTER_NAME__: string;
3
5
  const __SVELTEKIT_APP_DIR__: string;
@@ -13,13 +15,13 @@ declare global {
13
15
  const __SVELTEKIT_PATHS_ASSETS__: string;
14
16
  const __SVELTEKIT_PATHS_BASE__: string;
15
17
  const __SVELTEKIT_PATHS_RELATIVE__: boolean;
16
- /** True if `config.kit.experimental.instrumentation.server` is `true` */
18
+ /** True if `config.tracing.server` is `true` */
17
19
  const __SVELTEKIT_SERVER_TRACING_ENABLED__: boolean;
18
- /** True if `config.kit.experimental.forkPreloads` is `true` */
20
+ /** True if `config.experimental.forkPreloads` is `true` */
19
21
  const __SVELTEKIT_FORK_PRELOADS__: boolean;
20
- /** True if `config.kit.router.resolution === 'client'` */
22
+ /** True if `config.router.resolution === 'client'` */
21
23
  const __SVELTEKIT_CLIENT_ROUTING__: boolean;
22
- /** True if `config.kit.router.type === 'hash'` */
24
+ /** True if `config.router.type === 'hash'` */
23
25
  const __SVELTEKIT_HASH_ROUTING__: boolean;
24
26
  /**
25
27
  * True if any node in the manifest has a server load function.
@@ -31,28 +33,20 @@ declare global {
31
33
  * Used for treeshaking universal load code from client bundles when no universal loads exist.
32
34
  */
33
35
  const __SVELTEKIT_HAS_UNIVERSAL_LOAD__: boolean;
34
- /** The `__sveltekit_abc123` object in the init `<script>` */
35
- const __SVELTEKIT_PAYLOAD__: {
36
- /** The basepath, usually relative to the current page */
37
- base: string;
38
- /** Path to externally-hosted assets */
39
- assets?: string;
40
- /** Public environment variables */
41
- env?: Record<string, string>;
42
- /** Serialized data from query/form/command functions */
43
- query?: Record<string, any>;
44
- /** Serialized data from prerender functions */
45
- prerender?: Record<string, any>;
46
- /** Create a placeholder promise */
47
- defer?: (id: number) => Promise<any>;
48
- /** Resolve a placeholder promise */
49
- resolve?: (data: { id: number; data: any; error: any }) => void;
50
- };
36
+ /**
37
+ * The `__sveltekit_abc123` object in the init `<script>`.
38
+ * Should only be used when bundleStrategy !== 'inline' to avoid SvelteKit runtime changing on every build, preventing cacheability.
39
+ */
40
+ const __SVELTEKIT_PAYLOAD__: SvelteKitPayload;
51
41
  /**
52
42
  * The Vite `root` setting used to construct paths to nodes and components
53
43
  * for the SSR manifest during development
54
44
  */
55
45
  const __SVELTEKIT_ROOT__: string;
46
+ /**
47
+ * Whether the `experimental.async` flag is applied
48
+ */
49
+ const __SVELTEKIT_SUPPORTS_ASYNC__: boolean;
56
50
  /**
57
51
  * This makes the use of specific features visible at both dev and build time, in such a
58
52
  * way that we can error when they are not supported by the target platform.
@@ -68,7 +62,6 @@ declare global {
68
62
  * to throw an error if the feature would fail in production.
69
63
  */
70
64
  var __SVELTEKIT_TRACK__: (label: string) => void;
71
- var __SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__: boolean;
72
65
  var Bun: object;
73
66
  var Deno: object;
74
67
  }