@voltro/web 0.37.0 → 0.39.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 +316 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/{frameworkBoot--fOA34nd.js → frameworkBoot-Tso-IjA7.js} +113 -193
- package/dist/frameworkBoot.d.ts +4 -32
- package/dist/frameworkBoot.js +1 -1
- package/dist/index.d.ts +38 -0
- package/dist/index.js +7 -7
- package/dist/{mount-BKP99m_W.js → mount-BTAQ-8Vl.js} +7 -7
- package/dist/mount.js +1 -1
- package/dist/{serverContext-7toyzR70.js → serverContext-38JTbYPa.js} +96 -93
- package/dist/ssr.d.ts +41 -0
- package/dist/ssr.js +32 -32
- package/package.json +3 -3
|
@@ -2,19 +2,19 @@ import { t as e } from "./globalContext-d4A-ugDg.js";
|
|
|
2
2
|
import { AppClientsContext as t } from "./hooks.js";
|
|
3
3
|
import { c as n, l as r, r as i, s as a, u as o } from "./defaultFallbacks-B4Ak-R6R.js";
|
|
4
4
|
import { useCallback as s, useContext as c, useEffect as l, useRef as u, useState as d, useSyncExternalStore as f } from "react";
|
|
5
|
-
import { FrameworkRuntimesProvider as p, buildApiRuntime as m, ssrClientProxy as
|
|
6
|
-
import { Fragment as
|
|
5
|
+
import { FrameworkRuntimesProvider as p, buildApiRuntime as m, ssrClientProxy as ee, ssrStubHandle as te, startApiSupervisor as h, subscribeClientTraces as ne } from "@voltro/client";
|
|
6
|
+
import { Fragment as re, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
7
7
|
//#region src/reconnect.ts
|
|
8
|
-
var
|
|
8
|
+
var v = e("reconnect", null), y = () => c(v) ?? (() => {}), b = 150, x = 220, S = () => {
|
|
9
9
|
let e = f(o, n, n).some((e) => e.kind === "loading" || e.kind === "reconnecting"), [t, r] = d(!1);
|
|
10
10
|
return l(() => {
|
|
11
11
|
if (!e) {
|
|
12
12
|
r(!1);
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
let t = setTimeout(() => r(!0),
|
|
15
|
+
let t = setTimeout(() => r(!0), b);
|
|
16
16
|
return () => clearTimeout(t);
|
|
17
|
-
}, [e]), /* @__PURE__ */
|
|
17
|
+
}, [e]), /* @__PURE__ */ _("div", {
|
|
18
18
|
"aria-hidden": "true",
|
|
19
19
|
"data-voltro-nav-indicator": "",
|
|
20
20
|
style: {
|
|
@@ -25,7 +25,7 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
25
25
|
pointerEvents: "none",
|
|
26
26
|
opacity: +!!t,
|
|
27
27
|
transform: t ? "translateY(0) scale(1)" : "translateY(4px) scale(0.96)",
|
|
28
|
-
transition: `opacity ${
|
|
28
|
+
transition: `opacity ${x}ms ease, transform ${x}ms ease`,
|
|
29
29
|
display: "grid",
|
|
30
30
|
placeItems: "center",
|
|
31
31
|
width: 34,
|
|
@@ -37,137 +37,51 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
37
37
|
border: "1px solid color-mix(in oklch, canvastext 12%, transparent)",
|
|
38
38
|
boxShadow: "0 4px 14px color-mix(in oklch, canvastext 16%, transparent)"
|
|
39
39
|
},
|
|
40
|
-
children: [/* @__PURE__ */
|
|
40
|
+
children: [/* @__PURE__ */ g("span", { "data-voltro-nav-spinner": "" }), /* @__PURE__ */ g("style", { children: C })]
|
|
41
41
|
});
|
|
42
|
-
},
|
|
42
|
+
}, C = "\n@keyframes voltroNavSpin { to { transform: rotate(360deg); } }\n[data-voltro-nav-spinner] {\n width: 16px;\n height: 16px;\n border-radius: 50%;\n border: 2px solid color-mix(in oklch, canvastext 22%, transparent);\n border-top-color: color-mix(in oklch, canvastext 78%, transparent);\n animation: voltroNavSpin 0.7s linear infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n [data-voltro-nav-spinner] { animation-duration: 1.6s; }\n}\n", w = 2e3, T = () => typeof window < "u" && !1, ie = () => typeof window > "u" ? null : `${window.location.origin}/`, E = 2e4, D = "voltro:wedge-reload-at", ae = () => {
|
|
43
43
|
try {
|
|
44
|
-
let e = Number(window.sessionStorage.getItem(
|
|
45
|
-
if (t - e <
|
|
46
|
-
window.sessionStorage.setItem(
|
|
44
|
+
let e = Number(window.sessionStorage.getItem(D) ?? "0"), t = Date.now();
|
|
45
|
+
if (t - e < E) return;
|
|
46
|
+
window.sessionStorage.setItem(D, String(t));
|
|
47
47
|
} catch {}
|
|
48
48
|
window.location.reload();
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
healthPollHandle: null,
|
|
57
|
-
subjectMayHaveChanged: !1
|
|
58
|
-
}), O = (e) => {
|
|
59
|
-
e.healthPollHandle !== null && (clearInterval(e.healthPollHandle), e.healthPollHandle = null);
|
|
60
|
-
}, k = (e) => {
|
|
61
|
-
e.cache.destroy(e.runtime), e.runtime.dispose();
|
|
62
|
-
}, ce = (e) => {
|
|
63
|
-
let t = e.apis, n = e.buildClient, i = e.onChange, a = e.retryDelayMs ?? re, o = e.stableWindowMs ?? 5e3, s = e.scheduler?.setTimeout ?? ((e, t) => setTimeout(e, t)), c = e.scheduler?.clearTimeout ?? ((e) => {
|
|
64
|
-
clearTimeout(e);
|
|
65
|
-
}), l = e.scheduler?.queueMicrotask ?? queueMicrotask, u = /* @__PURE__ */ new Map();
|
|
66
|
-
for (let e of t) u.set(e.name, D());
|
|
67
|
-
let d = !1, f = /* @__PURE__ */ new Set(), p = (e, t) => {
|
|
68
|
-
let n = s(() => {
|
|
69
|
-
f.delete(n), e();
|
|
70
|
-
}, t);
|
|
71
|
-
return f.add(n), n;
|
|
72
|
-
}, m = () => {
|
|
73
|
-
if (d) return;
|
|
74
|
-
let e = /* @__PURE__ */ new Map();
|
|
75
|
-
for (let [t, n] of u) n.resolved && e.set(t, n.resolved);
|
|
76
|
-
i(e, t.every((t) => e.has(t.name)));
|
|
77
|
-
}, h = (e) => {
|
|
78
|
-
if (d) return;
|
|
79
|
-
let t = u.get(e.name);
|
|
80
|
-
if (!t) return;
|
|
81
|
-
t.failureCount += 1;
|
|
82
|
-
let n = a(t.failureCount), i = ++t.retryToken;
|
|
83
|
-
if (t.reconnectStatusDispose ||= r({
|
|
84
|
-
id: `voltro:supervisor:${e.name}`,
|
|
85
|
-
kind: "reconnecting",
|
|
86
|
-
label: "Reconnecting…"
|
|
87
|
-
}), ie() && t.everOpened && t.failureCount >= w && t.healthPollHandle === null) {
|
|
88
|
-
let e = ae();
|
|
89
|
-
e && (t.healthPollHandle = setInterval(() => {
|
|
49
|
+
}, oe = () => {
|
|
50
|
+
if (T()) return {
|
|
51
|
+
afterFailures: 2,
|
|
52
|
+
arm: () => {
|
|
53
|
+
let e = ie();
|
|
54
|
+
if (e === null) return () => {};
|
|
55
|
+
let t = setInterval(() => {
|
|
90
56
|
fetch(e, {
|
|
91
57
|
method: "GET",
|
|
92
58
|
cache: "no-store",
|
|
93
|
-
signal: AbortSignal.timeout(
|
|
59
|
+
signal: AbortSignal.timeout(w)
|
|
94
60
|
}).then((e) => {
|
|
95
|
-
e.status < 500 &&
|
|
61
|
+
e.status < 500 && ae();
|
|
96
62
|
}).catch(() => {});
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
p(() => {
|
|
100
|
-
d || t.retryToken === i && (t.generation += 1, g(e));
|
|
101
|
-
}, n);
|
|
102
|
-
}, g = async (e) => {
|
|
103
|
-
if (d) return;
|
|
104
|
-
let t = u.get(e.name);
|
|
105
|
-
if (!t) return;
|
|
106
|
-
let r = t.generation, i = () => {
|
|
107
|
-
if (d || t.generation !== r) return;
|
|
108
|
-
t.everOpened = !0, O(t), t.retryToken++;
|
|
109
|
-
let e = t.failureCount;
|
|
110
|
-
p(() => {
|
|
111
|
-
d || t.failureCount === e && (t.failureCount = 0);
|
|
112
|
-
}, o);
|
|
113
|
-
}, a = (n) => {
|
|
114
|
-
d || t.generation !== r || h(e);
|
|
115
|
-
};
|
|
116
|
-
try {
|
|
117
|
-
let o = await n(e, r, i, a);
|
|
118
|
-
if (d || t.generation !== r) {
|
|
119
|
-
k(o);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
let s = t.resolved;
|
|
123
|
-
s && !t.subjectMayHaveChanged && o.cache.seedStaleFrom(s.cache), t.subjectMayHaveChanged = !1, t.resolved = o, t.reconnectStatusDispose &&= (t.reconnectStatusDispose(), null), m(), s && k(s);
|
|
124
|
-
} catch {
|
|
125
|
-
if (d || t.generation !== r) return;
|
|
126
|
-
h(e);
|
|
63
|
+
}, w);
|
|
64
|
+
return () => clearInterval(t);
|
|
127
65
|
}
|
|
128
66
|
};
|
|
129
|
-
|
|
130
|
-
dispose: () => {
|
|
131
|
-
d = !0;
|
|
132
|
-
},
|
|
133
|
-
reconnect: () => {}
|
|
134
|
-
}) : (l(() => {
|
|
135
|
-
if (!d) for (let e of t) g(e);
|
|
136
|
-
}), {
|
|
137
|
-
dispose: () => {
|
|
138
|
-
if (!d) {
|
|
139
|
-
d = !0;
|
|
140
|
-
for (let e of f) c(e);
|
|
141
|
-
f.clear();
|
|
142
|
-
for (let [, e] of u) e.resolved && k(e.resolved), e.reconnectStatusDispose && e.reconnectStatusDispose(), O(e);
|
|
143
|
-
u.clear();
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
reconnect: () => {
|
|
147
|
-
if (!d) for (let e of t) {
|
|
148
|
-
let t = u.get(e.name);
|
|
149
|
-
t && (t.subjectMayHaveChanged = !0, t.retryToken += 1, t.generation += 1, t.failureCount = 0, O(t), g(e));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}, A = {
|
|
67
|
+
}, O = {
|
|
154
68
|
log: console.log.bind(console),
|
|
155
69
|
info: console.info.bind(console),
|
|
156
70
|
warn: console.warn.bind(console),
|
|
157
71
|
error: console.error.bind(console),
|
|
158
72
|
debug: console.debug.bind(console)
|
|
159
|
-
},
|
|
73
|
+
}, k = 200, A = 400, j = 20, M = 1e3, N = (e) => {
|
|
160
74
|
if (typeof e == "string") return e;
|
|
161
75
|
if (e === void 0) return "undefined";
|
|
162
76
|
if (e === null) return "null";
|
|
163
77
|
if (e instanceof Error) return e.stack ?? e.message;
|
|
164
78
|
if (typeof e == "object") try {
|
|
165
|
-
return JSON.stringify(e,
|
|
79
|
+
return JSON.stringify(e, se());
|
|
166
80
|
} catch {
|
|
167
81
|
return Object.prototype.toString.call(e);
|
|
168
82
|
}
|
|
169
83
|
return String(e);
|
|
170
|
-
},
|
|
84
|
+
}, se = () => {
|
|
171
85
|
let e = /* @__PURE__ */ new WeakSet();
|
|
172
86
|
return (t, n) => {
|
|
173
87
|
if (typeof n == "object" && n) {
|
|
@@ -176,20 +90,20 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
176
90
|
}
|
|
177
91
|
return n;
|
|
178
92
|
};
|
|
179
|
-
},
|
|
93
|
+
}, P = (e, t) => e.length > t ? `${e.slice(0, t)}…` : e, F = /%[sdifoOc]/g, I = (e) => {
|
|
180
94
|
if (e.length === 0) return {
|
|
181
95
|
message: "",
|
|
182
96
|
rest: []
|
|
183
97
|
};
|
|
184
98
|
let t = e[0];
|
|
185
|
-
if (typeof t != "string" || !
|
|
186
|
-
message:
|
|
99
|
+
if (typeof t != "string" || !F.test(t)) return {
|
|
100
|
+
message: N(t),
|
|
187
101
|
rest: e.slice(1)
|
|
188
102
|
};
|
|
189
|
-
|
|
103
|
+
F.lastIndex = 0;
|
|
190
104
|
let n = 1;
|
|
191
105
|
return {
|
|
192
|
-
message: t.replace(
|
|
106
|
+
message: t.replace(F, (t) => {
|
|
193
107
|
if (t === "%c") return n++, "";
|
|
194
108
|
if (n >= e.length) return t;
|
|
195
109
|
let r = e[n++];
|
|
@@ -205,21 +119,21 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
205
119
|
return Number.isFinite(e) ? String(e) : "NaN";
|
|
206
120
|
}
|
|
207
121
|
case "%o":
|
|
208
|
-
case "%O": return
|
|
122
|
+
case "%O": return N(r);
|
|
209
123
|
default: return t;
|
|
210
124
|
}
|
|
211
125
|
}),
|
|
212
126
|
rest: e.slice(n)
|
|
213
127
|
};
|
|
214
|
-
},
|
|
215
|
-
let t = e.flushAfterMs ??
|
|
128
|
+
}, L = (e) => {
|
|
129
|
+
let t = e.flushAfterMs ?? A, n = `${e.baseUrl.replace(/\/+$/, "")}/_voltro/inspect/clientLog`, r = [], i = null, a = !1, o = () => {
|
|
216
130
|
if (i !== null && (clearTimeout(i), i = null), r.length === 0) return;
|
|
217
131
|
let t = r;
|
|
218
132
|
r = [];
|
|
219
133
|
let a = {
|
|
220
134
|
app: e.appName,
|
|
221
135
|
page: typeof window < "u" ? window.location.pathname : void 0,
|
|
222
|
-
ua: typeof navigator < "u" ?
|
|
136
|
+
ua: typeof navigator < "u" ? P(navigator.userAgent, 200) : void 0,
|
|
223
137
|
entries: t
|
|
224
138
|
};
|
|
225
139
|
try {
|
|
@@ -235,11 +149,11 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
235
149
|
i === null && (i = setTimeout(o, t));
|
|
236
150
|
}, c = (e, t) => {
|
|
237
151
|
if (a) return;
|
|
238
|
-
r.length >=
|
|
152
|
+
r.length >= k && r.shift();
|
|
239
153
|
let n = t.find((e) => e instanceof Error), i = t.find((e) => typeof e == "object" && !!e && "componentStack" in e), c = typeof i?.componentStack == "string" ? i.componentStack : void 0, l = t[0] instanceof Error ? {
|
|
240
154
|
message: t[0].message,
|
|
241
155
|
rest: t.slice(1)
|
|
242
|
-
} :
|
|
156
|
+
} : I(t), u = P(l.message, M), d = l.rest.filter((e) => e !== n && e !== i).map((e) => P(N(e), M)), f;
|
|
243
157
|
n ? (f = n.stack ?? n.message, c && (f += `\n\nComponent stack:${c}`)) : e === "error" && (f = (/* @__PURE__ */ Error()).stack);
|
|
244
158
|
let p = {
|
|
245
159
|
ts: Date.now(),
|
|
@@ -248,29 +162,29 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
248
162
|
...d.length > 0 ? { args: d } : {},
|
|
249
163
|
...f === void 0 ? {} : { stack: f }
|
|
250
164
|
};
|
|
251
|
-
r.push(p), r.length >=
|
|
165
|
+
r.push(p), r.length >= j ? o() : s();
|
|
252
166
|
}, l = (e) => (...t) => {
|
|
253
|
-
|
|
167
|
+
O[e](...t), c(e, t);
|
|
254
168
|
};
|
|
255
169
|
console.log = l("log"), console.info = l("info"), console.warn = l("warn"), console.error = l("error"), console.debug = l("debug");
|
|
256
170
|
let u = () => {
|
|
257
171
|
o();
|
|
258
172
|
};
|
|
259
173
|
return typeof window < "u" && (window.addEventListener("beforeunload", u), window.addEventListener("pagehide", u)), { dispose: () => {
|
|
260
|
-
a = !0, o(), i !== null && (clearTimeout(i), i = null), console.log =
|
|
174
|
+
a = !0, o(), i !== null && (clearTimeout(i), i = null), console.log = O.log, console.info = O.info, console.warn = O.warn, console.error = O.error, console.debug = O.debug, typeof window < "u" && (window.removeEventListener("beforeunload", u), window.removeEventListener("pagehide", u));
|
|
261
175
|
} };
|
|
262
|
-
},
|
|
263
|
-
if (!
|
|
264
|
-
let e =
|
|
265
|
-
e !== void 0 &&
|
|
176
|
+
}, R = 500, z = /* @__PURE__ */ new Set(), B = (e) => {
|
|
177
|
+
if (!z.has(e) && (z.add(e), z.size > R)) {
|
|
178
|
+
let e = z.values().next().value;
|
|
179
|
+
e !== void 0 && z.delete(e);
|
|
266
180
|
}
|
|
267
|
-
},
|
|
268
|
-
|
|
269
|
-
}),
|
|
270
|
-
for (let t of
|
|
181
|
+
}, V = /* @__PURE__ */ new Set(), H = (e) => (V.add(e), () => {
|
|
182
|
+
V.delete(e);
|
|
183
|
+
}), U = (e) => {
|
|
184
|
+
for (let t of V) try {
|
|
271
185
|
t(e);
|
|
272
186
|
} catch {}
|
|
273
|
-
},
|
|
187
|
+
}, W = {
|
|
274
188
|
log: "log",
|
|
275
189
|
info: "info",
|
|
276
190
|
warn: "warn",
|
|
@@ -289,21 +203,21 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
289
203
|
try {
|
|
290
204
|
let n = JSON.parse(t.data).payload;
|
|
291
205
|
if (!n || typeof n.message != "string" || n.scope === "client") return;
|
|
292
|
-
let r = n.level === void 0 ? "log" :
|
|
293
|
-
|
|
206
|
+
let r = n.level === void 0 ? "log" : W[n.level], i = n.scope ? ` ${n.scope}` : "";
|
|
207
|
+
O[r](`%c[server ${e.originLabel}${i}]%c ${n.message}`, G[r], "", ...n.fields ? [n.fields] : []);
|
|
294
208
|
} catch {}
|
|
295
209
|
}), n.addEventListener("trace", (t) => {
|
|
296
210
|
try {
|
|
297
211
|
let n = JSON.parse(t.data).payload;
|
|
298
|
-
if (!n || n.status !== "error" || typeof n.traceId != "string" || !
|
|
212
|
+
if (!n || n.status !== "error" || typeof n.traceId != "string" || !z.has(n.traceId)) return;
|
|
299
213
|
let r = n.name ?? "span", i = n.statusMessage && n.statusMessage.length > 0 ? n.statusMessage : `${r} failed`;
|
|
300
|
-
|
|
214
|
+
U({
|
|
301
215
|
traceId: n.traceId,
|
|
302
216
|
spanName: r,
|
|
303
217
|
api: e.originLabel,
|
|
304
218
|
message: i,
|
|
305
219
|
ts: Date.now()
|
|
306
|
-
}),
|
|
220
|
+
}), O.error(`%c[trace ${e.originLabel}]%c ${r} failed — ${i} (trace ${n.traceId})`, G.error, "");
|
|
307
221
|
} catch {}
|
|
308
222
|
}), n.addEventListener("error", () => {
|
|
309
223
|
n && n.readyState === EventSource.CLOSED && (n = null, !r && i === null && (i = setTimeout(() => {
|
|
@@ -322,20 +236,20 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
322
236
|
muted: "oklch(0.65 0.012 285)",
|
|
323
237
|
danger: "oklch(0.7 0.21 22)",
|
|
324
238
|
dangerDim: "oklch(0.5 0.18 22 / 25%)"
|
|
325
|
-
}, J = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace",
|
|
239
|
+
}, J = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace", ce = "ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif", le = 0, ue = () => {
|
|
326
240
|
let [e, t] = d([]);
|
|
327
|
-
if (l(() =>
|
|
241
|
+
if (l(() => H((e) => {
|
|
328
242
|
t((t) => {
|
|
329
243
|
if (t.some((t) => t.traceId === e.traceId && t.spanName === e.spanName)) return t;
|
|
330
244
|
let n = [...t, {
|
|
331
245
|
...e,
|
|
332
|
-
id: ++
|
|
246
|
+
id: ++le
|
|
333
247
|
}];
|
|
334
248
|
return n.length > 4 ? n.slice(n.length - 4) : n;
|
|
335
249
|
});
|
|
336
250
|
}), []), e.length === 0) return null;
|
|
337
251
|
let n = (e) => t((t) => t.filter((t) => t.id !== e));
|
|
338
|
-
return /* @__PURE__ */
|
|
252
|
+
return /* @__PURE__ */ g("div", {
|
|
339
253
|
style: {
|
|
340
254
|
position: "fixed",
|
|
341
255
|
right: 16,
|
|
@@ -345,17 +259,17 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
345
259
|
flexDirection: "column",
|
|
346
260
|
gap: 10,
|
|
347
261
|
maxWidth: 380,
|
|
348
|
-
fontFamily:
|
|
262
|
+
fontFamily: ce,
|
|
349
263
|
pointerEvents: "none"
|
|
350
264
|
},
|
|
351
|
-
children: e.map((e) => /* @__PURE__ */
|
|
265
|
+
children: e.map((e) => /* @__PURE__ */ g(de, {
|
|
352
266
|
toast: e,
|
|
353
267
|
onDismiss: () => n(e.id)
|
|
354
268
|
}, e.id))
|
|
355
269
|
});
|
|
356
|
-
},
|
|
270
|
+
}, de = ({ toast: e, onDismiss: t }) => {
|
|
357
271
|
let [n, r] = d(!1), a = `voltro logs --trace ${e.traceId}`;
|
|
358
|
-
return /* @__PURE__ */
|
|
272
|
+
return /* @__PURE__ */ _("div", {
|
|
359
273
|
style: {
|
|
360
274
|
pointerEvents: "auto",
|
|
361
275
|
background: q.card,
|
|
@@ -369,14 +283,14 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
369
283
|
lineHeight: 1.45
|
|
370
284
|
},
|
|
371
285
|
children: [
|
|
372
|
-
/* @__PURE__ */
|
|
286
|
+
/* @__PURE__ */ _("div", {
|
|
373
287
|
style: {
|
|
374
288
|
display: "flex",
|
|
375
289
|
alignItems: "center",
|
|
376
290
|
justifyContent: "space-between",
|
|
377
291
|
gap: 8
|
|
378
292
|
},
|
|
379
|
-
children: [/* @__PURE__ */
|
|
293
|
+
children: [/* @__PURE__ */ g("span", {
|
|
380
294
|
style: {
|
|
381
295
|
color: q.danger,
|
|
382
296
|
fontWeight: 600,
|
|
@@ -384,7 +298,7 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
384
298
|
letterSpacing: .3
|
|
385
299
|
},
|
|
386
300
|
children: "⚠ Backend error"
|
|
387
|
-
}), /* @__PURE__ */
|
|
301
|
+
}), /* @__PURE__ */ g("button", {
|
|
388
302
|
onClick: t,
|
|
389
303
|
"aria-label": "Dismiss",
|
|
390
304
|
style: {
|
|
@@ -399,14 +313,14 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
399
313
|
children: "×"
|
|
400
314
|
})]
|
|
401
315
|
}),
|
|
402
|
-
/* @__PURE__ */
|
|
316
|
+
/* @__PURE__ */ _("div", {
|
|
403
317
|
style: {
|
|
404
318
|
marginTop: 6,
|
|
405
319
|
color: q.muted,
|
|
406
320
|
fontSize: 11.5
|
|
407
321
|
},
|
|
408
322
|
children: [
|
|
409
|
-
/* @__PURE__ */
|
|
323
|
+
/* @__PURE__ */ g("span", {
|
|
410
324
|
style: {
|
|
411
325
|
fontFamily: J,
|
|
412
326
|
color: q.fg
|
|
@@ -414,13 +328,13 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
414
328
|
children: e.api
|
|
415
329
|
}),
|
|
416
330
|
" · ",
|
|
417
|
-
/* @__PURE__ */
|
|
331
|
+
/* @__PURE__ */ g("span", {
|
|
418
332
|
style: { fontFamily: J },
|
|
419
333
|
children: e.spanName
|
|
420
334
|
})
|
|
421
335
|
]
|
|
422
336
|
}),
|
|
423
|
-
/* @__PURE__ */
|
|
337
|
+
/* @__PURE__ */ g("div", {
|
|
424
338
|
style: {
|
|
425
339
|
marginTop: 4,
|
|
426
340
|
color: q.fg,
|
|
@@ -428,7 +342,7 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
428
342
|
},
|
|
429
343
|
children: e.message
|
|
430
344
|
}),
|
|
431
|
-
/* @__PURE__ */
|
|
345
|
+
/* @__PURE__ */ g("button", {
|
|
432
346
|
onClick: () => {
|
|
433
347
|
i(a).then((e) => {
|
|
434
348
|
e !== "failed" && (r(!0), setTimeout(() => r(!1), 1500));
|
|
@@ -453,14 +367,14 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
453
367
|
})
|
|
454
368
|
]
|
|
455
369
|
});
|
|
456
|
-
},
|
|
370
|
+
}, fe = (e) => {
|
|
457
371
|
try {
|
|
458
372
|
let t = new URL(e);
|
|
459
373
|
return `${t.protocol === "wss:" ? "https:" : "http:"}//${t.host}`;
|
|
460
374
|
} catch {
|
|
461
375
|
return "";
|
|
462
376
|
}
|
|
463
|
-
}, Y = (e, t) => /^wss?:\/\//i.test(e) || /^https?:\/\//i.test(e) ?
|
|
377
|
+
}, Y = (e, t) => /^wss?:\/\//i.test(e) || /^https?:\/\//i.test(e) ? fe(e) : `/_voltro/api/${t}`, pe = typeof performance < "u" ? performance.now() : Date.now(), X = () => {
|
|
464
378
|
if (typeof window > "u") return !1;
|
|
465
379
|
try {
|
|
466
380
|
if (window.localStorage?.getItem("framework_debug") === "1") return !0;
|
|
@@ -474,10 +388,10 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
474
388
|
}.DEV === !0;
|
|
475
389
|
}, Z = (e, ...t) => {
|
|
476
390
|
if (!X()) return;
|
|
477
|
-
let n = ((typeof performance < "u" ? performance.now() : Date.now()) -
|
|
391
|
+
let n = ((typeof performance < "u" ? performance.now() : Date.now()) - pe).toFixed(0).padStart(6, " ");
|
|
478
392
|
console.log(`[fw ${e} +${n}ms]`, ...t);
|
|
479
|
-
}, Q = 3e3,
|
|
480
|
-
let o = ++
|
|
393
|
+
}, Q = 3e3, me = 0, he = (e, t, n, r) => (i, a) => {
|
|
394
|
+
let o = ++me;
|
|
481
395
|
Z(e, `ws#${o} create gen=${t} url=${i}`);
|
|
482
396
|
let s = new globalThis.WebSocket(i, a), c = !1, l = !1, u = (e) => {
|
|
483
397
|
l || (l = !0, r(e));
|
|
@@ -495,7 +409,7 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
495
409
|
} catch {}
|
|
496
410
|
}
|
|
497
411
|
}, Q), s;
|
|
498
|
-
},
|
|
412
|
+
}, ge = async (e, t, n, r) => {
|
|
499
413
|
Z(e.name, `build gen=${t}: making runtime`);
|
|
500
414
|
try {
|
|
501
415
|
let i = await m({
|
|
@@ -503,39 +417,45 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
503
417
|
wsUrl: e.wsUrl,
|
|
504
418
|
group: e.group,
|
|
505
419
|
headers: e.headers,
|
|
506
|
-
webSocketConstructor:
|
|
420
|
+
webSocketConstructor: he(e.name, t, n, r)
|
|
507
421
|
});
|
|
508
422
|
return Z(e.name, `build gen=${t}: runtime resolved`), i;
|
|
509
423
|
} catch (n) {
|
|
510
424
|
throw Z(e.name, `build gen=${t}: runtime FAILED, disposing`, n.message ?? n), n;
|
|
511
425
|
}
|
|
512
|
-
}, $ = ({ apis: e, children: n, chrome:
|
|
513
|
-
let [
|
|
426
|
+
}, $ = ({ apis: e, children: n, chrome: i }) => {
|
|
427
|
+
let [o, c] = d(() => ({
|
|
514
428
|
initialized: e.length === 0,
|
|
515
429
|
clients: /* @__PURE__ */ new Map()
|
|
516
|
-
})),
|
|
517
|
-
|
|
518
|
-
}, []), [
|
|
430
|
+
})), f = u(null), m = s(() => {
|
|
431
|
+
f.current?.reconnect();
|
|
432
|
+
}, []), [y, b] = d(!1);
|
|
519
433
|
l(() => {
|
|
520
434
|
b(!0);
|
|
521
435
|
}, []), l(() => {
|
|
522
|
-
let t =
|
|
436
|
+
let t = oe(), n = h({
|
|
523
437
|
apis: e,
|
|
524
|
-
buildClient:
|
|
438
|
+
buildClient: ge,
|
|
525
439
|
onChange: (e, t) => {
|
|
526
|
-
|
|
440
|
+
c({
|
|
527
441
|
clients: e,
|
|
528
442
|
initialized: t
|
|
529
443
|
});
|
|
530
|
-
}
|
|
444
|
+
},
|
|
445
|
+
onReconnecting: (e) => r({
|
|
446
|
+
id: `voltro:supervisor:${e}`,
|
|
447
|
+
kind: "reconnecting",
|
|
448
|
+
label: "Reconnecting…"
|
|
449
|
+
}),
|
|
450
|
+
...t ? { wedgeBackstop: t } : {}
|
|
531
451
|
});
|
|
532
|
-
return
|
|
533
|
-
|
|
452
|
+
return f.current = n, () => {
|
|
453
|
+
n.dispose(), f.current === n && (f.current = null);
|
|
534
454
|
};
|
|
535
455
|
}, [e]), l(() => {
|
|
536
456
|
if (!X() || typeof window > "u") return;
|
|
537
457
|
let t = [], n = [], r = e[0]?.name ?? "web";
|
|
538
|
-
t.push(
|
|
458
|
+
t.push(L({
|
|
539
459
|
baseUrl: window.location.origin,
|
|
540
460
|
appName: r
|
|
541
461
|
}));
|
|
@@ -546,15 +466,15 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
546
466
|
originLabel: t.name
|
|
547
467
|
}));
|
|
548
468
|
}
|
|
549
|
-
let i =
|
|
469
|
+
let i = ne((e) => B(e.traceId));
|
|
550
470
|
return () => {
|
|
551
471
|
for (let e of t) e.dispose();
|
|
552
472
|
for (let e of n) e.dispose();
|
|
553
473
|
i();
|
|
554
474
|
};
|
|
555
475
|
}, [e]);
|
|
556
|
-
let x = new Map(e.map((e) => [e.name,
|
|
557
|
-
let t =
|
|
476
|
+
let x = new Map(e.map((e) => [e.name, o.clients.get(e.name)?.client ?? ee])), C = new Map(e.map((e) => {
|
|
477
|
+
let t = o.clients.get(e.name);
|
|
558
478
|
return t ? [e.name, {
|
|
559
479
|
runtime: t.runtime,
|
|
560
480
|
cache: t.cache,
|
|
@@ -563,31 +483,31 @@ var y = e("reconnect", null), b = () => c(y) ?? (() => {}), x = 150, S = 220, C
|
|
|
563
483
|
inspectBaseUrl: Y(e.wsUrl, e.name),
|
|
564
484
|
errorBus: t.errorBus
|
|
565
485
|
}] : [e.name, {
|
|
566
|
-
...
|
|
486
|
+
...te,
|
|
567
487
|
descriptors: e.descriptors
|
|
568
488
|
}];
|
|
569
489
|
}));
|
|
570
|
-
return /* @__PURE__ */
|
|
571
|
-
value:
|
|
572
|
-
children: /* @__PURE__ */
|
|
573
|
-
apis:
|
|
574
|
-
children: /* @__PURE__ */
|
|
490
|
+
return /* @__PURE__ */ g(v.Provider, {
|
|
491
|
+
value: m,
|
|
492
|
+
children: /* @__PURE__ */ g(p, {
|
|
493
|
+
apis: C,
|
|
494
|
+
children: /* @__PURE__ */ g(t.Provider, {
|
|
575
495
|
value: x,
|
|
576
|
-
children: /* @__PURE__ */
|
|
577
|
-
chrome:
|
|
578
|
-
/* @__PURE__ */
|
|
579
|
-
|
|
580
|
-
X() ? /* @__PURE__ */
|
|
496
|
+
children: /* @__PURE__ */ g(a, {
|
|
497
|
+
chrome: y ? /* @__PURE__ */ _(re, { children: [
|
|
498
|
+
/* @__PURE__ */ g(S, {}),
|
|
499
|
+
i,
|
|
500
|
+
X() ? /* @__PURE__ */ g(ue, {}) : null
|
|
581
501
|
] }) : null,
|
|
582
502
|
children: n
|
|
583
503
|
})
|
|
584
504
|
})
|
|
585
505
|
})
|
|
586
506
|
});
|
|
587
|
-
},
|
|
507
|
+
}, _e = ({ App: e, apis: t, Devtools: n }) => /* @__PURE__ */ g($, {
|
|
588
508
|
apis: t,
|
|
589
|
-
chrome: n ? /* @__PURE__ */
|
|
590
|
-
children: /* @__PURE__ */
|
|
509
|
+
chrome: n ? /* @__PURE__ */ g(n, {}) : null,
|
|
510
|
+
children: /* @__PURE__ */ g(e, {})
|
|
591
511
|
});
|
|
592
512
|
//#endregion
|
|
593
|
-
export { K as a,
|
|
513
|
+
export { K as a, S as c, L as i, v as l, $ as n, B as o, I as r, H as s, _e as t, y as u };
|
package/dist/frameworkBoot.d.ts
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
+
import { ClientDescriptorMap } from '@voltro/client';
|
|
1
2
|
import { ComponentType } from 'react';
|
|
3
|
+
import { MountedApi } from '@voltro/client';
|
|
2
4
|
import { ReactNode } from 'react';
|
|
3
|
-
import { ResolvableHeaders } from '@voltro/client';
|
|
4
|
-
import { Rpc } from '@effect/rpc';
|
|
5
|
-
import { RpcGroup } from '@effect/rpc';
|
|
6
5
|
|
|
7
|
-
export
|
|
8
|
-
readonly [rpcTag: string]: {
|
|
9
|
-
readonly kind: 'query' | 'mutation' | 'action' | 'stream' | 'workflow';
|
|
10
|
-
readonly source?: string;
|
|
11
|
-
readonly targets?: ReadonlyArray<{
|
|
12
|
-
readonly table: string;
|
|
13
|
-
readonly op: 'insert' | 'update' | 'delete';
|
|
14
|
-
readonly order?: 'prepend' | 'append';
|
|
15
|
-
}>;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
6
|
+
export { ClientDescriptorMap }
|
|
18
7
|
|
|
19
8
|
export declare const FrameworkBoot: ({ App, apis, Devtools }: FrameworkBootProps) => ReactNode;
|
|
20
9
|
|
|
@@ -28,24 +17,7 @@ export declare interface FrameworkBootProps {
|
|
|
28
17
|
readonly Devtools?: ComponentType;
|
|
29
18
|
}
|
|
30
19
|
|
|
31
|
-
|
|
32
|
-
* Auth headers for an api's WS rpc client. @effect/rpc sends these in the
|
|
33
|
-
* per-request MESSAGE frame (NOT the WS upgrade — a browser can't set upgrade
|
|
34
|
-
* headers), so the server's AuthMiddleware sees them on every call; this is
|
|
35
|
-
* what lets a cross-origin api authenticate WS subscriptions. A thunk is
|
|
36
|
-
* resolved fresh on every (re)connect, so a rotating token (e.g. a Supabase
|
|
37
|
-
* access token) is pulled anew per connect instead of freezing at first mount.
|
|
38
|
-
*
|
|
39
|
-
* `ResolvableHeaders` is re-exported from `@voltro/client` (the lower layer that
|
|
40
|
-
* owns `buildApiRuntime`) so there is ONE definition, not a web-local copy.
|
|
41
|
-
*/
|
|
42
|
-
export declare interface MountedApi {
|
|
43
|
-
readonly name: string;
|
|
44
|
-
readonly group: RpcGroup.RpcGroup<Rpc.Any>;
|
|
45
|
-
readonly descriptors: ClientDescriptorMap;
|
|
46
|
-
readonly wsUrl: string;
|
|
47
|
-
readonly headers?: ResolvableHeaders | undefined;
|
|
48
|
-
}
|
|
20
|
+
export { MountedApi }
|
|
49
21
|
|
|
50
22
|
export declare const VoltroRuntimeProvider: ({ apis, children, chrome }: VoltroRuntimeProviderProps) => ReactNode;
|
|
51
23
|
|
package/dist/frameworkBoot.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./frameworkBoot
|
|
1
|
+
import { n as e, t } from "./frameworkBoot-Tso-IjA7.js";
|
|
2
2
|
export { t as FrameworkBoot, e as VoltroRuntimeProvider };
|