@sveltejs/kit 3.0.0-next.2 → 3.0.0-next.21

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 (195) hide show
  1. package/package.json +62 -36
  2. package/src/cli.js +15 -12
  3. package/src/constants.js +6 -1
  4. package/src/core/adapt/builder.js +66 -72
  5. package/src/core/adapt/index.js +17 -6
  6. package/src/core/config/index.js +134 -80
  7. package/src/core/config/options.js +295 -273
  8. package/src/core/config/types.d.ts +1 -1
  9. package/src/core/env.js +146 -16
  10. package/src/core/generate_manifest/index.js +18 -15
  11. package/src/core/postbuild/analyse.js +8 -20
  12. package/src/core/postbuild/crawl.js +22 -6
  13. package/src/core/postbuild/entities.js +8 -2
  14. package/src/core/postbuild/fallback.js +4 -2
  15. package/src/core/postbuild/prerender.js +222 -70
  16. package/src/core/postbuild/queue.js +2 -1
  17. package/src/core/sync/create_manifest_data/conflict.js +1 -1
  18. package/src/core/sync/create_manifest_data/index.js +82 -62
  19. package/src/core/sync/sync.js +40 -31
  20. package/src/core/sync/ts.js +1 -1
  21. package/src/core/sync/utils.js +22 -2
  22. package/src/core/sync/{write_non_ambient.js → write_app_types.js} +107 -58
  23. package/src/core/sync/write_client_manifest.js +14 -29
  24. package/src/core/sync/write_env.js +7 -5
  25. package/src/core/sync/write_server.js +37 -45
  26. package/src/core/sync/write_tsconfig/index.js +274 -0
  27. package/src/core/sync/write_tsconfig/test-app/package.json +7 -0
  28. package/src/core/sync/write_tsconfig/utils.js +77 -0
  29. package/src/core/sync/write_tsconfig/validate.js +128 -0
  30. package/src/core/sync/write_types/index.js +127 -123
  31. package/src/core/utils.js +30 -5
  32. package/src/exports/env/index.js +77 -0
  33. package/src/exports/env/public.d.ts +55 -0
  34. package/src/exports/hooks/index.js +3 -9
  35. package/src/exports/hooks/public.d.ts +195 -0
  36. package/src/exports/hooks/sequence.js +9 -6
  37. package/src/exports/index.js +52 -29
  38. package/src/exports/internal/client.js +5 -0
  39. package/src/exports/internal/env.js +8 -5
  40. package/src/exports/internal/index.js +1 -90
  41. package/src/exports/internal/{event.js → server/event.js} +2 -3
  42. package/src/exports/internal/server/index.js +37 -0
  43. package/src/exports/internal/server/telemetry.js +95 -0
  44. package/src/exports/internal/shared.js +90 -0
  45. package/src/exports/node/index.js +64 -22
  46. package/src/exports/params/index.js +70 -0
  47. package/src/exports/params/public.d.ts +63 -0
  48. package/src/exports/public.d.ts +50 -1733
  49. package/src/exports/remote/index.js +11 -0
  50. package/src/exports/remote/public.d.ts +519 -0
  51. package/src/exports/url.js +86 -0
  52. package/src/exports/vite/build/build_server.js +54 -65
  53. package/src/exports/vite/build/remote.js +24 -19
  54. package/src/exports/vite/build/utils.js +0 -8
  55. package/src/exports/vite/dev/index.js +218 -146
  56. package/src/exports/vite/index.js +1590 -858
  57. package/src/exports/vite/module_ids.js +2 -2
  58. package/src/exports/vite/preview/index.js +40 -32
  59. package/src/exports/vite/public.d.ts +588 -0
  60. package/src/exports/vite/utils.js +84 -46
  61. package/src/pathname.js +55 -0
  62. package/src/runner.js +15 -0
  63. package/src/runtime/app/env/internal.js +4 -4
  64. package/src/runtime/app/env/types.d.ts +1 -1
  65. package/src/runtime/app/environment/index.js +3 -3
  66. package/src/runtime/app/{forms.js → forms/index.js} +73 -42
  67. package/src/runtime/app/forms/public.d.ts +2 -0
  68. package/src/runtime/app/forms/types.d.ts +56 -0
  69. package/src/runtime/app/internal/transport.js +53 -0
  70. package/src/runtime/app/manifest/index.js +1 -0
  71. package/src/runtime/app/{navigation.js → navigation/index.js} +2 -1
  72. package/src/runtime/app/navigation/public.d.ts +237 -0
  73. package/src/runtime/app/paths/client.js +37 -37
  74. package/src/runtime/app/paths/index.js +1 -1
  75. package/src/runtime/app/paths/internal/client.js +34 -2
  76. package/src/runtime/app/paths/internal/server.js +6 -23
  77. package/src/runtime/app/paths/internal.d.ts +3 -0
  78. package/src/runtime/app/paths/public.d.ts +1 -29
  79. package/src/runtime/app/paths/server.js +36 -17
  80. package/src/runtime/app/paths/types.d.ts +11 -19
  81. package/src/runtime/app/server/index.js +2 -2
  82. package/src/runtime/app/server/public.d.ts +201 -0
  83. package/src/runtime/app/server/remote/command.js +13 -11
  84. package/src/runtime/app/server/remote/form.js +61 -39
  85. package/src/runtime/app/server/remote/prerender.js +45 -45
  86. package/src/runtime/app/server/remote/query.js +106 -108
  87. package/src/runtime/app/server/remote/requested.js +27 -19
  88. package/src/runtime/app/server/remote/shared.js +76 -76
  89. package/src/runtime/app/service-worker/index.js +24 -0
  90. package/src/runtime/app/state/client.js +4 -2
  91. package/src/runtime/app/state/index.js +7 -5
  92. package/src/runtime/app/state/public.d.ts +72 -0
  93. package/src/runtime/app/state/server.js +3 -0
  94. package/src/runtime/app/stores.js +15 -78
  95. package/src/runtime/client/bundle.js +1 -1
  96. package/src/runtime/client/client-entry.js +3 -0
  97. package/src/runtime/client/client.js +1336 -648
  98. package/src/runtime/client/constants.js +3 -6
  99. package/src/runtime/client/entry.js +24 -3
  100. package/src/runtime/client/fetcher.js +25 -25
  101. package/src/runtime/client/ndjson.js +1 -1
  102. package/src/runtime/client/parse.js +1 -1
  103. package/src/runtime/client/payload.js +17 -0
  104. package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
  105. package/src/runtime/client/remote-functions/command.svelte.js +37 -61
  106. package/src/runtime/client/remote-functions/form.svelte.js +267 -178
  107. package/src/runtime/client/remote-functions/prerender.svelte.js +32 -11
  108. package/src/runtime/client/remote-functions/query/index.js +10 -17
  109. package/src/runtime/client/remote-functions/query/instance.svelte.js +64 -18
  110. package/src/runtime/client/remote-functions/query/proxy.js +5 -5
  111. package/src/runtime/client/remote-functions/query-batch.svelte.js +61 -70
  112. package/src/runtime/client/remote-functions/query-live/index.js +1 -1
  113. package/src/runtime/client/remote-functions/query-live/instance.svelte.js +63 -21
  114. package/src/runtime/client/remote-functions/query-live/iterator.js +15 -12
  115. package/src/runtime/client/remote-functions/query-live/proxy.js +2 -12
  116. package/src/runtime/client/remote-functions/shared.svelte.js +90 -65
  117. package/src/runtime/client/snapshots.js +147 -0
  118. package/src/runtime/client/state.svelte.js +94 -55
  119. package/src/runtime/client/stream.js +3 -2
  120. package/src/runtime/client/types.d.ts +13 -9
  121. package/src/runtime/client/utils.js +22 -110
  122. package/src/runtime/components/root.svelte +56 -0
  123. package/src/runtime/env/dynamic/private.js +7 -0
  124. package/src/runtime/env/dynamic/public.js +7 -0
  125. package/src/runtime/env/static/private.js +6 -0
  126. package/src/runtime/env/static/public.js +6 -0
  127. package/src/runtime/form-utils.js +172 -61
  128. package/src/runtime/pathname.js +20 -32
  129. package/src/runtime/props.svelte.js +72 -0
  130. package/src/runtime/server/constants.js +0 -3
  131. package/src/runtime/server/cookie.js +72 -55
  132. package/src/runtime/server/csrf.js +65 -0
  133. package/src/runtime/server/data/index.js +49 -53
  134. package/src/runtime/server/dev.js +22 -0
  135. package/src/runtime/server/endpoint.js +6 -7
  136. package/src/runtime/server/env_module.js +0 -5
  137. package/src/runtime/server/errors.js +160 -0
  138. package/src/runtime/server/fetch.js +32 -39
  139. package/src/runtime/server/index.js +90 -64
  140. package/src/runtime/server/internal.js +71 -0
  141. package/src/runtime/server/page/actions.js +85 -64
  142. package/src/runtime/server/page/crypto.js +2 -2
  143. package/src/runtime/server/page/csp.js +88 -104
  144. package/src/runtime/server/page/data_serializer.js +24 -25
  145. package/src/runtime/server/page/index.js +36 -53
  146. package/src/runtime/server/page/load_data.js +50 -57
  147. package/src/runtime/server/page/render.js +173 -239
  148. package/src/runtime/server/page/respond_with_error.js +17 -31
  149. package/src/runtime/server/page/serialize_data.js +2 -13
  150. package/src/runtime/server/page/server_routing.js +85 -26
  151. package/src/runtime/server/remote-functions.js +640 -0
  152. package/src/runtime/server/respond.js +190 -131
  153. package/src/runtime/server/sourcemaps.js +183 -0
  154. package/src/runtime/server/state.js +53 -0
  155. package/src/runtime/server/utils.js +13 -155
  156. package/src/runtime/shared.js +20 -40
  157. package/src/runtime/utils.js +3 -0
  158. package/src/types/ambient-private.d.ts +11 -1
  159. package/src/types/ambient.d.ts +87 -36
  160. package/src/types/global-private.d.ts +25 -25
  161. package/src/types/internal.d.ts +163 -157
  162. package/src/types/private.d.ts +41 -1
  163. package/src/utils/error.js +28 -4
  164. package/src/utils/escape.js +9 -25
  165. package/src/utils/features.js +1 -1
  166. package/src/utils/filesystem.js +1 -23
  167. package/src/utils/fork.js +7 -2
  168. package/src/utils/hash.js +21 -0
  169. package/src/utils/http.js +8 -7
  170. package/src/utils/import.js +9 -2
  171. package/src/utils/imports.js +83 -0
  172. package/src/utils/mime.js +9 -0
  173. package/src/utils/page_nodes.js +6 -7
  174. package/src/utils/params.js +67 -0
  175. package/src/utils/regex.js +9 -0
  176. package/src/utils/routing.js +145 -73
  177. package/src/utils/shared-iterator.js +5 -0
  178. package/src/utils/streaming.js +14 -4
  179. package/src/utils/url.js +33 -2
  180. package/src/version.js +1 -1
  181. package/types/index.d.ts +2616 -2433
  182. package/types/index.d.ts.map +120 -106
  183. package/src/core/sync/write_ambient.js +0 -18
  184. package/src/core/sync/write_root.js +0 -148
  185. package/src/core/sync/write_tsconfig.js +0 -250
  186. package/src/exports/internal/server.js +0 -22
  187. package/src/exports/node/polyfills.js +0 -30
  188. package/src/runtime/server/app.js +0 -9
  189. package/src/runtime/server/remote.js +0 -457
  190. package/src/runtime/shared-server.js +0 -7
  191. package/src/runtime/telemetry/otel.js +0 -21
  192. package/src/runtime/telemetry/record_span.js +0 -65
  193. package/src/types/synthetic/$lib.md +0 -5
  194. /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
  195. /package/src/{runtime/telemetry/noop.js → telemetry.js} +0 -0
