@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,148 +0,0 @@
1
- import { dedent, write_if_changed } from './utils.js';
2
-
3
- /**
4
- * @param {import('types').ManifestData} manifest_data
5
- * @param {import('types').ValidatedConfig} config
6
- * @param {string} output
7
- */
8
- export function write_root(manifest_data, config, output) {
9
- // TODO remove default layout altogether
10
-
11
- const use_boundaries = config.kit.experimental.handleRenderingErrors;
12
-
13
- const max_depth = Math.max(
14
- ...manifest_data.routes.map((route) =>
15
- route.page ? route.page.layouts.filter(Boolean).length + 1 : 0
16
- ),
17
- 1
18
- );
19
-
20
- const levels = [];
21
- for (let i = 0; i <= max_depth; i += 1) {
22
- levels.push(i);
23
- }
24
-
25
- let l = max_depth;
26
- /** @type {string} */
27
- let pyramid;
28
-
29
- if (use_boundaries) {
30
- // with the @const we force the data[depth] access to be derived, which is important to not fire updates needlessly
31
- // TODO in Svelte 5 we should rethink the client.js side, we can likely make data a $state and only update indexes that changed there, simplifying this a lot
32
- pyramid = dedent`
33
- {#snippet pyramid(depth)}
34
- {@const Pyramid = constructors[depth]}
35
- {#snippet failed(error)}
36
- {@const ErrorPage = errors[depth]}
37
- <ErrorPage {error} />
38
- {/snippet}
39
- <svelte:boundary failed={errors[depth] ? failed : undefined}>
40
- {#if constructors[depth + 1]}
41
- {@const d = data[depth]}
42
- <!-- svelte-ignore binding_property_non_reactive -->
43
- <Pyramid bind:this={components[depth]} data={d} {form} params={page.params}>
44
- {@render pyramid(depth + 1)}
45
- </Pyramid>
46
- {:else}
47
- {@const d = data[depth]}
48
- <!-- svelte-ignore binding_property_non_reactive -->
49
- <Pyramid bind:this={components[depth]} data={d} {form} params={page.params} {error} />
50
- {/if}
51
- </svelte:boundary>
52
- {/snippet}
53
-
54
- {@render pyramid(0)}
55
- `;
56
- } else {
57
- pyramid = dedent`
58
- <!-- svelte-ignore binding_property_non_reactive -->
59
- <Pyramid_${l} bind:this={components[${l}]} data={data_${l}} {form} params={page.params} />`;
60
-
61
- while (l--) {
62
- pyramid = dedent`
63
- {#if constructors[${l + 1}]}
64
- {@const Pyramid_${l} = constructors[${l}]}
65
- <!-- svelte-ignore binding_property_non_reactive -->
66
- <Pyramid_${l} bind:this={components[${l}]} data={data_${l}} {form} params={page.params}>
67
- ${pyramid}
68
- </Pyramid_${l}>
69
- {:else}
70
- {@const Pyramid_${l} = constructors[${l}]}
71
- <!-- svelte-ignore binding_property_non_reactive -->
72
- <Pyramid_${l} bind:this={components[${l}]} data={data_${l}} {form} params={page.params} />
73
- {/if}
74
- `;
75
- }
76
- }
77
-
78
- write_if_changed(
79
- `${output}/root.svelte`,
80
- dedent`
81
- <!-- This file is generated by @sveltejs/kit — do not edit it! -->
82
- <svelte:options runes={true} />
83
- <script>
84
- import { setContext, onMount, tick } from 'svelte';
85
- import { browser } from '$app/env';
86
-
87
- // stores
88
- let { stores, page, constructors, components = [], form, ${use_boundaries ? 'errors = [], error, ' : ''}${levels
89
- .map((l) => `data_${l} = null`)
90
- .join(', ')} } = $props();
91
- ${use_boundaries ? `let data = $derived({${levels.map((l) => `'${l}': data_${l}`).join(', ')}})` : ''}
92
-
93
- if (browser) {
94
- $effect.pre(() => stores.page.set(page));
95
- } else {
96
- // svelte-ignore state_referenced_locally
97
- setContext('__svelte__', stores);
98
- // svelte-ignore state_referenced_locally
99
- stores.page.set(page);
100
- }
101
-
102
- $effect(() => {
103
- stores;page;constructors;components;form;${use_boundaries ? 'errors;error;' : ''}${levels.map((l) => `data_${l}`).join(';')};
104
- stores.page.notify();
105
- });
106
-
107
- let mounted = $state(false);
108
- let navigated = $state(false);
109
- let title = $state(null);
110
-
111
- onMount(() => {
112
- const unsubscribe = stores.page.subscribe(() => {
113
- if (mounted) {
114
- navigated = true;
115
- tick().then(() => {
116
- title = document.title || 'untitled page';
117
- });
118
- }
119
- });
120
-
121
- mounted = true;
122
- return unsubscribe;
123
- });
124
-
125
- const Pyramid_${max_depth} = $derived(constructors[${max_depth}]);
126
- </script>
127
-
128
- ${pyramid}
129
-
130
- {#if mounted}
131
- <div id="svelte-announcer" aria-live="assertive" aria-atomic="true" style="position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px">
132
- {#if navigated}
133
- {title}
134
- {/if}
135
- </div>
136
- {/if}
137
- `
138
- );
139
-
140
- write_if_changed(
141
- `${output}/root.js`,
142
- dedent`
143
- import { asClassComponent } from 'svelte/legacy';
144
- import Root from './root.svelte';
145
- export default asClassComponent(Root);
146
- `
147
- );
148
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * @template {{ tracing: { enabled: boolean, root: import('@opentelemetry/api').Span, current: import('@opentelemetry/api').Span } }} T
3
- * @param {T} event_like
4
- * @param {import('@opentelemetry/api').Span} current
5
- * @returns {T}
6
- */
7
- export function merge_tracing(event_like, current) {
8
- return {
9
- ...event_like,
10
- tracing: {
11
- ...event_like.tracing,
12
- current
13
- }
14
- };
15
- }
16
-
17
- export {
18
- with_request_store,
19
- getRequestEvent,
20
- get_request_store,
21
- try_get_request_store
22
- } from './event.js';