@voltro/web 0.7.0 → 0.9.0
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/CHANGELOG.md +40 -0
- package/dist/index.d.ts +88 -1
- package/dist/index.js +68 -45
- package/dist/mount-Gsn3ouYx.js +76 -0
- package/dist/mount.js +1 -1
- package/dist/routerState-DpUqogK8.js +101 -0
- package/dist/{serverContext-DSValgbm.js → serverContext-COzippNt.js} +271 -224
- package/dist/ssr.d.ts +189 -14
- package/dist/ssr.js +41 -40
- package/package.json +3 -3
- package/dist/mount-DhGdfjSE.js +0 -74
|
@@ -1,57 +1,58 @@
|
|
|
1
1
|
import { t as e } from "./globalContext-d4A-ugDg.js";
|
|
2
2
|
import { c as t, n, t as r } from "./defaultFallbacks-CGs2z5qv.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { f as i, i as a } from "./routerState-DpUqogK8.js";
|
|
4
|
+
import { Component as o, useCallback as s, useContext as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
5
|
+
import { jsx as p, jsxs as ee } from "react/jsx-runtime";
|
|
5
6
|
//#region src/routeEventBus.ts
|
|
6
|
-
var
|
|
7
|
+
var m = {
|
|
7
8
|
pathname: "/",
|
|
8
9
|
params: {},
|
|
9
10
|
loaderData: void 0
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
for (let e of
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
}),
|
|
11
|
+
}, h = /* @__PURE__ */ new Set(), te = (e) => {
|
|
12
|
+
m = e;
|
|
13
|
+
for (let e of h) e();
|
|
14
|
+
}, g = () => m, _ = (e) => (h.add(e), () => {
|
|
15
|
+
h.delete(e);
|
|
16
|
+
}), v = class extends Error {
|
|
16
17
|
_voltroControl = "not-found";
|
|
17
18
|
constructor(e) {
|
|
18
19
|
super(e ? `Not found: ${e}` : "Not found"), this.name = "NotFoundError";
|
|
19
20
|
}
|
|
20
|
-
},
|
|
21
|
+
}, y = class extends Error {
|
|
21
22
|
_voltroControl = "redirect";
|
|
22
23
|
location;
|
|
23
24
|
status;
|
|
24
25
|
constructor(e, t) {
|
|
25
26
|
super(`Redirect: ${e}`), this.name = "RedirectError", this.location = e, this.status = t?.status ?? 303;
|
|
26
27
|
}
|
|
27
|
-
},
|
|
28
|
-
throw new
|
|
29
|
-
},
|
|
30
|
-
throw new
|
|
31
|
-
}, ne = (e) => e instanceof Error && e._voltroControl === "not-found",
|
|
28
|
+
}, b = (e) => {
|
|
29
|
+
throw new v(e);
|
|
30
|
+
}, x = (e, t) => {
|
|
31
|
+
throw new y(e, t);
|
|
32
|
+
}, ne = (e) => e instanceof Error && e._voltroControl === "not-found", S = (e) => e instanceof Error && e._voltroControl === "redirect" && typeof e.location == "string", C = 0, w = 1, T = 2, E = 3, D = (e) => e.startsWith("[[...") && e.endsWith("]]") ? {
|
|
32
33
|
source: "(.*)",
|
|
33
34
|
paramName: e.slice(5, -2),
|
|
34
|
-
weight:
|
|
35
|
+
weight: T
|
|
35
36
|
} : e.startsWith("[...") && e.endsWith("]") ? {
|
|
36
37
|
source: "(.+)",
|
|
37
38
|
paramName: e.slice(4, -1),
|
|
38
|
-
weight:
|
|
39
|
+
weight: E
|
|
39
40
|
} : e.startsWith("[") && e.endsWith("]") ? {
|
|
40
41
|
source: "([^/]+)",
|
|
41
42
|
paramName: e.slice(1, -1),
|
|
42
|
-
weight:
|
|
43
|
+
weight: w
|
|
43
44
|
} : {
|
|
44
45
|
source: e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
45
46
|
paramName: null,
|
|
46
|
-
weight:
|
|
47
|
-
},
|
|
48
|
-
let t = e.pattern.split("/").map(
|
|
47
|
+
weight: C
|
|
48
|
+
}, re = (e) => {
|
|
49
|
+
let t = e.pattern.split("/").map(D);
|
|
49
50
|
for (let n = 0; n < t.length - 1; n++) {
|
|
50
51
|
let r = t[n];
|
|
51
|
-
if (r.weight ===
|
|
52
|
+
if (r.weight === E || r.weight === T) throw Error(`Route ${JSON.stringify(e.pattern)}: catch-all segment must be last. Anything after a catch-all is unreachable.`);
|
|
52
53
|
}
|
|
53
54
|
let n, r = t[t.length - 1];
|
|
54
|
-
n = r && r.weight ===
|
|
55
|
+
n = r && r.weight === T ? `${t.slice(0, -1).map((e) => e.source).join("/")}(?:/(.*))?` : t.map((e) => e.source).join("/");
|
|
55
56
|
let i = t.map((e) => e.paramName).filter((e) => e !== null), a = t.reduce((e, t) => e + t.weight, 0);
|
|
56
57
|
return {
|
|
57
58
|
...e,
|
|
@@ -62,7 +63,7 @@ var f = {
|
|
|
62
63
|
}, ie = (e) => [...e].map((e, t) => ({
|
|
63
64
|
route: e,
|
|
64
65
|
index: t
|
|
65
|
-
})).sort((e, t) => e.route.priority === t.route.priority ? e.index - t.index : e.route.priority - t.route.priority).map(({ route: e }) => e),
|
|
66
|
+
})).sort((e, t) => e.route.priority === t.route.priority ? e.index - t.index : e.route.priority - t.route.priority).map(({ route: e }) => e), O = (e, t) => {
|
|
66
67
|
let n = ie(e);
|
|
67
68
|
for (let e of n) {
|
|
68
69
|
let n = e.regex.exec(t);
|
|
@@ -79,20 +80,23 @@ var f = {
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
return null;
|
|
82
|
-
},
|
|
83
|
+
}, ae = (e, t, n) => k(`${e}__seg${t}`, n), k = (e, t) => `${e}\u0000${Object.entries(t).sort(([e], [t]) => e < t ? -1 : 1).map(([e, t]) => `${e}=${t}`).join("")}`, oe = (e, t) => {
|
|
84
|
+
let n = e(t);
|
|
85
|
+
return n instanceof Promise ? n.then(i) : i(n);
|
|
86
|
+
}, se = (e, t, n, r) => e === void 0 ? null : typeof e == "function" ? e({
|
|
83
87
|
params: t,
|
|
84
88
|
loaderData: n,
|
|
85
89
|
locale: r ?? "en"
|
|
86
|
-
}) : e,
|
|
90
|
+
}) : e, ce = (e, t) => {
|
|
87
91
|
let n = null, r = -1;
|
|
88
92
|
for (let i of e) (i.prefix === "" || t === i.prefix || t.startsWith(`${i.prefix}/`)) && i.prefix.length > r && (n = i, r = i.prefix.length);
|
|
89
93
|
return n;
|
|
90
|
-
},
|
|
94
|
+
}, A = (e, t, n) => {
|
|
91
95
|
if (e) for (let r = n; r >= 0; r--) {
|
|
92
96
|
let n = e[r]?.[t];
|
|
93
97
|
if (n !== void 0) return n;
|
|
94
98
|
}
|
|
95
|
-
},
|
|
99
|
+
}, le = class {
|
|
96
100
|
entries = /* @__PURE__ */ new Map();
|
|
97
101
|
get(e) {
|
|
98
102
|
return this.entries.get(e);
|
|
@@ -131,70 +135,89 @@ var f = {
|
|
|
131
135
|
let t = `${e}\u0000`;
|
|
132
136
|
for (let e of this.entries.keys()) e.startsWith(t) && this.entries.delete(e);
|
|
133
137
|
}
|
|
138
|
+
seed(e, t) {
|
|
139
|
+
this.entries.has(e) || this.entries.set(e, {
|
|
140
|
+
status: "success",
|
|
141
|
+
data: t
|
|
142
|
+
});
|
|
143
|
+
}
|
|
134
144
|
clear() {
|
|
135
145
|
this.entries.clear();
|
|
136
146
|
}
|
|
137
|
-
},
|
|
138
|
-
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return
|
|
147
|
+
}, j = { kind: "native" }, ue = (e, t) => {
|
|
148
|
+
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return j;
|
|
139
149
|
let n = e.target, r = n instanceof Element ? n.closest("a") : null;
|
|
140
|
-
if (!r) return
|
|
150
|
+
if (!r) return j;
|
|
141
151
|
let i = r.getAttribute("href");
|
|
142
|
-
if (i === null) return
|
|
152
|
+
if (i === null) return j;
|
|
143
153
|
let a = r.getAttribute("target");
|
|
144
|
-
if (a && a !== "_self" || r.hasAttribute("download") || r.hasAttribute("data-no-spa")) return
|
|
154
|
+
if (a && a !== "_self" || r.hasAttribute("download") || r.hasAttribute("data-no-spa")) return j;
|
|
145
155
|
let o = r.getAttribute("rel");
|
|
146
|
-
if (o && /(^|\s)external(\s|$)/i.test(o)) return
|
|
156
|
+
if (o && /(^|\s)external(\s|$)/i.test(o)) return j;
|
|
147
157
|
let s, c;
|
|
148
158
|
try {
|
|
149
159
|
c = new URL(t), s = new URL(i, c);
|
|
150
160
|
} catch {
|
|
151
|
-
return
|
|
161
|
+
return j;
|
|
152
162
|
}
|
|
153
|
-
return s.origin !== c.origin || s.pathname === c.pathname && s.search === c.search && s.hash !== "" ?
|
|
163
|
+
return s.origin !== c.origin || s.pathname === c.pathname && s.search === c.search && s.hash !== "" ? j : {
|
|
154
164
|
kind: "spa",
|
|
155
165
|
to: s.pathname + s.search + s.hash
|
|
156
166
|
};
|
|
157
|
-
},
|
|
167
|
+
}, M = (e) => {
|
|
158
168
|
let t = e.replace(/^#/, "");
|
|
159
169
|
try {
|
|
160
170
|
return decodeURIComponent(t);
|
|
161
171
|
} catch {
|
|
162
172
|
return t;
|
|
163
173
|
}
|
|
164
|
-
},
|
|
165
|
-
let t =
|
|
174
|
+
}, N = (e) => {
|
|
175
|
+
let t = M(e);
|
|
166
176
|
return t ? document.getElementById(t) ?? document.getElementsByName(t)[0] ?? null : null;
|
|
167
|
-
},
|
|
177
|
+
}, de = (e) => {
|
|
168
178
|
if (typeof window.requestAnimationFrame == "function") {
|
|
169
179
|
window.requestAnimationFrame(e);
|
|
170
180
|
return;
|
|
171
181
|
}
|
|
172
182
|
window.setTimeout(e, 0);
|
|
173
|
-
},
|
|
183
|
+
}, fe = (e) => {
|
|
174
184
|
if (!e.hash) {
|
|
175
185
|
window.scrollTo(0, 0);
|
|
176
186
|
return;
|
|
177
187
|
}
|
|
178
|
-
|
|
179
|
-
let t =
|
|
188
|
+
de(() => {
|
|
189
|
+
let t = N(e.hash);
|
|
180
190
|
if (t) {
|
|
181
191
|
t.scrollIntoView();
|
|
182
192
|
return;
|
|
183
193
|
}
|
|
184
194
|
window.scrollTo(0, 0);
|
|
185
195
|
});
|
|
186
|
-
},
|
|
196
|
+
}, P = 0, pe = () => {
|
|
187
197
|
let e = typeof crypto < "u" ? crypto : void 0;
|
|
188
|
-
return e && typeof e.randomUUID == "function" ? e.randomUUID() : (
|
|
189
|
-
},
|
|
190
|
-
let e =
|
|
198
|
+
return e && typeof e.randomUUID == "function" ? e.randomUUID() : (P += 1, `k${Date.now().toString(36)}-${P}`);
|
|
199
|
+
}, F = e("router", null), I = () => {
|
|
200
|
+
let e = c(F);
|
|
191
201
|
if (!e) throw Error("Router hooks must be used inside <Router>.");
|
|
192
202
|
return e;
|
|
193
|
-
},
|
|
203
|
+
}, L = e("loaderData", void 0), me = (e, t) => {
|
|
204
|
+
if (!e || e.pathname !== t) return;
|
|
205
|
+
let n = {};
|
|
206
|
+
for (let [t, r] of e.segments) n[t] = r;
|
|
207
|
+
return {
|
|
208
|
+
page: e.page,
|
|
209
|
+
segments: n
|
|
210
|
+
};
|
|
211
|
+
}, he = (e, t) => {
|
|
212
|
+
if (e === t) return !0;
|
|
213
|
+
if (!e || !t || !Object.is(e.page, t.page)) return !1;
|
|
214
|
+
let n = Object.keys(e.segments), r = Object.keys(t.segments);
|
|
215
|
+
return n.length === r.length && n.every((n) => Object.is(e.segments[Number(n)], t.segments[Number(n)]));
|
|
216
|
+
}, ge = () => {
|
|
194
217
|
if (typeof document > "u") return;
|
|
195
218
|
let e = document.cookie.match(/(?:^|;\s*)voltro:lang=([^;]*)/);
|
|
196
219
|
return e ? decodeURIComponent(e[1]) : void 0;
|
|
197
|
-
},
|
|
220
|
+
}, _e = (e) => {
|
|
198
221
|
if (e === null || typeof document > "u") return () => {};
|
|
199
222
|
let t = document.title, n = [], r = [], i = [], a = [], o = [];
|
|
200
223
|
typeof e.title == "string" && (document.title = e.title);
|
|
@@ -229,7 +252,7 @@ var f = {
|
|
|
229
252
|
}
|
|
230
253
|
if (e.jsonLd) for (let t of e.jsonLd) {
|
|
231
254
|
let e = document.createElement("script");
|
|
232
|
-
e.type = "application/ld+json", e.setAttribute("data-voltro-page-jsonld", ""), e.textContent =
|
|
255
|
+
e.type = "application/ld+json", e.setAttribute("data-voltro-page-jsonld", ""), e.textContent = R(t), document.head.appendChild(e), o.push(e);
|
|
233
256
|
}
|
|
234
257
|
return () => {
|
|
235
258
|
document.title = t;
|
|
@@ -239,7 +262,7 @@ var f = {
|
|
|
239
262
|
for (let { el: e, previous: t } of r) e.content = t;
|
|
240
263
|
for (let { el: e, previous: t } of a) e.href = t;
|
|
241
264
|
};
|
|
242
|
-
},
|
|
265
|
+
}, R = (e) => JSON.stringify(e).replace(/<\/(script)/gi, "<\\/$1").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"), z = class extends o {
|
|
243
266
|
state = { error: null };
|
|
244
267
|
static getDerivedStateFromError(e) {
|
|
245
268
|
return { error: e };
|
|
@@ -256,18 +279,18 @@ var f = {
|
|
|
256
279
|
render() {
|
|
257
280
|
if (this.state.error !== null) {
|
|
258
281
|
let { Fallback: e } = this.props;
|
|
259
|
-
return /* @__PURE__ */
|
|
282
|
+
return /* @__PURE__ */ p(e, {
|
|
260
283
|
error: this.state.error,
|
|
261
284
|
reset: this.reset
|
|
262
285
|
});
|
|
263
286
|
}
|
|
264
287
|
return this.props.children;
|
|
265
288
|
}
|
|
266
|
-
},
|
|
267
|
-
let [
|
|
289
|
+
}, B = "data-voltro-page-slot", ve = () => /* @__PURE__ */ p("div", { [B]: "" }), ye = ({ routes: e, notFounds: i = [], notFound: o = n, errorFallback: c = r }) => {
|
|
290
|
+
let [m, h] = f(() => window.location.pathname), [g, _] = f(() => window.location.pathname), [v, y] = f(() => window.location.search + window.location.hash), b = d(new le()), x = d(/* @__PURE__ */ new Map()), [C, w] = f(null), T = s((e, t) => (x.current.set(e, t), () => {
|
|
268
291
|
x.current.delete(e);
|
|
269
|
-
}), []),
|
|
270
|
-
|
|
292
|
+
}), []), E = d(/* @__PURE__ */ new Map()), D = d(null), j = u(() => ie(e.map(re)), [e]);
|
|
293
|
+
l(() => {
|
|
271
294
|
if (typeof window > "u") return;
|
|
272
295
|
let e = window.history.scrollRestoration;
|
|
273
296
|
try {
|
|
@@ -275,7 +298,7 @@ var f = {
|
|
|
275
298
|
} catch {}
|
|
276
299
|
return window.history.state?.__vwebKey || window.history.replaceState({
|
|
277
300
|
...window.history.state,
|
|
278
|
-
__vwebKey:
|
|
301
|
+
__vwebKey: pe()
|
|
279
302
|
}, ""), () => {
|
|
280
303
|
try {
|
|
281
304
|
window.history.scrollRestoration = e;
|
|
@@ -283,120 +306,134 @@ var f = {
|
|
|
283
306
|
};
|
|
284
307
|
}, []);
|
|
285
308
|
let M = () => window.history.state?.__vwebKey ?? "initial";
|
|
286
|
-
|
|
309
|
+
l(() => {
|
|
287
310
|
let e = () => {
|
|
288
|
-
let e =
|
|
289
|
-
|
|
311
|
+
let e = E.current.get(M());
|
|
312
|
+
D.current = e ?? {
|
|
290
313
|
x: 0,
|
|
291
314
|
y: 0
|
|
292
|
-
},
|
|
315
|
+
}, h(window.location.pathname), y(window.location.search + window.location.hash);
|
|
293
316
|
};
|
|
294
317
|
return window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e);
|
|
295
318
|
}, []);
|
|
296
|
-
let N =
|
|
297
|
-
|
|
319
|
+
let N = s((e, t, n) => {
|
|
320
|
+
E.current.set(M(), {
|
|
298
321
|
x: window.scrollX,
|
|
299
322
|
y: window.scrollY
|
|
300
323
|
});
|
|
301
|
-
let r = { __vwebKey:
|
|
302
|
-
n?.replace ? window.history.replaceState(r, "", e) : window.history.pushState(r, "", e),
|
|
303
|
-
}, []),
|
|
324
|
+
let r = { __vwebKey: pe() };
|
|
325
|
+
n?.replace ? window.history.replaceState(r, "", e) : window.history.pushState(r, "", e), h(t.pathname), y(t.search + t.hash), n?.scroll !== !1 && fe(t);
|
|
326
|
+
}, []), P = s((e, t) => {
|
|
304
327
|
let n = new URL(window.location.href), r = new URL(e, n);
|
|
305
328
|
if (!(r.pathname === n.pathname && r.search === n.search && r.hash === n.hash)) {
|
|
306
329
|
for (let n of x.current.values()) if (n({
|
|
307
330
|
to: e,
|
|
308
331
|
...t ? { opts: t } : {}
|
|
309
332
|
})) {
|
|
310
|
-
|
|
333
|
+
w({
|
|
311
334
|
to: e,
|
|
312
335
|
...t ? { opts: t } : {},
|
|
313
336
|
retry: () => {
|
|
314
|
-
|
|
337
|
+
w(null), N(e, r, t);
|
|
315
338
|
},
|
|
316
|
-
reset: () =>
|
|
339
|
+
reset: () => w(null)
|
|
317
340
|
});
|
|
318
341
|
return;
|
|
319
342
|
}
|
|
320
343
|
N(e, r, t);
|
|
321
344
|
}
|
|
322
345
|
}, [N]);
|
|
323
|
-
|
|
346
|
+
l(() => {
|
|
324
347
|
if (typeof document > "u") return;
|
|
325
348
|
let e = (e) => {
|
|
326
|
-
let t =
|
|
327
|
-
t.kind === "spa" && (e.preventDefault(),
|
|
349
|
+
let t = ue(e, window.location.href);
|
|
350
|
+
t.kind === "spa" && (e.preventDefault(), P(t.to));
|
|
328
351
|
};
|
|
329
352
|
return document.addEventListener("click", e), () => document.removeEventListener("click", e);
|
|
330
|
-
}, [
|
|
331
|
-
let
|
|
332
|
-
|
|
333
|
-
let e =
|
|
334
|
-
if (!e?.load ||
|
|
353
|
+
}, [P]);
|
|
354
|
+
let I = u(() => O(j, m), [j, m]), R = d(/* @__PURE__ */ new Map()), [B, ye] = f(0);
|
|
355
|
+
l(() => {
|
|
356
|
+
let e = I?.route;
|
|
357
|
+
if (!e?.load || R.current.has(e.pattern)) return;
|
|
335
358
|
let t = !1;
|
|
336
359
|
return e.load().then((n) => {
|
|
337
|
-
t || (
|
|
360
|
+
t || (R.current.set(e.pattern, n), ye((e) => e + 1));
|
|
338
361
|
}).catch(() => {}), () => {
|
|
339
362
|
t = !0;
|
|
340
363
|
};
|
|
341
|
-
}, [
|
|
342
|
-
let V =
|
|
343
|
-
if (!
|
|
344
|
-
let e =
|
|
364
|
+
}, [I?.route.load ? I.route.pattern : null]);
|
|
365
|
+
let V = u(() => {
|
|
366
|
+
if (!I) return null;
|
|
367
|
+
let e = I.route;
|
|
345
368
|
if (!e.load) return e;
|
|
346
|
-
let t =
|
|
369
|
+
let t = R.current.get(e.pattern);
|
|
347
370
|
return t ? {
|
|
348
371
|
...e,
|
|
349
|
-
...
|
|
372
|
+
...De(t),
|
|
350
373
|
load: void 0
|
|
351
374
|
} : null;
|
|
352
|
-
}, [
|
|
375
|
+
}, [I, B]), H = u(() => O(j, g), [j, g]), U = u(() => {
|
|
353
376
|
if (!H) return null;
|
|
354
377
|
let e = H.route;
|
|
355
378
|
if (!e.load) return e;
|
|
356
|
-
let t =
|
|
379
|
+
let t = R.current.get(e.pattern);
|
|
357
380
|
return t ? {
|
|
358
381
|
...e,
|
|
359
|
-
...
|
|
382
|
+
...De(t),
|
|
360
383
|
load: void 0
|
|
361
384
|
} : null;
|
|
362
|
-
}, [H, B]), W =
|
|
363
|
-
let t = new URL(e, window.location.origin), n =
|
|
385
|
+
}, [H, B]), W = s((e) => {
|
|
386
|
+
let t = new URL(e, window.location.origin), n = O(j, t.pathname);
|
|
364
387
|
if (!n) return;
|
|
365
388
|
let r = (e, r) => {
|
|
366
|
-
|
|
389
|
+
b.current.start(e, (e) => oe(r, {
|
|
367
390
|
params: n.params,
|
|
368
391
|
pathname: t.pathname,
|
|
369
392
|
signal: e
|
|
370
393
|
}));
|
|
371
394
|
};
|
|
372
|
-
n.route.loader && r(
|
|
373
|
-
e.loader && r(
|
|
395
|
+
n.route.loader && r(k(n.route.pattern, n.params), n.route.loader), n.route.chain?.forEach((e, t) => {
|
|
396
|
+
e.loader && r(ae(n.route.pattern, t, n.params), e.loader);
|
|
374
397
|
});
|
|
375
|
-
}, [j]), [G, K] =
|
|
376
|
-
|
|
398
|
+
}, [j]), [G, K] = f({ status: "idle" }), q = d(void 0);
|
|
399
|
+
q.current === void 0 && (q.current = a());
|
|
400
|
+
let Se = d(!1), [Ce, we] = f(() => q.current?.pageClientOnly === !0 && q.current.pathname === m);
|
|
401
|
+
l(() => {
|
|
402
|
+
we(!1);
|
|
403
|
+
}, []);
|
|
404
|
+
let [J, Te] = f(() => ({
|
|
405
|
+
pathname: m,
|
|
406
|
+
data: me(q.current ?? null, m),
|
|
407
|
+
chain: I?.route.chain
|
|
408
|
+
}));
|
|
409
|
+
l(() => {
|
|
377
410
|
let e = (e) => {
|
|
378
|
-
|
|
411
|
+
_(m), Te((t) => t.pathname === m && he(t.data, e) ? t : {
|
|
412
|
+
pathname: m,
|
|
413
|
+
data: e,
|
|
414
|
+
chain: I?.route.chain
|
|
415
|
+
});
|
|
379
416
|
};
|
|
380
|
-
if (!
|
|
417
|
+
if (!I) {
|
|
381
418
|
K({ status: "idle" }), e(void 0);
|
|
382
419
|
return;
|
|
383
420
|
}
|
|
384
421
|
if (!V) {
|
|
385
422
|
K({
|
|
386
423
|
status: "pending",
|
|
387
|
-
key:
|
|
424
|
+
key: k(I.route.pattern, I.params)
|
|
388
425
|
});
|
|
389
426
|
return;
|
|
390
427
|
}
|
|
391
|
-
let t = V, { params: n } =
|
|
428
|
+
let t = V, { params: n } = I, r = t.chain, i = (t.Pending ?? A(r, "Pending", r ? r.length - 1 : -1)) !== void 0, a = [];
|
|
392
429
|
if (t.loader) {
|
|
393
430
|
let e = t.loader;
|
|
394
431
|
a.push({
|
|
395
|
-
cacheKey:
|
|
432
|
+
cacheKey: k(t.pattern, n),
|
|
396
433
|
target: "page",
|
|
397
|
-
run: (t) => e
|
|
434
|
+
run: (t) => oe(e, {
|
|
398
435
|
params: n,
|
|
399
|
-
pathname:
|
|
436
|
+
pathname: m,
|
|
400
437
|
signal: t
|
|
401
438
|
})
|
|
402
439
|
});
|
|
@@ -405,11 +442,11 @@ var f = {
|
|
|
405
442
|
if (e.loader) {
|
|
406
443
|
let i = e.loader;
|
|
407
444
|
a.push({
|
|
408
|
-
cacheKey:
|
|
445
|
+
cacheKey: ae(t.pattern, r, n),
|
|
409
446
|
target: r,
|
|
410
|
-
run: (e) => i
|
|
447
|
+
run: (e) => oe(i, {
|
|
411
448
|
params: n,
|
|
412
|
-
pathname:
|
|
449
|
+
pathname: m,
|
|
413
450
|
signal: e
|
|
414
451
|
})
|
|
415
452
|
});
|
|
@@ -418,13 +455,18 @@ var f = {
|
|
|
418
455
|
K({ status: "idle" }), e(void 0);
|
|
419
456
|
return;
|
|
420
457
|
}
|
|
421
|
-
let o =
|
|
458
|
+
let o = k(t.pattern, n), s = q.current;
|
|
459
|
+
if (s && !Se.current && m === s.pathname) {
|
|
460
|
+
Se.current = !0;
|
|
461
|
+
for (let e of a) e.target === "page" ? s.pageRan && b.current.seed(e.cacheKey, s.page) : s.segments.has(e.target) && b.current.seed(e.cacheKey, s.segments.get(e.target));
|
|
462
|
+
}
|
|
463
|
+
let c = a.map((e) => ({
|
|
422
464
|
spec: e,
|
|
423
|
-
entry:
|
|
424
|
-
})),
|
|
465
|
+
entry: b.current.start(e.cacheKey, e.run)
|
|
466
|
+
})), l = () => {
|
|
425
467
|
let e = {}, t;
|
|
426
|
-
for (let { spec: n } of
|
|
427
|
-
let r =
|
|
468
|
+
for (let { spec: n } of c) {
|
|
469
|
+
let r = b.current.get(n.cacheKey);
|
|
428
470
|
if (!r || r.status === "pending") return null;
|
|
429
471
|
if (r.status === "error") return {
|
|
430
472
|
ok: !1,
|
|
@@ -439,27 +481,27 @@ var f = {
|
|
|
439
481
|
segments: e
|
|
440
482
|
}
|
|
441
483
|
};
|
|
442
|
-
},
|
|
443
|
-
if (
|
|
444
|
-
|
|
484
|
+
}, u = l();
|
|
485
|
+
if (u) {
|
|
486
|
+
u.ok ? (K({
|
|
445
487
|
status: "success",
|
|
446
488
|
key: o,
|
|
447
|
-
data:
|
|
448
|
-
}), e(
|
|
489
|
+
data: u.data
|
|
490
|
+
}), e(u.data)) : (K({
|
|
449
491
|
status: "error",
|
|
450
492
|
key: o,
|
|
451
|
-
error:
|
|
452
|
-
}),
|
|
493
|
+
error: u.error
|
|
494
|
+
}), S(u.error) || e(void 0));
|
|
453
495
|
return;
|
|
454
496
|
}
|
|
455
497
|
K({
|
|
456
498
|
status: "pending",
|
|
457
499
|
key: o
|
|
458
|
-
}), i &&
|
|
459
|
-
let
|
|
460
|
-
return Promise.all(
|
|
461
|
-
if (
|
|
462
|
-
let t =
|
|
500
|
+
}), i && _(m);
|
|
501
|
+
let d = !1, f = c.map(({ entry: e }) => e.status === "pending" ? e.promise : Promise.resolve());
|
|
502
|
+
return Promise.all(f).then(() => {
|
|
503
|
+
if (d) return;
|
|
504
|
+
let t = l();
|
|
463
505
|
t && (t.ok ? (K({
|
|
464
506
|
status: "success",
|
|
465
507
|
key: o,
|
|
@@ -468,58 +510,58 @@ var f = {
|
|
|
468
510
|
status: "error",
|
|
469
511
|
key: o,
|
|
470
512
|
error: t.error
|
|
471
|
-
}),
|
|
513
|
+
}), S(t.error) || e(void 0)));
|
|
472
514
|
}), () => {
|
|
473
|
-
|
|
515
|
+
d = !0;
|
|
474
516
|
};
|
|
475
517
|
}, [
|
|
476
|
-
|
|
518
|
+
I,
|
|
477
519
|
V,
|
|
478
|
-
|
|
520
|
+
m
|
|
479
521
|
]);
|
|
480
|
-
let
|
|
522
|
+
let Y = J.data?.page, X = g === m, Ee = J.pathname === g, Oe = Ee ? J.data?.page : void 0, ke = ge(), Z = u(() => {
|
|
481
523
|
if (!H) return null;
|
|
482
|
-
let e = H.params.locale ??
|
|
483
|
-
return
|
|
524
|
+
let e = H.params.locale ?? ke;
|
|
525
|
+
return se(U?.meta, H.params, Y, e);
|
|
484
526
|
}, [
|
|
485
527
|
H,
|
|
486
528
|
U,
|
|
487
|
-
|
|
488
|
-
|
|
529
|
+
Y,
|
|
530
|
+
ke
|
|
489
531
|
]);
|
|
490
|
-
|
|
491
|
-
let [
|
|
492
|
-
|
|
493
|
-
if (!
|
|
494
|
-
|
|
532
|
+
l(() => _e(Z), [Z]);
|
|
533
|
+
let [Q, Ae] = f(""), je = d(!1), [Me, Ne] = f(!1);
|
|
534
|
+
l(() => {
|
|
535
|
+
if (!je.current) {
|
|
536
|
+
je.current = !0, Ne(!0);
|
|
495
537
|
return;
|
|
496
538
|
}
|
|
497
539
|
let e = Z?.title ?? (typeof document < "u" ? document.title : "");
|
|
498
|
-
|
|
499
|
-
}, [
|
|
500
|
-
let e =
|
|
501
|
-
e && (
|
|
502
|
-
}, [
|
|
503
|
-
let
|
|
504
|
-
pathname:
|
|
505
|
-
search:
|
|
506
|
-
navigate:
|
|
540
|
+
Ae(e && e.length > 0 ? e : g);
|
|
541
|
+
}, [g, Z]), l(() => {
|
|
542
|
+
let e = D.current;
|
|
543
|
+
e && (D.current = null, de(() => window.scrollTo(e.x, e.y)));
|
|
544
|
+
}, [g]);
|
|
545
|
+
let Pe = u(() => ({
|
|
546
|
+
pathname: g,
|
|
547
|
+
search: v,
|
|
548
|
+
navigate: P,
|
|
507
549
|
params: H?.params ?? {},
|
|
508
550
|
prefetch: W,
|
|
509
|
-
loaderData:
|
|
510
|
-
registerBlocker:
|
|
511
|
-
blocked:
|
|
551
|
+
loaderData: Y,
|
|
552
|
+
registerBlocker: T,
|
|
553
|
+
blocked: C
|
|
512
554
|
}), [
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
555
|
+
g,
|
|
556
|
+
v,
|
|
557
|
+
P,
|
|
516
558
|
H,
|
|
517
559
|
W,
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
560
|
+
Y,
|
|
561
|
+
T,
|
|
562
|
+
C
|
|
521
563
|
]);
|
|
522
|
-
|
|
564
|
+
l(() => {
|
|
523
565
|
if (typeof window > "u") return;
|
|
524
566
|
let e = (e) => {
|
|
525
567
|
let t = !1;
|
|
@@ -530,81 +572,86 @@ var f = {
|
|
|
530
572
|
t && (e.preventDefault(), e.returnValue = "");
|
|
531
573
|
};
|
|
532
574
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
533
|
-
}, []),
|
|
575
|
+
}, []), l(() => {
|
|
534
576
|
te({
|
|
535
|
-
pathname:
|
|
577
|
+
pathname: g,
|
|
536
578
|
params: H?.params ?? {},
|
|
537
|
-
loaderData:
|
|
579
|
+
loaderData: Y
|
|
538
580
|
});
|
|
539
581
|
}, [
|
|
540
|
-
|
|
582
|
+
g,
|
|
541
583
|
H,
|
|
542
|
-
|
|
543
|
-
]),
|
|
584
|
+
Y
|
|
585
|
+
]), l(() => {
|
|
544
586
|
if (G.status === "pending") return t({
|
|
545
587
|
id: "voltro:router:loader",
|
|
546
588
|
kind: "loading",
|
|
547
589
|
label: "Loading…"
|
|
548
590
|
});
|
|
549
|
-
}, [G.status]),
|
|
591
|
+
}, [G.status]), l(() => {
|
|
550
592
|
if (G.status === "error") return t({
|
|
551
593
|
id: "voltro:router:loader-error",
|
|
552
594
|
kind: "error",
|
|
553
595
|
label: "Loader failed"
|
|
554
596
|
});
|
|
555
|
-
}, [G.status]),
|
|
556
|
-
G.status === "error" &&
|
|
557
|
-
}, [G,
|
|
558
|
-
let
|
|
559
|
-
let e =
|
|
597
|
+
}, [G.status]), l(() => {
|
|
598
|
+
G.status === "error" && S(G.error) && P(G.error.location, { replace: !0 });
|
|
599
|
+
}, [G, P]);
|
|
600
|
+
let Fe = () => {
|
|
601
|
+
let e = ce(i, g);
|
|
560
602
|
if (e) {
|
|
561
603
|
let { Component: t, chain: n } = e;
|
|
562
|
-
return
|
|
604
|
+
return xe(n, /* @__PURE__ */ p(t, {}), g, c);
|
|
563
605
|
}
|
|
564
|
-
return /* @__PURE__ */
|
|
565
|
-
},
|
|
566
|
-
if (!H) $ =
|
|
567
|
-
else if (ne(
|
|
606
|
+
return /* @__PURE__ */ p(o, {});
|
|
607
|
+
}, Ie = X && H && G.status === "error" ? G.error : void 0, $;
|
|
608
|
+
if (!H) $ = Fe();
|
|
609
|
+
else if (ne(Ie)) $ = Fe();
|
|
568
610
|
else {
|
|
569
|
-
let e = H.route.chain, t = e ? e.length - 1 : -1, n = U?.ErrorBoundary ??
|
|
570
|
-
if (
|
|
611
|
+
let e = H.route.chain, t = e ? e.length - 1 : -1, n = U?.ErrorBoundary ?? A(e, "Error", t) ?? c, r;
|
|
612
|
+
if (Ce) r = /* @__PURE__ */ p(ve, {});
|
|
613
|
+
else if (X && G.status === "error" && !S(G.error)) r = /* @__PURE__ */ p(n, {
|
|
571
614
|
error: G.error,
|
|
572
615
|
reset: () => {
|
|
573
|
-
|
|
616
|
+
b.current.invalidate(H.route.pattern), h((e) => e), K({ status: "idle" });
|
|
574
617
|
}
|
|
575
618
|
});
|
|
576
|
-
else if (
|
|
577
|
-
let i = U?.Pending ??
|
|
578
|
-
if (i) r = /* @__PURE__ */
|
|
619
|
+
else if (X && G.status === "pending") {
|
|
620
|
+
let i = U?.Pending ?? A(e, "Pending", t);
|
|
621
|
+
if (i) r = /* @__PURE__ */ p(i, {});
|
|
579
622
|
else if (U?.Component) {
|
|
580
623
|
let e = U.Component;
|
|
581
|
-
r = /* @__PURE__ */
|
|
582
|
-
resetKey:
|
|
624
|
+
r = /* @__PURE__ */ p(z, {
|
|
625
|
+
resetKey: g,
|
|
583
626
|
Fallback: n,
|
|
584
|
-
children: /* @__PURE__ */
|
|
585
|
-
value:
|
|
586
|
-
children: /* @__PURE__ */
|
|
627
|
+
children: /* @__PURE__ */ p(L.Provider, {
|
|
628
|
+
value: Oe,
|
|
629
|
+
children: /* @__PURE__ */ p(e, {})
|
|
587
630
|
})
|
|
588
631
|
});
|
|
589
632
|
} else r = null;
|
|
590
633
|
} else {
|
|
591
634
|
let e = U?.Component;
|
|
592
|
-
r = e ? /* @__PURE__ */
|
|
593
|
-
resetKey:
|
|
635
|
+
r = e ? /* @__PURE__ */ p(z, {
|
|
636
|
+
resetKey: g,
|
|
594
637
|
Fallback: n,
|
|
595
|
-
children: /* @__PURE__ */
|
|
596
|
-
value:
|
|
597
|
-
children: /* @__PURE__ */
|
|
638
|
+
children: /* @__PURE__ */ p(L.Provider, {
|
|
639
|
+
value: Oe,
|
|
640
|
+
children: /* @__PURE__ */ p(e, {})
|
|
598
641
|
})
|
|
599
642
|
}) : null;
|
|
600
643
|
}
|
|
601
|
-
$ =
|
|
644
|
+
$ = xe(e, r, g, c, (t) => {
|
|
645
|
+
if (Ee) return J.data?.segments[t];
|
|
646
|
+
let n = e?.[t]?.Layout;
|
|
647
|
+
return n !== void 0 && n === J.chain?.[t]?.Layout ? J.data?.segments[t] : void 0;
|
|
648
|
+
});
|
|
602
649
|
}
|
|
603
|
-
return /* @__PURE__ */ ee(
|
|
604
|
-
value:
|
|
605
|
-
children: [$,
|
|
650
|
+
return /* @__PURE__ */ ee(F.Provider, {
|
|
651
|
+
value: Pe,
|
|
652
|
+
children: [$, Me ? /* @__PURE__ */ p(be, { message: Q }) : null]
|
|
606
653
|
});
|
|
607
|
-
},
|
|
654
|
+
}, V = {
|
|
608
655
|
position: "absolute",
|
|
609
656
|
width: 1,
|
|
610
657
|
height: 1,
|
|
@@ -614,28 +661,28 @@ var f = {
|
|
|
614
661
|
clip: "rect(0, 0, 0, 0)",
|
|
615
662
|
whiteSpace: "nowrap",
|
|
616
663
|
border: 0
|
|
617
|
-
},
|
|
664
|
+
}, be = ({ message: e }) => /* @__PURE__ */ p("div", {
|
|
618
665
|
"data-vweb-route-announcer": "",
|
|
619
666
|
role: "status",
|
|
620
667
|
"aria-live": "assertive",
|
|
621
668
|
"aria-atomic": "true",
|
|
622
|
-
style:
|
|
669
|
+
style: V,
|
|
623
670
|
children: e
|
|
624
|
-
}),
|
|
671
|
+
}), xe = (e, t, n, r, i) => {
|
|
625
672
|
if (!e || e.length === 0) return t;
|
|
626
673
|
let a = t;
|
|
627
674
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
628
675
|
let r = e[t];
|
|
629
676
|
if (r.Layout) {
|
|
630
677
|
let e = r.Layout;
|
|
631
|
-
a = /* @__PURE__ */
|
|
678
|
+
a = /* @__PURE__ */ p(L.Provider, {
|
|
632
679
|
value: i?.(t),
|
|
633
|
-
children: /* @__PURE__ */
|
|
680
|
+
children: /* @__PURE__ */ p(e, { children: a })
|
|
634
681
|
});
|
|
635
682
|
}
|
|
636
683
|
if (r.Error) {
|
|
637
684
|
let e = r.Error;
|
|
638
|
-
a = /* @__PURE__ */
|
|
685
|
+
a = /* @__PURE__ */ p(z, {
|
|
639
686
|
resetKey: n,
|
|
640
687
|
Fallback: e,
|
|
641
688
|
children: a
|
|
@@ -643,9 +690,9 @@ var f = {
|
|
|
643
690
|
}
|
|
644
691
|
}
|
|
645
692
|
return a;
|
|
646
|
-
},
|
|
647
|
-
let { registerBlocker: t, blocked: n } =
|
|
648
|
-
return i.current = e,
|
|
693
|
+
}, H = () => I().pathname, U = () => I().navigate, W = () => I().params, G = () => c(L), K = () => I().prefetch, q = (e) => {
|
|
694
|
+
let { registerBlocker: t, blocked: n } = I(), r = d(Symbol("voltro:blocker")), i = d(e);
|
|
695
|
+
return i.current = e, l(() => {
|
|
649
696
|
let e = r.current;
|
|
650
697
|
return t(e, (e) => {
|
|
651
698
|
let t = i.current;
|
|
@@ -657,40 +704,40 @@ var f = {
|
|
|
657
704
|
retry: n.retry,
|
|
658
705
|
reset: n.reset
|
|
659
706
|
} : { blocked: !1 };
|
|
660
|
-
},
|
|
661
|
-
let { navigate: e } =
|
|
662
|
-
return
|
|
663
|
-
let r = new URLSearchParams(typeof window < "u" ? window.location.search : ""), i =
|
|
707
|
+
}, Se = (e) => e instanceof URLSearchParams ? e : new URLSearchParams(e), Ce = () => {
|
|
708
|
+
let { navigate: e } = I();
|
|
709
|
+
return s((t, n) => {
|
|
710
|
+
let r = new URLSearchParams(typeof window < "u" ? window.location.search : ""), i = Se(typeof t == "function" ? t(r) : t).toString(), a = typeof window < "u" ? window.location.pathname : "/", o = i ? `${a}?${i}` : a;
|
|
664
711
|
e(o, {
|
|
665
712
|
replace: !n?.push,
|
|
666
713
|
...n?.scroll === void 0 ? {} : { scroll: n.scroll }
|
|
667
714
|
});
|
|
668
715
|
}, [e]);
|
|
669
|
-
},
|
|
716
|
+
}, we = (e) => e, J = (e, t) => {
|
|
670
717
|
let n = new URLSearchParams();
|
|
671
718
|
for (let [e, r] of Object.entries(t)) r !== void 0 && n.append(e, String(r));
|
|
672
719
|
let r = n.toString();
|
|
673
720
|
return r ? `${e}?${r}` : e;
|
|
674
|
-
},
|
|
675
|
-
let c =
|
|
721
|
+
}, Te = (e, t) => `${e}#${t.replace(/^#/, "")}`, Y = (e) => /^([a-z][a-z0-9+.-]*:|\/\/|#)/i.test(e), X = ({ to: e, children: t, onClick: n, prefetch: r = !1, replace: i = !1, onMouseEnter: a, onFocus: o, ...s }) => {
|
|
722
|
+
let c = U(), l = K(), u = Y(e), d = (t) => {
|
|
676
723
|
u || t.metaKey || t.ctrlKey || t.shiftKey || t.altKey || t.button !== 0 || (t.preventDefault(), n?.(t), c(e, i ? { replace: i } : void 0));
|
|
677
724
|
}, f = (t) => {
|
|
678
725
|
r && !u && l(e), a?.(t);
|
|
679
|
-
},
|
|
726
|
+
}, ee = (t) => {
|
|
680
727
|
r && !u && l(e), o?.(t);
|
|
681
728
|
};
|
|
682
|
-
return /* @__PURE__ */
|
|
729
|
+
return /* @__PURE__ */ p("a", {
|
|
683
730
|
...s,
|
|
684
731
|
href: e,
|
|
685
|
-
onClick:
|
|
732
|
+
onClick: d,
|
|
686
733
|
onMouseEnter: f,
|
|
687
|
-
onFocus:
|
|
734
|
+
onFocus: ee,
|
|
688
735
|
children: t
|
|
689
736
|
});
|
|
690
|
-
},
|
|
737
|
+
}, Ee = (e) => X({
|
|
691
738
|
...e,
|
|
692
739
|
to: e.to
|
|
693
|
-
}),
|
|
740
|
+
}), De = (e) => ({
|
|
694
741
|
Component: e.default,
|
|
695
742
|
meta: e.meta,
|
|
696
743
|
loader: e.loader,
|
|
@@ -698,30 +745,30 @@ var f = {
|
|
|
698
745
|
Pending: e.Pending,
|
|
699
746
|
renderMode: e.renderMode,
|
|
700
747
|
interactive: e.interactive
|
|
701
|
-
}),
|
|
748
|
+
}), Oe = (e, t, n = {}) => ({
|
|
702
749
|
pattern: e,
|
|
703
|
-
...
|
|
750
|
+
...De(t),
|
|
704
751
|
chain: n.chain
|
|
705
|
-
}),
|
|
752
|
+
}), ke = (e, t, n = {}) => ({
|
|
706
753
|
pattern: e,
|
|
707
754
|
load: t,
|
|
708
755
|
chain: n.chain
|
|
709
|
-
}),
|
|
710
|
-
let n =
|
|
756
|
+
}), Z = async (e, t) => {
|
|
757
|
+
let n = O(e.map(re), t)?.route.load;
|
|
711
758
|
if (n) try {
|
|
712
759
|
await n();
|
|
713
760
|
} catch {}
|
|
714
|
-
}, Q = e("serverRequest", null),
|
|
715
|
-
let e =
|
|
761
|
+
}, Q = e("serverRequest", null), Ae = () => c(Q), je = () => {
|
|
762
|
+
let e = Ae();
|
|
716
763
|
if (e !== null) {
|
|
717
764
|
let t = e.url.indexOf("?");
|
|
718
765
|
return new URLSearchParams(t >= 0 ? e.url.slice(t + 1) : "");
|
|
719
766
|
}
|
|
720
767
|
return typeof window < "u" ? new URLSearchParams(window.location.search) : new URLSearchParams();
|
|
721
|
-
},
|
|
768
|
+
}, Me = ({ value: e, children: t }) => /* @__PURE__ */ p(Q.Provider, {
|
|
722
769
|
value: e,
|
|
723
770
|
children: t
|
|
724
|
-
}),
|
|
771
|
+
}), Ne = (e) => {
|
|
725
772
|
let t = {};
|
|
726
773
|
if (!e) return t;
|
|
727
774
|
for (let n of e.split(";")) {
|
|
@@ -739,4 +786,4 @@ var f = {
|
|
|
739
786
|
return t;
|
|
740
787
|
};
|
|
741
788
|
//#endregion
|
|
742
|
-
export {
|
|
789
|
+
export { W as A, x as B, se as C, G as D, q as E, v as F, te as H, y as I, ne as L, Ce as M, Te as N, H as O, J as P, S as R, ue as S, ie as T, _ as U, g as V, ke as _, Ae as a, Oe as b, L as c, Ee as d, ye as f, ce as g, we as h, je as i, K as j, U as k, B as l, re as m, Me as n, X as o, F as p, Ne as r, le as s, Q as t, ve as u, k as v, ae as w, Z as x, O as y, b as z };
|