@@ -1,59 +1,98 @@
1
- import { onMount } from 'svelte';
2
- import { updated_listener } from './utils.js';
3
-
4
- /** @type {import('@sveltejs/kit').Page} */
5
- export let page;
6
-
7
- /** @type {{ current: import('@sveltejs/kit').Navigation | null }} */
8
- export let navigating;
9
-
10
- /** @type {{ current: boolean }} */
11
- export let updated;
12
-
13
- // this is a bootleg way to tell if we're in old svelte or new svelte
14
- const is_legacy =
15
- onMount.toString().includes('$$') || /function \w+\(\) \{\}/.test(onMount.toString());
16
-
17
- const placeholder_url = 'a:';
18
-
19
- if (is_legacy) {
20
- page = {
21
- data: {},
22
- form: null,
23
- error: null,
24
- params: {},
25
- route: { id: null },
26
- state: {},
27
- status: -1,
28
- url: new URL(placeholder_url)
29
- };
30
- navigating = { current: null };
31
- updated = { current: false };
32
- } else {
33
- page = new (class Page {
34
- data = $state.raw({});
35
- form = $state.raw(null);
36
- error = $state.raw(null);
37
- params = $state.raw({});
38
- route = $state.raw({ id: null });
39
- state = $state.raw({});
40
- status = $state.raw(-1);
41
- url = $state.raw(new URL(placeholder_url));
42
- })();
43
-
44
- navigating = new (class Navigating {
45
- current = $state.raw(null);
46
- })();
47
-
48
- updated = new (class Updated {
49
- current = $state.raw(false);
50
- })();
51
- updated_listener.v = () => (updated.current = true);
52
- }
1
+ /** @import { Navigation } from '$app/navigation' */
2
+ /** @import { Page } from '$app/state' */
3
+ import { version } from '$app/env';
4
+ import { assets } from '#app/paths';
5
+ import { BROWSER, DEV } from 'esm-env';
6
+
7
+ /** @type {Page} */
8
+ export const page = new (class Page {
9
+ data = $state.raw({});
10
+ form = $state.raw(null);
11
+ error = $state.raw(null);
12
+ params = $state.raw({});
13
+ route = $state.raw({ id: null });
14
+ shallow = $state.raw(null);
15
+ state = $state.raw({});
16
+ status = $state.raw(-1);
17
+ url = $state.raw(new URL('a:'));
18
+ })();
19
+
20
+ export const navigating = new (class Navigating {
21
+ /** @type {Navigation | null} */
22
+ current = $state.raw(null);
23
+ })();
24
+
25
+ export const updated = new (class Updated {
26
+ current = $state.raw(false);
27
+ // eslint-disable-next-line @typescript-eslint/require-await
28
+ check = async () => false;
29
+ })();
53
30
 
