@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.
- package/package.json +62 -36
- package/src/cli.js +15 -12
- package/src/constants.js +6 -1
- package/src/core/adapt/builder.js +66 -72
- package/src/core/adapt/index.js +17 -6
- package/src/core/config/index.js +134 -80
- package/src/core/config/options.js +295 -273
- package/src/core/config/types.d.ts +1 -1
- package/src/core/env.js +146 -16
- package/src/core/generate_manifest/index.js +18 -15
- package/src/core/postbuild/analyse.js +8 -20
- package/src/core/postbuild/crawl.js +22 -6
- package/src/core/postbuild/entities.js +8 -2
- package/src/core/postbuild/fallback.js +4 -2
- package/src/core/postbuild/prerender.js +222 -70
- package/src/core/postbuild/queue.js +2 -1
- package/src/core/sync/create_manifest_data/conflict.js +1 -1
- package/src/core/sync/create_manifest_data/index.js +82 -62
- package/src/core/sync/sync.js +40 -31
- package/src/core/sync/ts.js +1 -1
- package/src/core/sync/utils.js +22 -2
- package/src/core/sync/{write_non_ambient.js → write_app_types.js} +107 -58
- package/src/core/sync/write_client_manifest.js +14 -29
- package/src/core/sync/write_env.js +7 -5
- package/src/core/sync/write_server.js +37 -45
- package/src/core/sync/write_tsconfig/index.js +274 -0
- package/src/core/sync/write_tsconfig/test-app/package.json +7 -0
- package/src/core/sync/write_tsconfig/utils.js +77 -0
- package/src/core/sync/write_tsconfig/validate.js +128 -0
- package/src/core/sync/write_types/index.js +127 -123
- package/src/core/utils.js +30 -5
- package/src/exports/env/index.js +77 -0
- package/src/exports/env/public.d.ts +55 -0
- package/src/exports/hooks/index.js +3 -9
- package/src/exports/hooks/public.d.ts +195 -0
- package/src/exports/hooks/sequence.js +9 -6
- package/src/exports/index.js +52 -29
- package/src/exports/internal/client.js +5 -0
- package/src/exports/internal/env.js +8 -5
- package/src/exports/internal/index.js +1 -90
- package/src/exports/internal/{event.js → server/event.js} +2 -3
- package/src/exports/internal/server/index.js +37 -0
- package/src/exports/internal/server/telemetry.js +95 -0
- package/src/exports/internal/shared.js +90 -0
- package/src/exports/node/index.js +64 -22
- package/src/exports/params/index.js +70 -0
- package/src/exports/params/public.d.ts +63 -0
- package/src/exports/public.d.ts +50 -1733
- package/src/exports/remote/index.js +11 -0
- package/src/exports/remote/public.d.ts +519 -0
- package/src/exports/url.js +86 -0
- package/src/exports/vite/build/build_server.js +54 -65
- package/src/exports/vite/build/remote.js +24 -19
- package/src/exports/vite/build/utils.js +0 -8
- package/src/exports/vite/dev/index.js +218 -146
- package/src/exports/vite/index.js +1590 -858
- package/src/exports/vite/module_ids.js +2 -2
- package/src/exports/vite/preview/index.js +40 -32
- package/src/exports/vite/public.d.ts +588 -0
- package/src/exports/vite/utils.js +84 -46
- package/src/pathname.js +55 -0
- package/src/runner.js +15 -0
- package/src/runtime/app/env/internal.js +4 -4
- package/src/runtime/app/env/types.d.ts +1 -1
- package/src/runtime/app/environment/index.js +3 -3
- package/src/runtime/app/{forms.js → forms/index.js} +73 -42
- package/src/runtime/app/forms/public.d.ts +2 -0
- package/src/runtime/app/forms/types.d.ts +56 -0
- package/src/runtime/app/internal/transport.js +53 -0
- package/src/runtime/app/manifest/index.js +1 -0
- package/src/runtime/app/{navigation.js → navigation/index.js} +2 -1
- package/src/runtime/app/navigation/public.d.ts +237 -0
- package/src/runtime/app/paths/client.js +37 -37
- package/src/runtime/app/paths/index.js +1 -1
- package/src/runtime/app/paths/internal/client.js +34 -2
- package/src/runtime/app/paths/internal/server.js +6 -23
- package/src/runtime/app/paths/internal.d.ts +3 -0
- package/src/runtime/app/paths/public.d.ts +1 -29
- package/src/runtime/app/paths/server.js +36 -17
- package/src/runtime/app/paths/types.d.ts +11 -19
- package/src/runtime/app/server/index.js +2 -2
- package/src/runtime/app/server/public.d.ts +201 -0
- package/src/runtime/app/server/remote/command.js +13 -11
- package/src/runtime/app/server/remote/form.js +61 -39
- package/src/runtime/app/server/remote/prerender.js +45 -45
- package/src/runtime/app/server/remote/query.js +106 -108
- package/src/runtime/app/server/remote/requested.js +27 -19
- package/src/runtime/app/server/remote/shared.js +76 -76
- package/src/runtime/app/service-worker/index.js +24 -0
- package/src/runtime/app/state/client.js +4 -2
- package/src/runtime/app/state/index.js +7 -5
- package/src/runtime/app/state/public.d.ts +72 -0
- package/src/runtime/app/state/server.js +3 -0
- package/src/runtime/app/stores.js +15 -78
- package/src/runtime/client/bundle.js +1 -1
- package/src/runtime/client/client-entry.js +3 -0
- package/src/runtime/client/client.js +1336 -648
- package/src/runtime/client/constants.js +3 -6
- package/src/runtime/client/entry.js +24 -3
- package/src/runtime/client/fetcher.js +25 -25
- package/src/runtime/client/ndjson.js +1 -1
- package/src/runtime/client/parse.js +1 -1
- package/src/runtime/client/payload.js +17 -0
- package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
- package/src/runtime/client/remote-functions/command.svelte.js +37 -61
- package/src/runtime/client/remote-functions/form.svelte.js +267 -178
- package/src/runtime/client/remote-functions/prerender.svelte.js +32 -11
- package/src/runtime/client/remote-functions/query/index.js +10 -17
- package/src/runtime/client/remote-functions/query/instance.svelte.js +64 -18
- package/src/runtime/client/remote-functions/query/proxy.js +5 -5
- package/src/runtime/client/remote-functions/query-batch.svelte.js +61 -70
- package/src/runtime/client/remote-functions/query-live/index.js +1 -1
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +63 -21
- package/src/runtime/client/remote-functions/query-live/iterator.js +15 -12
- package/src/runtime/client/remote-functions/query-live/proxy.js +2 -12
- package/src/runtime/client/remote-functions/shared.svelte.js +90 -65
- package/src/runtime/client/snapshots.js +147 -0
- package/src/runtime/client/state.svelte.js +94 -55
- package/src/runtime/client/stream.js +3 -2
- package/src/runtime/client/types.d.ts +13 -9
- package/src/runtime/client/utils.js +22 -110
- package/src/runtime/components/root.svelte +56 -0
- package/src/runtime/env/dynamic/private.js +7 -0
- package/src/runtime/env/dynamic/public.js +7 -0
- package/src/runtime/env/static/private.js +6 -0
- package/src/runtime/env/static/public.js +6 -0
- package/src/runtime/form-utils.js +172 -61
- package/src/runtime/pathname.js +20 -32
- package/src/runtime/props.svelte.js +72 -0
- package/src/runtime/server/constants.js +0 -3
- package/src/runtime/server/cookie.js +72 -55
- package/src/runtime/server/csrf.js +65 -0
- package/src/runtime/server/data/index.js +49 -53
- package/src/runtime/server/dev.js +22 -0
- package/src/runtime/server/endpoint.js +6 -7
- package/src/runtime/server/env_module.js +0 -5
- package/src/runtime/server/errors.js +160 -0
- package/src/runtime/server/fetch.js +32 -39
- package/src/runtime/server/index.js +90 -64
- package/src/runtime/server/internal.js +71 -0
- package/src/runtime/server/page/actions.js +85 -64
- package/src/runtime/server/page/crypto.js +2 -2
- package/src/runtime/server/page/csp.js +88 -104
- package/src/runtime/server/page/data_serializer.js +24 -25
- package/src/runtime/server/page/index.js +36 -53
- package/src/runtime/server/page/load_data.js +50 -57
- package/src/runtime/server/page/render.js +173 -239
- package/src/runtime/server/page/respond_with_error.js +17 -31
- package/src/runtime/server/page/serialize_data.js +2 -13
- package/src/runtime/server/page/server_routing.js +85 -26
- package/src/runtime/server/remote-functions.js +640 -0
- package/src/runtime/server/respond.js +190 -131
- package/src/runtime/server/sourcemaps.js +183 -0
- package/src/runtime/server/state.js +53 -0
- package/src/runtime/server/utils.js +13 -155
- package/src/runtime/shared.js +20 -40
- package/src/runtime/utils.js +3 -0
- package/src/types/ambient-private.d.ts +11 -1
- package/src/types/ambient.d.ts +87 -36
- package/src/types/global-private.d.ts +25 -25
- package/src/types/internal.d.ts +163 -157
- package/src/types/private.d.ts +41 -1
- package/src/utils/error.js +28 -4
- package/src/utils/escape.js +9 -25
- package/src/utils/features.js +1 -1
- package/src/utils/filesystem.js +1 -23
- package/src/utils/fork.js +7 -2
- package/src/utils/hash.js +21 -0
- package/src/utils/http.js +8 -7
- package/src/utils/import.js +9 -2
- package/src/utils/imports.js +83 -0
- package/src/utils/mime.js +9 -0
- package/src/utils/page_nodes.js +6 -7
- package/src/utils/params.js +67 -0
- package/src/utils/regex.js +9 -0
- package/src/utils/routing.js +145 -73
- package/src/utils/shared-iterator.js +5 -0
- package/src/utils/streaming.js +14 -4
- package/src/utils/url.js +33 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +2616 -2433
- package/types/index.d.ts.map +120 -106
- package/src/core/sync/write_ambient.js +0 -18
- package/src/core/sync/write_root.js +0 -148
- package/src/core/sync/write_tsconfig.js +0 -250
- package/src/exports/internal/server.js +0 -22
- package/src/exports/node/polyfills.js +0 -30
- package/src/runtime/server/app.js +0 -9
- package/src/runtime/server/remote.js +0 -457
- package/src/runtime/shared-server.js +0 -7
- package/src/runtime/telemetry/otel.js +0 -21
- package/src/runtime/telemetry/record_span.js +0 -65
- package/src/types/synthetic/$lib.md +0 -5
- /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
- /package/src/{runtime/telemetry/noop.js → telemetry.js} +0 -0
|
@@ -1,59 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** @type {
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
*
|
|
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
|
|
58
|
-
|
|
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 {
|
|
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]:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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}
|