pgserve 2.2.0 → 2.2.2

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/bin/pgserve-wrapper.cjs +1 -0
  3. package/console/dist/app.js +121 -0
  4. package/console/dist/index.html +13 -0
  5. package/package.json +12 -6
  6. package/scripts/postinstall.cjs +60 -0
  7. package/scripts/test-bun-self-heal.sh +163 -0
  8. package/scripts/test-npx.sh +60 -0
  9. package/src/cli-install.cjs +14 -0
  10. package/src/cli-ui.cjs +19 -2
  11. package/src/upgrade/index.js +65 -0
  12. package/src/upgrade/runner.js +23 -0
  13. package/src/upgrade/steps/binary-cache-flush.js +67 -0
  14. package/src/upgrade/steps/consumer-signal.js +40 -0
  15. package/src/upgrade/steps/env-refresh.js +89 -0
  16. package/src/upgrade/steps/health-validate.js +53 -0
  17. package/src/upgrade/steps/plpgsql-resolve.js +66 -0
  18. package/src/upgrade/steps/port-reconcile.js +52 -0
  19. package/console/README.md +0 -131
  20. package/console/api.js +0 -173
  21. package/console/app.jsx +0 -483
  22. package/console/components.jsx +0 -167
  23. package/console/data.jsx +0 -350
  24. package/console/index.html +0 -31
  25. package/console/screens/databases.jsx +0 -5
  26. package/console/screens/health.jsx +0 -5
  27. package/console/screens/ingress.jsx +0 -5
  28. package/console/screens/optimizer.jsx +0 -5
  29. package/console/screens/rlm-sim.jsx +0 -5
  30. package/console/screens/rlm-trace.jsx +0 -5
  31. package/console/screens/security.jsx +0 -5
  32. package/console/screens/settings.jsx +0 -611
  33. package/console/screens/sql.jsx +0 -5
  34. package/console/screens/sync.jsx +0 -5
  35. package/console/screens/tables.jsx +0 -5
  36. package/console/tweaks-panel.jsx +0 -425
  37. /package/console/{colors_and_type.css → dist/colors_and_type.css} +0 -0
  38. /package/console/{console.css → dist/console.css} +0 -0
