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