@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/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-Gsn3ouYx.js";
6
- import { c as re, d as ie, h as ae, l as oe, p as se, u as ce } from "./routerState-DpUqogK8.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, _ as A, a as j, b as M, c as N, d as P, f as F, g as I, h as L, i as R, j as z, k as he, l as ge, m as _e, n as ve, o as ye, p as be, r as xe, s as Se, t as Ce, u as we, v as Te, w as Ee, x as De, y as Oe, z as ke } from "./serverContext-COzippNt.js";
8
- import { Component as Ae, Suspense as je, createElement as B, use as Me, useCallback as Ne, useContext as Pe, useSyncExternalStore as Fe } from "react";
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 Ie = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PURE__ */ H(je, {
13
+ var Le = ({ value: e, fallback: t, children: n, errorFallback: r }) => /* @__PURE__ */ H(Me, {
14
14
  fallback: t,
15
- children: /* @__PURE__ */ H(Re, {
15
+ children: /* @__PURE__ */ H(ze, {
16
16
  errorFallback: r,
17
- children: /* @__PURE__ */ H(Le, {
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 } }), Le = ({ value: e, errorFallback: t, children: n }) => {
24
- let r = Me(e), i = ce(e), a = ae(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
- }, Re = class extends Ae {
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 }), ze = ({ loader: e, children: t }) => B(K.Provider, { value: { loader: e } }, t), q = [
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
- ], Be = (e, t, n, r) => {
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
- }, Ve = ({ 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 = Pe(K).loader, p = s ?? 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 } = Be(p, e, n, i), g = c === "blur" && l ? {
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
- }, He = ({ to: e, children: t, className: n }) => B("a", {
88
+ }, Ue = ({ to: e, children: t, className: n }) => B("a", {
89
89
  href: e,
90
90
  className: n
91
- }, t), Ue = {
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
- }, We = {
102
+ }, Ge = {
103
103
  maxWidth: "48rem",
104
104
  margin: "0 auto",
105
105
  padding: "2rem 1.5rem",
106
106
  width: "100%"
107
- }, Ge = (e) => {
108
- let { brand: t, topNav: n, children: r, pathname: i, footer: a, breadcrumbs: o, headerRight: s } = e, c = e.Link ?? He, l = B("nav", {
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: Ue
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: We
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", Y = 31536e3, Ke = () => {
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
- }, qe = () => {
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" ? qe() ? "dark" : "light" : e, Z = 0, Q = /* @__PURE__ */ new Set(), $ = () => {
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
- }, Je = (e) => {
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
- }, Ye = () => {
194
- let e = Ke();
193
+ }, Xe = () => {
194
+ let e = Je();
195
195
  return `${Z}:${e}:${X(e)}`;
196
- }, Xe = () => "0:system:light", Ze = () => {
197
- let [, e, t] = Fe(Je, Ye, Xe).split(":");
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: Ne((e) => {
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=${Y}; SameSite=Lax`, document.documentElement.classList.toggle("dark", X(e) === "dark");
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
- }, Qe = "framework-web";
208
+ }, $e = "framework-web";
209
209
  //#endregion
210
- export { t as AppClientsContext, Ie as Await, Ge as BlogLayout, p as FallbackStringsProvider, Ve as Image, ze as ImageConfigProvider, ye as Link, Se as LoaderCache, N as LoaderDataContext, i as NavigationIndicator, me as NotFoundError, ge as PAGE_SLOT_ATTR, we as PageSlot, P as PlainLink, o as ReconnectContext, y as RedirectError, F as Router, be as RouterContext, Ce as ServerRequestContext, ve as ServerRequestProvider, J as THEME_COOKIE, Qe as WEB_NAME, _e as compileRoute, d as defaultFallbackStrings, re as defer, L as externalUrl, I as findNotFound, c as formatPrintf, ee as getIslandComponent, k as getRouteSnapshot, g as getStatuses, te as hydrateIslandsOnPage, a as installBrowserConsoleBridge, r as installServerLogRelay, se as isDeferredLoaderResult, b as isNotFound, T as isRedirect, _ as island, A as lazyPageRoute, Te as loaderCacheKey, Oe as matchRoute, ne as mount, ke as notFound, M as pageRoute, xe as parseCookieHeader, G as passthroughImageLoader, De as preloadRouteModule, f as pushStatus, ue as redirect, s as registerClientTrace, E as resolveAnchorNavigation, de as resolveMeta, Ee as segmentLoaderKey, v as setRouteSnapshot, D as sortRoutesByPriority, O as subscribeRouteSnapshot, m as subscribeStatuses, l as subscribeTraceErrors, n as useAppClient, pe as useBlocker, h as useFallbackStrings, fe as useLoaderData, C as useLocation, he as useNavigate, le as useParams, z as usePrefetch, u as useReconnect, R as useSearchParams, j as useServerRequest, x as useSetSearchParams, Ze as useTheme, S as withHash, w as withQuery };
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-DpUqogK8.js";
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(n(f.textContent, window.location.pathname));
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-Gsn3ouYx.js";
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 (n !== "ssr") 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.`);
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, t) => {
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, i = new Set(r.ran?.segments ?? []), a = /* @__PURE__ */ new Map();
84
- for (let e of i) a.set(e, D(r.segments?.[String(e)], r.deferred?.segments?.[String(e)]));
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: D(r.page, r.deferred?.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
- }, D = (e, t) => {
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
- }, O = null, k = (e) => {
98
- O = e;
99
- }, A = () => O;
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, A as i, h as l, b as m, C as n, k as o, a as p, E as r, x as s, S as t, l as u };
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 };