sveltekit-ui 1.1.71 → 1.1.73
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/.vercel/output/config.json +64 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/Checkbox.js +285 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/client.js +1609 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/client2.js +5320 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/docs.js +26418 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/env.js +8 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/exports.js +371 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/index.svelte.js +869 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/index2.svelte.js +220 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/index3.svelte.js +914 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/index4.svelte.js +2035 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/internal.js +823 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/internal2.js +34 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/server.js +4203 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/shared.js +298 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/state.js +76 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/utils.js +903 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/endpoints/sitemap.xml/_server.js +223 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/fallbacks/error.svelte.js +10 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/hooks.server.js +7 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/pages/_layout.js +8 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/pages/_layout.svelte.js +826 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/pages/_page.svelte.js +345 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/pages/components/_component_/_page.svelte.js +9431 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/pages/test/_page.svelte.js +50 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/pages/test2/_page.svelte.js +10909 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/pages/test3/_page.server.js +9466 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/entries/pages/test3/_page.svelte.js +99 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/index.js +3515 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/nodes/0.js +10 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/nodes/1.js +8 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/nodes/2.js +8 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/nodes/3.js +8 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/nodes/4.js +8 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/nodes/5.js +8 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/nodes/6.js +10 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/vercel-tmp/index.js +42 -0
- package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/vercel-tmp/manifest.js +78 -0
- package/.vercel/output/functions/![-]/catchall.func/.vc-config.json +11 -0
- package/.vercel/output/functions/![-]/catchall.func/package.json +1 -0
- package/.vercel/output/static/_app/immutable/assets/0.D1AvWWSC.css +1 -0
- package/.vercel/output/static/_app/immutable/assets/2.D3o4PLbP.css +1 -0
- package/.vercel/output/static/_app/immutable/assets/3.DK3uvf0v.css +1 -0
- package/.vercel/output/static/_app/immutable/assets/6.BnjxUmH7.css +1 -0
- package/.vercel/output/static/_app/immutable/assets/Checkbox.CJEZNdbe.css +1 -0
- package/.vercel/output/static/_app/immutable/assets/alloy-voice-sample.PT8wH6s9.mp3 +0 -0
- package/.vercel/output/static/_app/immutable/assets/docs.CDTCxDP7.css +1 -0
- package/.vercel/output/static/_app/immutable/assets/echo-voice-sample.pUPbplSr.mp3 +0 -0
- package/.vercel/output/static/_app/immutable/assets/fable-voice-sample.DLFL6517.mp3 +0 -0
- package/.vercel/output/static/_app/immutable/assets/index.CCk09GbO.css +1 -0
- package/.vercel/output/static/_app/immutable/assets/index.CYJKF3O7.css +1 -0
- package/.vercel/output/static/_app/immutable/assets/index.DCBl_q1O.css +1 -0
- package/.vercel/output/static/_app/immutable/assets/index.DatXVBdh.css +1 -0
- package/.vercel/output/static/_app/immutable/assets/nova-voice-sample.DWaD-VGb.mp3 +0 -0
- package/.vercel/output/static/_app/immutable/assets/onyx-voice-sample.DMRXZHJF.mp3 +0 -0
- package/.vercel/output/static/_app/immutable/assets/shimmer-voice-sample.Cho2QgFr.mp3 +0 -0
- package/.vercel/output/static/_app/immutable/chunks/BLfjN0VF.js +1 -0
- package/.vercel/output/static/_app/immutable/chunks/BddFMzPD.js +1 -0
- package/.vercel/output/static/_app/immutable/chunks/Bjy-W4x2.js +81 -0
- package/.vercel/output/static/_app/immutable/chunks/BqBxxYmA.js +14 -0
- package/.vercel/output/static/_app/immutable/chunks/CJM4yLow.js +25 -0
- package/.vercel/output/static/_app/immutable/chunks/CRYWmS0s.js +19 -0
- package/.vercel/output/static/_app/immutable/chunks/CZIC9Qgj.js +11 -0
- package/.vercel/output/static/_app/immutable/chunks/CvmT24cS.js +3 -0
- package/.vercel/output/static/_app/immutable/chunks/D566uQC1.js +2 -0
- package/.vercel/output/static/_app/immutable/chunks/SvbogVTv.js +119 -0
- package/.vercel/output/static/_app/immutable/chunks/_g5tLpFU.js +3 -0
- package/.vercel/output/static/_app/immutable/chunks/u3U-vofW.js +15 -0
- package/.vercel/output/static/_app/immutable/chunks/xihTtKlq.js +1 -0
- package/.vercel/output/static/_app/immutable/entry/app.td6ThZ7k.js +2 -0
- package/.vercel/output/static/_app/immutable/entry/start.2Q3_BAwG.js +1 -0
- package/.vercel/output/static/_app/immutable/nodes/0.C2Ckbl4e.js +8 -0
- package/.vercel/output/static/_app/immutable/nodes/1.DLziSd8k.js +1 -0
- package/.vercel/output/static/_app/immutable/nodes/2.BX7tnCWG.js +58 -0
- package/.vercel/output/static/_app/immutable/nodes/3.CEpCPaPY.js +22 -0
- package/.vercel/output/static/_app/immutable/nodes/4.Ux2eRH04.js +1 -0
- package/.vercel/output/static/_app/immutable/nodes/5.Cv9G2Xkm.js +1 -0
- package/.vercel/output/static/_app/immutable/nodes/6.DcYd4Shl.js +1 -0
- package/.vercel/output/static/_app/version.json +1 -0
- package/.vercel/output/static/android-chrome-192x192.png +0 -0
- package/.vercel/output/static/android-chrome-512x512.png +0 -0
- package/.vercel/output/static/apple-touch-icon.png +0 -0
- package/.vercel/output/static/favicon-inactive.svg +4 -0
- package/.vercel/output/static/favicon-themed.svg +11 -0
- package/.vercel/output/static/favicon-transparent-bg.webp +0 -0
- package/.vercel/output/static/favicon-transparent.webp +0 -0
- package/.vercel/output/static/favicon.png +0 -0
- package/.vercel/output/static/favicon.svg +3 -0
- package/.vercel/output/static/favicon.webp +0 -0
- package/.vercel/output/static/fonts/ProximaVara.woff2 +0 -0
- package/.vercel/output/static/fonts/Quicksand-VariableFont.woff2 +0 -0
- package/.vercel/output/static/fonts/RobotoSerif-VariableFont.woff2 +0 -0
- package/.vercel/output/static/full_logo.webp +0 -0
- package/.vercel/output/static/icon.png +0 -0
- package/.vercel/output/static/site.webmanifest +21 -0
- package/.vercel/output/static/thumbnail.png +0 -0
- package/.vercel/output/static/thumbnail.webp +0 -0
- package/package.json +4 -4
package/.vercel/output/functions/![-]/catchall.func/.svelte-kit/output/server/chunks/client.js
ADDED
|
@@ -0,0 +1,1609 @@
|
|
|
1
|
+
import { a as settled, o as tick$1, r as index_server_exports } from "./internal.js";
|
|
2
|
+
import { d as get_message, f as get_status, m as base64_decode, n as TRAILING_SLASH_PARAM, r as create_remote_key, t as INVALIDATED_PARAM, v as noop } from "./shared.js";
|
|
3
|
+
import { s as base } from "./internal2.js";
|
|
4
|
+
import { S as compact, f as make_trackable, g as add_data_suffix, h as noop_span, l as decode_params, p as normalize_path, s as hash, u as decode_pathname } from "./exports.js";
|
|
5
|
+
import { E as writable, ht as noop$1 } from "./server.js";
|
|
6
|
+
import { HttpError, Redirect, SvelteKitError } from "@sveltejs/kit/internal";
|
|
7
|
+
import "@sveltejs/kit/internal/server";
|
|
8
|
+
import * as devalue from "devalue";
|
|
9
|
+
var cache = /* @__PURE__ */ new Map();
|
|
10
|
+
/**
|
|
11
|
+
* Should be called on the initial run of load functions that hydrate the page.
|
|
12
|
+
* Saves any requests with cache-control max-age to the cache.
|
|
13
|
+
* @param {URL | string} resource
|
|
14
|
+
* @param {RequestInit} [opts]
|
|
15
|
+
*/
|
|
16
|
+
function initial_fetch(resource, opts) {
|
|
17
|
+
const selector = build_selector(resource, opts);
|
|
18
|
+
const script = document.querySelector(selector);
|
|
19
|
+
if (script?.textContent) {
|
|
20
|
+
script.remove();
|
|
21
|
+
let { body, ...init } = JSON.parse(script.textContent);
|
|
22
|
+
if (script.getAttribute("data-b64") !== null) body = base64_decode(body);
|
|
23
|
+
const ttl = script.getAttribute("data-ttl");
|
|
24
|
+
if (ttl) cache.set(selector, {
|
|
25
|
+
body,
|
|
26
|
+
init,
|
|
27
|
+
ttl: 1e3 * Number(ttl)
|
|
28
|
+
});
|
|
29
|
+
return Promise.resolve(new Response(body, init));
|
|
30
|
+
}
|
|
31
|
+
return window.fetch(resource, opts);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Tries to get the response from the cache, if max-age allows it, else does a fetch.
|
|
35
|
+
* @param {URL | string} resource
|
|
36
|
+
* @param {string} resolved
|
|
37
|
+
* @param {RequestInit} [opts]
|
|
38
|
+
*/
|
|
39
|
+
function subsequent_fetch(resource, resolved, opts) {
|
|
40
|
+
if (cache.size > 0) {
|
|
41
|
+
const selector = build_selector(resource, opts);
|
|
42
|
+
const cached = cache.get(selector);
|
|
43
|
+
if (cached) {
|
|
44
|
+
if (performance.now() < cached.ttl && [
|
|
45
|
+
"default",
|
|
46
|
+
"force-cache",
|
|
47
|
+
"only-if-cached",
|
|
48
|
+
void 0
|
|
49
|
+
].includes(opts?.cache)) return new Response(cached.body, cached.init);
|
|
50
|
+
cache.delete(selector);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return window.fetch(resolved, opts);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build the cache key for a given request
|
|
57
|
+
* @param {URL | RequestInfo} resource
|
|
58
|
+
* @param {RequestInit} [opts]
|
|
59
|
+
*/
|
|
60
|
+
function build_selector(resource, opts) {
|
|
61
|
+
let selector = `script[data-sveltekit-fetched][data-url=${JSON.stringify(resource instanceof Request ? resource.url : resource)}]`;
|
|
62
|
+
if (opts?.headers || opts?.body) {
|
|
63
|
+
/** @type {import('types').StrictBody[]} */
|
|
64
|
+
const values = [];
|
|
65
|
+
if (opts.headers) values.push([...new Headers(opts.headers)].join(","));
|
|
66
|
+
if (opts.body && (typeof opts.body === "string" || ArrayBuffer.isView(opts.body))) values.push(opts.body);
|
|
67
|
+
selector += `[data-hash="${hash(...values)}"]`;
|
|
68
|
+
}
|
|
69
|
+
return selector;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region node_modules/@sveltejs/kit/src/runtime/client/session-storage.js
|
|
73
|
+
/**
|
|
74
|
+
* Read a value from `sessionStorage`
|
|
75
|
+
* @param {string} key
|
|
76
|
+
* @param {(value: string) => any} parse
|
|
77
|
+
*/
|
|
78
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
79
|
+
function get(key, parse = JSON.parse) {
|
|
80
|
+
try {
|
|
81
|
+
return parse(sessionStorage[key]);
|
|
82
|
+
} catch {}
|
|
83
|
+
}
|
|
84
|
+
var STATES_KEY = "sveltekit:states";
|
|
85
|
+
var HISTORY_INDEX = "sveltekit:history";
|
|
86
|
+
var NAVIGATION_INDEX = "sveltekit:navigation";
|
|
87
|
+
var PRELOAD_PRIORITIES = {
|
|
88
|
+
tap: 1,
|
|
89
|
+
hover: 2,
|
|
90
|
+
viewport: 3,
|
|
91
|
+
eager: 4,
|
|
92
|
+
off: -1,
|
|
93
|
+
false: -1
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region node_modules/@sveltejs/kit/src/runtime/client/utils.js
|
|
97
|
+
var origin = "";
|
|
98
|
+
/** @param {string | URL} url */
|
|
99
|
+
function resolve_url(url) {
|
|
100
|
+
if (url instanceof URL) return url;
|
|
101
|
+
let baseURI = document.baseURI;
|
|
102
|
+
if (!baseURI) {
|
|
103
|
+
const baseTags = document.getElementsByTagName("base");
|
|
104
|
+
baseURI = baseTags.length ? baseTags[0].href : document.URL;
|
|
105
|
+
}
|
|
106
|
+
return new URL(url, baseURI);
|
|
107
|
+
}
|
|
108
|
+
function scroll_state() {
|
|
109
|
+
return {
|
|
110
|
+
x: pageXOffset,
|
|
111
|
+
y: pageYOffset
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
({ ...PRELOAD_PRIORITIES }), PRELOAD_PRIORITIES.hover;
|
|
115
|
+
/** @param {any} value */
|
|
116
|
+
function notifiable_store(value) {
|
|
117
|
+
const store = writable(value);
|
|
118
|
+
let ready = true;
|
|
119
|
+
function notify() {
|
|
120
|
+
ready = true;
|
|
121
|
+
store.update((val) => val);
|
|
122
|
+
}
|
|
123
|
+
/** @param {any} new_value */
|
|
124
|
+
function set(new_value) {
|
|
125
|
+
ready = false;
|
|
126
|
+
store.set(new_value);
|
|
127
|
+
}
|
|
128
|
+
/** @param {(value: any) => void} run */
|
|
129
|
+
function subscribe(run) {
|
|
130
|
+
/** @type {any} */
|
|
131
|
+
let old_value;
|
|
132
|
+
return store.subscribe((new_value) => {
|
|
133
|
+
if (old_value === void 0 || ready && new_value !== old_value) run(old_value = new_value);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
notify,
|
|
138
|
+
set,
|
|
139
|
+
subscribe
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
var updated_listener = { v: noop };
|
|
143
|
+
function create_updated_store() {
|
|
144
|
+
const { set, subscribe } = writable(false);
|
|
145
|
+
return {
|
|
146
|
+
subscribe,
|
|
147
|
+
check: async () => false
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Is external if
|
|
152
|
+
* - origin different
|
|
153
|
+
* - path doesn't start with base
|
|
154
|
+
* - uses hash router and pathname is more than base
|
|
155
|
+
* @param {URL} url
|
|
156
|
+
* @param {string} base
|
|
157
|
+
* @param {boolean} hash_routing
|
|
158
|
+
*/
|
|
159
|
+
function is_external_url(url, base, hash_routing) {
|
|
160
|
+
if (url.origin !== origin || !url.pathname.startsWith(base)) return true;
|
|
161
|
+
if (hash_routing) return url.pathname !== location.pathname;
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region node_modules/@sveltejs/kit/src/runtime/client/state.svelte.js
|
|
166
|
+
var page;
|
|
167
|
+
var navigating;
|
|
168
|
+
var updated;
|
|
169
|
+
var is_legacy = noop$1.toString().includes("$$") || /function \w+\(\) \{\}/.test(noop$1.toString());
|
|
170
|
+
var placeholder_url = "a:";
|
|
171
|
+
if (is_legacy) {
|
|
172
|
+
page = {
|
|
173
|
+
data: {},
|
|
174
|
+
form: null,
|
|
175
|
+
error: null,
|
|
176
|
+
params: {},
|
|
177
|
+
route: { id: null },
|
|
178
|
+
state: {},
|
|
179
|
+
status: -1,
|
|
180
|
+
url: new URL(placeholder_url)
|
|
181
|
+
};
|
|
182
|
+
navigating = { current: null };
|
|
183
|
+
updated = { current: false };
|
|
184
|
+
} else {
|
|
185
|
+
page = new class Page {
|
|
186
|
+
data = {};
|
|
187
|
+
form = null;
|
|
188
|
+
error = null;
|
|
189
|
+
params = {};
|
|
190
|
+
route = { id: null };
|
|
191
|
+
state = {};
|
|
192
|
+
status = -1;
|
|
193
|
+
url = new URL(placeholder_url);
|
|
194
|
+
}();
|
|
195
|
+
navigating = new class Navigating {
|
|
196
|
+
current = null;
|
|
197
|
+
}();
|
|
198
|
+
updated = new class Updated {
|
|
199
|
+
current = false;
|
|
200
|
+
}();
|
|
201
|
+
updated_listener.v = () => updated.current = true;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* @param {import('@sveltejs/kit').Page} new_page
|
|
205
|
+
*/
|
|
206
|
+
function update(new_page) {
|
|
207
|
+
Object.assign(page, new_page);
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region node_modules/@sveltejs/kit/src/runtime/client/stream.js
|
|
211
|
+
/**
|
|
212
|
+
* Reads from a stream, decoding it as text and yielding each block of content
|
|
213
|
+
* separated by `delimiter`. The trailing block (if any) is yielded once the
|
|
214
|
+
* stream closes.
|
|
215
|
+
* @param {ReadableStreamDefaultReader<Uint8Array>} reader
|
|
216
|
+
* @param {string} delimiter
|
|
217
|
+
*/
|
|
218
|
+
async function* read_stream(reader, delimiter) {
|
|
219
|
+
let done = false;
|
|
220
|
+
let buffer = "";
|
|
221
|
+
const decoder = new TextDecoder();
|
|
222
|
+
while (true) {
|
|
223
|
+
let split = buffer.indexOf(delimiter);
|
|
224
|
+
while (split !== -1) {
|
|
225
|
+
yield buffer.slice(0, split);
|
|
226
|
+
buffer = buffer.slice(split + delimiter.length);
|
|
227
|
+
split = buffer.indexOf(delimiter);
|
|
228
|
+
}
|
|
229
|
+
if (done) {
|
|
230
|
+
if (buffer) yield buffer;
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const chunk = await reader.read();
|
|
234
|
+
done = chunk.done;
|
|
235
|
+
if (chunk.value) buffer += decoder.decode(chunk.value, { stream: true });
|
|
236
|
+
if (done) buffer += decoder.decode();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region node_modules/@sveltejs/kit/src/runtime/client/ndjson.js
|
|
241
|
+
/**
|
|
242
|
+
* Yields parsed JSON objects from a ReadableStream of newline-delimited JSON.
|
|
243
|
+
* Each yielded value is the raw `JSON.parse`'d object — callers handle deserialization.
|
|
244
|
+
* @param {ReadableStreamDefaultReader<Uint8Array>} reader
|
|
245
|
+
*/
|
|
246
|
+
async function* read_ndjson(reader) {
|
|
247
|
+
for await (const block of read_stream(reader, "\n")) {
|
|
248
|
+
const line = block.trim();
|
|
249
|
+
if (line) yield JSON.parse(line);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region node_modules/@sveltejs/kit/src/runtime/client/client.js
|
|
254
|
+
/** @import { RemoteFunctionDataNode, ServerNodesResponse, ServerRedirectNode } from 'types' */
|
|
255
|
+
/** @import { CacheEntry } from './remote-functions/cache.svelte.js' */
|
|
256
|
+
/** @import { Query } from './remote-functions/query/instance.svelte.js' */
|
|
257
|
+
/** @import { LiveQuery } from './remote-functions/query-live/instance.svelte.js' */
|
|
258
|
+
var { onMount, tick } = index_server_exports;
|
|
259
|
+
/**
|
|
260
|
+
* Set via transformError, reset and read at the end of navigate.
|
|
261
|
+
* Necessary because a navigation might succeed loading but during rendering
|
|
262
|
+
* an error occurs, at which point the navigation result needs to be overridden with the error result.
|
|
263
|
+
* TODO this is all very hacky, rethink for SvelteKit 3 where we can assume Svelte 5 and do an overhaul of client.js
|
|
264
|
+
* @type {{ error: App.Error, status: number } | null}
|
|
265
|
+
*/
|
|
266
|
+
var rendering_error = null;
|
|
267
|
+
/**
|
|
268
|
+
* history index -> { x, y }
|
|
269
|
+
* @type {Record<number, { x: number; y: number }>}
|
|
270
|
+
*/
|
|
271
|
+
var scroll_positions = /* @__PURE__ */ get("sveltekit:scroll") ?? {};
|
|
272
|
+
/**
|
|
273
|
+
* navigation index -> any
|
|
274
|
+
* @type {Record<string, any[]>}
|
|
275
|
+
*/
|
|
276
|
+
var snapshots = /* @__PURE__ */ get("sveltekit:snapshot") ?? {};
|
|
277
|
+
var stores = {
|
|
278
|
+
url: /* @__PURE__ */ notifiable_store({}),
|
|
279
|
+
page: /* @__PURE__ */ notifiable_store({}),
|
|
280
|
+
navigating: /* @__PURE__ */ writable(null),
|
|
281
|
+
updated: /* @__PURE__ */ create_updated_store()
|
|
282
|
+
};
|
|
283
|
+
/** @param {number} index */
|
|
284
|
+
function update_scroll_positions(index) {
|
|
285
|
+
scroll_positions[index] = scroll_state();
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* @param {number} current_history_index
|
|
289
|
+
* @param {number} current_navigation_index
|
|
290
|
+
*/
|
|
291
|
+
function clear_onward_history(current_history_index, current_navigation_index) {
|
|
292
|
+
let i = current_history_index + 1;
|
|
293
|
+
while (scroll_positions[i]) {
|
|
294
|
+
delete scroll_positions[i];
|
|
295
|
+
i += 1;
|
|
296
|
+
}
|
|
297
|
+
i = current_navigation_index + 1;
|
|
298
|
+
while (snapshots[i]) {
|
|
299
|
+
delete snapshots[i];
|
|
300
|
+
i += 1;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Loads `href` the old-fashioned way, with a full page reload.
|
|
305
|
+
* Returns a `Promise` that never resolves (to prevent any
|
|
306
|
+
* subsequent work, e.g. history manipulation, from happening)
|
|
307
|
+
* @param {URL} url
|
|
308
|
+
* @param {boolean} [replace] if `true`, will replace the current `history` entry rather than creating a new one with `pushState`
|
|
309
|
+
* @returns {Promise<any>} a promise that never resolves
|
|
310
|
+
*/
|
|
311
|
+
function native_navigation(url, replace = false) {
|
|
312
|
+
if (replace) location.replace(url.href);
|
|
313
|
+
else location.href = url.href;
|
|
314
|
+
return new Promise(noop);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Checks whether a service worker is registered, and if it is,
|
|
318
|
+
* tries to update it.
|
|
319
|
+
*/
|
|
320
|
+
async function update_service_worker() {
|
|
321
|
+
if ("serviceWorker" in navigator) {
|
|
322
|
+
const registration = await navigator.serviceWorker.getRegistration(base || "/");
|
|
323
|
+
if (registration) await registration.update();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/** @type {import('types').CSRRoute[]} All routes of the app. Only available when kit.router.resolution=client */
|
|
327
|
+
var routes;
|
|
328
|
+
/** @type {import('types').CSRPageNodeLoader} */
|
|
329
|
+
var default_layout_loader;
|
|
330
|
+
/** @type {import('types').CSRPageNodeLoader} */
|
|
331
|
+
var default_error_loader;
|
|
332
|
+
/** @type {HTMLElement} */
|
|
333
|
+
var target;
|
|
334
|
+
/** @type {import('./types.js').SvelteKitApp} */
|
|
335
|
+
var app;
|
|
336
|
+
/** @type {Array<((url: URL) => boolean)>} */
|
|
337
|
+
var invalidated = [];
|
|
338
|
+
/**
|
|
339
|
+
* An array of the `+layout.svelte` and `+page.svelte` component instances
|
|
340
|
+
* that currently live on the page — used for capturing and restoring snapshots.
|
|
341
|
+
* It's updated/manipulated through `bind:this` in `Root.svelte`.
|
|
342
|
+
* @type {import('svelte').SvelteComponent[]}
|
|
343
|
+
*/
|
|
344
|
+
var components = [];
|
|
345
|
+
/** @type {{id: string, token: {}, promise: Promise<import('./types.js').NavigationResult>, fork: Promise<import('svelte').Fork | null> | null} | null} */
|
|
346
|
+
var load_cache = null;
|
|
347
|
+
function discard_load_cache() {
|
|
348
|
+
load_cache?.fork?.then((f) => f?.discard());
|
|
349
|
+
load_cache = null;
|
|
350
|
+
current_a = {
|
|
351
|
+
element: void 0,
|
|
352
|
+
href: void 0
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* @type {Map<string, Promise<URL>>}
|
|
357
|
+
* Cache for client-side rerouting, since it could contain async calls which we want to
|
|
358
|
+
* avoid running multiple times which would slow down navigations (e.g. else preloading
|
|
359
|
+
* wouldn't help because on navigation it would be called again). Since `reroute` should be
|
|
360
|
+
* a pure function (i.e. always return the same) value it's safe to cache across navigations.
|
|
361
|
+
* The server reroute calls don't need to be cached because they are called using `import(...)`
|
|
362
|
+
* which is cached per the JS spec.
|
|
363
|
+
*/
|
|
364
|
+
var reroute_cache = /* @__PURE__ */ new Map();
|
|
365
|
+
/**
|
|
366
|
+
* Note on before_navigate_callbacks, on_navigate_callbacks and after_navigate_callbacks:
|
|
367
|
+
* do not re-assign as some closures keep references to these Sets
|
|
368
|
+
*/
|
|
369
|
+
/** @type {Set<(navigation: import('@sveltejs/kit').BeforeNavigate) => void>} */
|
|
370
|
+
var before_navigate_callbacks = /* @__PURE__ */ new Set();
|
|
371
|
+
/** @type {Set<(navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>>} */
|
|
372
|
+
var on_navigate_callbacks = /* @__PURE__ */ new Set();
|
|
373
|
+
/** @type {Set<(navigation: import('@sveltejs/kit').AfterNavigate) => void>} */
|
|
374
|
+
var after_navigate_callbacks = /* @__PURE__ */ new Set();
|
|
375
|
+
/** @type {import('./types.js').NavigationState & { nav: import('@sveltejs/kit').NavigationEvent }} */
|
|
376
|
+
var current = {
|
|
377
|
+
branch: [],
|
|
378
|
+
error: null,
|
|
379
|
+
url: null,
|
|
380
|
+
nav: null
|
|
381
|
+
};
|
|
382
|
+
/** this being true means we SSR'd */
|
|
383
|
+
var hydrated = false;
|
|
384
|
+
var started = false;
|
|
385
|
+
var autoscroll = true;
|
|
386
|
+
var is_navigating = false;
|
|
387
|
+
var force_invalidation = false;
|
|
388
|
+
/** @type {import('svelte').SvelteComponent} */
|
|
389
|
+
var root;
|
|
390
|
+
/** @type {number} keeping track of the history index in order to prevent popstate navigation events if needed */
|
|
391
|
+
var current_history_index;
|
|
392
|
+
/** @type {number} */
|
|
393
|
+
var current_navigation_index;
|
|
394
|
+
/** @type {{}} */
|
|
395
|
+
var token;
|
|
396
|
+
/**
|
|
397
|
+
* A set of tokens which are associated to current preloads.
|
|
398
|
+
* If a preload becomes a real navigation, it's removed from the set.
|
|
399
|
+
* If a preload token is in the set and the preload errors, the error
|
|
400
|
+
* handling logic (for example reloading) is skipped.
|
|
401
|
+
*/
|
|
402
|
+
/** @type {Set<{}>} */
|
|
403
|
+
var preload_tokens = /* @__PURE__ */ new Set();
|
|
404
|
+
/**
|
|
405
|
+
* @type {Map<string, Map<string, CacheEntry<Query<any>>>>}
|
|
406
|
+
* A map of query id -> payload -> query internals for all active queries.
|
|
407
|
+
*/
|
|
408
|
+
var query_map = /* @__PURE__ */ new Map();
|
|
409
|
+
/**
|
|
410
|
+
* @type {Map<string, Map<string, CacheEntry<LiveQuery<any>>>>}
|
|
411
|
+
* A map of id -> payload -> live query internals for all active queries.
|
|
412
|
+
*/
|
|
413
|
+
var live_query_map = /* @__PURE__ */ new Map();
|
|
414
|
+
function reset_invalidation() {
|
|
415
|
+
invalidated.length = 0;
|
|
416
|
+
force_invalidation = false;
|
|
417
|
+
}
|
|
418
|
+
/** @param {number} index */
|
|
419
|
+
function capture_snapshot(index) {
|
|
420
|
+
if (components.some((c) => c?.snapshot)) snapshots[index] = components.map((c) => c?.snapshot?.capture());
|
|
421
|
+
}
|
|
422
|
+
/** @param {number} index */
|
|
423
|
+
function restore_snapshot(index) {
|
|
424
|
+
snapshots[index]?.forEach((value, i) => {
|
|
425
|
+
components[i]?.snapshot?.restore(value);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* @param {string | URL} url
|
|
430
|
+
* @param {{ replaceState?: boolean; noScroll?: boolean; keepFocus?: boolean; invalidateAll?: boolean; invalidate?: Array<string | URL | ((url: URL) => boolean)>; state?: Record<string, any> }} options
|
|
431
|
+
* @param {number} redirect_count
|
|
432
|
+
* @param {{}} [nav_token]
|
|
433
|
+
* @returns {Promise<void>}
|
|
434
|
+
*/
|
|
435
|
+
async function _goto(url, options, redirect_count, nav_token) {
|
|
436
|
+
/** @type {Set<string>} */
|
|
437
|
+
let query_keys;
|
|
438
|
+
/** @type {Set<string>} */
|
|
439
|
+
let live_query_keys;
|
|
440
|
+
if (options.invalidateAll) discard_load_cache();
|
|
441
|
+
await navigate({
|
|
442
|
+
type: "goto",
|
|
443
|
+
url: resolve_url(url),
|
|
444
|
+
keepfocus: options.keepFocus,
|
|
445
|
+
noscroll: options.noScroll,
|
|
446
|
+
replace_state: options.replaceState,
|
|
447
|
+
state: options.state,
|
|
448
|
+
redirect_count,
|
|
449
|
+
nav_token,
|
|
450
|
+
accept: () => {
|
|
451
|
+
if (options.invalidateAll) {
|
|
452
|
+
force_invalidation = true;
|
|
453
|
+
query_keys = /* @__PURE__ */ new Set();
|
|
454
|
+
for (const [id, entries] of query_map) for (const [payload, entry] of entries) {
|
|
455
|
+
entry.resource?.reset();
|
|
456
|
+
query_keys.add(create_remote_key(id, payload));
|
|
457
|
+
}
|
|
458
|
+
live_query_keys = /* @__PURE__ */ new Set();
|
|
459
|
+
for (const [id, entries] of live_query_map) for (const payload of entries.keys()) live_query_keys.add(create_remote_key(id, payload));
|
|
460
|
+
}
|
|
461
|
+
if (options.invalidate) options.invalidate.forEach(push_invalidated);
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
if (options.invalidateAll) tick$1().then(tick$1).then(() => {
|
|
465
|
+
for (const [id, entries] of query_map) for (const [payload, { resource }] of entries) if (query_keys?.has(create_remote_key(id, payload))) resource.start();
|
|
466
|
+
for (const [id, entries] of live_query_map) for (const [payload, { resource }] of entries) if (live_query_keys?.has(create_remote_key(id, payload))) resource.reconnect();
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* @param {import('./types.js').NavigationFinished} result
|
|
471
|
+
* @param {HTMLElement} target
|
|
472
|
+
* @param {boolean} hydrate
|
|
473
|
+
*/
|
|
474
|
+
async function initialize(result, target, hydrate) {
|
|
475
|
+
/** @type {import('@sveltejs/kit').NavigationEvent} */
|
|
476
|
+
const nav = {
|
|
477
|
+
params: current.params,
|
|
478
|
+
route: { id: current.route?.id ?? null },
|
|
479
|
+
url: new URL(location.href)
|
|
480
|
+
};
|
|
481
|
+
current = {
|
|
482
|
+
...result.state,
|
|
483
|
+
nav
|
|
484
|
+
};
|
|
485
|
+
update(result.props.page);
|
|
486
|
+
root = new app.root({
|
|
487
|
+
target,
|
|
488
|
+
props: {
|
|
489
|
+
...result.props,
|
|
490
|
+
stores,
|
|
491
|
+
components
|
|
492
|
+
},
|
|
493
|
+
hydrate,
|
|
494
|
+
sync: false,
|
|
495
|
+
transformError: void 0
|
|
496
|
+
});
|
|
497
|
+
await Promise.resolve();
|
|
498
|
+
if (hydrate) {
|
|
499
|
+
/** @type {import('@sveltejs/kit').AfterNavigate} */
|
|
500
|
+
const navigation = {
|
|
501
|
+
from: null,
|
|
502
|
+
to: {
|
|
503
|
+
...nav,
|
|
504
|
+
scroll: scroll_positions[current_history_index] ?? scroll_state()
|
|
505
|
+
},
|
|
506
|
+
willUnload: false,
|
|
507
|
+
type: "enter",
|
|
508
|
+
complete: Promise.resolve()
|
|
509
|
+
};
|
|
510
|
+
after_navigate_callbacks.forEach((fn) => fn(navigation));
|
|
511
|
+
}
|
|
512
|
+
restore_snapshot(current_navigation_index);
|
|
513
|
+
started = true;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
*
|
|
517
|
+
* @param {{
|
|
518
|
+
* url: URL;
|
|
519
|
+
* params: Record<string, string>;
|
|
520
|
+
* branch: Array<import('./types.js').BranchNode | undefined>;
|
|
521
|
+
* errors?: Array<import('types').CSRPageNodeLoader | undefined>;
|
|
522
|
+
* status: number;
|
|
523
|
+
* error: App.Error | null;
|
|
524
|
+
* route: import('types').CSRRoute | null;
|
|
525
|
+
* form?: Record<string, any> | null;
|
|
526
|
+
* }} opts
|
|
527
|
+
*/
|
|
528
|
+
async function get_navigation_result_from_branch({ url, params, branch, errors, status, error, route, form }) {
|
|
529
|
+
/** @type {import('types').TrailingSlash} */
|
|
530
|
+
let slash = "never";
|
|
531
|
+
if (base && (url.pathname === base || url.pathname === base + "/")) slash = "always";
|
|
532
|
+
else for (const node of branch) if (node?.slash !== void 0) slash = node.slash;
|
|
533
|
+
url.pathname = normalize_path(url.pathname, slash);
|
|
534
|
+
url.search = url.search;
|
|
535
|
+
/** @type {import('./types.js').NavigationFinished} */
|
|
536
|
+
const result = {
|
|
537
|
+
type: "loaded",
|
|
538
|
+
state: {
|
|
539
|
+
url,
|
|
540
|
+
params,
|
|
541
|
+
branch,
|
|
542
|
+
error,
|
|
543
|
+
route
|
|
544
|
+
},
|
|
545
|
+
props: {
|
|
546
|
+
constructors: compact(branch).map((branch_node) => branch_node.node.component),
|
|
547
|
+
page: clone_page(page)
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
if (form !== void 0) result.props.form = form;
|
|
551
|
+
let data = {};
|
|
552
|
+
let data_changed = !page;
|
|
553
|
+
let p = 0;
|
|
554
|
+
for (let i = 0; i < Math.max(branch.length, current.branch.length); i += 1) {
|
|
555
|
+
const node = branch[i];
|
|
556
|
+
const prev = current.branch[i];
|
|
557
|
+
if (node?.data !== prev?.data) data_changed = true;
|
|
558
|
+
if (!node) continue;
|
|
559
|
+
data = {
|
|
560
|
+
...data,
|
|
561
|
+
...node.data
|
|
562
|
+
};
|
|
563
|
+
if (data_changed) result.props[`data_${p}`] = data;
|
|
564
|
+
p += 1;
|
|
565
|
+
}
|
|
566
|
+
if (!current.url || url.href !== current.url.href || current.error !== error || form !== void 0 && form !== page.form || data_changed) result.props.page = {
|
|
567
|
+
error,
|
|
568
|
+
params,
|
|
569
|
+
route: { id: route?.id ?? null },
|
|
570
|
+
state: {},
|
|
571
|
+
status,
|
|
572
|
+
url: new URL(url),
|
|
573
|
+
form: form ?? null,
|
|
574
|
+
data: data_changed ? data : page.data
|
|
575
|
+
};
|
|
576
|
+
return result;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Call the universal load function of the given node, if it exists.
|
|
580
|
+
*
|
|
581
|
+
* @param {{
|
|
582
|
+
* loader: import('types').CSRPageNodeLoader;
|
|
583
|
+
* parent: () => Promise<Record<string, any>>;
|
|
584
|
+
* url: URL;
|
|
585
|
+
* params: Record<string, string>;
|
|
586
|
+
* route: { id: string | null };
|
|
587
|
+
* server_data_node: import('./types.js').DataNode | null;
|
|
588
|
+
* }} options
|
|
589
|
+
* @returns {Promise<import('./types.js').BranchNode>}
|
|
590
|
+
*/
|
|
591
|
+
async function load_node({ loader, parent, url, params, route, server_data_node }) {
|
|
592
|
+
/** @type {Record<string, any> | null} */
|
|
593
|
+
let data = null;
|
|
594
|
+
let is_tracking = true;
|
|
595
|
+
/** @type {import('types').Uses} */
|
|
596
|
+
const uses = {
|
|
597
|
+
dependencies: /* @__PURE__ */ new Set(),
|
|
598
|
+
params: /* @__PURE__ */ new Set(),
|
|
599
|
+
parent: false,
|
|
600
|
+
route: false,
|
|
601
|
+
url: false,
|
|
602
|
+
search_params: /* @__PURE__ */ new Set()
|
|
603
|
+
};
|
|
604
|
+
const node = await loader();
|
|
605
|
+
if (node.universal?.load) {
|
|
606
|
+
/** @param {string[]} deps */
|
|
607
|
+
function depends(...deps) {
|
|
608
|
+
for (const dep of deps) {
|
|
609
|
+
const { href } = new URL(dep, url);
|
|
610
|
+
uses.dependencies.add(href);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
/** @type {import('@sveltejs/kit').LoadEvent} */
|
|
614
|
+
const load_input = {
|
|
615
|
+
tracing: {
|
|
616
|
+
enabled: false,
|
|
617
|
+
root: noop_span,
|
|
618
|
+
current: noop_span
|
|
619
|
+
},
|
|
620
|
+
route: new Proxy(route, { get: (target, key) => {
|
|
621
|
+
if (is_tracking) uses.route = true;
|
|
622
|
+
return target[key];
|
|
623
|
+
} }),
|
|
624
|
+
params: new Proxy(params, { get: (target, key) => {
|
|
625
|
+
if (is_tracking) uses.params.add(key);
|
|
626
|
+
return target[key];
|
|
627
|
+
} }),
|
|
628
|
+
data: server_data_node?.data ?? null,
|
|
629
|
+
url: make_trackable(url, () => {
|
|
630
|
+
if (is_tracking) uses.url = true;
|
|
631
|
+
}, (param) => {
|
|
632
|
+
if (is_tracking) uses.search_params.add(param);
|
|
633
|
+
}, app.hash),
|
|
634
|
+
async fetch(resource, init) {
|
|
635
|
+
if (resource instanceof Request) init = {
|
|
636
|
+
body: resource.method === "GET" || resource.method === "HEAD" ? void 0 : await resource.blob(),
|
|
637
|
+
cache: resource.cache,
|
|
638
|
+
credentials: resource.credentials,
|
|
639
|
+
headers: [...resource.headers].length > 0 ? resource?.headers : void 0,
|
|
640
|
+
integrity: resource.integrity,
|
|
641
|
+
keepalive: resource.keepalive,
|
|
642
|
+
method: resource.method,
|
|
643
|
+
mode: resource.mode,
|
|
644
|
+
redirect: resource.redirect,
|
|
645
|
+
referrer: resource.referrer,
|
|
646
|
+
referrerPolicy: resource.referrerPolicy,
|
|
647
|
+
signal: resource.signal,
|
|
648
|
+
...init
|
|
649
|
+
};
|
|
650
|
+
const { resolved, promise } = resolve_fetch_url(resource, init, url);
|
|
651
|
+
if (is_tracking) depends(resolved.href);
|
|
652
|
+
return promise;
|
|
653
|
+
},
|
|
654
|
+
setHeaders: noop,
|
|
655
|
+
depends,
|
|
656
|
+
parent() {
|
|
657
|
+
if (is_tracking) uses.parent = true;
|
|
658
|
+
return parent();
|
|
659
|
+
},
|
|
660
|
+
untrack(fn) {
|
|
661
|
+
is_tracking = false;
|
|
662
|
+
try {
|
|
663
|
+
return fn();
|
|
664
|
+
} finally {
|
|
665
|
+
is_tracking = true;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
data = await node.universal.load.call(null, load_input) ?? null;
|
|
670
|
+
}
|
|
671
|
+
return {
|
|
672
|
+
node,
|
|
673
|
+
loader,
|
|
674
|
+
server: server_data_node,
|
|
675
|
+
universal: node.universal?.load ? {
|
|
676
|
+
type: "data",
|
|
677
|
+
data,
|
|
678
|
+
uses
|
|
679
|
+
} : null,
|
|
680
|
+
data: data ?? server_data_node?.data ?? null,
|
|
681
|
+
slash: node.universal?.trailingSlash ?? server_data_node?.slash
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* @param {Request | string | URL} input
|
|
686
|
+
* @param {RequestInit | undefined} init
|
|
687
|
+
* @param {URL} url
|
|
688
|
+
*/
|
|
689
|
+
function resolve_fetch_url(input, init, url) {
|
|
690
|
+
let requested = input instanceof Request ? input.url : input;
|
|
691
|
+
const resolved = new URL(requested, url);
|
|
692
|
+
if (resolved.origin === url.origin) requested = resolved.href.slice(url.origin.length);
|
|
693
|
+
return {
|
|
694
|
+
resolved,
|
|
695
|
+
promise: started ? subsequent_fetch(requested, resolved.href, init) : initial_fetch(requested, init)
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* @param {boolean} parent_changed
|
|
700
|
+
* @param {boolean} route_changed
|
|
701
|
+
* @param {boolean} url_changed
|
|
702
|
+
* @param {Set<string>} search_params_changed
|
|
703
|
+
* @param {import('types').Uses | undefined} uses
|
|
704
|
+
* @param {Record<string, string>} params
|
|
705
|
+
*/
|
|
706
|
+
function has_changed(parent_changed, route_changed, url_changed, search_params_changed, uses, params) {
|
|
707
|
+
if (force_invalidation) return true;
|
|
708
|
+
if (!uses) return false;
|
|
709
|
+
if (uses.parent && parent_changed) return true;
|
|
710
|
+
if (uses.route && route_changed) return true;
|
|
711
|
+
if (uses.url && url_changed) return true;
|
|
712
|
+
for (const tracked_params of uses.search_params) if (search_params_changed.has(tracked_params)) return true;
|
|
713
|
+
for (const param of uses.params) if (params[param] !== current.params[param]) return true;
|
|
714
|
+
for (const href of uses.dependencies) if (invalidated.some((fn) => fn(new URL(href)))) return true;
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* @param {import('types').ServerDataNode | import('types').ServerDataSkippedNode | null} node
|
|
719
|
+
* @param {import('./types.js').DataNode | null} [previous]
|
|
720
|
+
* @returns {import('./types.js').DataNode | null}
|
|
721
|
+
*/
|
|
722
|
+
function create_data_node(node, previous) {
|
|
723
|
+
if (node?.type === "data") return node;
|
|
724
|
+
if (node?.type === "skip") return previous ?? null;
|
|
725
|
+
return null;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* @param {URL | null} old_url
|
|
729
|
+
* @param {URL} new_url
|
|
730
|
+
*/
|
|
731
|
+
function diff_search_params(old_url, new_url) {
|
|
732
|
+
if (!old_url) return new Set(new_url.searchParams.keys());
|
|
733
|
+
const changed = /* @__PURE__ */ new Set([...old_url.searchParams.keys(), ...new_url.searchParams.keys()]);
|
|
734
|
+
for (const key of changed) {
|
|
735
|
+
const old_values = old_url.searchParams.getAll(key);
|
|
736
|
+
const new_values = new_url.searchParams.getAll(key);
|
|
737
|
+
if (old_values.every((value) => new_values.includes(value)) && new_values.every((value) => old_values.includes(value))) changed.delete(key);
|
|
738
|
+
}
|
|
739
|
+
return changed;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* @param {Omit<import('./types.js').NavigationFinished['state'], 'branch'> & { error: App.Error }} opts
|
|
743
|
+
* @returns {import('./types.js').NavigationFinished}
|
|
744
|
+
*/
|
|
745
|
+
function preload_error({ error, url, route, params }) {
|
|
746
|
+
return {
|
|
747
|
+
type: "loaded",
|
|
748
|
+
state: {
|
|
749
|
+
error,
|
|
750
|
+
url,
|
|
751
|
+
route,
|
|
752
|
+
params,
|
|
753
|
+
branch: []
|
|
754
|
+
},
|
|
755
|
+
props: {
|
|
756
|
+
page: clone_page(page),
|
|
757
|
+
constructors: []
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* @overload
|
|
763
|
+
* @param {import('./types.js').NavigationIntent} intent
|
|
764
|
+
* @returns {Promise<import('./types.js').NavigationResult | undefined>}
|
|
765
|
+
*/
|
|
766
|
+
/**
|
|
767
|
+
* @overload
|
|
768
|
+
* @param {import('./types.js').NavigationIntent & { preload: {} }} intent
|
|
769
|
+
* @returns {Promise<import('./types.js').NavigationResult>}
|
|
770
|
+
*/
|
|
771
|
+
/**
|
|
772
|
+
* @param {import('./types.js').NavigationIntent & { preload?: {} }} intent
|
|
773
|
+
* @returns {Promise<import('./types.js').NavigationResult | undefined>}
|
|
774
|
+
*/
|
|
775
|
+
async function load_route({ id, invalidating, url, params, route, preload }) {
|
|
776
|
+
if (load_cache?.id === id) {
|
|
777
|
+
preload_tokens.delete(load_cache.token);
|
|
778
|
+
return load_cache.promise;
|
|
779
|
+
}
|
|
780
|
+
const { errors, layouts, leaf } = route;
|
|
781
|
+
const loaders = [...layouts, leaf];
|
|
782
|
+
errors.forEach((loader) => loader?.().catch(noop));
|
|
783
|
+
loaders.forEach((loader) => loader?.[1]().catch(noop));
|
|
784
|
+
/** @type {import('types').ServerNodesResponse | import('types').ServerRedirectNode | null} */
|
|
785
|
+
let server_data = null;
|
|
786
|
+
const url_changed = current.url ? id !== get_page_key(current.url) : false;
|
|
787
|
+
const route_changed = current.route ? route.id !== current.route.id : false;
|
|
788
|
+
const search_params_changed = diff_search_params(current.url, url);
|
|
789
|
+
let parent_invalid = false;
|
|
790
|
+
{
|
|
791
|
+
const invalid_server_nodes = loaders.map((loader, i) => {
|
|
792
|
+
const previous = current.branch[i];
|
|
793
|
+
const invalid = !!loader?.[0] && (previous?.loader !== loader[1] || has_changed(parent_invalid, route_changed, url_changed, search_params_changed, previous.server?.uses, params));
|
|
794
|
+
if (invalid) parent_invalid = true;
|
|
795
|
+
return invalid;
|
|
796
|
+
});
|
|
797
|
+
if (invalid_server_nodes.some(Boolean)) {
|
|
798
|
+
try {
|
|
799
|
+
server_data = await load_data(url, invalid_server_nodes);
|
|
800
|
+
} catch (error) {
|
|
801
|
+
const handled_error = await handle_error(error, {
|
|
802
|
+
url,
|
|
803
|
+
params,
|
|
804
|
+
route: { id }
|
|
805
|
+
});
|
|
806
|
+
if (preload && preload_tokens.has(preload)) return preload_error({
|
|
807
|
+
error: handled_error,
|
|
808
|
+
url,
|
|
809
|
+
params,
|
|
810
|
+
route
|
|
811
|
+
});
|
|
812
|
+
return load_root_error_page({
|
|
813
|
+
status: get_status(error),
|
|
814
|
+
error: handled_error,
|
|
815
|
+
url,
|
|
816
|
+
route
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
if (server_data.type === "redirect") return server_data;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
const server_data_nodes = server_data?.nodes;
|
|
823
|
+
let parent_changed = false;
|
|
824
|
+
const branch_promises = loaders.map(async (loader, i) => {
|
|
825
|
+
if (!loader) return;
|
|
826
|
+
/** @type {import('./types.js').BranchNode | undefined} */
|
|
827
|
+
const previous = current.branch[i];
|
|
828
|
+
const server_data_node = server_data_nodes?.[i];
|
|
829
|
+
if ((!server_data_node || server_data_node.type === "skip") && loader[1] === previous?.loader && !has_changed(parent_changed, route_changed, url_changed, search_params_changed, previous.universal?.uses, params)) return previous;
|
|
830
|
+
parent_changed = true;
|
|
831
|
+
if (server_data_node?.type === "error") throw server_data_node;
|
|
832
|
+
return load_node({
|
|
833
|
+
loader: loader[1],
|
|
834
|
+
url,
|
|
835
|
+
params,
|
|
836
|
+
route,
|
|
837
|
+
parent: async () => {
|
|
838
|
+
const data = {};
|
|
839
|
+
for (let j = 0; j < i; j += 1) Object.assign(data, (await branch_promises[j])?.data);
|
|
840
|
+
return data;
|
|
841
|
+
},
|
|
842
|
+
server_data_node: create_data_node(server_data_node === void 0 && loader[0] ? { type: "skip" } : server_data_node ?? null, loader[0] ? previous?.server : void 0)
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
for (const p of branch_promises) p.catch(noop);
|
|
846
|
+
/** @type {Array<import('./types.js').BranchNode | undefined>} */
|
|
847
|
+
const branch = [];
|
|
848
|
+
for (let i = 0; i < loaders.length; i += 1) if (loaders[i]) try {
|
|
849
|
+
branch.push(await branch_promises[i]);
|
|
850
|
+
} catch (err) {
|
|
851
|
+
if (err instanceof Redirect) return {
|
|
852
|
+
type: "redirect",
|
|
853
|
+
location: err.location
|
|
854
|
+
};
|
|
855
|
+
if (preload && preload_tokens.has(preload)) return preload_error({
|
|
856
|
+
error: await handle_error(err, {
|
|
857
|
+
params,
|
|
858
|
+
url,
|
|
859
|
+
route: { id: route.id }
|
|
860
|
+
}),
|
|
861
|
+
url,
|
|
862
|
+
params,
|
|
863
|
+
route
|
|
864
|
+
});
|
|
865
|
+
let status = get_status(err);
|
|
866
|
+
/** @type {App.Error} */
|
|
867
|
+
let error;
|
|
868
|
+
if (server_data_nodes?.includes(err)) {
|
|
869
|
+
status = err.status ?? status;
|
|
870
|
+
error = err.error;
|
|
871
|
+
} else if (err instanceof HttpError) error = err.body;
|
|
872
|
+
else {
|
|
873
|
+
if (await stores.updated.check()) {
|
|
874
|
+
await update_service_worker();
|
|
875
|
+
return await native_navigation(url);
|
|
876
|
+
}
|
|
877
|
+
error = await handle_error(err, {
|
|
878
|
+
params,
|
|
879
|
+
url,
|
|
880
|
+
route: { id: route.id }
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
const error_load = await load_nearest_error_page(i, branch, errors);
|
|
884
|
+
if (error_load) return get_navigation_result_from_branch({
|
|
885
|
+
url,
|
|
886
|
+
params,
|
|
887
|
+
branch: branch.slice(0, error_load.idx).concat(error_load.node),
|
|
888
|
+
errors,
|
|
889
|
+
status,
|
|
890
|
+
error,
|
|
891
|
+
route
|
|
892
|
+
});
|
|
893
|
+
else return await server_fallback(url, { id: route.id }, error, status);
|
|
894
|
+
}
|
|
895
|
+
else branch.push(void 0);
|
|
896
|
+
return get_navigation_result_from_branch({
|
|
897
|
+
url,
|
|
898
|
+
params,
|
|
899
|
+
branch,
|
|
900
|
+
errors,
|
|
901
|
+
status: 200,
|
|
902
|
+
error: null,
|
|
903
|
+
route,
|
|
904
|
+
form: invalidating ? void 0 : null
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* @param {number} i Start index to backtrack from
|
|
909
|
+
* @param {Array<import('./types.js').BranchNode | undefined>} branch Branch to backtrack
|
|
910
|
+
* @param {Array<import('types').CSRPageNodeLoader | undefined>} errors All error pages for this branch
|
|
911
|
+
* @returns {Promise<{idx: number; node: import('./types.js').BranchNode} | undefined>}
|
|
912
|
+
*/
|
|
913
|
+
async function load_nearest_error_page(i, branch, errors) {
|
|
914
|
+
while (i--) if (errors[i]) {
|
|
915
|
+
let j = i;
|
|
916
|
+
while (!branch[j]) j -= 1;
|
|
917
|
+
try {
|
|
918
|
+
return {
|
|
919
|
+
idx: j + 1,
|
|
920
|
+
node: {
|
|
921
|
+
node: await errors[i](),
|
|
922
|
+
loader: errors[i],
|
|
923
|
+
data: {},
|
|
924
|
+
server: null,
|
|
925
|
+
universal: null
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
} catch {
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* @param {{
|
|
935
|
+
* status: number;
|
|
936
|
+
* error: App.Error;
|
|
937
|
+
* url: URL;
|
|
938
|
+
* route: { id: string | null }
|
|
939
|
+
* }} opts
|
|
940
|
+
* @returns {Promise<import('./types.js').NavigationFinished | undefined>} returns `undefined` in case of a redirect
|
|
941
|
+
*/
|
|
942
|
+
async function load_root_error_page({ status, error, url, route }) {
|
|
943
|
+
/** @type {Record<string, string>} */
|
|
944
|
+
const params = {};
|
|
945
|
+
/** @type {import('types').ServerDataNode | null} */
|
|
946
|
+
let server_data_node = null;
|
|
947
|
+
if (app.server_loads[0] === 0) try {
|
|
948
|
+
const server_data = await load_data(url, [true]);
|
|
949
|
+
if (server_data.type !== "data" || server_data.nodes[0] && server_data.nodes[0].type !== "data") throw 0;
|
|
950
|
+
server_data_node = server_data.nodes[0] ?? null;
|
|
951
|
+
} catch (e) {
|
|
952
|
+
if (!(e instanceof HttpError && e.status === 404) && (url.origin !== origin || url.pathname !== location.pathname || hydrated)) return await native_navigation(url);
|
|
953
|
+
}
|
|
954
|
+
try {
|
|
955
|
+
return get_navigation_result_from_branch({
|
|
956
|
+
url,
|
|
957
|
+
params,
|
|
958
|
+
branch: [await load_node({
|
|
959
|
+
loader: default_layout_loader,
|
|
960
|
+
url,
|
|
961
|
+
params,
|
|
962
|
+
route,
|
|
963
|
+
parent: () => Promise.resolve({}),
|
|
964
|
+
server_data_node: create_data_node(server_data_node)
|
|
965
|
+
}), {
|
|
966
|
+
node: await default_error_loader(),
|
|
967
|
+
loader: default_error_loader,
|
|
968
|
+
universal: null,
|
|
969
|
+
server: null,
|
|
970
|
+
data: null
|
|
971
|
+
}],
|
|
972
|
+
status,
|
|
973
|
+
error,
|
|
974
|
+
errors: [],
|
|
975
|
+
route: null
|
|
976
|
+
});
|
|
977
|
+
} catch (error) {
|
|
978
|
+
if (error instanceof Redirect) {
|
|
979
|
+
await _goto(new URL(error.location, location.href), {}, 0);
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
const error_template = await app.get_error_template();
|
|
983
|
+
const handled = await handle_error(error, {
|
|
984
|
+
url,
|
|
985
|
+
params,
|
|
986
|
+
route
|
|
987
|
+
});
|
|
988
|
+
const html = error_template({
|
|
989
|
+
status,
|
|
990
|
+
message: String(handled?.message ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")
|
|
991
|
+
});
|
|
992
|
+
const parsed = new DOMParser().parseFromString(html, "text/html");
|
|
993
|
+
document.documentElement.replaceChild(document.adoptNode(parsed.head), document.head);
|
|
994
|
+
document.documentElement.replaceChild(document.adoptNode(parsed.body), document.body);
|
|
995
|
+
throw error;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Resolve the relative rerouted URL for a client-side navigation
|
|
1000
|
+
* @param {URL} url
|
|
1001
|
+
* @returns {Promise<URL | undefined>}
|
|
1002
|
+
*/
|
|
1003
|
+
async function get_rerouted_url(url) {
|
|
1004
|
+
const href = url.href;
|
|
1005
|
+
if (reroute_cache.has(href)) return reroute_cache.get(href);
|
|
1006
|
+
let rerouted;
|
|
1007
|
+
try {
|
|
1008
|
+
const promise = (async () => {
|
|
1009
|
+
let rerouted = await app.hooks.reroute({
|
|
1010
|
+
url: new URL(url),
|
|
1011
|
+
fetch: async (input, init) => {
|
|
1012
|
+
return resolve_fetch_url(input, init, url).promise;
|
|
1013
|
+
}
|
|
1014
|
+
}) ?? url;
|
|
1015
|
+
if (typeof rerouted === "string") {
|
|
1016
|
+
const tmp = new URL(url);
|
|
1017
|
+
if (app.hash) tmp.hash = rerouted;
|
|
1018
|
+
else tmp.pathname = rerouted;
|
|
1019
|
+
rerouted = tmp;
|
|
1020
|
+
}
|
|
1021
|
+
return rerouted;
|
|
1022
|
+
})();
|
|
1023
|
+
reroute_cache.set(href, promise);
|
|
1024
|
+
rerouted = await promise;
|
|
1025
|
+
} catch (e) {
|
|
1026
|
+
reroute_cache.delete(href);
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
return rerouted;
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Resolve the full info (which route, params, etc.) for a client-side navigation from the URL,
|
|
1033
|
+
* taking the reroute hook into account. If this isn't a client-side-navigation (or the URL is undefined),
|
|
1034
|
+
* returns undefined.
|
|
1035
|
+
* @param {URL | undefined} url
|
|
1036
|
+
* @param {boolean} invalidating
|
|
1037
|
+
* @returns {Promise<import('./types.js').NavigationIntent | undefined>}
|
|
1038
|
+
*/
|
|
1039
|
+
async function get_navigation_intent(url, invalidating) {
|
|
1040
|
+
if (!url) return;
|
|
1041
|
+
if (is_external_url(url, base, app.hash)) return;
|
|
1042
|
+
{
|
|
1043
|
+
const rerouted = await get_rerouted_url(url);
|
|
1044
|
+
if (!rerouted) return;
|
|
1045
|
+
const path = get_url_path(rerouted);
|
|
1046
|
+
for (const route of routes) {
|
|
1047
|
+
const params = route.exec(path);
|
|
1048
|
+
if (params) return {
|
|
1049
|
+
id: get_page_key(url),
|
|
1050
|
+
invalidating,
|
|
1051
|
+
route,
|
|
1052
|
+
params: decode_params(params),
|
|
1053
|
+
url
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
/** @param {URL} url */
|
|
1059
|
+
function get_url_path(url) {
|
|
1060
|
+
return decode_pathname(app.hash ? url.hash.replace(/^#/, "").replace(/[?#].+/, "") : url.pathname.slice(base.length)) || "/";
|
|
1061
|
+
}
|
|
1062
|
+
/** @param {URL} url */
|
|
1063
|
+
function get_page_key(url) {
|
|
1064
|
+
return (app.hash ? url.hash.replace(/^#/, "") : url.pathname) + url.search;
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* @param {{
|
|
1068
|
+
* url: URL;
|
|
1069
|
+
* type: import('@sveltejs/kit').Navigation["type"];
|
|
1070
|
+
* intent?: import('./types.js').NavigationIntent;
|
|
1071
|
+
* delta?: number;
|
|
1072
|
+
* event?: PopStateEvent | MouseEvent;
|
|
1073
|
+
* scroll?: { x: number, y: number };
|
|
1074
|
+
* }} opts
|
|
1075
|
+
*/
|
|
1076
|
+
function _before_navigate({ url, type, intent, delta, event, scroll }) {
|
|
1077
|
+
let should_block = false;
|
|
1078
|
+
const nav = create_navigation(current, intent, url, type, scroll ?? null);
|
|
1079
|
+
if (delta !== void 0) nav.navigation.delta = delta;
|
|
1080
|
+
if (event !== void 0) nav.navigation.event = event;
|
|
1081
|
+
const cancellable = {
|
|
1082
|
+
...nav.navigation,
|
|
1083
|
+
cancel: () => {
|
|
1084
|
+
should_block = true;
|
|
1085
|
+
nav.reject(/* @__PURE__ */ new Error("navigation cancelled"));
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
if (!is_navigating) before_navigate_callbacks.forEach((fn) => fn(cancellable));
|
|
1089
|
+
return should_block ? null : nav;
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* @param {{
|
|
1093
|
+
* type: import('@sveltejs/kit').NavigationType;
|
|
1094
|
+
* url: URL;
|
|
1095
|
+
* popped?: {
|
|
1096
|
+
* state: Record<string, any>;
|
|
1097
|
+
* scroll: { x: number, y: number };
|
|
1098
|
+
* delta: number;
|
|
1099
|
+
* };
|
|
1100
|
+
* keepfocus?: boolean;
|
|
1101
|
+
* noscroll?: boolean;
|
|
1102
|
+
* replace_state?: boolean;
|
|
1103
|
+
* state?: Record<string, any>;
|
|
1104
|
+
* redirect_count?: number;
|
|
1105
|
+
* nav_token?: {};
|
|
1106
|
+
* accept?: () => void;
|
|
1107
|
+
* block?: () => void;
|
|
1108
|
+
* event?: Event
|
|
1109
|
+
* }} opts
|
|
1110
|
+
* @returns {Promise<void>}
|
|
1111
|
+
*/
|
|
1112
|
+
async function navigate({ type, url, popped, keepfocus, noscroll, replace_state, state = {}, redirect_count = 0, nav_token = {}, accept = noop, block = noop, event }) {
|
|
1113
|
+
const prev_token = token;
|
|
1114
|
+
token = nav_token;
|
|
1115
|
+
const intent = await get_navigation_intent(url, false);
|
|
1116
|
+
const nav = type === "enter" ? create_navigation(current, intent, url, type) : _before_navigate({
|
|
1117
|
+
url,
|
|
1118
|
+
type,
|
|
1119
|
+
delta: popped?.delta,
|
|
1120
|
+
intent,
|
|
1121
|
+
scroll: popped?.scroll,
|
|
1122
|
+
event
|
|
1123
|
+
});
|
|
1124
|
+
if (!nav) {
|
|
1125
|
+
block();
|
|
1126
|
+
if (token === nav_token) token = prev_token;
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
const previous_history_index = current_history_index;
|
|
1130
|
+
const previous_navigation_index = current_navigation_index;
|
|
1131
|
+
accept();
|
|
1132
|
+
is_navigating = true;
|
|
1133
|
+
if (started && nav.navigation.type !== "enter") stores.navigating.set(navigating.current = nav.navigation);
|
|
1134
|
+
let navigation_result = intent && await load_route(intent);
|
|
1135
|
+
if (!navigation_result) if (is_external_url(url, base, app.hash)) return await native_navigation(url, replace_state);
|
|
1136
|
+
else navigation_result = await server_fallback(url, { id: null }, await handle_error(new SvelteKitError(404, "Not Found", `Not found: ${url.pathname}`), {
|
|
1137
|
+
url,
|
|
1138
|
+
params: {},
|
|
1139
|
+
route: { id: null }
|
|
1140
|
+
}), 404, replace_state);
|
|
1141
|
+
url = intent?.url || url;
|
|
1142
|
+
if (token !== nav_token) {
|
|
1143
|
+
nav.reject(/* @__PURE__ */ new Error("navigation aborted"));
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1146
|
+
if (!navigation_result) return;
|
|
1147
|
+
if (navigation_result.type === "redirect") {
|
|
1148
|
+
if (redirect_count < 20) {
|
|
1149
|
+
await navigate({
|
|
1150
|
+
type,
|
|
1151
|
+
url: new URL(navigation_result.location, url),
|
|
1152
|
+
popped,
|
|
1153
|
+
keepfocus,
|
|
1154
|
+
noscroll,
|
|
1155
|
+
replace_state,
|
|
1156
|
+
state,
|
|
1157
|
+
redirect_count: redirect_count + 1,
|
|
1158
|
+
nav_token
|
|
1159
|
+
});
|
|
1160
|
+
nav.fulfil(void 0);
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
navigation_result = await load_root_error_page({
|
|
1164
|
+
status: 500,
|
|
1165
|
+
error: await handle_error(/* @__PURE__ */ new Error("Redirect loop"), {
|
|
1166
|
+
url,
|
|
1167
|
+
params: {},
|
|
1168
|
+
route: { id: null }
|
|
1169
|
+
}),
|
|
1170
|
+
url,
|
|
1171
|
+
route: { id: null }
|
|
1172
|
+
});
|
|
1173
|
+
if (!navigation_result) return;
|
|
1174
|
+
} else if (navigation_result.props.page.status >= 400) {
|
|
1175
|
+
if (await stores.updated.check()) {
|
|
1176
|
+
await update_service_worker();
|
|
1177
|
+
return await native_navigation(url, replace_state);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
reset_invalidation();
|
|
1181
|
+
update_scroll_positions(previous_history_index);
|
|
1182
|
+
capture_snapshot(previous_navigation_index);
|
|
1183
|
+
if (navigation_result.props.page.url.pathname !== url.pathname) url.pathname = navigation_result.props.page.url.pathname;
|
|
1184
|
+
state = popped ? popped.state : state;
|
|
1185
|
+
if (!popped) {
|
|
1186
|
+
const change = replace_state ? 0 : 1;
|
|
1187
|
+
const entry = {
|
|
1188
|
+
[HISTORY_INDEX]: current_history_index += change,
|
|
1189
|
+
[NAVIGATION_INDEX]: current_navigation_index += change,
|
|
1190
|
+
[STATES_KEY]: state
|
|
1191
|
+
};
|
|
1192
|
+
(replace_state ? history.replaceState : history.pushState).call(history, entry, "", url);
|
|
1193
|
+
if (!replace_state) clear_onward_history(current_history_index, current_navigation_index);
|
|
1194
|
+
}
|
|
1195
|
+
const load_cache_fork = intent && load_cache?.id === intent.id ? load_cache.fork : null;
|
|
1196
|
+
if (load_cache?.fork && !load_cache_fork) discard_load_cache();
|
|
1197
|
+
else {
|
|
1198
|
+
load_cache = null;
|
|
1199
|
+
current_a = {
|
|
1200
|
+
element: void 0,
|
|
1201
|
+
href: void 0
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
navigation_result.props.page.state = state;
|
|
1205
|
+
/**
|
|
1206
|
+
* @type {Promise<void> | undefined}
|
|
1207
|
+
*/
|
|
1208
|
+
let commit_promise;
|
|
1209
|
+
if (started) {
|
|
1210
|
+
const after_navigate = (await Promise.all(Array.from(on_navigate_callbacks, (fn) => fn(nav.navigation)))).filter(
|
|
1211
|
+
/** @returns {value is () => void} */
|
|
1212
|
+
(value) => typeof value === "function"
|
|
1213
|
+
);
|
|
1214
|
+
if (after_navigate.length > 0) {
|
|
1215
|
+
function cleanup() {
|
|
1216
|
+
after_navigate.forEach((fn) => {
|
|
1217
|
+
after_navigate_callbacks.delete(fn);
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
after_navigate.push(cleanup);
|
|
1221
|
+
after_navigate.forEach((fn) => {
|
|
1222
|
+
after_navigate_callbacks.add(fn);
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
const target = nav.navigation.to;
|
|
1226
|
+
current = {
|
|
1227
|
+
...navigation_result.state,
|
|
1228
|
+
nav: {
|
|
1229
|
+
params: target.params,
|
|
1230
|
+
route: target.route,
|
|
1231
|
+
url: target.url
|
|
1232
|
+
}
|
|
1233
|
+
};
|
|
1234
|
+
if (navigation_result.props.page) navigation_result.props.page.url = url;
|
|
1235
|
+
if (!keepfocus && document.activeElement instanceof HTMLElement && document.activeElement !== document.body) document.activeElement.blur();
|
|
1236
|
+
const fork = load_cache_fork && await load_cache_fork;
|
|
1237
|
+
if (fork) commit_promise = fork.commit();
|
|
1238
|
+
else {
|
|
1239
|
+
rendering_error = null;
|
|
1240
|
+
root.$set(navigation_result.props);
|
|
1241
|
+
if (rendering_error) Object.assign(navigation_result.props.page, rendering_error);
|
|
1242
|
+
update(navigation_result.props.page);
|
|
1243
|
+
commit_promise = settled?.();
|
|
1244
|
+
}
|
|
1245
|
+
} else await initialize(navigation_result, target, false);
|
|
1246
|
+
const { activeElement } = document;
|
|
1247
|
+
await commit_promise;
|
|
1248
|
+
await tick$1();
|
|
1249
|
+
await tick$1();
|
|
1250
|
+
if (token !== nav_token) {
|
|
1251
|
+
nav.reject(/* @__PURE__ */ new Error("navigation aborted"));
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
if (navigation_result.props.page && rendering_error) Object.assign(navigation_result.props.page, rendering_error);
|
|
1255
|
+
/** @type {Element | null | ''} */
|
|
1256
|
+
let deep_linked = null;
|
|
1257
|
+
if (autoscroll) {
|
|
1258
|
+
const scroll = popped ? popped.scroll : noscroll ? scroll_state() : null;
|
|
1259
|
+
if (scroll) scrollTo(scroll.x, scroll.y);
|
|
1260
|
+
else if (deep_linked = url.hash && document.getElementById(get_id(url))) deep_linked.scrollIntoView();
|
|
1261
|
+
else scrollTo(0, 0);
|
|
1262
|
+
}
|
|
1263
|
+
const changed_focus = document.activeElement !== activeElement && document.activeElement !== document.body;
|
|
1264
|
+
if (!keepfocus && !changed_focus) reset_focus(url, !deep_linked);
|
|
1265
|
+
autoscroll = true;
|
|
1266
|
+
is_navigating = false;
|
|
1267
|
+
nav.fulfil(void 0);
|
|
1268
|
+
if (nav.navigation.to) nav.navigation.to.scroll = scroll_state();
|
|
1269
|
+
after_navigate_callbacks.forEach((fn) => fn(nav.navigation));
|
|
1270
|
+
if (type === "popstate") restore_snapshot(current_navigation_index);
|
|
1271
|
+
stores.navigating.set(navigating.current = null);
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Does a full page reload if it wouldn't result in an endless loop in the SPA case
|
|
1275
|
+
* @param {URL} url
|
|
1276
|
+
* @param {{ id: string | null }} route
|
|
1277
|
+
* @param {App.Error} error
|
|
1278
|
+
* @param {number} status
|
|
1279
|
+
* @param {boolean} [replace_state]
|
|
1280
|
+
* @returns {Promise<import('./types.js').NavigationFinished | undefined>}
|
|
1281
|
+
*/
|
|
1282
|
+
async function server_fallback(url, route, error, status, replace_state) {
|
|
1283
|
+
if (url.origin === origin && url.pathname === location.pathname && !hydrated) return await load_root_error_page({
|
|
1284
|
+
status,
|
|
1285
|
+
error,
|
|
1286
|
+
url,
|
|
1287
|
+
route
|
|
1288
|
+
});
|
|
1289
|
+
return await native_navigation(url, replace_state);
|
|
1290
|
+
}
|
|
1291
|
+
/** @typedef {(typeof PRELOAD_PRIORITIES)['hover'] | (typeof PRELOAD_PRIORITIES)['tap']} PreloadDataPriority */
|
|
1292
|
+
/**
|
|
1293
|
+
* The anchor element whose href is being preloaded. It is reset after navigation
|
|
1294
|
+
* or changes when a different anchor element is being preloaded.
|
|
1295
|
+
* @type {{ element: Element | SVGAElement | undefined; href: string | SVGAnimatedString | undefined }}
|
|
1296
|
+
*/
|
|
1297
|
+
var current_a = {
|
|
1298
|
+
element: void 0,
|
|
1299
|
+
href: void 0
|
|
1300
|
+
};
|
|
1301
|
+
/**
|
|
1302
|
+
* @param {unknown} error
|
|
1303
|
+
* @param {import('@sveltejs/kit').NavigationEvent} event
|
|
1304
|
+
* @returns {import('types').MaybePromise<App.Error>}
|
|
1305
|
+
*/
|
|
1306
|
+
function handle_error(error, event) {
|
|
1307
|
+
if (error instanceof HttpError) return error.body;
|
|
1308
|
+
const status = get_status(error);
|
|
1309
|
+
const message = get_message(error);
|
|
1310
|
+
return app.hooks.handleError({
|
|
1311
|
+
error,
|
|
1312
|
+
event,
|
|
1313
|
+
status,
|
|
1314
|
+
message
|
|
1315
|
+
}) ?? { message };
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* @template {Function} T
|
|
1319
|
+
* @param {Set<T>} callbacks
|
|
1320
|
+
* @param {T} callback
|
|
1321
|
+
*/
|
|
1322
|
+
function add_navigation_callback(callbacks, callback) {
|
|
1323
|
+
onMount(() => {
|
|
1324
|
+
callbacks.add(callback);
|
|
1325
|
+
return () => {
|
|
1326
|
+
callbacks.delete(callback);
|
|
1327
|
+
};
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a URL.
|
|
1332
|
+
*
|
|
1333
|
+
* `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
1334
|
+
* @param {(navigation: import('@sveltejs/kit').AfterNavigate) => void} callback
|
|
1335
|
+
* @returns {void}
|
|
1336
|
+
*/
|
|
1337
|
+
function afterNavigate(callback) {
|
|
1338
|
+
add_navigation_callback(after_navigate_callbacks, callback);
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* A navigation interceptor that triggers before we navigate to a URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls.
|
|
1342
|
+
*
|
|
1343
|
+
* Calling `cancel()` will prevent the navigation from completing. If `navigation.type === 'leave'` — meaning the user is navigating away from the app (or closing the tab) — calling `cancel` will trigger the native browser unload confirmation dialog. In this case, the navigation may or may not be cancelled depending on the user's response.
|
|
1344
|
+
*
|
|
1345
|
+
* When a navigation isn't to a SvelteKit-owned route (and therefore controlled by SvelteKit's client-side router), `navigation.to.route.id` will be `null`.
|
|
1346
|
+
*
|
|
1347
|
+
* If the navigation will (if not cancelled) cause the document to unload — in other words `'leave'` navigations and `'link'` navigations where `navigation.to.route === null` — `navigation.willUnload` is `true`.
|
|
1348
|
+
*
|
|
1349
|
+
* `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
1350
|
+
* @param {(navigation: import('@sveltejs/kit').BeforeNavigate) => void} callback
|
|
1351
|
+
* @returns {void}
|
|
1352
|
+
*/
|
|
1353
|
+
function beforeNavigate(callback) {
|
|
1354
|
+
add_navigation_callback(before_navigate_callbacks, callback);
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL except during full-page navigations.
|
|
1358
|
+
*
|
|
1359
|
+
* If you return a `Promise`, SvelteKit will wait for it to resolve before completing the navigation. This allows you to — for example — use `document.startViewTransition`. Avoid promises that are slow to resolve, since navigation will appear stalled to the user.
|
|
1360
|
+
*
|
|
1361
|
+
* If a function (or a `Promise` that resolves to a function) is returned from the callback, it will be called once the DOM has updated.
|
|
1362
|
+
*
|
|
1363
|
+
* `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
1364
|
+
* @param {(navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>} callback
|
|
1365
|
+
* @returns {void}
|
|
1366
|
+
*/
|
|
1367
|
+
function onNavigate(callback) {
|
|
1368
|
+
add_navigation_callback(on_navigate_callbacks, callback);
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Allows you to navigate programmatically to a given route, with options such as keeping the current element focused.
|
|
1372
|
+
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
|
|
1373
|
+
*
|
|
1374
|
+
* For external URLs, use `window.location = url` instead of calling `goto(url)`.
|
|
1375
|
+
*
|
|
1376
|
+
* @param {string | URL} url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app.
|
|
1377
|
+
* @param {Object} [opts] Options related to the navigation
|
|
1378
|
+
* @param {boolean} [opts.replaceState] If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
|
|
1379
|
+
* @param {boolean} [opts.noScroll] If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
|
|
1380
|
+
* @param {boolean} [opts.keepFocus] If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
|
|
1381
|
+
* @param {boolean} [opts.invalidateAll] If `true`, all `load` functions of the page will be rerun. See https://svelte.dev/docs/kit/load#rerunning-load-functions for more info on invalidation.
|
|
1382
|
+
* @param {Array<string | URL | ((url: URL) => boolean)>} [opts.invalidate] Causes any load functions to re-run if they depend on one of the urls
|
|
1383
|
+
* @param {App.PageState} [opts.state] An optional object that will be available as `page.state`
|
|
1384
|
+
* @returns {Promise<void>}
|
|
1385
|
+
*/
|
|
1386
|
+
function goto(url, opts = {}) {
|
|
1387
|
+
throw new Error("Cannot call goto(...) on the server");
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* @param {string | URL | ((url: URL) => boolean)} resource The invalidated URL
|
|
1391
|
+
*/
|
|
1392
|
+
function push_invalidated(resource) {
|
|
1393
|
+
if (typeof resource === "function") invalidated.push(resource);
|
|
1394
|
+
else {
|
|
1395
|
+
const { href } = new URL(resource, location.href);
|
|
1396
|
+
invalidated.push((url) => url.href === href);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Causes all `load` and `query` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated.
|
|
1401
|
+
* @returns {Promise<void>}
|
|
1402
|
+
*/
|
|
1403
|
+
function invalidateAll() {
|
|
1404
|
+
throw new Error("Cannot call invalidateAll() on the server");
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* @param {URL} url
|
|
1408
|
+
* @param {boolean[]} invalid
|
|
1409
|
+
* @returns {Promise<import('types').ServerNodesResponse | import('types').ServerRedirectNode>}
|
|
1410
|
+
*/
|
|
1411
|
+
async function load_data(url, invalid) {
|
|
1412
|
+
const data_url = new URL(url);
|
|
1413
|
+
data_url.pathname = add_data_suffix(url.pathname);
|
|
1414
|
+
if (url.pathname.endsWith("/")) data_url.searchParams.append(TRAILING_SLASH_PARAM, "1");
|
|
1415
|
+
data_url.searchParams.append(INVALIDATED_PARAM, invalid.map((i) => i ? "1" : "0").join(""));
|
|
1416
|
+
const res = await (0, window.fetch)(data_url.href, {});
|
|
1417
|
+
if (!res.ok) {
|
|
1418
|
+
/** @type {string | undefined} */
|
|
1419
|
+
let message;
|
|
1420
|
+
if (res.headers.get("content-type")?.includes("application/json")) message = await res.json();
|
|
1421
|
+
else if (res.status === 404) message = "Not Found";
|
|
1422
|
+
else if (res.status === 500) message = "Internal Error";
|
|
1423
|
+
throw new HttpError(res.status, message);
|
|
1424
|
+
}
|
|
1425
|
+
return new Promise((resolve, reject) => {
|
|
1426
|
+
process_stream(resolve, res).catch(reject);
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* @param {(value: ServerNodesResponse | ServerRedirectNode) => void} resolve
|
|
1431
|
+
* @param {Response} res
|
|
1432
|
+
* @returns {Promise<void>}
|
|
1433
|
+
*/
|
|
1434
|
+
async function process_stream(resolve, res) {
|
|
1435
|
+
const reader = res.body.getReader();
|
|
1436
|
+
/**
|
|
1437
|
+
* Map of deferred promises that will be resolved by a subsequent chunk of data
|
|
1438
|
+
* @type {Map<string, import('types').Deferred>}
|
|
1439
|
+
*/
|
|
1440
|
+
const deferreds = /* @__PURE__ */ new Map();
|
|
1441
|
+
/**
|
|
1442
|
+
* @param {any} data
|
|
1443
|
+
*/
|
|
1444
|
+
function deserialize(data) {
|
|
1445
|
+
return devalue.unflatten(data, {
|
|
1446
|
+
...app.decoders,
|
|
1447
|
+
Promise: (id) => {
|
|
1448
|
+
return new Promise((fulfil, reject) => {
|
|
1449
|
+
deferreds.set(id, {
|
|
1450
|
+
fulfil,
|
|
1451
|
+
reject
|
|
1452
|
+
});
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
for await (const node of read_ndjson(reader)) {
|
|
1458
|
+
if (node.type === "redirect") return resolve(node);
|
|
1459
|
+
if (node.type === "data") {
|
|
1460
|
+
node.nodes?.forEach((node) => {
|
|
1461
|
+
if (node?.type === "data") {
|
|
1462
|
+
node.uses = deserialize_uses(node.uses);
|
|
1463
|
+
node.data = deserialize(node.data);
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
resolve(node);
|
|
1467
|
+
} else if (node.type === "chunk") {
|
|
1468
|
+
const { id, data, error } = node;
|
|
1469
|
+
const deferred = deferreds.get(id);
|
|
1470
|
+
deferreds.delete(id);
|
|
1471
|
+
if (error) deferred.reject(deserialize(error));
|
|
1472
|
+
else deferred.fulfil(deserialize(data));
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* @param {any} uses
|
|
1478
|
+
* @return {import('types').Uses}
|
|
1479
|
+
*/
|
|
1480
|
+
function deserialize_uses(uses) {
|
|
1481
|
+
return {
|
|
1482
|
+
dependencies: new Set(uses?.dependencies ?? []),
|
|
1483
|
+
params: new Set(uses?.params ?? []),
|
|
1484
|
+
parent: !!uses?.parent,
|
|
1485
|
+
route: !!uses?.route,
|
|
1486
|
+
url: !!uses?.url,
|
|
1487
|
+
search_params: new Set(uses?.search_params ?? [])
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* @param {URL} url
|
|
1492
|
+
* @param {boolean} [scroll]
|
|
1493
|
+
*/
|
|
1494
|
+
function reset_focus(url, scroll = true) {
|
|
1495
|
+
const autofocus = document.querySelector("[autofocus]");
|
|
1496
|
+
if (autofocus) autofocus.focus();
|
|
1497
|
+
else {
|
|
1498
|
+
const id = get_id(url);
|
|
1499
|
+
if (id && document.getElementById(id)) {
|
|
1500
|
+
const { x, y } = scroll_state();
|
|
1501
|
+
setTimeout(() => {
|
|
1502
|
+
const history_state = history.state;
|
|
1503
|
+
location.replace(new URL(`#${id}`, location.href));
|
|
1504
|
+
history.replaceState(history_state, "", url);
|
|
1505
|
+
if (scroll) scrollTo(x, y);
|
|
1506
|
+
});
|
|
1507
|
+
} else {
|
|
1508
|
+
const root = document.body;
|
|
1509
|
+
const tabindex = root.getAttribute("tabindex");
|
|
1510
|
+
root.tabIndex = -1;
|
|
1511
|
+
root.focus({
|
|
1512
|
+
preventScroll: true,
|
|
1513
|
+
focusVisible: false
|
|
1514
|
+
});
|
|
1515
|
+
if (tabindex !== null) root.setAttribute("tabindex", tabindex);
|
|
1516
|
+
else root.removeAttribute("tabindex");
|
|
1517
|
+
}
|
|
1518
|
+
const selection = getSelection();
|
|
1519
|
+
if (selection && selection.type !== "None") {
|
|
1520
|
+
/** @type {Range[]} */
|
|
1521
|
+
const ranges = [];
|
|
1522
|
+
for (let i = 0; i < selection.rangeCount; i += 1) ranges.push(selection.getRangeAt(i));
|
|
1523
|
+
setTimeout(() => {
|
|
1524
|
+
if (selection.rangeCount !== ranges.length) return;
|
|
1525
|
+
for (let i = 0; i < selection.rangeCount; i += 1) {
|
|
1526
|
+
const a = ranges[i];
|
|
1527
|
+
const b = selection.getRangeAt(i);
|
|
1528
|
+
if (a.commonAncestorContainer !== b.commonAncestorContainer || a.startContainer !== b.startContainer || a.endContainer !== b.endContainer || a.startOffset !== b.startOffset || a.endOffset !== b.endOffset) return;
|
|
1529
|
+
}
|
|
1530
|
+
selection.removeAllRanges();
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* @template {import('@sveltejs/kit').NavigationType} T
|
|
1537
|
+
* @param {import('./types.js').NavigationState} current
|
|
1538
|
+
* @param {import('./types.js').NavigationIntent | undefined} intent
|
|
1539
|
+
* @param {URL | null} url
|
|
1540
|
+
* @param {T} type
|
|
1541
|
+
* @param {{ x: number, y: number } | null} [target_scroll] The scroll position for the target (for popstate navigations)
|
|
1542
|
+
*/
|
|
1543
|
+
function create_navigation(current, intent, url, type, target_scroll = null) {
|
|
1544
|
+
/** @type {(value: any) => void} */
|
|
1545
|
+
let fulfil;
|
|
1546
|
+
/** @type {(error: any) => void} */
|
|
1547
|
+
let reject;
|
|
1548
|
+
const complete = new Promise((f, r) => {
|
|
1549
|
+
fulfil = f;
|
|
1550
|
+
reject = r;
|
|
1551
|
+
});
|
|
1552
|
+
complete.catch(noop);
|
|
1553
|
+
return {
|
|
1554
|
+
navigation: {
|
|
1555
|
+
from: {
|
|
1556
|
+
params: current.params,
|
|
1557
|
+
route: { id: current.route?.id ?? null },
|
|
1558
|
+
url: current.url,
|
|
1559
|
+
scroll: scroll_state()
|
|
1560
|
+
},
|
|
1561
|
+
to: url && {
|
|
1562
|
+
params: intent?.params ?? null,
|
|
1563
|
+
route: { id: intent?.route?.id ?? null },
|
|
1564
|
+
url,
|
|
1565
|
+
scroll: target_scroll
|
|
1566
|
+
},
|
|
1567
|
+
willUnload: !intent,
|
|
1568
|
+
type,
|
|
1569
|
+
complete
|
|
1570
|
+
},
|
|
1571
|
+
fulfil,
|
|
1572
|
+
reject
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* TODO: remove this in 3.0 when the page store is also removed
|
|
1577
|
+
*
|
|
1578
|
+
* We need to assign a new page object so that subscribers are correctly notified.
|
|
1579
|
+
* However, spreading `{ ...page }` returns an empty object so we manually
|
|
1580
|
+
* assign to each property instead.
|
|
1581
|
+
*
|
|
1582
|
+
* @param {import('@sveltejs/kit').Page} page
|
|
1583
|
+
*/
|
|
1584
|
+
function clone_page(page) {
|
|
1585
|
+
return {
|
|
1586
|
+
data: page.data,
|
|
1587
|
+
error: page.error,
|
|
1588
|
+
form: page.form,
|
|
1589
|
+
params: page.params,
|
|
1590
|
+
route: page.route,
|
|
1591
|
+
state: page.state,
|
|
1592
|
+
status: page.status,
|
|
1593
|
+
url: page.url
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
* @param {URL} url
|
|
1598
|
+
* @returns {string}
|
|
1599
|
+
*/
|
|
1600
|
+
function get_id(url) {
|
|
1601
|
+
let id;
|
|
1602
|
+
if (app.hash) {
|
|
1603
|
+
const [, , second] = url.hash.split("#", 3);
|
|
1604
|
+
id = second ?? "";
|
|
1605
|
+
} else id = url.hash.slice(1);
|
|
1606
|
+
return decodeURIComponent(id);
|
|
1607
|
+
}
|
|
1608
|
+
//#endregion
|
|
1609
|
+
export { onNavigate as a, page as c, invalidateAll as i, updated as l, beforeNavigate as n, stores as o, goto as r, navigating as s, afterNavigate as t };
|