54
31
  /**
55
- * @param {import('@sveltejs/kit').Page} new_page
32
+ * Internal: mark `updated.current` as `true` if the given version differs.
33
+ * Called from the server response header path. No-op unless version checks
34
+ * are enabled (assigned below). Not exported on the public `updated` object.
35
+ * @type {(new_version: string | null) => void}
56
36
  */
57
- export function update(new_page) {
58
- Object.assign(page, new_page);
37
+ export let notify_version = () => {};
38
+
39
+ if (!DEV && BROWSER) {
40
+ const interval = __SVELTEKIT_APP_VERSION_POLL_INTERVAL__;
41
+
42
+ /** @type {number | undefined} */
43
+ let timeout;
44
+
45
+ /** @type {Promise<boolean> | undefined} */
46
+ let checking;
47
+
48
+ if (__SVELTEKIT_APP_VERSION_CHECKS_ENABLED__) {
49
+ /**
50
+ * Mark `updated.current` as `true` if the given version differs from the one
51
+ * the app was hydrated with. Called from the server response header path.
52
+ * Does NOT reset the poll timer — unlike `check()`, this is a passive observation
53
+ * from a single server instance's response, not an explicit version check. The
54
+ * poll timer continues on its original schedule as a backstop. This is important
55
+ * for platforms that implement skew protection, where `x-sveltekit-version`
56
+ * may be out of date — in this case we still need to poll for `version.json`.
57
+ * @param {string | null} new_version
58
+ */
59
+ notify_version = (new_version) => {
60
+ if (new_version && new_version !== version) {
61
+ updated.current = true;
62
+ }
63
+ };
64
+ }
65
+
66
+ /** @type {() => Promise<boolean>} */
67
+ updated.check = function check() {
68
+ window.clearTimeout(timeout);
69
+
70
+ if (updated.current) {
71
+ return Promise.resolve(true);
72
+ }
73
+
74
+ return (checking ??= (async () => {
75
+ try {
76
+ const res = await fetch(`${assets}/${__SVELTEKIT_APP_VERSION_FILE__}`, {
77
+ headers: {
78
+ 'cache-control': 'no-cache'
79
+ }
80
+ });
81
+
82
+ if (!res.ok) {
83
+ return false;
84
+ }
85
+
86
+ const data = await res.json();
87
+ return (updated.current ||= data.version !== version);
88
+ } catch {
89
+ return false;
90
+ } finally {
91
+ checking = undefined;
92
+ if (interval && !updated.current) timeout = window.setTimeout(check, interval);
93
+ }
94
+ })());
95
+ };
96
+
97
+ if (interval) timeout = window.setTimeout(updated.check, interval);
59
98
  }
@@ -4,11 +4,12 @@
4
4
  * stream closes.
5
5
  * @param {ReadableStreamDefaultReader<Uint8Array>} reader
6
6
  * @param {string} delimiter
7
+ * @param {TextDecoderOptions} [options]
7
8
  */
8
- export async function* read_stream(reader, delimiter) {
9
+ export async function* read_stream(reader, delimiter, options) {
9
10
  let done = false;
10
11
  let buffer = '';
11
- const decoder = new TextDecoder();
12
+ const decoder = new TextDecoder(undefined, options);
12
13
 
13
14
  while (true) {
14
15
  let split = buffer.indexOf(delimiter);
@@ -1,4 +1,3 @@
1
- import { SvelteComponent } from 'svelte';
2
1
  import {
3
2
  ClientHooks,
4
3
  CSRPageNode,
@@ -9,7 +8,9 @@ import {
9
8
  TrailingSlash,
10
9
  Uses
11
10
  } from 'types';
12
- import { Page, ParamMatcher } from '@sveltejs/kit';
11
+ import { ParamMatcher } from '@sveltejs/kit/params';
12
+ import { Page } from '$app/state';
13
+ import { RenderNode } from '../props.svelte.js';
13
14
 
14
15
  export interface SvelteKitApp {
15
16
  /**
@@ -39,7 +40,7 @@ export interface SvelteKitApp {
39
40
  dictionary: Record<string, [leaf: number, layouts: number[], errors?: number[]]>;
40
41
 
41
42
  /**
42
- * A map of `[matcherName: string]: (..) => boolean`, which is used to match route parameters.
43
+ * A map of `[matcherName: string]: ParamMatcher`, which is used to match and parse route parameters.
43
44
  *
44
45
  * In case of router.resolution=server, this object is empty, as resolution happens on the server.
45
46
  */
@@ -57,7 +58,11 @@ export interface SvelteKitApp {
57
58
  */
58
59
  hash: boolean;
59
60
 
60
- root: typeof SvelteComponent;
61
+ /**
62
+ * Lazily loads the contents of src/error.html, used as a last-resort
63
+ * error page when the root layout's load function throws during client-side rendering.
64
+ */
65
+ get_error_template: () => Promise<(data: { status: number; message: string }) => string>;
61
66
  }
62
67
 
63
68
  export type NavigationIntent = {
@@ -77,6 +82,7 @@ export type NavigationResult = NavigationRedirect | NavigationFinished;
77
82
 
78
83
  export type NavigationRedirect = {
79
84
  type: 'redirect';
85
+ status: number;
80
86
  location: string;
81
87
  };
82
88
 
@@ -84,13 +90,10 @@ export type NavigationFinished = {
84
90
  type: 'loaded';
85
91
  state: NavigationState;
86
92
  props: {
87
- constructors: Array<typeof SvelteComponent>;
88
- errors?: Array<typeof SvelteComponent | undefined>;
89
- components?: SvelteComponent[];
90
93
  page: Page;
91
94
  form?: Record<string, any> | null;
92
95
  error?: App.Error;
93
- [key: `data_${number}`]: Record<string, any>;
96
+ tree: RenderNode;
94
97
  };
95
98
  };
96
99
 
@@ -119,7 +122,8 @@ export interface NavigationState {
119
122
  }
120
123
 
121
124
  export interface HydrateOptions {
122
- status: number;
125
+ /** Provided in the case of a form action that returns `fail`, but otherwise derived from `error` */
126
+ status?: number;
123
127
  error: App.Error | null;
124
128
  node_ids: number[];
125
129
  params: Record<string, string>;
@@ -1,12 +1,6 @@
1
1
  import { BROWSER, DEV } from 'esm-env';
2
- import { writable } from 'svelte/store';
3
- import { assets } from '$app/paths';
4
- import { version } from '$app/env';
5
- import { noop } from '../../utils/functions.js';
6
2
  import { PRELOAD_PRIORITIES } from './constants.js';
7
3
 
8
- /* global __SVELTEKIT_APP_VERSION_FILE__, __SVELTEKIT_APP_VERSION_POLL_INTERVAL__ */
9
-
10
4
  export const origin = BROWSER ? location.origin : '';
11
5
 
12
6
  /** @param {string | URL} url */
@@ -37,10 +31,9 @@ const warned = new WeakSet();
37
31
  const valid_link_options = /** @type {const} */ ({
38
32
  'preload-code': ['', 'false', 'tap', 'hover', 'viewport', 'eager'],
39
33
  'preload-data': ['', 'false', 'tap', 'hover'],
40
- keepfocus: ['', 'true', 'false'],
41
- noscroll: ['', 'true', 'false'],
42
34
  reload: ['', 'true', 'false'],
43
- replacestate: ['', 'true', 'false']
35
+ replacestate: ['', 'true', 'false'],
36
+ reset: ['', 'true', 'false']
44
37
  });
45
38
 
46
39
  /**
@@ -129,6 +122,7 @@ export function get_link_info(a, base, uses_hash_router) {
129
122
  /** @type {URL | undefined} */
130
123
  let url;
131
124
 
125
+ // TODO replace the try/catch with `URL.parse` when browser support allows (Chrome 126, Firefox 126, Safari 18)
132
126
  try {
133
127
  url = new URL(a instanceof SVGAElement ? a.href.baseVal : a.href, document.baseURI);
134
128
 
@@ -156,12 +150,6 @@ export function get_link_info(a, base, uses_hash_router) {
156
150
  * @param {HTMLFormElement | HTMLAnchorElement | SVGAElement} element
157
151
  */
158
152
  export function get_router_options(element) {
159
- /** @type {ValidLinkOptions<'keepfocus'> | null} */
160
- let keepfocus = null;
161
-
162
- /** @type {ValidLinkOptions<'noscroll'> | null} */
163
- let noscroll = null;
164
-
165
153
  /** @type {ValidLinkOptions<'preload-code'> | null} */
166
154
  let preload_code = null;
167
155
 
@@ -174,16 +162,31 @@ export function get_router_options(element) {
174
162
  /** @type {ValidLinkOptions<'replacestate'> | null} */
175
163
  let replace_state = null;
176
164
 
165
+ /** @type {ValidLinkOptions<'reset'> | null} */
166
+ let reset = null;
167
+
177
168
  /** @type {Element} */
178
169
  let el = element;
179
170
 
180
171
  while (el && el !== document.documentElement) {
172
+ if (DEV) {
173
+ for (const name of ['keepfocus', 'noscroll']) {
174
+ const value = el.getAttribute(`data-sveltekit-${name}`);
175
+ if (value !== null && !warned.has(el)) {
176
+ warned.add(el);
177
+ console.warn(
178
+ `\`data-sveltekit-${name}="true"\` has been replaced with \`data-sveltekit-reset="false"\``
179
+ );
180
+ console.log(el);
181
+ }
182
+ }
183
+ }
184
+
181
185
  if (preload_code === null) preload_code = link_option(el, 'preload-code');
182
186
  if (preload_data === null) preload_data = link_option(el, 'preload-data');
183
- if (keepfocus === null) keepfocus = link_option(el, 'keepfocus');
184
- if (noscroll === null) noscroll = link_option(el, 'noscroll');
185
187
  if (reload === null) reload = link_option(el, 'reload');
186
188
  if (replace_state === null) replace_state = link_option(el, 'replacestate');
189
+ if (reset === null) reset = link_option(el, 'reset');
187
190
 
188
191
  el = /** @type {Element} */ (parent_element(el));
189
192
  }
@@ -204,100 +207,9 @@ export function get_router_options(element) {
204
207
  return {
205
208
  preload_code: levels[preload_code ?? 'false'],
206
209
  preload_data: levels[preload_data ?? 'false'],
207
- keepfocus: get_option_state(keepfocus),
208
- noscroll: get_option_state(noscroll),
209
210
  reload: get_option_state(reload),
210
- replace_state: get_option_state(replace_state)
211
- };
212
- }
213
-
214
- /** @param {any} value */
215
- export function notifiable_store(value) {
216
- const store = writable(value);
217
- let ready = true;
218
-
219
- function notify() {
220
- ready = true;
221
- store.update((val) => val);
222
- }
223
-
224
- /** @param {any} new_value */
225
- function set(new_value) {
226
- ready = false;
227
- store.set(new_value);
228
- }
229
-
230
- /** @param {(value: any) => void} run */
231
- function subscribe(run) {
232
- /** @type {any} */
233
- let old_value;
234
- return store.subscribe((new_value) => {
235
- if (old_value === undefined || (ready && new_value !== old_value)) {
236
- run((old_value = new_value));
237
- }
238
- });
239
- }
240
-
241
- return { notify, set, subscribe };
242
- }
243
-
244
- export const updated_listener = {
245
- v: noop
246
- };
247
-
248
- export function create_updated_store() {
249
- const { set, subscribe } = writable(false);
250
-
251
- if (__SVELTEKIT_DEV__ || !BROWSER) {
252
- return {
253
- subscribe,
254
- // eslint-disable-next-line @typescript-eslint/require-await
255
- check: async () => false
256
- };
257
- }
258
-
259
- const interval = __SVELTEKIT_APP_VERSION_POLL_INTERVAL__;
260
-
261
- /** @type {NodeJS.Timeout} */
262
- let timeout;
263
-
264
- /** @type {() => Promise<boolean>} */
265
- async function check() {
266
- clearTimeout(timeout);
267
-
268
- if (interval) timeout = setTimeout(check, interval);
269
-
270
- try {
271
- const res = await fetch(`${assets}/${__SVELTEKIT_APP_VERSION_FILE__}`, {
272
- headers: {
273
- 'cache-control': 'no-cache'
274
- }
275
- });
276
-
277
- if (!res.ok) {
278
- return false;
279
- }
280
-
281
- const data = await res.json();
282
- const updated = data.version !== version;
283
-
284
- if (updated) {
285
- set(true);
286
- updated_listener.v();
287
- clearTimeout(timeout);
288
- }
289
-
290
- return updated;
291
- } catch {
292
- return false;
293
- }
294
- }
295
-
296
- if (interval) timeout = setTimeout(check, interval);
297
-
298
- return {
299
- subscribe,
300
- check
211
+ replace_state: get_option_state(replace_state),
212
+ reset: get_option_state(reset) ?? true
301
213
  };
302
214
  }
303
215
 
@@ -0,0 +1,56 @@
1
+ <script lang="ts">
2
+ import { afterNavigate } from '$app/navigation';
3
+ import type { Props, RenderNode } from '../props.svelte.js';
4
+
5
+ const { page, components, onerror, tree, form, error }: Props = $props();
6
+
7
+ let mounted = $state(false);
8
+ let navigated = $state(false);
9
+ let title = $state('');
10
+
11
+ afterNavigate(() => {
12
+ if (mounted) {
13
+ navigated = true;
14
+ title = document.title || 'untitled page';
15
+ } else {
16
+ mounted = true;
17
+ }
18
+ });
19
+ </script>
20
+
21
+ {#snippet node(n: RenderNode, depth: number)}
22
+ {const Component = $derived(n.component)}
23
+ {const Error = $derived(n.error)}
24
+ {const data = $derived(n.data)}
25
+
26
+ <svelte:boundary {onerror}>
27
+ {#if n.child}
28
+ <!-- svelte-ignore binding_property_non_reactive -->
29
+ <Component bind:this={components[depth]} {data} {form} params={page.params}>
30
+ {@render node(n.child, depth + 1)}
31
+ </Component>
32
+ {:else}
33
+ <!-- svelte-ignore binding_property_non_reactive -->
34
+ <Component bind:this={components[depth]} {data} {form} params={page.params} {error} />
35
+ {/if}
36
+
37
+ {#snippet failed(error: unknown)}
38
+ <Error {error} />
39
+ {/snippet}
40
+ </svelte:boundary>
41
+ {/snippet}
42
+
43
+ {@render node(tree, 0)}
44
+
45
+ {#if mounted}
46
+ <div
47
+ id="svelte-announcer"
48
+ aria-live="assertive"
49
+ aria-atomic="true"
50
+ 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"
51
+ >
52
+ {#if navigated}
53
+ {title}
54
+ {/if}
55
+ </div>
56
+ {/if}
@@ -0,0 +1,7 @@
1
+ import { DEV } from 'esm-env';
2
+ import * as env from '../../app/env/private.js';
3
+ export { env };
4
+
5
+ if (DEV) {
6
+ console.warn('`$env/dynamic/private` is deprecated, use `$app/env/private` instead');
7
+ }
@@ -0,0 +1,7 @@
1
+ import { DEV } from 'esm-env';
2
+ import * as env from '../../app/env/public/index.js';
3
+ export { env };
4
+
5
+ if (DEV) {
6
+ console.warn('`$env/dynamic/public` is deprecated, use `$app/env/public` instead');
7
+ }
@@ -0,0 +1,6 @@
1
+ import { DEV } from 'esm-env';
2
+ export * from '../../app/env/private.js';
3
+
4
+ if (DEV) {
5
+ console.warn('`$env/static/private` is deprecated, use `$app/env/private` instead');
6
+ }
@@ -0,0 +1,6 @@
1
+ import { DEV } from 'esm-env';
2
+ export * from '../../app/env/public/index.js';
3
+
4
+ if (DEV) {
5
+ console.warn('`$env/static/public` is deprecated, use `$app/env/public` instead');
6
+ }