package/console/app.jsx DELETED
@@ -1,483 +0,0 @@
1
- /* autopg · app shell · routing · theme.
2
- *
3
- * Adapted from the design system's pgserve-console kit. Differences vs the
4
- * pristine design:
5
- * - identity flips from `pgserve` to `autopg` in the topbar / sidebar.
6
- * - SECTIONS gains two RLM screens (rlm-trace, rlm-sim) so all 11 routes
7
- * register; the wish ships them as `[ coming soon ]` placeholders.
8
- * - theme toggle persists into `settings.ui.theme` via the autopg helper
9
- * API, surviving reloads. Other tweaks remain ephemeral for v1.
10
- */
11
-
12
- const SECTIONS = [
13
- { id: 'databases', label: 'Databases', glyph: '◫', count: '6', group: 'data' },
14
- { id: 'tables', label: 'Tables', glyph: '▦', count: '47', group: 'data' },
15
- { id: 'sql', label: 'SQL Editor', glyph: '›_', count: null, group: 'data' },
16
- { id: 'optimizer', label: 'Optimizer', glyph: '◇', count: '4', group: 'ops' },
17
- { id: 'security', label: 'Security', glyph: '✦', count: '2', group: 'ops' },
18
- { id: 'ingress', label: 'Ingress', glyph: '⇨', count: '23', group: 'ops' },
19
- { id: 'health', label: 'Health', glyph: '◍', count: null, group: 'ops' },
20
- { id: 'sync', label: 'Sync & Backups',glyph: '⇆', count: null, group: 'ops' },
21
- { id: 'rlm-trace', label: 'RLM Trace', glyph: '⌬', count: null, group: 'rlm' },
22
- { id: 'rlm-sim', label: 'RLM Sim', glyph: '⊙', count: null, group: 'rlm' },
23
- { id: 'settings', label: 'Settings', glyph: '⚙', count: null, group: 'system' },
24
- ];
25
-
26
- const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
27
- "phosphor": "green",
28
- "density": "standard",
29
- "crt": "subtle"
30
- }/*EDITMODE-END*/;
31
-
32
- const PHOSPHOR_PRESETS = {
33
- green: { accent: '#7DD3A4', accentHover: '#97DFB6', accentPress: '#5FB988', vector: '#B69BE0', audit: '#D6A574', label: 'P1 · GREEN' },
34
- amber: { accent: '#E8B860', accentHover: '#F2C97A', accentPress: '#C99A45', vector: '#E89E60', audit: '#D6C474', label: 'P3 · AMBER' },
35
- cyan: { accent: '#6EE0E0', accentHover: '#8FEAEA', accentPress: '#4FBFBF', vector: '#9BB6E0', audit: '#D6B574', label: 'IBM · CYAN' },
36
- magenta: { accent: '#E07BB8', accentHover: '#EA97C9', accentPress: '#B8628F', vector: '#B69BE0', audit: '#E0997B', label: 'SYN · MAGENTA' },
37
- paper: { accent: '#C8C2B0', accentHover: '#D8D2C0', accentPress: '#A8A290', vector: '#B6B0A0', audit: '#D6CCA0', label: 'PAPER · MUTED' },
38
- };
39
-
40
- const DENSITY_PRESETS = {
41
- compact: { space: 0.78, row: 24, base: 12, h1: 20, gap: 14, label: 'compact' },
42
- standard: { space: 1.00, row: 28, base: 13, h1: 22, gap: 18, label: 'standard' },
43
- roomy: { space: 1.28, row: 36, base: 14, h1: 26, gap: 26, label: 'roomy' },
44
- };
45
-
46
- const CRT_PRESETS = {
47
- off: { scanline: 0, glow: 0, vignette: 0, chroma: 0, curve: 0, label: 'flat' },
48
- subtle: { scanline: 0.04, glow: 4, vignette: 0.18, chroma: 0, curve: 0, label: 'subtle' },
49
- heavy: { scanline: 0.10, glow: 10, vignette: 0.42, chroma: 0.6, curve: 1, label: 'heavy' },
50
- };
51
-
52
- /* Format helpers — small, dependency-free, scoped to the footer. */
53
- function fmtUptime(sec) {
54
- if (sec == null || !Number.isFinite(sec)) return '—';
55
- const s = Math.max(0, Math.floor(sec));
56
- const d = Math.floor(s / 86400);
57
- const h = Math.floor((s % 86400) / 3600);
58
- const m = Math.floor((s % 3600) / 60);
59
- const r = s % 60;
60
- if (d) return `${d}d ${h}h ${m}m`;
61
- if (h) return `${h}h ${m}m`;
62
- if (m) return `${m}m ${r}s`;
63
- return `${r}s`;
64
- }
65
- function fmtBytes(b) {
66
- if (b == null || !Number.isFinite(b)) return '—';
67
- const u = ['B', 'KB', 'MB', 'GB', 'TB'];
68
- let i = 0;
69
- let v = Number(b);
70
- while (v >= 1024 && i < u.length - 1) { v /= 1024; i += 1; }
71
- return `${v >= 10 ? v.toFixed(0) : v.toFixed(1)} ${u[i]}`;
72
- }
73
- function fmtNum(n) {
74
- if (n == null || !Number.isFinite(Number(n))) return '—';
75
- return Number(n).toLocaleString();
76
- }
77
-
78
- /* LiveFooter — the only place where pgserve health is reported.
79
- * Polls /api/stats (SQL-backed: connections, databases, pg version, uptime,
80
- * cache hit %, total xact, total db size) and /api/status (pm2-backed:
81
- * daemon pid, restarts, memory) on a 3 s cadence (6 s when down).
82
- *
83
- * Compact line shows the headline numbers; the `title` attribute holds a
84
- * multi-line health report rendered as the native browser tooltip on hover.
85
- * No custom popover layer is needed — keeps the footer single-purpose.
86
- */
87
- function LiveFooter() {
88
- const [stats, setStats] = useState(null);
89
- const [status, setStatus] = useState(null);
90
- const [open, setOpen] = useState(false);
91
- const popRef = useRef(null);
92
- const btnRef = useRef(null);
93
-
94
- useEffect(() => {
95
- if (!window.AutopgApi) return;
96
- let alive = true;
97
- let timer;
98
- const tick = async () => {
99
- const [s, st] = await Promise.all([
100
- window.AutopgApi.getStats().catch(() => null),
101
- window.AutopgApi.getStatus().catch(() => null),
102
- ]);
103
- if (!alive) return;
104
- setStats(s);
105
- setStatus(st);
106
- // Slow the cadence when down to avoid hammering a failed daemon.
107
- timer = setTimeout(tick, s?.ok ? 3000 : 6000);
108
- };
109
- tick();
110
- return () => { alive = false; if (timer) clearTimeout(timer); };
111
- }, []);
112
-
113
- // Click-outside + Escape to close the popover.
114
- useEffect(() => {
115
- if (!open) return undefined;
116
- const onDown = (e) => {
117
- if (popRef.current?.contains(e.target)) return;
118
- if (btnRef.current?.contains(e.target)) return;
119
- setOpen(false);
120
- };
121
- const onKey = (e) => { if (e.key === 'Escape') setOpen(false); };
122
- document.addEventListener('mousedown', onDown);
123
- document.addEventListener('keydown', onKey);
124
- return () => {
125
- document.removeEventListener('mousedown', onDown);
126
- document.removeEventListener('keydown', onKey);
127
- };
128
- }, [open]);
129
-
130
- const live = !!stats?.ok;
131
- const pid = status?.pid;
132
- const restarts = status?.restarts;
133
- const daemonMem = status?.memory ?? status?.mem;
134
- const ts = stats?.ts ? new Date(stats.ts).toTimeString().slice(0, 8) : '—';
135
-
136
- // Multiline health report — same shape used inside the popover <pre>.
137
- const healthReport = (() => {
138
- const lines = [];
139
- lines.push(`autopg ${stats?.autopg?.version ?? '—'}`);
140
- lines.push(`port ${stats?.port ?? '—'}`);
141
- lines.push('');
142
- if (live) {
143
- lines.push('postgres');
144
- lines.push(` version ${stats.pg.version}`);
145
- lines.push(` uptime ${fmtUptime(stats.pg.uptimeSec)}`);
146
- lines.push(` connections ${stats.connections}`);
147
- lines.push(` databases ${stats.databases}`);
148
- lines.push(` size ${fmtBytes(stats.pg.sizeBytes)}`);
149
- lines.push(` cache hit ${stats.pg.cacheHitPct == null ? '—' : `${stats.pg.cacheHitPct}%`}`);
150
- lines.push(` total xact ${fmtNum(stats.pg.txTotal)}`);
151
- } else {
152
- lines.push('postgres');
153
- lines.push(` status ${stats?.reason || 'unreachable'}`);
154
- if (stats?.message) lines.push(` error ${stats.message}`);
155
- }
156
- lines.push('');
157
- if (status && !status.error) {
158
- lines.push('daemon (pm2)');
159
- lines.push(` pid ${pid ?? '—'}`);
160
- lines.push(` restarts ${restarts ?? '—'}`);
161
- if (daemonMem) lines.push(` memory ${typeof daemonMem === 'number' ? fmtBytes(daemonMem) : daemonMem}`);
162
- } else {
163
- lines.push('daemon (pm2)');
164
- lines.push(' not supervised — running in foreground or unreachable');
165
- }
166
- lines.push('');
167
- lines.push(`last sample ${ts}`);
168
- return lines.join('\n');
169
- })();
170
-
171
- const liveLabel = live ? 'live' : 'daemon down';
172
- const btnTitle = live ? 'click to open health report' : 'daemon unreachable — click for details';
173
-
174
- return (
175
- <div className="footer">
176
- {/* meta strip — left-aligned facts in left-to-right reading order */}
177
- <span>autopg <span style={{ color: 'var(--accent)' }}>{stats?.autopg?.version ?? '—'}</span></span>
178
- {pid != null && (
179
- <>
180
- <span className="sep">/</span>
181
- <span>pid <span style={{ color: 'var(--accent)' }}>{pid}</span></span>
182
- </>
183
- )}
184
- {live && (
185
- <>
186
- <span className="sep">/</span>
187
- <span>pg {stats.pg.version}</span>
188
- <span className="sep">/</span>
189
- <span>{stats.connections} conns · {stats.databases} dbs</span>
190
- {stats.pg.cacheHitPct != null && (
191
- <>
192
- <span className="sep">/</span>
193
- <span>cache · <span className="ok">{stats.pg.cacheHitPct}%</span></span>
194
- </>
195
- )}
196
- </>
197
- )}
198
- {!live && stats?.reason && (
199
- <>
200
- <span className="sep">/</span>
201
- <span>{stats.reason}</span>
202
- </>
203
- )}
204
-
205
- {/* live-status button — clickable, right-aligned, opens health popover */}
206
- <button
207
- ref={btnRef}
208
- className={`live-btn ${live ? 'on' : 'down'}`}
209
- onClick={() => setOpen((v) => !v)}
210
- title={btnTitle}
211
- aria-expanded={open}
212
- aria-haspopup="dialog"
213
- style={{ marginLeft: 'auto' }}
214
- >
215
- <span className="dot" /> {liveLabel}
216
- </button>
217
-
218
- {open && (
219
- <div ref={popRef} className="live-popover" role="dialog" aria-label="pgserve health report">
220
- <div className="head">
221
- <span>health · last sample {ts}</span>
222
- <button className="close" onClick={() => setOpen(false)} aria-label="close">×</button>
223
- </div>
224
- <pre>{healthReport}</pre>
225
- </div>
226
- )}
227
- </div>
228
- );
229
- }
230
-
231
- function App() {
232
- const [route, setRoute] = useState('settings');
233
- const [theme, setThemeLocal] = useState('mdr');
234
- const [now, setNow] = useState('00:00:00');
235
- const [tw, setTweak] = window.useTweaks(TWEAK_DEFAULTS);
236
- const [bootError, setBootError] = useState(null);
237
-
238
- /* On boot: pull current settings to seed theme + tell the Settings screen
239
- * the path the daemon is actually reading from. The error is non-fatal —
240
- * the rest of the console still renders so operators can navigate. */
241
- useEffect(() => {
242
- let cancelled = false;
243
- if (!window.AutopgApi) return undefined;
244
- window.AutopgApi.getSettings()
245
- .then((data) => {
246
- if (cancelled) return;
247
- const t = data?.settings?.ui?.theme;
248
- if (t === 'mdr' || t === 'lumon') setThemeLocal(t);
249
- })
250
- .catch((err) => {
251
- if (cancelled) return;
252
- // eslint-disable-next-line no-console
253
- console.warn('autopg console: initial settings load failed', err);
254
- setBootError(err.message || String(err));
255
- });
256
- return () => {
257
- cancelled = true;
258
- };
259
- }, []);
260
-
261
- const setTheme = useMemo(() => async (next) => {
262
- setThemeLocal(next);
263
- if (!window.AutopgApi) return;
264
- try {
265
- await window.AutopgApi.putSettings({ ui: { theme: next } });
266
- } catch (err) {
267
- // eslint-disable-next-line no-console
268
- console.warn('autopg console: theme persist failed', err);
269
- }
270
- }, []);
271
-
272
- useEffect(() => {
273
- document.documentElement.dataset.theme = theme;
274
- }, [theme]);
275
-
276
- useEffect(() => {
277
- const r = document.documentElement;
278
- const phos = PHOSPHOR_PRESETS[tw.phosphor] || PHOSPHOR_PRESETS.green;
279
- const den = DENSITY_PRESETS[tw.density] || DENSITY_PRESETS.standard;
280
- const crt = CRT_PRESETS[tw.crt] || CRT_PRESETS.subtle;
281
-
282
- if (theme === 'mdr') {
283
- r.style.setProperty('--c-accent', phos.accent);
284
- r.style.setProperty('--c-accent-hover', phos.accentHover);
285
- r.style.setProperty('--c-accent-press', phos.accentPress);
286
- r.style.setProperty('--c-vector', phos.vector);
287
- r.style.setProperty('--c-audit', phos.audit);
288
- } else {
289
- ['--c-accent', '--c-accent-hover', '--c-accent-press', '--c-vector', '--c-audit']
290
- .forEach(p => r.style.removeProperty(p));
291
- }
292
-
293
- r.style.setProperty('--space-1', `${4 * den.space}px`);
294
- r.style.setProperty('--space-2', `${8 * den.space}px`);
295
- r.style.setProperty('--space-3', `${12 * den.space}px`);
296
- r.style.setProperty('--space-4', `${16 * den.space}px`);
297
- r.style.setProperty('--space-5', `${24 * den.space}px`);
298
- r.style.setProperty('--space-6', `${32 * den.space}px`);
299
- r.style.setProperty('--row-control', `${den.row}px`);
300
- r.style.setProperty('--row-table', `${den.row + 4}px`);
301
- r.style.setProperty('--t-md', `${den.base}px`);
302
- r.style.setProperty('--t-lg', `${den.base + 2}px`);
303
- r.style.setProperty('--t-2xl', `${den.h1}px`);
304
-
305
- r.style.setProperty('--scanline-opacity', String(crt.scanline));
306
- r.style.setProperty('--phosphor-glow', `${crt.glow}px`);
307
- r.style.setProperty('--crt-vignette', String(crt.vignette));
308
- r.style.setProperty('--crt-chroma', `${crt.chroma}px`);
309
- r.dataset.crt = tw.crt;
310
- r.dataset.density = tw.density;
311
- r.dataset.phosphor = tw.phosphor;
312
- }, [tw.phosphor, tw.density, tw.crt, theme]);
313
-
314
- useEffect(() => {
315
- const tick = () => {
316
- const d = new Date();
317
- setNow(d.toTimeString().slice(0, 8));
318
- };
319
- tick();
320
- const t = setInterval(tick, 1000);
321
- return () => clearInterval(t);
322
- }, []);
323
-
324
- const groups = useMemo(() => ([
325
- { id: 'data', label: 'data', items: SECTIONS.filter(s => s.group === 'data') },
326
- { id: 'ops', label: 'ops', items: SECTIONS.filter(s => s.group === 'ops') },
327
- { id: 'rlm', label: 'rlm', items: SECTIONS.filter(s => s.group === 'rlm') },
328
- { id: 'system', label: 'system', items: SECTIONS.filter(s => s.group === 'system') },
329
- ]), []);
330
-
331
- // Every entry MUST be a stable component reference. The previous
332
- // `settings: () => window.ScreenSettings({ theme, setTheme })` wrapper was
333
- // recreated on every App re-render (the 1Hz clock alone re-renders the
334
- // whole tree), making React treat each tick as a new component type and
335
- // unmount/remount ScreenSettings — losing scroll, focus, and the
336
- // /api/settings fetch state. Direct refs only; pass props in JSX below.
337
- const Screen = {
338
- databases: window.ScreenDatabases,
339
- tables: window.ScreenTables,
340
- sql: window.ScreenSQL,
341
- optimizer: window.ScreenOptimizer,
342
- security: window.ScreenSecurity,
343
- ingress: window.ScreenIngress,
344
- health: window.ScreenHealth,
345
- sync: window.ScreenSync,
346
- 'rlm-trace': window.ScreenRlmTrace,
347
- 'rlm-sim': window.ScreenRlmSim,
348
- settings: window.ScreenSettings,
349
- }[route];
350
-
351
- return (
352
- <div className="app">
353
- {/* topbar */}
354
- <div className="topbar">
355
- <div className="wm">
356
- <span className="cur">▌</span><span>autopg</span>
357
- </div>
358
- <div className="meta">
359
- <span className="sep">/</span>
360
- <span>console · v1</span>
361
- <span className="sep">·</span>
362
- <span style={{ color: 'var(--accent)' }}>{route}</span>
363
- <span className="sep">·</span>
364
- <span>{now}</span>
365
- </div>
366
- <div className="right">
367
- {bootError && <span className="pill" style={{ color: 'var(--err, #d66)' }}>api · {bootError}</span>}
368
- <span className="pill"><span className="dot"></span> ~/.autopg</span>
369
- <div className="theme-switch">
370
- <button
371
- onClick={() => setTheme(theme === 'mdr' ? 'lumon' : 'mdr')}
372
- title={theme === 'mdr' ? 'switch to light' : 'switch to dark'}
373
- aria-label={theme === 'mdr' ? 'switch to light theme' : 'switch to dark theme'}
374
- >
375
- {theme === 'mdr' ? (
376
- /* moon — currently dark */
377
- <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
378
- <path d="M14 9.5A6 6 0 1 1 6.5 2a5 5 0 0 0 7.5 7.5z" />
379
- </svg>
380
- ) : (
381
- /* sun — currently light */
382
- <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round">
383
- <circle cx="8" cy="8" r="3" />
384
- <path d="M8 1.5v2 M8 12.5v2 M14.5 8h-2 M3.5 8h-2 M12.6 3.4l-1.4 1.4 M4.8 11.2l-1.4 1.4 M12.6 12.6l-1.4-1.4 M4.8 4.8l-1.4-1.4" />
385
- </svg>
386
- )}
387
- </button>
388
- </div>
389
- </div>
390
- </div>
391
-
392
- {/* sidebar */}
393
- <div className="sidebar">
394
- <div style={{ padding: '0 18px 12px', fontSize: 10, letterSpacing: '0.12em', textTransform: 'uppercase', color: 'var(--text-dim)' }}>
395
- ~/.autopg
396
- </div>
397
- {groups.map(g => (
398
- <div className="group" key={g.id}>
399
- <div className="group-label">[ {g.label} ]</div>
400
- {g.items.map(s => (
401
- <div
402
- key={s.id}
403
- className={cx('nav-item', route === s.id && 'on')}
404
- onClick={() => setRoute(s.id)}
405
- data-screen-label={s.label}
406
- >
407
- <span className="glyph">{s.glyph}</span>
408
- <span>{s.label}</span>
409
- {s.count && <span className="count">{s.count}</span>}
410
- </div>
411
- ))}
412
- </div>
413
- ))}
414
- <div style={{ padding: '14px 18px', fontSize: 10, color: 'var(--text-dim)', borderTop: '1px solid var(--line)', marginTop: 14 }}>
415
- <div style={{ marginBottom: 4 }}>autopg · settings vertical</div>
416
- <div>health vertical · next wish</div>
417
- </div>
418
- </div>
419
-
420
- {/* main */}
421
- <div className="main">
422
- {Screen
423
- ? <Screen theme={theme} setTheme={setTheme} />
424
- : <div className="page">loading…</div>}
425
- </div>
426
-
427
- {/* footer — live pgserve health line; full report on hover */}
428
- <LiveFooter />
429
-
430
- {/* CRT overlay */}
431
- <div className="crt-overlay" aria-hidden="true">
432
- <div className="crt-scan"></div>
433
- <div className="crt-vig"></div>
434
- <div className="crt-chroma"></div>
435
- </div>
436
-
437
- <window.TweaksPanel title="Tweaks">
438
- <window.TweakSection label="Phosphor" />
439
- <window.TweakSelect
440
- label="Tube color"
441
- value={tw.phosphor}
442
- options={[
443
- { value: 'green', label: 'P1 · green (default)' },
444
- { value: 'amber', label: 'P3 · amber' },
445
- { value: 'cyan', label: 'IBM · cyan' },
446
- { value: 'magenta', label: 'Synthwave · magenta' },
447
- { value: 'paper', label: 'Paper · muted' },
448
- ]}
449
- onChange={(v) => setTweak('phosphor', v)}
450
- />
451
- <div style={{ fontSize: 10, color: 'rgba(41,38,27,.55)', marginTop: -4, lineHeight: 1.4 }}>
452
- Recolors accent, vector, and audit families across every screen. Lumon (light) keeps its institutional blue.
453
- </div>
454
-
455
- <window.TweakSection label="Density" />
456
- <window.TweakRadio
457
- label="Layout"
458
- value={tw.density}
459
- options={[
460
- { value: 'compact', label: 'Compact' },
461
- { value: 'standard', label: 'Standard' },
462
- { value: 'roomy', label: 'Roomy' },
463
- ]}
464
- onChange={(v) => setTweak('density', v)}
465
- />
466
-
467
- <window.TweakSection label="CRT intensity" />
468
- <window.TweakRadio
469
- label="Tube"
470
- value={tw.crt}
471
- options={[
472
- { value: 'off', label: 'Flat' },
473
- { value: 'subtle', label: 'Subtle' },
474
- { value: 'heavy', label: 'Heavy' },
475
- ]}
476
- onChange={(v) => setTweak('crt', v)}
477
- />
478
- </window.TweaksPanel>
479
- </div>
480
- );
481
- }
482
-
483
- ReactDOM.createRoot(document.getElementById('root')).render(<App />);
@@ -1,167 +0,0 @@
1
- /* pgserve · atoms */
2
- const { useState, useEffect, useRef, useMemo } = React;
3
-
4
- const cx = (...c) => c.filter(Boolean).join(' ');
5
-
6
- function Btn({ kind = 'default', size, children, onClick, title }) {
7
- return (
8
- <button
9
- className={cx('btn', kind !== 'default' && kind, size === 'sm' && 'sm')}
10
- onClick={onClick}
11
- title={title}
12
- >
13
- {children}
14
- </button>
15
- );
16
- }
17
-
18
- function Tag({ kind, children }) {
19
- return <span className={cx('tag', kind)}>{children}</span>;
20
- }
21
-
22
- function Dot({ color = 'var(--accent)' }) {
23
- return <span style={{ width: 6, height: 6, borderRadius: '50%', background: color, display: 'inline-block' }} />;
24
- }
25
-
26
- function BracketH({ children, hint }) {
27
- return (
28
- <h3 className="bracket-h">
29
- [ {children} ]{hint && <span className="dim">{hint}</span>}
30
- </h3>
31
- );
32
- }
33
-
34
- function Stat({ label, value, sub, accent = false, status }) {
35
- return (
36
- <div className="stat">
37
- <div className="lbl">{label}</div>
38
- <div className="val">
39
- {accent ? <span className="accent">{value}</span> : value}
40
- </div>
41
- {sub && <div className="sub"><span className={status}>{sub}</span></div>}
42
- </div>
43
- );
44
- }
45
-
46
- /* CLI block-bar meter */
47
- function MiniBar({ value, max = 100, width = 20, kind = 'ok' }) {
48
- const filled = Math.round((value / max) * width);
49
- const empty = Math.max(0, width - filled);
50
- return (
51
- <span className="mbar">
52
- <span className={cx('blk', kind !== 'ok' && kind)}>{'█'.repeat(filled)}</span>
53
- <span className="empty">{'░'.repeat(empty)}</span>
54
- </span>
55
- );
56
- }
57
-
58
- function Threshold({ label, value, max = 100, suffix = '%', kind = 'ok' }) {
59
- const pct = Math.min(100, (value / max) * 100);
60
- return (
61
- <div className="threshold">
62
- <span className="lbl">{label}</span>
63
- <span className="track">
64
- <span className={cx('fill', kind !== 'ok' && kind)} style={{ width: `${pct}%` }} />
65
- </span>
66
- <span className="v">{value}{suffix}</span>
67
- </div>
68
- );
69
- }
70
-
71
- /* live-tailing log line */
72
- function LogLine({ ts, lvl = 'info', evt, msg }) {
73
- return (
74
- <div className="log-line">
75
- <span className="ts">{ts}</span>
76
- <span className={cx('lvl', lvl)}>{evt}</span>
77
- <span className="msg">{msg}</span>
78
- </div>
79
- );
80
- }
81
-
82
- /* SVG sparkline */
83
- function Sparkline({ data, w = 120, h = 28, color = 'var(--accent)' }) {
84
- const max = Math.max(...data), min = Math.min(...data);
85
- const range = max - min || 1;
86
- const step = w / (data.length - 1);
87
- const pts = data.map((d, i) => `${(i * step).toFixed(1)},${(h - ((d - min) / range) * (h - 4) - 2).toFixed(1)}`).join(' ');
88
- const areaPts = `0,${h} ${pts} ${w},${h}`;
89
- return (
90
- <svg className="spark" width={w} height={h} viewBox={`0 0 ${w} ${h}`}>
91
- <polygon points={areaPts} fill={color} opacity="0.12" />
92
- <polyline points={pts} fill="none" stroke={color} strokeWidth="1.2" />
93
- </svg>
94
- );
95
- }
96
-
97
- /* fingerprint hex emphasis */
98
- function FP({ hex }) {
99
- return <span style={{ color: 'var(--accent)' }}>{hex}</span>;
100
- }
101
-
102
- /* segmented control */
103
- function Seg({ options, value, onChange }) {
104
- return (
105
- <div className="seg">
106
- {options.map(o => (
107
- <button key={o.value} className={value === o.value ? 'on' : ''} onClick={() => onChange(o.value)}>
108
- {o.label}
109
- </button>
110
- ))}
111
- </div>
112
- );
113
- }
114
-
115
- /* alert banner */
116
- function Alert({ kind = 'warn', label, children, actions }) {
117
- return (
118
- <div className={cx('alert', kind)}>
119
- <span className="lbl">{label}</span>
120
- <span className="msg">{children}</span>
121
- {actions && <span className="actions">{actions}</span>}
122
- </div>
123
- );
124
- }
125
-
126
- /* score chip 0..100 */
127
- function Score({ value, max = 100 }) {
128
- const kind = value >= 80 ? 'ok' : value >= 60 ? 'warn' : 'err';
129
- return (
130
- <span className={cx('score', kind)}>
131
- <span className="v">{value}</span>
132
- <span className="max">/{max}</span>
133
- </span>
134
- );
135
- }
136
-
137
- /* bracket-eyebrow */
138
- function Eyebrow({ children, info = true }) {
139
- return <span className={info ? 'bracket-eyebrow' : 'eyebrow'}>{children}</span>;
140
- }
141
-
142
- /* placeholder for screens not yet implemented in v1; renders inside the
143
- * standard <page> shell so navigation chrome stays consistent and the
144
- * sidebar reads "[ coming soon ]" rather than blowing the React tree up. */
145
- function ComingSoon({ title, crumb }) {
146
- return (
147
- <div className="page">
148
- <div className="page-head">
149
- <h1>{title}</h1>
150
- {crumb && <span className="crumb">{crumb}</span>}
151
- </div>
152
- <div className="panel" style={{ padding: 32, textAlign: 'center' }}>
153
- <div style={{ fontSize: 14, letterSpacing: '0.08em', textTransform: 'uppercase', color: 'var(--text-dim)' }}>
154
- [ coming soon ]
155
- </div>
156
- <div style={{ marginTop: 12, fontSize: 12, color: 'var(--text-dim)' }}>
157
- this screen scaffolds the autopg-console-settings wish; a future wish ships its content.
158
- </div>
159
- </div>
160
- </div>
161
- );
162
- }
163
-
164
- Object.assign(window, {
165
- cx, Btn, Tag, Dot, BracketH, Stat, MiniBar, Threshold, LogLine,
166
- Sparkline, FP, Seg, Alert, Score, Eyebrow, ComingSoon,
167
- });