@voltro/web 0.9.0 → 0.10.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 +310 -7
- package/dist/index.d.ts +18 -5
- package/dist/index.js +34 -34
- package/dist/{mount-Gsn3ouYx.js → mount-CKsOnjiF.js} +3 -3
- package/dist/mount.js +1 -1
- package/dist/{routerState-DpUqogK8.js → routerState-cjTiUIum.js} +21 -11
- package/dist/{serverContext-COzippNt.js → serverContext-BP0ywwLZ.js} +198 -193
- package/dist/ssr.d.ts +61 -15
- package/dist/ssr.js +9 -9
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,28 +2,28 @@ import { t as e } from "./globalContext-d4A-ugDg.js";
|
|
|
2
2
|
import { AppClientsContext as t, useAppClient as n } from "./hooks.js";
|
|
3
3
|
import { a as r, c as i, i as a, l as o, o as s, r as c, s as l, u } from "./frameworkBoot-C_d7E8Fj.js";
|
|
4
4
|
import { a as d, c as f, i as p, l as m, o as h, s as g } from "./defaultFallbacks-CGs2z5qv.js";
|
|
5
|
-
import { i as _, n as ee, r as te, t as ne } from "./mount-
|
|
6
|
-
import { c as re, d as ie, h as ae, l as oe, p as se, u as ce } from "./routerState-
|
|
7
|
-
import { A as le, B as ue, C as de, D as fe, E as pe, F as me, H as v, I as y, L as b, M as x, N as S, O as C, P as w, R as T, S as E, T as D, U as O, V as k,
|
|
8
|
-
import { Component as
|
|
5
|
+
import { i as _, n as ee, r as te, t as ne } from "./mount-CKsOnjiF.js";
|
|
6
|
+
import { c as re, d as ie, h as ae, l as oe, p as se, u as ce } from "./routerState-cjTiUIum.js";
|
|
7
|
+
import { A as le, B as ue, C as de, D as fe, E as pe, F as me, H as v, I as y, L as b, M as x, N as S, O as C, P as w, R as T, S as E, T as D, U as O, V as k, W as A, _ as j, a as M, b as N, c as P, d as F, f as I, g as L, h as R, i as z, j as he, k as ge, l as _e, m as ve, n as ye, o as be, p as xe, r as Se, s as Ce, t as we, u as Te, v as Ee, w as De, x as Oe, y as ke, z as Ae } from "./serverContext-BP0ywwLZ.js";
|
|
8
|
+
import { Component as je, Suspense as Me, createElement as B, use as Ne, useCallback as Pe, useContext as Fe, useSyncExternalStore as Ie } from "react";
|
|
9
9
|
import { Fragment as V, jsx as H, jsxs as U } from "react/jsx-runtime";
|
|
10
10
|
export * from "@voltro/client";
|
|
11
11
|
export * from "@voltro/ui";
|
|
12
12
|
//#region src/await.tsx
|
|
13
|
-
var
|
|
13
|
+
var Le = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PURE__ */ H(Me, {
|
|
14
14
|
fallback: t,
|
|
15
|
-
children: /* @__PURE__ */ H(
|
|
15
|
+
children: /* @__PURE__ */ H(ze, {
|
|
16
16
|
errorFallback: r,
|
|
17
|
-
children: /* @__PURE__ */ H(
|
|
17
|
+
children: /* @__PURE__ */ H(Re, {
|
|
18
18
|
value: e,
|
|
19
19
|
errorFallback: r ?? null,
|
|
20
20
|
children: n
|
|
21
21
|
})
|
|
22
22
|
})
|
|
23
|
-
}), W = ({ body: e }) => /* @__PURE__ */ H("script", { dangerouslySetInnerHTML: { __html: e } }),
|
|
24
|
-
let r =
|
|
23
|
+
}), W = ({ body: e }) => /* @__PURE__ */ H("script", { dangerouslySetInnerHTML: { __html: e } }), Re = ({ value: e, errorFallback: t, children: n }) => {
|
|
24
|
+
let r = Ne(e), i = ce(e), a = ae(r);
|
|
25
25
|
return a === void 0 ? /* @__PURE__ */ U(V, { children: [i === void 0 ? null : /* @__PURE__ */ H(W, { body: ie(i, r) }), n(r)] }) : /* @__PURE__ */ U(V, { children: [i === void 0 ? null : /* @__PURE__ */ H(W, { body: oe(i, a) }), t] });
|
|
26
|
-
},
|
|
26
|
+
}, ze = class extends je {
|
|
27
27
|
state = { error: void 0 };
|
|
28
28
|
static getDerivedStateFromError(e) {
|
|
29
29
|
return { error: e };
|
|
@@ -31,7 +31,7 @@ var Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PUR
|
|
|
31
31
|
render() {
|
|
32
32
|
return this.state.error === void 0 ? this.props.children : this.props.errorFallback ?? null;
|
|
33
33
|
}
|
|
34
|
-
}, G = ({ src: e }) => e, K = e("imageConfig", { loader: G }),
|
|
34
|
+
}, G = ({ src: e }) => e, K = e("imageConfig", { loader: G }), Be = ({ loader: e, children: t }) => B(K.Provider, { value: { loader: e } }, t), q = [
|
|
35
35
|
640,
|
|
36
36
|
750,
|
|
37
37
|
828,
|
|
@@ -40,7 +40,7 @@ var Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PUR
|
|
|
40
40
|
1920,
|
|
41
41
|
2048,
|
|
42
42
|
3840
|
|
43
|
-
],
|
|
43
|
+
], Ve = (e, t, n, r) => {
|
|
44
44
|
let i = n !== void 0 && !r ? Array.from(new Set(q.filter((e) => e <= n * 2).concat(n))).sort((e, t) => e - t) : [...q];
|
|
45
45
|
return {
|
|
46
46
|
srcSet: i.map((n) => `${e({
|
|
@@ -52,10 +52,10 @@ var Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PUR
|
|
|
52
52
|
width: i[i.length - 1]
|
|
53
53
|
})
|
|
54
54
|
};
|
|
55
|
-
},
|
|
56
|
-
let f =
|
|
55
|
+
}, He = ({ src: e, alt: t, width: n, height: r, fill: i = !1, sizes: a, priority: o = !1, loader: s, placeholder: c = "empty", blurDataURL: l, style: u, ...d }) => {
|
|
56
|
+
let f = Fe(K).loader, p = s ?? f;
|
|
57
57
|
!i && (n === void 0 || r === void 0) && typeof console < "u" && console.warn(`<Image src="${e}"> needs both width and height (or fill) to reserve layout space and avoid CLS.`);
|
|
58
|
-
let { srcSet: m, fallback: h } =
|
|
58
|
+
let { srcSet: m, fallback: h } = Ve(p, e, n, i), g = c === "blur" && l ? {
|
|
59
59
|
backgroundImage: `url(${l})`,
|
|
60
60
|
backgroundSize: "cover",
|
|
61
61
|
backgroundPosition: "center"
|
|
@@ -85,10 +85,10 @@ var Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PUR
|
|
|
85
85
|
},
|
|
86
86
|
...d
|
|
87
87
|
});
|
|
88
|
-
},
|
|
88
|
+
}, Ue = ({ to: e, children: t, className: n }) => B("a", {
|
|
89
89
|
href: e,
|
|
90
90
|
className: n
|
|
91
|
-
}, t),
|
|
91
|
+
}, t), We = {
|
|
92
92
|
position: "sticky",
|
|
93
93
|
top: 0,
|
|
94
94
|
zIndex: 10,
|
|
@@ -99,13 +99,13 @@ var Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PUR
|
|
|
99
99
|
padding: "1rem 1.5rem",
|
|
100
100
|
borderBottom: "1px solid var(--voltro-blog-border, rgba(127,127,127,0.2))",
|
|
101
101
|
backdropFilter: "blur(8px)"
|
|
102
|
-
},
|
|
102
|
+
}, Ge = {
|
|
103
103
|
maxWidth: "48rem",
|
|
104
104
|
margin: "0 auto",
|
|
105
105
|
padding: "2rem 1.5rem",
|
|
106
106
|
width: "100%"
|
|
107
|
-
},
|
|
108
|
-
let { brand: t, topNav: n, children: r, pathname: i, footer: a, breadcrumbs: o, headerRight: s } = e, c = e.Link ??
|
|
107
|
+
}, Ke = (e) => {
|
|
108
|
+
let { brand: t, topNav: n, children: r, pathname: i, footer: a, breadcrumbs: o, headerRight: s } = e, c = e.Link ?? Ue, l = B("nav", {
|
|
109
109
|
className: "voltro-blog-nav",
|
|
110
110
|
style: {
|
|
111
111
|
display: "flex",
|
|
@@ -122,7 +122,7 @@ var Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PUR
|
|
|
122
122
|
});
|
|
123
123
|
})), u = B("header", {
|
|
124
124
|
className: "voltro-blog-header",
|
|
125
|
-
style:
|
|
125
|
+
style: We
|
|
126
126
|
}, B("div", { className: "voltro-blog-brand" }, t), s ? B("div", { style: {
|
|
127
127
|
display: "flex",
|
|
128
128
|
gap: "1rem",
|
|
@@ -150,7 +150,7 @@ var Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PUR
|
|
|
150
150
|
})) : null;
|
|
151
151
|
return B("div", { className: "voltro-blog-layout" }, u, B("main", {
|
|
152
152
|
className: "voltro-blog-main",
|
|
153
|
-
style:
|
|
153
|
+
style: Ge
|
|
154
154
|
}, d, r), a ? B("footer", {
|
|
155
155
|
className: "voltro-blog-footer",
|
|
156
156
|
style: {
|
|
@@ -160,7 +160,7 @@ var Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PUR
|
|
|
160
160
|
borderTop: "1px solid var(--voltro-blog-border, rgba(127,127,127,0.2))"
|
|
161
161
|
}
|
|
162
162
|
}, a) : null);
|
|
163
|
-
}, J = "voltro:theme",
|
|
163
|
+
}, J = "voltro:theme", qe = 31536e3, Je = () => {
|
|
164
164
|
if (typeof document > "u") return "system";
|
|
165
165
|
try {
|
|
166
166
|
let e = document.cookie.match(/(?:^|;\s*)voltro:theme=([^;]*)/), t = e?.[1] === void 0 ? "" : decodeURIComponent(e[1]);
|
|
@@ -168,17 +168,17 @@ var Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PUR
|
|
|
168
168
|
} catch {
|
|
169
169
|
return "system";
|
|
170
170
|
}
|
|
171
|
-
},
|
|
171
|
+
}, Y = () => {
|
|
172
172
|
if (typeof window > "u" || !window.matchMedia) return !1;
|
|
173
173
|
try {
|
|
174
174
|
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
175
175
|
} catch {
|
|
176
176
|
return !1;
|
|
177
177
|
}
|
|
178
|
-
}, X = (e) => e === "system" ?
|
|
178
|
+
}, X = (e) => e === "system" ? Y() ? "dark" : "light" : e, Z = 0, Q = /* @__PURE__ */ new Set(), $ = () => {
|
|
179
179
|
Z++;
|
|
180
180
|
for (let e of Q) e();
|
|
181
|
-
},
|
|
181
|
+
}, Ye = (e) => {
|
|
182
182
|
Q.add(e);
|
|
183
183
|
let t, n = () => $();
|
|
184
184
|
if (typeof window < "u" && window.matchMedia) try {
|
|
@@ -190,21 +190,21 @@ var Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PUR
|
|
|
190
190
|
t?.removeEventListener("change", n);
|
|
191
191
|
} catch {}
|
|
192
192
|
};
|
|
193
|
-
},
|
|
194
|
-
let e =
|
|
193
|
+
}, Xe = () => {
|
|
194
|
+
let e = Je();
|
|
195
195
|
return `${Z}:${e}:${X(e)}`;
|
|
196
|
-
},
|
|
197
|
-
let [, e, t] =
|
|
196
|
+
}, Ze = () => "0:system:light", Qe = () => {
|
|
197
|
+
let [, e, t] = Ie(Ye, Xe, Ze).split(":");
|
|
198
198
|
return {
|
|
199
199
|
theme: e,
|
|
200
200
|
resolvedTheme: t,
|
|
201
|
-
setTheme:
|
|
201
|
+
setTheme: Pe((e) => {
|
|
202
202
|
if (typeof document < "u") try {
|
|
203
|
-
document.cookie = e === "system" ? `${J}=; path=/; max-age=0; SameSite=Lax` : `${J}=${e}; path=/; max-age=${
|
|
203
|
+
document.cookie = e === "system" ? `${J}=; path=/; max-age=0; SameSite=Lax` : `${J}=${e}; path=/; max-age=${qe}; SameSite=Lax`, document.documentElement.classList.toggle("dark", X(e) === "dark");
|
|
204
204
|
} catch {}
|
|
205
205
|
$();
|
|
206
206
|
}, [])
|
|
207
207
|
};
|
|
208
|
-
},
|
|
208
|
+
}, $e = "framework-web";
|
|
209
209
|
//#endregion
|
|
210
|
-
export { t as AppClientsContext,
|
|
210
|
+
export { t as AppClientsContext, Le as Await, Ke as BlogLayout, p as FallbackStringsProvider, He as Image, Be as ImageConfigProvider, be as Link, Ce as LoaderCache, P as LoaderDataContext, i as NavigationIndicator, y as NotFoundError, _e as PAGE_SLOT_ATTR, Te as PageSlot, F as PlainLink, I as RENDER_MODES, o as ReconnectContext, b as RedirectError, xe as Router, ve as RouterContext, we as ServerRequestContext, ye as ServerRequestProvider, J as THEME_COOKIE, $e as WEB_NAME, R as compileRoute, d as defaultFallbackStrings, re as defer, L as externalUrl, j as findNotFound, c as formatPrintf, ee as getIslandComponent, v as getRouteSnapshot, g as getStatuses, te as hydrateIslandsOnPage, a as installBrowserConsoleBridge, r as installServerLogRelay, se as isDeferredLoaderResult, T as isNotFound, Ae as isRedirect, _ as island, Ee as lazyPageRoute, ke as loaderCacheKey, N as matchRoute, ne as mount, ue as notFound, Oe as pageRoute, Se as parseCookieHeader, G as passthroughImageLoader, E as preloadRouteModule, f as pushStatus, k as redirect, s as registerClientTrace, de as resolveAnchorNavigation, De as resolveMeta, D as segmentLoaderKey, O as setRouteSnapshot, pe as sortRoutesByPriority, A as subscribeRouteSnapshot, m as subscribeStatuses, l as subscribeTraceErrors, n as useAppClient, fe as useBlocker, h as useFallbackStrings, C as useLoaderData, ge as useLocation, le as useNavigate, he as useParams, x as usePrefetch, u as useReconnect, z as useSearchParams, M as useServerRequest, S as useSetSearchParams, Qe as useTheme, w as withHash, me as withQuery };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./frameworkBoot-C_d7E8Fj.js";
|
|
2
|
-
import { o as t, r as n, t as r } from "./routerState-
|
|
2
|
+
import { o as t, r as n, t as r } from "./routerState-cjTiUIum.js";
|
|
3
3
|
import { StrictMode as i, createElement as a } from "react";
|
|
4
4
|
import { createRoot as o, hydrateRoot as s } from "react-dom/client";
|
|
5
5
|
import { jsx as c } from "react/jsx-runtime";
|
|
@@ -58,13 +58,13 @@ var l = /* @__PURE__ */ new Map(), u = (e, t) => {
|
|
|
58
58
|
descriptors: t.descriptors ?? {},
|
|
59
59
|
wsUrl: t.wsUrl ?? h(e),
|
|
60
60
|
headers: t.headers
|
|
61
|
-
})), f = document.getElementById(r), p = f !== null && u.children.length > 0, g = document.querySelector("meta[name=\"voltro-interactive\"]")?.getAttribute("content") ?? "full";
|
|
61
|
+
})), f = n(document.getElementById(r)?.textContent, window.location.pathname), p = f !== null && u.children.length > 0, g = document.querySelector("meta[name=\"voltro-interactive\"]")?.getAttribute("content") ?? "full";
|
|
62
62
|
if (g === "none") return;
|
|
63
63
|
if (g === "islands") {
|
|
64
64
|
m();
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
p && t(
|
|
67
|
+
p && t(f);
|
|
68
68
|
let _ = /* @__PURE__ */ c(i, { children: /* @__PURE__ */ c(e, {
|
|
69
69
|
App: a,
|
|
70
70
|
apis: d,
|
package/dist/mount.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./mount-
|
|
1
|
+
import { t as e } from "./mount-CKsOnjiF.js";
|
|
2
2
|
export { e as mount };
|
|
@@ -53,12 +53,14 @@ var e = /* @__PURE__ */ RegExp("\\u2028", "g"), t = /* @__PURE__ */ RegExp("\\u2
|
|
|
53
53
|
deferredIds: r
|
|
54
54
|
};
|
|
55
55
|
}, x = (e) => {
|
|
56
|
-
let { page: t, renderMode: n, interactive: r } = e;
|
|
57
|
-
if (
|
|
56
|
+
let { page: t, renderMode: n, interactive: r, layoutShell: i } = e;
|
|
57
|
+
if (i === "artefact") throw Error(`[voltro] a layout in "${t}"'s chain uses defer() in its loader, but this page's SSR layout shell is PRERENDERED at build time into a static HTML file. defer() streams values in AFTER the shell, and a file has no "after" — the <Await> fallback would be frozen into the artefact forever. Drop defer() from the layout loader and return the values directly (the shell then prerenders as before), or give the layout per-request data so the page is served on demand.`);
|
|
58
|
+
if (!(n === "ssr" || n === "spa" && i === "stream")) throw Error(`[voltro] "${t}" uses defer() in its loader but has renderMode: '${n}'. defer() streams values in AFTER the shell, which only a per-request response can do — '${n}' produces a stored HTML artefact with no "after". Set \`export const renderMode = 'ssr'\` on this page, or drop defer() and return the values directly.`);
|
|
58
59
|
if (r !== "full") throw Error(`[voltro] "${t}" uses defer() in its loader but has interactive: '${r}'. ` + (r === "none" ? "Revealing a streamed <Suspense> boundary requires React's inline reveal scripts, and interactive: 'none' ships no JS at all — the <Await> fallback would be permanent. " : "interactive: 'islands' never hydrates the page's React root, so nothing consumes the streamed values and the <Await> fallback would be permanent. ") + "Remove the `interactive` export (defaults to 'full'), or drop defer() and return the values directly.");
|
|
59
60
|
}, S = "__voltro_state__", C = (e) => {
|
|
60
61
|
let t = Object.keys(e.segmentLoaderData ?? {}).map((e) => Number(e)).filter((e) => Number.isInteger(e)).sort((e, t) => e - t), n = e.deferredPageIds !== void 0, r = e.deferredSegmentIds !== void 0 && Object.keys(e.deferredSegmentIds).length > 0;
|
|
61
62
|
return {
|
|
63
|
+
path: e.path,
|
|
62
64
|
page: e.loaderData,
|
|
63
65
|
...e.segmentLoaderData ? { segments: e.segmentLoaderData } : {},
|
|
64
66
|
ran: {
|
|
@@ -71,7 +73,13 @@ var e = /* @__PURE__ */ RegExp("\\u2028", "g"), t = /* @__PURE__ */ RegExp("\\u2
|
|
|
71
73
|
...r ? { segments: e.deferredSegmentIds } : {}
|
|
72
74
|
} } : {}
|
|
73
75
|
};
|
|
74
|
-
}, w = (e) => `<script type="application/json" id="${S}">${n(C(e))}<\/script>`, T = /* @__PURE__ */ new Map(), E = (e
|
|
76
|
+
}, w = (e) => `<script type="application/json" id="${S}">${n(C(e))}<\/script>`, T = /* @__PURE__ */ new Map(), E = (e) => {
|
|
77
|
+
let t = e;
|
|
78
|
+
try {
|
|
79
|
+
t = decodeURIComponent(t);
|
|
80
|
+
} catch {}
|
|
81
|
+
return t.endsWith("/index.html") && (t = t.slice(0, -10)), t.length > 1 && t.endsWith("/") && (t = t.slice(0, -1)), t.length === 0 ? "/" : t;
|
|
82
|
+
}, D = (e, t) => {
|
|
75
83
|
if (!e) return null;
|
|
76
84
|
let n;
|
|
77
85
|
try {
|
|
@@ -80,22 +88,24 @@ var e = /* @__PURE__ */ RegExp("\\u2028", "g"), t = /* @__PURE__ */ RegExp("\\u2
|
|
|
80
88
|
return null;
|
|
81
89
|
}
|
|
82
90
|
if (typeof n != "object" || !n || Array.isArray(n)) return null;
|
|
83
|
-
let r = n
|
|
84
|
-
|
|
91
|
+
let r = n;
|
|
92
|
+
if (typeof r.path != "string" || E(r.path) !== E(t)) return null;
|
|
93
|
+
let i = new Set(r.ran?.segments ?? []), a = /* @__PURE__ */ new Map();
|
|
94
|
+
for (let e of i) a.set(e, O(r.segments?.[String(e)], r.deferred?.segments?.[String(e)]));
|
|
85
95
|
return {
|
|
86
|
-
page:
|
|
96
|
+
page: O(r.page, r.deferred?.page),
|
|
87
97
|
pageRan: r.ran?.page === !0,
|
|
88
98
|
segments: a.size > 0 ? a : T,
|
|
89
99
|
pageClientOnly: r.pageClientOnly === !0,
|
|
90
100
|
pathname: t
|
|
91
101
|
};
|
|
92
|
-
},
|
|
102
|
+
}, O = (e, t) => {
|
|
93
103
|
if (!t) return e;
|
|
94
104
|
let n = g(), r = { ...e ?? {} };
|
|
95
105
|
for (let [e, i] of Object.entries(t)) r[e] = c(n.get(i), i);
|
|
96
106
|
return r;
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
},
|
|
107
|
+
}, k = null, A = (e) => {
|
|
108
|
+
k = e;
|
|
109
|
+
}, j = () => k;
|
|
100
110
|
//#endregion
|
|
101
|
-
export { n as _, w as a, i as c, m as d, o as f, p as g, y as h,
|
|
111
|
+
export { n as _, w as a, i as c, m as d, o as f, p as g, y as h, j as i, h as l, b as m, C as n, A as o, a as p, D as r, x as s, S as t, l as u };
|