@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.
@@ -0,0 +1,541 @@
1
+ import { createContext as e, useCallback as t, useContext as n, useMemo as r, useRef as i, useState as a } from "react";
2
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
3
+ //#region src/statusBus.ts
4
+ var l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), d = [], f = () => {
5
+ d = Array.from(l.values());
6
+ }, p = () => {
7
+ f();
8
+ for (let e of u) try {
9
+ e();
10
+ } catch {}
11
+ }, m = (e) => {
12
+ l.set(e.id, e), p();
13
+ let t = !1;
14
+ return () => {
15
+ t || (t = !0, l.delete(e.id) && p());
16
+ };
17
+ }, h = () => d, g = (e) => (u.add(e), () => {
18
+ u.delete(e);
19
+ }), _ = {
20
+ error: {
21
+ brandTag: "voltro · runtime error",
22
+ stackTrace: "Stack trace",
23
+ retry: "Retry",
24
+ reload: "Reload page",
25
+ copy: "Copy error",
26
+ copied: "Copied ✓",
27
+ copyFailed: "Pick text below ↓",
28
+ serverContextHeading: "Server-side context",
29
+ serverContextHint: (e) => /* @__PURE__ */ c(o, { children: [
30
+ "Run ",
31
+ e,
32
+ " in a terminal to see what the server emitted around this failure — handler errors, rpc-tag context, and any prior warnings land there too."
33
+ ] })
34
+ },
35
+ notFound: {
36
+ badge: "404 · not found",
37
+ heading: "No page for this URL",
38
+ body: (e, t) => /* @__PURE__ */ c(o, { children: [
39
+ "The router has no entry matching ",
40
+ e,
41
+ ". Check ",
42
+ t,
43
+ " — file-based routing maps directly from the directory tree."
44
+ ] })
45
+ }
46
+ }, v = e(_), y = (e, t) => ({
47
+ error: {
48
+ ...e.error,
49
+ ...t.error
50
+ },
51
+ notFound: {
52
+ ...e.notFound,
53
+ ...t.notFound
54
+ }
55
+ });
56
+ function b(e) {
57
+ let t = n(v), i = r(() => y(t, e.strings), [t, e.strings]);
58
+ return /* @__PURE__ */ s(v.Provider, {
59
+ value: i,
60
+ children: e.children
61
+ });
62
+ }
63
+ var x = (e) => {
64
+ let t = n(v);
65
+ return r(() => e ? y(t, e) : t, [t, e]);
66
+ }, S = async (e) => {
67
+ if (typeof navigator < "u" && navigator.clipboard?.writeText) try {
68
+ return await navigator.clipboard.writeText(e), "native";
69
+ } catch {}
70
+ if (typeof document > "u") return "failed";
71
+ let t = document.createElement("textarea");
72
+ t.value = e, t.style.position = "fixed", t.style.top = "-9999px", t.style.left = "-9999px", t.style.opacity = "0", t.setAttribute("readonly", ""), t.setAttribute("aria-hidden", "true"), document.body.appendChild(t);
73
+ try {
74
+ t.focus(), t.select(), t.setSelectionRange(0, e.length);
75
+ let n = document.execCommand;
76
+ return typeof n == "function" && n.call(document, "copy") ? "fallback" : "failed";
77
+ } catch {
78
+ return "failed";
79
+ } finally {
80
+ document.body.removeChild(t);
81
+ }
82
+ }, C = {
83
+ background: "oklch(0.155 0.005 285)",
84
+ backgroundElevated: "oklch(0.19 0.006 285)",
85
+ foreground: "oklch(0.98 0.005 285)",
86
+ foregroundMuted: "oklch(0.65 0.012 285)",
87
+ foregroundSubtle: "oklch(0.5 0.012 285)",
88
+ card: "oklch(0.21 0.006 285)",
89
+ border: "oklch(1 0 0 / 12%)",
90
+ borderStrong: "oklch(1 0 0 / 22%)",
91
+ accent: "oklch(0.7 0.18 290)",
92
+ accentDim: "oklch(0.55 0.18 290)",
93
+ accentGlow: "oklch(0.7 0.18 290 / 35%)",
94
+ danger: "oklch(0.7 0.21 22)",
95
+ dangerDim: "oklch(0.5 0.18 22 / 60%)",
96
+ info: "oklch(0.7 0.18 240)"
97
+ }, w = "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif", T = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace", E = `
98
+ [data-vweb-fb="root"] *,
99
+ [data-vweb-fb="root"] *::before,
100
+ [data-vweb-fb="root"] *::after {
101
+ box-sizing: border-box;
102
+ }
103
+ [data-vweb-fb-btn] {
104
+ cursor: pointer;
105
+ font: inherit;
106
+ color: inherit;
107
+ background: transparent;
108
+ border: 1px solid transparent;
109
+ border-radius: 6px;
110
+ padding: 8px 14px;
111
+ transition: background-color 120ms ease, border-color 120ms ease, transform 80ms ease;
112
+ }
113
+ [data-vweb-fb-btn]:hover { transform: translateY(-1px); }
114
+ [data-vweb-fb-btn]:active { transform: translateY(0); }
115
+ [data-vweb-fb-btn="primary"] {
116
+ background-color: ${C.accent};
117
+ color: ${C.background};
118
+ font-weight: 600;
119
+ box-shadow: 0 4px 16px -2px ${C.accentGlow};
120
+ }
121
+ [data-vweb-fb-btn="primary"]:hover { background-color: ${C.accentDim}; }
122
+ [data-vweb-fb-btn="secondary"] {
123
+ border-color: ${C.borderStrong};
124
+ color: ${C.foreground};
125
+ }
126
+ [data-vweb-fb-btn="secondary"]:hover {
127
+ background-color: ${C.backgroundElevated};
128
+ border-color: ${C.accent};
129
+ }
130
+ [data-vweb-fb-summary] {
131
+ cursor: pointer;
132
+ user-select: none;
133
+ list-style: none;
134
+ display: flex;
135
+ align-items: center;
136
+ gap: 8px;
137
+ padding: 6px 0;
138
+ color: ${C.foregroundMuted};
139
+ font-size: 12px;
140
+ font-weight: 500;
141
+ letter-spacing: 0.02em;
142
+ text-transform: uppercase;
143
+ }
144
+ [data-vweb-fb-summary]::-webkit-details-marker { display: none; }
145
+ [data-vweb-fb-summary]::before {
146
+ content: '▸';
147
+ display: inline-block;
148
+ font-size: 10px;
149
+ transition: transform 120ms ease;
150
+ color: ${C.foregroundSubtle};
151
+ }
152
+ [data-vweb-fb="root"] details[open] > [data-vweb-fb-summary]::before {
153
+ transform: rotate(90deg);
154
+ }
155
+ [data-vweb-fb-summary]:hover { color: ${C.foreground}; }
156
+ @keyframes vwebFbFadeIn {
157
+ from { opacity: 0; }
158
+ to { opacity: 1; }
159
+ }
160
+ @keyframes vwebFbScaleIn {
161
+ from { opacity: 0; transform: translateY(8px) scale(0.985); }
162
+ to { opacity: 1; transform: translateY(0) scale(1); }
163
+ }
164
+ [data-vweb-fb="backdrop"] {
165
+ animation: vwebFbFadeIn 200ms ease-out;
166
+ }
167
+ [data-vweb-fb="card"] {
168
+ animation: vwebFbScaleIn 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
169
+ }
170
+ @media (prefers-reduced-motion: reduce) {
171
+ [data-vweb-fb="backdrop"],
172
+ [data-vweb-fb="card"] {
173
+ animation: none;
174
+ }
175
+ }
176
+ `, D = () => /* @__PURE__ */ s("style", { dangerouslySetInnerHTML: { __html: E } }), O = (e) => {
177
+ if (e instanceof Error) return {
178
+ name: e.name || "Error",
179
+ message: e.message || "(no message)",
180
+ stack: e.stack
181
+ };
182
+ if (typeof e == "string") return {
183
+ name: "Error",
184
+ message: e,
185
+ stack: void 0
186
+ };
187
+ if (e && typeof e == "object") {
188
+ let t = e;
189
+ return {
190
+ name: typeof t.name == "string" ? t.name : "Error",
191
+ message: typeof t.message == "string" ? t.message : k(e),
192
+ stack: typeof t.stack == "string" ? t.stack : void 0
193
+ };
194
+ }
195
+ return {
196
+ name: "Error",
197
+ message: String(e),
198
+ stack: void 0
199
+ };
200
+ }, k = (e) => {
201
+ try {
202
+ return JSON.stringify(e, null, 2);
203
+ } catch {
204
+ return String(e);
205
+ }
206
+ }, A = (e, t) => {
207
+ let n = e.indexOf("\n");
208
+ return n === -1 ? e === t ? "" : e : e.slice(0, n).trim() === t.trim() ? e.slice(n + 1).replace(/^\n+/, "") : e;
209
+ }, j = (e, t) => {
210
+ if (!e) return [];
211
+ let n = A(e, t);
212
+ return n.length === 0 ? [] : n.split("\n");
213
+ }, M = ({ tone: e, children: t }) => {
214
+ let n = {
215
+ danger: C.danger,
216
+ info: C.info
217
+ }[e], r = `radial-gradient(ellipse 900px 700px at 50% 50%, color-mix(in oklch, ${n} 12%, transparent) 0%, color-mix(in oklch, ${n} 4%, transparent) 30%, oklch(0.08 0.005 285) 80%)`;
218
+ return /* @__PURE__ */ c("div", {
219
+ "data-vweb-fb": "root",
220
+ style: {
221
+ position: "fixed",
222
+ inset: 0,
223
+ zIndex: 2147483646,
224
+ color: C.foreground,
225
+ fontFamily: w,
226
+ fontSize: 14,
227
+ lineHeight: 1.5
228
+ },
229
+ children: [
230
+ /* @__PURE__ */ s(D, {}),
231
+ /* @__PURE__ */ s("div", {
232
+ "data-vweb-fb": "backdrop",
233
+ style: {
234
+ position: "absolute",
235
+ inset: 0,
236
+ background: r
237
+ }
238
+ }),
239
+ /* @__PURE__ */ s("div", {
240
+ style: {
241
+ position: "relative",
242
+ height: "100%",
243
+ width: "100%",
244
+ display: "flex",
245
+ alignItems: "center",
246
+ justifyContent: "center",
247
+ padding: 32,
248
+ overflowY: "auto"
249
+ },
250
+ children: /* @__PURE__ */ c("div", {
251
+ "data-vweb-fb": "card",
252
+ role: e === "danger" ? "alert" : void 0,
253
+ style: {
254
+ width: "100%",
255
+ maxWidth: 720,
256
+ background: C.card,
257
+ border: `1px solid ${C.border}`,
258
+ borderRadius: 14,
259
+ overflow: "hidden",
260
+ boxShadow: `0 32px 80px -16px oklch(0 0 0 / 75%), 0 8px 24px oklch(0 0 0 / 50%), 0 0 0 1px ${C.border}, 0 0 60px -10px color-mix(in oklch, ${n} 25%, transparent)`
261
+ },
262
+ children: [/* @__PURE__ */ s("div", { style: {
263
+ height: 2,
264
+ background: n
265
+ } }), t]
266
+ })
267
+ })
268
+ ]
269
+ });
270
+ }, N = ({ error: e, reset: n, strings: o }) => {
271
+ let l = x(o).error, u = r(() => O(e), [e]), d = `${u.name}: ${u.message}`, f = r(() => j(u.stack, d), [u.stack, d]), [p, m] = a("idle"), h = i(null), g = t(async () => {
272
+ let e = u.stack ? A(u.stack, d) : "";
273
+ if (await S([
274
+ d,
275
+ "",
276
+ e.length > 0 ? e : "(no stack)"
277
+ ].join("\n")) === "failed") {
278
+ let e = h.current;
279
+ if (e && typeof window < "u") {
280
+ let t = document.createRange();
281
+ t.selectNodeContents(e);
282
+ let n = window.getSelection();
283
+ n?.removeAllRanges(), n?.addRange(t);
284
+ }
285
+ m("failed");
286
+ } else m("copied");
287
+ window.setTimeout(() => m("idle"), 2e3);
288
+ }, [u, d]), _ = t(() => {
289
+ typeof window < "u" && window.location.reload();
290
+ }, []);
291
+ return /* @__PURE__ */ c(M, {
292
+ tone: "danger",
293
+ children: [
294
+ /* @__PURE__ */ c("div", {
295
+ style: {
296
+ display: "flex",
297
+ alignItems: "center",
298
+ justifyContent: "space-between",
299
+ padding: "16px 24px 0"
300
+ },
301
+ children: [/* @__PURE__ */ c("div", {
302
+ style: {
303
+ display: "inline-flex",
304
+ alignItems: "center",
305
+ gap: 8,
306
+ padding: "4px 10px",
307
+ borderRadius: 999,
308
+ background: `${C.danger} / 15%`,
309
+ backgroundColor: `color-mix(in oklch, ${C.danger} 18%, transparent)`,
310
+ color: C.danger,
311
+ fontSize: 11,
312
+ fontWeight: 600,
313
+ letterSpacing: "0.06em",
314
+ textTransform: "uppercase",
315
+ border: `1px solid color-mix(in oklch, ${C.danger} 30%, transparent)`
316
+ },
317
+ children: ["▲ ", u.name]
318
+ }), /* @__PURE__ */ s("div", {
319
+ style: {
320
+ fontSize: 11,
321
+ color: C.foregroundSubtle,
322
+ letterSpacing: "0.04em"
323
+ },
324
+ children: l.brandTag
325
+ })]
326
+ }),
327
+ /* @__PURE__ */ s("h1", {
328
+ style: {
329
+ margin: "16px 24px 4px",
330
+ fontSize: 20,
331
+ fontWeight: 600,
332
+ lineHeight: 1.35,
333
+ color: C.foreground,
334
+ wordBreak: "break-word"
335
+ },
336
+ children: u.message
337
+ }),
338
+ f.length > 0 ? /* @__PURE__ */ c("details", {
339
+ style: { margin: "16px 24px 0" },
340
+ open: !0,
341
+ children: [/* @__PURE__ */ s("summary", {
342
+ "data-vweb-fb-summary": !0,
343
+ children: l.stackTrace
344
+ }), /* @__PURE__ */ s("pre", {
345
+ style: {
346
+ margin: "8px 0 0",
347
+ padding: 12,
348
+ background: C.background,
349
+ border: `1px solid ${C.border}`,
350
+ borderRadius: 8,
351
+ fontFamily: T,
352
+ fontSize: 12,
353
+ lineHeight: 1.6,
354
+ color: C.foregroundMuted,
355
+ overflowX: "auto",
356
+ whiteSpace: "pre",
357
+ maxHeight: 320,
358
+ overflowY: "auto"
359
+ },
360
+ children: f.map((e, t) => {
361
+ let n = /^(\s*at\s+)(.*?)\s*(\(.*\))?$/.exec(e);
362
+ if (!n) return /* @__PURE__ */ s("div", { children: e }, t);
363
+ let [, r, i, a] = n;
364
+ return /* @__PURE__ */ c("div", { children: [
365
+ /* @__PURE__ */ s("span", {
366
+ style: { color: C.foregroundSubtle },
367
+ children: r
368
+ }),
369
+ /* @__PURE__ */ s("span", {
370
+ style: { color: C.foreground },
371
+ children: i
372
+ }),
373
+ a ? /* @__PURE__ */ c("span", {
374
+ style: { color: C.foregroundSubtle },
375
+ children: [" ", a]
376
+ }) : null
377
+ ] }, t);
378
+ })
379
+ })]
380
+ }) : null,
381
+ /* @__PURE__ */ c("div", {
382
+ style: {
383
+ display: "flex",
384
+ flexWrap: "wrap",
385
+ gap: 10,
386
+ padding: "20px 24px 0"
387
+ },
388
+ children: [
389
+ /* @__PURE__ */ s("button", {
390
+ "data-vweb-fb-btn": "primary",
391
+ type: "button",
392
+ onClick: n,
393
+ autoFocus: !0,
394
+ children: l.retry
395
+ }),
396
+ /* @__PURE__ */ s("button", {
397
+ "data-vweb-fb-btn": "secondary",
398
+ type: "button",
399
+ onClick: _,
400
+ children: l.reload
401
+ }),
402
+ /* @__PURE__ */ s("button", {
403
+ "data-vweb-fb-btn": "secondary",
404
+ type: "button",
405
+ onClick: g,
406
+ style: p === "copied" ? {
407
+ borderColor: "oklch(0.72 0.15 162 / 50%)",
408
+ color: "oklch(0.72 0.15 162)"
409
+ } : p === "failed" ? {
410
+ borderColor: `${C.danger} / 50%`,
411
+ color: C.danger
412
+ } : void 0,
413
+ children: p === "copied" ? l.copied : p === "failed" ? l.copyFailed : l.copy
414
+ })
415
+ ]
416
+ }),
417
+ p === "failed" ? /* @__PURE__ */ s("pre", {
418
+ ref: h,
419
+ tabIndex: 0,
420
+ style: {
421
+ margin: "12px 24px 0",
422
+ padding: 12,
423
+ background: C.background,
424
+ border: `1px dashed ${C.danger}`,
425
+ borderRadius: 8,
426
+ fontFamily: T,
427
+ fontSize: 12,
428
+ lineHeight: 1.5,
429
+ color: C.foreground,
430
+ maxHeight: 200,
431
+ overflow: "auto",
432
+ whiteSpace: "pre-wrap",
433
+ wordBreak: "break-word",
434
+ userSelect: "text"
435
+ },
436
+ children: (() => {
437
+ let e = u.stack ? A(u.stack, d) : "";
438
+ return `${d}\n\n${e.length > 0 ? e : "(no stack)"}`;
439
+ })()
440
+ }) : null,
441
+ /* @__PURE__ */ c("div", {
442
+ style: {
443
+ margin: "20px 24px",
444
+ padding: "12px 14px",
445
+ borderRadius: 8,
446
+ background: C.backgroundElevated,
447
+ border: `1px solid ${C.border}`,
448
+ color: C.foregroundMuted,
449
+ fontSize: 12,
450
+ lineHeight: 1.6
451
+ },
452
+ children: [/* @__PURE__ */ s("div", {
453
+ style: {
454
+ marginBottom: 4,
455
+ color: C.foreground,
456
+ fontWeight: 500
457
+ },
458
+ children: l.serverContextHeading
459
+ }), l.serverContextHint(/* @__PURE__ */ s("code", {
460
+ style: {
461
+ fontFamily: T,
462
+ fontSize: 12,
463
+ padding: "2px 6px",
464
+ borderRadius: 4,
465
+ background: C.background,
466
+ border: `1px solid ${C.border}`,
467
+ color: C.accent
468
+ },
469
+ children: "voltro logs --since 30s"
470
+ }))]
471
+ })
472
+ ]
473
+ });
474
+ }, P = (e) => {
475
+ let t = x(e.strings).notFound, n = /* @__PURE__ */ s("code", {
476
+ style: {
477
+ fontFamily: T,
478
+ fontSize: 13,
479
+ padding: "2px 6px",
480
+ borderRadius: 4,
481
+ background: C.background,
482
+ border: `1px solid ${C.border}`,
483
+ color: C.foreground
484
+ },
485
+ children: typeof window < "u" ? window.location.pathname : "(unknown)"
486
+ }), r = /* @__PURE__ */ s("code", {
487
+ style: {
488
+ fontFamily: T,
489
+ fontSize: 13,
490
+ padding: "2px 6px",
491
+ borderRadius: 4,
492
+ background: C.background,
493
+ border: `1px solid ${C.border}`,
494
+ color: C.foregroundMuted
495
+ },
496
+ children: "src/pages/"
497
+ });
498
+ return /* @__PURE__ */ c(M, {
499
+ tone: "info",
500
+ children: [
501
+ /* @__PURE__ */ s("div", {
502
+ style: { padding: "16px 24px 0" },
503
+ children: /* @__PURE__ */ s("div", {
504
+ style: {
505
+ display: "inline-flex",
506
+ padding: "4px 10px",
507
+ borderRadius: 999,
508
+ backgroundColor: `color-mix(in oklch, ${C.info} 18%, transparent)`,
509
+ color: C.info,
510
+ fontSize: 11,
511
+ fontWeight: 600,
512
+ letterSpacing: "0.06em",
513
+ textTransform: "uppercase",
514
+ border: `1px solid color-mix(in oklch, ${C.info} 30%, transparent)`
515
+ },
516
+ children: t.badge
517
+ })
518
+ }),
519
+ /* @__PURE__ */ s("h1", {
520
+ style: {
521
+ margin: "16px 24px 4px",
522
+ fontSize: 22,
523
+ fontWeight: 600,
524
+ color: C.foreground
525
+ },
526
+ children: t.heading
527
+ }),
528
+ /* @__PURE__ */ s("p", {
529
+ style: {
530
+ margin: "0 24px 24px",
531
+ color: C.foregroundMuted,
532
+ fontSize: 14,
533
+ lineHeight: 1.6
534
+ },
535
+ children: t.body(n, r)
536
+ })
537
+ ]
538
+ });
539
+ };
540
+ //#endregion
541
+ export { _ as a, m as c, b as i, g as l, P as n, x as o, S as r, h as s, N as t };