@join-pantheon/cli 0.33.11 → 0.34.0-rc.1
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/accounts.js +229 -8
- package/dist/admin-pages.js +674 -0
- package/dist/admin-stats.js +11 -5
- package/dist/admin-ui.js +416 -0
- package/dist/board.js +17 -2
- package/dist/byte-lru.js +52 -0
- package/dist/cli.js +180 -37
- package/dist/desktop-app.js +2 -2
- package/dist/flow-stats.js +501 -0
- package/dist/home-guard.js +27 -2
- package/dist/home-safety.js +1 -0
- package/dist/ledger.js +10 -4
- package/dist/leftovers.js +178 -0
- package/dist/notice.js +1 -0
- package/dist/notifier.js +15 -3
- package/dist/open-in.js +349 -0
- package/dist/relay.js +1429 -617
- package/dist/roster-file.js +0 -6
- package/dist/store.js +36 -1
- package/dist/tray.js +16 -1
- package/dist/uri-handler.js +1 -1
- package/dist/viewer-pages.js +190 -0
- package/helper/macos/main.swift +25 -5
- package/helper/macos/menubar.swift +56 -1
- package/helper/macos/prebuilt/manifest.json +5 -5
- package/helper/macos/prebuilt/pantheon-hud +0 -0
- package/helper/macos/prebuilt/pantheon-tray +0 -0
- package/helper/windows/pantheon-tray.ps1 +26 -1
- package/package.json +1 -1
package/dist/admin-stats.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ACTS } from "./protocol.js";
|
|
2
|
+
import { relayComposed } from "./verify-act.js";
|
|
2
3
|
export const DAY = 86_400_000;
|
|
3
4
|
export const emptyRefusals = () => ({ total: 0, by_code: {}, recent: [], stamps: [] });
|
|
4
5
|
export function noteRefusal(r, e, keep = 50) {
|
|
@@ -18,12 +19,13 @@ export const emptyActivity = () => ({
|
|
|
18
19
|
messages: 0, messages_24h: 0, messages_7d: 0, by_act: {}, by_act_24h: {},
|
|
19
20
|
senders: [], senders_24h: [], sessions_24h: 0, roles_24h: {}, first: null, last: null,
|
|
20
21
|
});
|
|
22
|
+
export const isMessage = (r) => !relayComposed(r);
|
|
21
23
|
export function activity(records, now = Date.now(), key = (r) => r.from) {
|
|
22
24
|
const a = emptyActivity();
|
|
23
25
|
const senders = new Set(), senders24 = new Set(), sessions24 = new Set();
|
|
24
26
|
const day = now - DAY, week = now - 7 * DAY;
|
|
25
27
|
for (const r of records) {
|
|
26
|
-
if (r
|
|
28
|
+
if (!isMessage(r))
|
|
27
29
|
continue;
|
|
28
30
|
a.messages++;
|
|
29
31
|
a.by_act[r.act] = (a.by_act[r.act] ?? 0) + 1;
|
|
@@ -142,7 +144,7 @@ export function spaceHealth(input) {
|
|
|
142
144
|
const now = input.now ?? Date.now();
|
|
143
145
|
const relayAgeMs = input.relayAgeMs ?? Infinity;
|
|
144
146
|
const admitted = input.members.filter((m) => m.admitted);
|
|
145
|
-
const messages = input.records.filter(
|
|
147
|
+
const messages = input.records.filter(isMessage);
|
|
146
148
|
let messages_7d = 0, messages_prev_21d = 0, last_message = null;
|
|
147
149
|
const days = new Set();
|
|
148
150
|
for (const r of messages) {
|
|
@@ -177,7 +179,7 @@ export function spaceHealth(input) {
|
|
|
177
179
|
? `${input.interactive} at a keyboard now${services ? `, ${services} service connection${services === 1 ? "" : "s"}` : ""}`
|
|
178
180
|
: services ? `${services} connected, services only — nobody at a keyboard` : "";
|
|
179
181
|
let verdict, says;
|
|
180
|
-
if (
|
|
182
|
+
if (messages_7d > 0) {
|
|
181
183
|
verdict = "active";
|
|
182
184
|
says = `${messages_7d} message${messages_7d === 1 ? "" : "s"} this week${presence ? `, ${presence}` : ""}`;
|
|
183
185
|
}
|
|
@@ -205,13 +207,17 @@ export function spaceHealth(input) {
|
|
|
205
207
|
messages_7d, messages_prev_21d, active_days_prev_21d: days.size, last_message, last_seen, versions, behind,
|
|
206
208
|
};
|
|
207
209
|
}
|
|
208
|
-
export function fleetReport(rows, relayPkg, now = Date.now(), relayAgeMs = Infinity) {
|
|
210
|
+
export function fleetReport(rows, relayPkg, now = Date.now(), relayAgeMs = Infinity, unreadable = []) {
|
|
209
211
|
const date = new Date(now).toISOString().slice(0, 10);
|
|
210
212
|
const counts = VERDICT_ORDER.map((v) => [v, rows.filter((r) => r.verdict === v).length]).filter(([, n]) => n > 0);
|
|
213
|
+
const total = rows.length + unreadable.length;
|
|
211
214
|
const lines = [
|
|
212
215
|
`pantheon relay ${relayPkg} — the week to ${date}`,
|
|
213
|
-
`${
|
|
216
|
+
`${total} space${total === 1 ? "" : "s"}${unreadable.length ? ` · ${unreadable.length} unreadable` : ""}${counts.map(([v, n]) => ` · ${n} ${v}`).join("")}`,
|
|
214
217
|
];
|
|
218
|
+
const uw = Math.max(4, ...unreadable.map((u) => u.name.length));
|
|
219
|
+
for (const u of unreadable)
|
|
220
|
+
lines.push(`${"unreadable".padEnd(13)} ${u.name.padEnd(uw)} history can't be read right now (${u.code})`);
|
|
215
221
|
const sorted = [...rows].sort((a, b) => VERDICT_ORDER.indexOf(a.verdict) - VERDICT_ORDER.indexOf(b.verdict) || b.messages_7d - a.messages_7d || a.name.localeCompare(b.name));
|
|
216
222
|
const width = Math.max(4, ...sorted.map((r) => r.name.length));
|
|
217
223
|
for (const r of sorted)
|
package/dist/admin-ui.js
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
export const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (m) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[m]));
|
|
3
|
+
export const MARK = `<svg class="mark" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linecap="round" aria-hidden="true"><path d="M6.399 5.083A8.9 8.9 0 0 1 17.601 5.083"/><path d="M8.811 20.309A8.9 8.9 0 0 1 3.21 10.608"/><path d="M20.79 10.608A8.9 8.9 0 0 1 15.189 20.309"/></svg>`;
|
|
4
|
+
export const SEAL = `<svg class="seal" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 .8l1.5 1.3 1.9-.4.8 1.8 1.8.8-.4 1.9L15 7.7l-1.3 1.5.4 1.9-1.8.8-.8 1.8-1.9-.4L8 14.6l-1.5-1.3-1.9.4-.8-1.8-1.8-.8.4-1.9L1 7.7l1.3-1.5-.4-1.9 1.8-.8.8-1.8 1.9.4z"/><circle cx="8" cy="7.7" r="3.1" fill="none" stroke="var(--surface)" stroke-width="1.2"/></svg>`;
|
|
5
|
+
export const FONTS_HREF = "https://fonts.googleapis.com/css2?family=Archivo+Black&family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap";
|
|
6
|
+
const TOKENS = `
|
|
7
|
+
:root{
|
|
8
|
+
--paper:#ece0c8;--cream:#f1e7d3;--stone:#ddd0b6;--ink:#1b1917;--ink-mid:#26221f;--ink-lift:#3a3430;
|
|
9
|
+
--coral:#e36f55;--coral-deep:#b8492f;--mustard:#e0aa3e;--teal:#2e8a84;--teal-deep:#1f5f5b;
|
|
10
|
+
--ui:"Geist",ui-sans-serif,system-ui,sans-serif;--ui-mono:"Geist Mono",ui-monospace,monospace;--display:"Archivo Black","Arial Black",sans-serif;
|
|
11
|
+
--ease-out:cubic-bezier(.16,1,.3,1);
|
|
12
|
+
--chart-worker:var(--teal);--chart-person:var(--mustard);
|
|
13
|
+
|
|
14
|
+
--bg:var(--paper);--surface:var(--cream);--surface-2:#e5d8bd;--line:#d3c4a6;--edge:#c3b291;
|
|
15
|
+
--text:var(--ink);--muted:#5b5248;--quiet:#6b6155;--shadow:rgba(27,25,23,.9);
|
|
16
|
+
--accent:var(--coral);--accent-text:var(--coral-deep);--on-accent:var(--ink);
|
|
17
|
+
--chip-bg:var(--teal-deep);--chip-text:var(--cream);
|
|
18
|
+
--worker:var(--chart-worker);--person:var(--chart-person);--grid:#d9cbae;--matrix-low:var(--ink);
|
|
19
|
+
/* text on a lever that ends or removes something: coral-deep, one step darker to reach 4.5:1 on cream */
|
|
20
|
+
--danger-text:#a13f28;
|
|
21
|
+
/* who-asked-whom cells: how strong the darkest may get, and its text, so every cell keeps 4.5:1 */
|
|
22
|
+
--matrix-max:.85;--matrix-text:var(--ink);
|
|
23
|
+
color-scheme:light;
|
|
24
|
+
}
|
|
25
|
+
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
|
|
26
|
+
--bg:var(--ink);--surface:var(--ink-mid);--surface-2:#2f2a26;--line:#3a3430;--edge:#4a423b;
|
|
27
|
+
--text:var(--cream);--muted:#b9ad97;--quiet:#9d917b;--shadow:#0b0a09;
|
|
28
|
+
--accent-text:var(--coral);--grid:#3a3430;--matrix-low:var(--cream);--danger-text:var(--coral);--matrix-max:.75;--matrix-text:var(--cream);color-scheme:dark;
|
|
29
|
+
}}
|
|
30
|
+
:root[data-theme="dark"]{
|
|
31
|
+
--bg:var(--ink);--surface:var(--ink-mid);--surface-2:#2f2a26;--line:#3a3430;--edge:#4a423b;
|
|
32
|
+
--text:var(--cream);--muted:#b9ad97;--quiet:#9d917b;--shadow:#0b0a09;
|
|
33
|
+
--accent-text:var(--coral);--grid:#3a3430;--matrix-low:var(--cream);--danger-text:var(--coral);--matrix-max:.75;--matrix-text:var(--cream);color-scheme:dark;
|
|
34
|
+
}`;
|
|
35
|
+
export const CSS = `${TOKENS}
|
|
36
|
+
*{box-sizing:border-box}
|
|
37
|
+
html{-webkit-text-size-adjust:100%}
|
|
38
|
+
body{margin:0;background:var(--bg);color:var(--text);font:400 14px/1.5 var(--ui);font-feature-settings:"ss01"}
|
|
39
|
+
a{color:inherit;text-decoration:underline;text-decoration-color:var(--edge);text-underline-offset:3px}
|
|
40
|
+
a:hover{text-decoration-color:currentColor}
|
|
41
|
+
:focus-visible{outline:3px solid var(--mustard);outline-offset:2px;border-radius:4px}
|
|
42
|
+
code,.mono{font-family:var(--ui-mono);font-size:12.5px}
|
|
43
|
+
.muted{color:var(--muted)}.quiet{color:var(--quiet)}
|
|
44
|
+
.num{font-variant-numeric:tabular-nums}
|
|
45
|
+
h1,h2,h3{margin:0;font-weight:600;letter-spacing:-.01em}
|
|
46
|
+
h1{font-size:22px}h2{font-size:17px}h3{font-size:14.5px}
|
|
47
|
+
.mark{width:22px;height:22px;flex:none}
|
|
48
|
+
.seal{width:14px;height:14px;flex:none;vertical-align:-2px}
|
|
49
|
+
.skip{position:absolute;left:-999px;top:8px;background:var(--text);color:var(--bg);padding:6px 10px;border-radius:6px;z-index:60}
|
|
50
|
+
.skip:focus{left:12px}
|
|
51
|
+
|
|
52
|
+
.top{display:flex;align-items:center;gap:18px;flex-wrap:wrap;padding:14px clamp(16px,3vw,32px);border-bottom:1px solid var(--line);background:var(--bg)}
|
|
53
|
+
.lockup{display:flex;align-items:center;gap:8px;text-decoration:none;color:var(--text)}
|
|
54
|
+
.lockup b{font:400 18px/1 var(--display);letter-spacing:-.01em}
|
|
55
|
+
.ctx{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:13px;flex-wrap:wrap;min-width:0}
|
|
56
|
+
.ctx .sep{opacity:.5}
|
|
57
|
+
.tabs{display:flex;gap:2px;flex-wrap:wrap}
|
|
58
|
+
.tabs a{white-space:nowrap;padding:6px 10px;border-radius:6px;text-decoration:none;color:var(--muted);font-weight:500;font-size:13.5px}
|
|
59
|
+
.tabs a:hover{background:var(--surface-2);color:var(--text)}
|
|
60
|
+
.tabs a[aria-current]{color:var(--text);box-shadow:inset 0 -2px 0 var(--text);border-radius:0}
|
|
61
|
+
.tabs a .n{font-family:var(--ui-mono);font-size:11.5px;color:var(--quiet);margin-left:4px}
|
|
62
|
+
.right{margin-left:auto;display:flex;align-items:center;gap:12px;font-size:13px;color:var(--muted);flex-wrap:wrap}
|
|
63
|
+
.iconbtn{font:500 12.5px var(--ui);color:var(--text);background:transparent;border:1px solid var(--line);border-radius:7px;padding:5px 9px;cursor:pointer;text-decoration:none;display:inline-block}
|
|
64
|
+
.iconbtn:hover{border-color:var(--edge);background:var(--surface-2)}
|
|
65
|
+
.linkbtn{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer;text-decoration:underline;text-decoration-color:var(--edge);text-underline-offset:3px}
|
|
66
|
+
|
|
67
|
+
main{padding:0 clamp(16px,3vw,32px) 56px;max-width:1440px;margin:0 auto}
|
|
68
|
+
.row{display:flex;align-items:baseline;gap:12px;flex-wrap:wrap}
|
|
69
|
+
.sec{margin-top:36px}
|
|
70
|
+
.sechead{display:flex;align-items:baseline;gap:12px;flex-wrap:wrap;margin-bottom:12px}
|
|
71
|
+
.sechead p{margin:0;color:var(--muted);font-size:13px}
|
|
72
|
+
.sechead .end{margin-left:auto;display:flex;gap:8px;align-items:center;font-size:13px;flex-wrap:wrap}
|
|
73
|
+
.cardhead{padding:16px 18px 0}
|
|
74
|
+
|
|
75
|
+
.health{display:flex;flex-wrap:wrap;gap:6px 22px;padding:10px 0;margin-top:14px;font-size:12.5px;color:var(--muted)}
|
|
76
|
+
.health span b{color:var(--text);font-weight:500}
|
|
77
|
+
.dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--teal);margin-right:6px;vertical-align:0}
|
|
78
|
+
.dot.off{background:transparent;border:1.5px solid var(--quiet)}
|
|
79
|
+
.dot.amber{background:var(--mustard)}
|
|
80
|
+
.dot.bad{background:var(--coral)}
|
|
81
|
+
|
|
82
|
+
.seg{display:inline-flex;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--surface)}
|
|
83
|
+
.seg a{font:500 12.5px var(--ui);color:var(--muted);text-decoration:none;padding:6px 11px}
|
|
84
|
+
.seg a:hover{color:var(--text)}
|
|
85
|
+
.seg a[aria-current]{background:var(--text);color:var(--bg)}
|
|
86
|
+
.seg a:focus-visible{outline-offset:-3px;border-radius:7px}
|
|
87
|
+
|
|
88
|
+
.tiles{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:12px;margin-top:16px}
|
|
89
|
+
.tile{background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:14px 16px 13px;box-shadow:0 3px 0 var(--line);min-width:0}
|
|
90
|
+
.tile .l{font-size:12.5px;color:var(--muted);font-weight:500}
|
|
91
|
+
.tile .v{font-size:28px;font-weight:600;line-height:1.15;margin:6px 0 2px;letter-spacing:-.02em}
|
|
92
|
+
.tile .v small{font-size:13px;font-weight:500;color:var(--muted);margin-left:4px;letter-spacing:0}
|
|
93
|
+
.tile .d{font-size:12.5px;color:var(--muted)}
|
|
94
|
+
.tile.call{border-color:var(--text);box-shadow:0 4px 0 var(--shadow)}
|
|
95
|
+
.tile.call .v{color:var(--accent-text)}
|
|
96
|
+
.delta{font-family:var(--ui-mono);font-size:11.5px;color:var(--text);background:var(--surface-2);border-radius:5px;padding:1px 5px;margin-left:6px;vertical-align:2px}
|
|
97
|
+
|
|
98
|
+
.card{background:var(--surface);border:1px solid var(--line);border-radius:10px;box-shadow:0 3px 0 var(--line);min-width:0}
|
|
99
|
+
.card.pad{padding:16px 18px}
|
|
100
|
+
.scroll{overflow-x:auto}
|
|
101
|
+
.grid2{display:grid;grid-template-columns:minmax(0,1.55fr) minmax(0,1fr);gap:16px;align-items:start}
|
|
102
|
+
.grid2.even{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
|
|
103
|
+
.stack{display:flex;flex-direction:column;gap:16px;min-width:0}
|
|
104
|
+
table{border-collapse:collapse;width:100%;font-variant-numeric:tabular-nums}
|
|
105
|
+
th{font-size:12.5px;font-weight:500;color:var(--muted);text-align:left;padding:10px 14px;border-bottom:1px solid var(--line);white-space:nowrap}
|
|
106
|
+
td{padding:11px 14px;border-bottom:1px solid var(--line);vertical-align:top}
|
|
107
|
+
tbody tr:last-child td{border-bottom:0}
|
|
108
|
+
tbody tr.link{cursor:pointer}
|
|
109
|
+
tbody tr.link:hover td{background:var(--surface-2)}
|
|
110
|
+
td.r,th.r{text-align:right}
|
|
111
|
+
td.empty{color:var(--muted);text-align:center;padding:22px 14px}
|
|
112
|
+
.sub{display:block;font-size:12.5px;color:var(--muted);margin-top:2px}
|
|
113
|
+
.who{font-weight:500}
|
|
114
|
+
.tname{font-weight:600;text-decoration:none}
|
|
115
|
+
.tname:hover{text-decoration:underline}
|
|
116
|
+
.wrapc{overflow-wrap:anywhere}
|
|
117
|
+
|
|
118
|
+
.chip{display:inline-flex;align-items:center;gap:5px;font:500 12px/1 var(--ui);padding:4px 8px;border-radius:999px;white-space:nowrap;background:var(--chip-bg);color:var(--chip-text)}
|
|
119
|
+
.chip.plain{background:var(--surface-2);color:var(--text);box-shadow:inset 0 0 0 1px var(--line)}
|
|
120
|
+
.chip.line{background:transparent;color:var(--text);box-shadow:inset 0 0 0 1.5px var(--text)}
|
|
121
|
+
.chip.mono{font-family:var(--ui-mono);font-size:11.5px}
|
|
122
|
+
.chip .seal{width:12px;height:12px}
|
|
123
|
+
.role{font:500 12px var(--ui);color:var(--muted);white-space:nowrap}
|
|
124
|
+
.role.w::before,.role.p::before{content:"";display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:5px;vertical-align:0}
|
|
125
|
+
.role.w::before{background:var(--worker)}.role.p::before{background:var(--person)}
|
|
126
|
+
|
|
127
|
+
.meter{display:inline-block;width:72px;height:6px;border-radius:3px;background:var(--surface-2);box-shadow:inset 0 0 0 1px var(--line);vertical-align:2px;margin-right:8px;overflow:hidden}
|
|
128
|
+
.meter i{display:block;height:100%;border-radius:3px;background:var(--quiet)}
|
|
129
|
+
.meter i.hot{background:var(--mustard)}
|
|
130
|
+
.meter i.over{background:var(--text)}
|
|
131
|
+
|
|
132
|
+
.steps{display:flex;align-items:flex-start;gap:0;margin-top:8px;max-width:560px}
|
|
133
|
+
.step{flex:0 0 112px;position:relative;min-width:0;text-align:left}
|
|
134
|
+
.step .pt{width:12px;height:12px;border-radius:50%;border:2px solid var(--edge);background:var(--surface);position:relative;z-index:1}
|
|
135
|
+
.step.done .pt{background:var(--teal);border-color:var(--teal)}
|
|
136
|
+
.step.now .pt{background:var(--surface);border-color:var(--mustard);box-shadow:0 0 0 3px color-mix(in srgb,var(--mustard) 30%,transparent)}
|
|
137
|
+
.step::after{content:"";position:absolute;left:12px;right:0;top:5px;height:2px;background:var(--line)}
|
|
138
|
+
.step.done::after{background:var(--mustard)}
|
|
139
|
+
.step:last-child::after{display:none}
|
|
140
|
+
.step .sl{font:500 11.5px var(--ui-mono);color:var(--text);margin-top:6px;white-space:nowrap}
|
|
141
|
+
.step .st{font-size:11.5px;color:var(--muted);white-space:nowrap}
|
|
142
|
+
.step.todo .sl{color:var(--quiet)}
|
|
143
|
+
|
|
144
|
+
.list{list-style:none;margin:0;padding:0}
|
|
145
|
+
.list li{padding:12px 18px;border-bottom:1px solid var(--line);display:flex;gap:12px;align-items:flex-start}
|
|
146
|
+
.list li:last-child{border-bottom:0}
|
|
147
|
+
.list .ic{flex:none;width:22px;height:22px;border-radius:6px;display:grid;place-items:center;background:var(--surface-2);box-shadow:inset 0 0 0 1px var(--line);font:600 12px var(--ui-mono);color:var(--text)}
|
|
148
|
+
.list .t{min-width:0;flex:1}
|
|
149
|
+
.list .t b{font-weight:600}
|
|
150
|
+
.list .t .sub{margin-top:3px}
|
|
151
|
+
.list li.none{color:var(--muted)}
|
|
152
|
+
|
|
153
|
+
.chart{position:relative}
|
|
154
|
+
.chart svg{display:block;width:100%;height:auto;overflow:visible}
|
|
155
|
+
.legend{display:flex;gap:16px;flex-wrap:wrap;font-size:12.5px;color:var(--muted);margin:4px 0 8px}
|
|
156
|
+
.legend span::before{content:"";display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:6px;vertical-align:-1px}
|
|
157
|
+
.legend .w::before{background:var(--worker)}.legend .p::before{background:var(--person)}
|
|
158
|
+
.axis{font:400 11px var(--ui-mono);fill:var(--muted)}
|
|
159
|
+
.hit{fill:transparent;cursor:default}
|
|
160
|
+
.col:hover rect,.col:hover path,.col:focus rect,.col:focus path{opacity:.85}
|
|
161
|
+
.chart svg[tabindex]:focus-visible{outline:3px solid var(--mustard);outline-offset:4px}
|
|
162
|
+
.col.kbd .hit{stroke:var(--mustard);stroke-width:3}.col.kbd rect,.col.kbd path{opacity:.85}
|
|
163
|
+
details.tv{margin-top:8px;font-size:12.5px}
|
|
164
|
+
details.tv summary{cursor:pointer;color:var(--muted)}
|
|
165
|
+
details.tv table{margin-top:8px}
|
|
166
|
+
details.tv td,details.tv th{padding:4px 10px}
|
|
167
|
+
#tip{position:fixed;z-index:50;pointer-events:none;background:var(--text);color:var(--bg);font:500 12px/1.45 var(--ui);padding:7px 9px;border-radius:7px;max-width:260px;opacity:0;transition:opacity .12s}
|
|
168
|
+
#tip b{font-weight:600;font-size:13px}
|
|
169
|
+
|
|
170
|
+
.matrix{border-collapse:separate;border-spacing:3px;width:auto}
|
|
171
|
+
.matrix th{border:0;padding:4px 6px;font-size:12px}
|
|
172
|
+
.matrix td{border:0;width:58px;height:40px;text-align:center;vertical-align:middle;border-radius:6px;font:500 13px var(--ui-mono);padding:0}
|
|
173
|
+
.matrix td.self{background:transparent}
|
|
174
|
+
.matrix td.z{color:var(--quiet);background:transparent;box-shadow:inset 0 0 0 1px var(--line)}
|
|
175
|
+
.matrix td.h{background:color-mix(in srgb,var(--teal) calc(var(--a) * var(--matrix-max) * 100%),var(--surface));color:var(--matrix-text)}
|
|
176
|
+
.matrix th.rowh{text-align:right}
|
|
177
|
+
|
|
178
|
+
.note{font-size:12.5px;color:var(--muted);margin:10px 0 0;max-width:90ch}
|
|
179
|
+
.privacy{display:flex;gap:10px;align-items:flex-start;padding:12px 16px;border-radius:10px;background:var(--surface-2);box-shadow:inset 0 0 0 1px var(--line);font-size:13px;margin-top:16px}
|
|
180
|
+
.hidden-text{font-style:normal;color:var(--quiet);font-size:12.5px}
|
|
181
|
+
.flash{margin-top:14px;padding:10px 14px;border-radius:9px;background:var(--surface);border:1px solid var(--text);font-size:13.5px}
|
|
182
|
+
.more{white-space:nowrap;font:500 12.5px var(--ui);background:transparent;border:0;color:var(--text);text-decoration:underline;text-decoration-color:var(--edge);text-underline-offset:3px;cursor:pointer;padding:0}
|
|
183
|
+
.agewrap{white-space:nowrap}
|
|
184
|
+
.fullbody{white-space:pre-wrap;overflow-wrap:anywhere;font:400 13px/1.55 var(--ui);background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:12px 14px;margin-top:8px}
|
|
185
|
+
.kv{display:grid;grid-template-columns:max-content 1fr;gap:3px 14px;font-size:12.5px;margin-top:8px}
|
|
186
|
+
.kv span{color:var(--muted)}
|
|
187
|
+
|
|
188
|
+
/* forms */
|
|
189
|
+
input.field,select.field,input[type=search].field{font:13px var(--ui);padding:6px 10px;border-radius:7px;border:1px solid var(--line);background:var(--surface);color:var(--text);min-width:0}
|
|
190
|
+
input[type=number].field{width:80px}
|
|
191
|
+
.filters{display:flex;flex-wrap:wrap;gap:10px 14px;align-items:flex-end;margin-bottom:12px}
|
|
192
|
+
.filters label{display:flex;flex-direction:column;gap:4px;font-size:12.5px;color:var(--muted)}
|
|
193
|
+
.filters label.chk{flex-direction:row;align-items:center;gap:6px}
|
|
194
|
+
.btn{font:500 12.5px var(--ui);color:var(--text);background:var(--surface-2);border:1px solid var(--edge);border-radius:7px;padding:6px 11px;cursor:pointer}
|
|
195
|
+
.btn:hover{border-color:var(--text)}
|
|
196
|
+
.btn.danger{color:var(--danger-text);border-color:currentColor;background:transparent}
|
|
197
|
+
.inl{display:inline}
|
|
198
|
+
|
|
199
|
+
/* the destructive and rare levers live behind a menu */
|
|
200
|
+
details.menu{position:relative;display:inline-block}
|
|
201
|
+
details.menu>summary{list-style:none;font:600 15px/1 var(--ui);letter-spacing:1px;border:1px solid var(--line);color:var(--text);border-radius:6px;width:30px;height:26px;display:grid;place-items:center;cursor:pointer;user-select:none}
|
|
202
|
+
details.menu>summary::-webkit-details-marker{display:none}
|
|
203
|
+
details.menu[open]>summary{background:var(--surface-2)}
|
|
204
|
+
details.menu .pop{position:absolute;right:0;top:32px;z-index:20;background:var(--surface);border:1px solid var(--text);border-radius:10px;box-shadow:0 4px 0 var(--shadow);padding:8px;min-width:260px;text-align:left;display:flex;flex-direction:column;gap:6px}
|
|
205
|
+
details.menu .pop form{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin:0}
|
|
206
|
+
details.menu .pop .h{font-size:11.5px;color:var(--muted);padding:2px 4px}
|
|
207
|
+
details.menu .pop button.item{width:100%;text-align:left;font:500 13px var(--ui);background:transparent;border:0;border-radius:6px;padding:7px 8px;color:var(--text);cursor:pointer}
|
|
208
|
+
details.menu .pop button.item:hover{background:var(--surface-2)}
|
|
209
|
+
details.menu .pop button.item.danger{color:var(--danger-text)}
|
|
210
|
+
details.menu .pop hr{border:0;border-top:1px solid var(--line);margin:2px 0;width:100%}
|
|
211
|
+
|
|
212
|
+
@media (max-width:1180px){.tiles{grid-template-columns:repeat(3,minmax(0,1fr))}}
|
|
213
|
+
@media (max-width:900px){.grid2,.grid2.even{grid-template-columns:minmax(0,1fr)}}
|
|
214
|
+
@media (max-width:720px){
|
|
215
|
+
.tiles{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
|
|
216
|
+
.tile{padding:12px 13px}.tile .v{font-size:24px}
|
|
217
|
+
.right{margin-left:0;width:100%;justify-content:space-between}
|
|
218
|
+
.tabs{width:100%;flex-wrap:wrap;row-gap:4px}
|
|
219
|
+
.rt thead{display:none}
|
|
220
|
+
.rt,.rt tbody,.rt tr,.rt td{display:block;width:100%}
|
|
221
|
+
.rt tr{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px 14px;padding:14px 16px;border-bottom:1px solid var(--line)}
|
|
222
|
+
.rt tbody tr:last-child{border-bottom:0}
|
|
223
|
+
.rt td{border:0;padding:0;text-align:left!important;min-width:0}
|
|
224
|
+
.rt td.span{grid-column:1/-1}
|
|
225
|
+
.rt td.hide-s{display:none}
|
|
226
|
+
.rt td.menu-s{grid-column:1/-1}
|
|
227
|
+
.rt td[data-l]::before{content:attr(data-l);display:block;font-size:11.5px;color:var(--muted);margin-bottom:2px}
|
|
228
|
+
.steps{max-width:none}
|
|
229
|
+
.step{flex:1 1 0}.step .sl{font-size:10.5px}.step .st{font-size:10.5px}
|
|
230
|
+
.wide{display:none}
|
|
231
|
+
.matrix td{width:44px;height:34px;font-size:12px}
|
|
232
|
+
.health{gap:4px 14px}
|
|
233
|
+
details.menu .pop{right:auto;left:0}
|
|
234
|
+
}
|
|
235
|
+
@media (min-width:721px){.narrow{display:none}}
|
|
236
|
+
@media (prefers-reduced-motion:reduce){*,*::before,*::after{transition:none!important;animation:none!important;scroll-behavior:auto!important}}
|
|
237
|
+
`;
|
|
238
|
+
export const newNonce = () => randomBytes(16).toString("base64");
|
|
239
|
+
export const csp = (nonce) => `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'nonce-${nonce}' https://fonts.googleapis.com; style-src-attr 'unsafe-inline'; font-src https://fonts.gstatic.com; img-src data:; form-action 'self'; frame-ancestors 'none'; base-uri 'none'`;
|
|
240
|
+
export const pageHeaders = (nonce) => ({
|
|
241
|
+
"content-type": "text/html; charset=utf-8", "cache-control": "no-store", "referrer-policy": "no-referrer",
|
|
242
|
+
"x-content-type-options": "nosniff", "x-frame-options": "DENY", "content-security-policy": csp(nonce),
|
|
243
|
+
});
|
|
244
|
+
export function head(o) {
|
|
245
|
+
return `<!doctype html>
|
|
246
|
+
<html lang="en">
|
|
247
|
+
<head>
|
|
248
|
+
<meta charset="utf-8">
|
|
249
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
250
|
+
<meta name="robots" content="noindex,nofollow">${o.refresh ? `
|
|
251
|
+
<meta http-equiv="refresh" content="${Math.max(1, Math.round(o.refresh))}${o.refreshTo ? `;url=${esc(o.refreshTo)}` : ""}">` : ""}
|
|
252
|
+
<title>${esc(o.title)}</title>
|
|
253
|
+
<meta name="description" content="${esc(o.description)}">
|
|
254
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
255
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
256
|
+
<link href="${FONTS_HREF}" rel="stylesheet">
|
|
257
|
+
<style nonce="${esc(o.nonce)}">${CSS}${o.extraCss ?? ""}</style>
|
|
258
|
+
</head>`;
|
|
259
|
+
}
|
|
260
|
+
export function script(nonce) {
|
|
261
|
+
return `<div id="tip" role="tooltip"></div>
|
|
262
|
+
<script nonce="${nonce}">
|
|
263
|
+
(function(){
|
|
264
|
+
var root=document.documentElement, KEY="pantheon-admin-theme";
|
|
265
|
+
try{var saved=localStorage.getItem(KEY); if(saved==="light"||saved==="dark") root.setAttribute("data-theme",saved);}catch(e){}
|
|
266
|
+
var q=new URLSearchParams(location.search).get("theme"); if(q==="light"||q==="dark") root.setAttribute("data-theme",q);
|
|
267
|
+
function isDark(){var t=root.getAttribute("data-theme"); return t? t==="dark" : matchMedia("(prefers-color-scheme: dark)").matches;}
|
|
268
|
+
function label(){document.querySelectorAll("[data-theme-toggle]").forEach(function(b){b.textContent=isDark()?"Light":"Dark";b.setAttribute("aria-label","Switch to "+(isDark()?"light":"dark")+" theme");});}
|
|
269
|
+
document.addEventListener("click",function(e){
|
|
270
|
+
var b=e.target.closest("[data-theme-toggle]"); if(!b) return;
|
|
271
|
+
var next=isDark()?"light":"dark"; root.setAttribute("data-theme",next);
|
|
272
|
+
try{localStorage.setItem(KEY,next);}catch(err){}
|
|
273
|
+
label();
|
|
274
|
+
});
|
|
275
|
+
label();
|
|
276
|
+
var tip=document.getElementById("tip");
|
|
277
|
+
function show(el,x,y){var lines=(el.getAttribute("data-tip")||"").split("|");tip.textContent="";lines.forEach(function(l,i){var d=document.createElement(i?"div":"b");d.textContent=l;tip.appendChild(d)});tip.style.opacity="1";var r=tip.getBoundingClientRect();var nx=Math.min(x+14,innerWidth-r.width-8);var ny=y-r.height-12;if(ny<8)ny=y+16;tip.style.left=nx+"px";tip.style.top=ny+"px";}
|
|
278
|
+
function hide(){tip.style.opacity="0";}
|
|
279
|
+
document.querySelectorAll("[data-tip]").forEach(function(el){
|
|
280
|
+
el.addEventListener("pointermove",function(e){show(el,e.clientX,e.clientY)});
|
|
281
|
+
el.addEventListener("pointerleave",hide);
|
|
282
|
+
if(el.hasAttribute("tabindex")){
|
|
283
|
+
el.addEventListener("focus",function(){var r=el.getBoundingClientRect();show(el,r.left+r.width/2,r.top)});
|
|
284
|
+
el.addEventListener("blur",hide);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
document.querySelectorAll("tr[data-href]").forEach(function(tr){
|
|
288
|
+
tr.addEventListener("click",function(e){if(e.target.closest("a,button,summary,input,select,form"))return;location.href=tr.getAttribute("data-href")});
|
|
289
|
+
});
|
|
290
|
+
var WD=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"], MN=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
|
|
291
|
+
function two(n){return (n<10?"0":"")+n;}
|
|
292
|
+
// Every time on the page, in this browser's own zone. A time today shows as 14:05; any other day with its date.
|
|
293
|
+
var today=new Date().toDateString();
|
|
294
|
+
document.querySelectorAll("time[data-t]").forEach(function(t){
|
|
295
|
+
var d=new Date(Number(t.getAttribute("data-t"))); if(isNaN(d)) return;
|
|
296
|
+
var f=t.getAttribute("data-f"), day=WD[d.getDay()]+" "+d.getDate()+" "+MN[d.getMonth()], hm=two(d.getHours())+":"+two(d.getMinutes());
|
|
297
|
+
if(f==="time"&&d.toDateString()!==today) f="full";
|
|
298
|
+
t.textContent=f==="date"?day:f==="full"?day+" "+hm:f==="sec"?hm+":"+two(d.getSeconds()):hm; t.title=d.toString();
|
|
299
|
+
});
|
|
300
|
+
// A chart is one tab stop: arrow keys walk its columns, each read out by the tooltip; the table view has every number.
|
|
301
|
+
document.querySelectorAll("svg[data-cols]").forEach(function(svg){
|
|
302
|
+
var cols=svg.querySelectorAll(".col"), i=-1;
|
|
303
|
+
function at(k){ if(!cols.length) return; if(i>-1) cols[i].classList.remove("kbd"); i=Math.max(0,Math.min(cols.length-1,k)); var c=cols[i]; c.classList.add("kbd"); var r=c.getBoundingClientRect(); show(c,r.left+r.width/2,r.top); svg.setAttribute("aria-label",c.getAttribute("aria-label")); }
|
|
304
|
+
svg.addEventListener("keydown",function(e){
|
|
305
|
+
if(e.key==="ArrowRight"){at(i+1);e.preventDefault();} else if(e.key==="ArrowLeft"){at(i<0?cols.length-1:i-1);e.preventDefault();}
|
|
306
|
+
else if(e.key==="Home"){at(0);e.preventDefault();} else if(e.key==="End"){at(cols.length-1);e.preventDefault();}
|
|
307
|
+
});
|
|
308
|
+
svg.addEventListener("blur",function(){ if(i>-1) cols[i].classList.remove("kbd"); i=-1; hide(); });
|
|
309
|
+
});
|
|
310
|
+
document.querySelectorAll("input[data-filter]").forEach(function(inp){
|
|
311
|
+
var table=document.getElementById(inp.getAttribute("data-filter")); if(!table) return;
|
|
312
|
+
var out=document.createElement("p"); out.className="note"; out.setAttribute("role","status");
|
|
313
|
+
(table.closest(".card")||table).insertAdjacentElement("afterend",out);
|
|
314
|
+
inp.addEventListener("input",function(){
|
|
315
|
+
var q=inp.value.trim().toLowerCase(), rows=table.querySelectorAll("tbody tr"), shown=0;
|
|
316
|
+
for(var i=0;i<rows.length;i++){var m=!q||rows[i].textContent.toLowerCase().indexOf(q)>-1;rows[i].hidden=!m;if(m)shown++;}
|
|
317
|
+
out.textContent=q?(shown?shown+" matching":"Nothing matches. Clear the filter to see everything."):"";
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
document.addEventListener("submit",function(e){
|
|
321
|
+
var f=e.target, c=f.getAttribute("data-confirm"), typed=f.getAttribute("data-type-to-confirm");
|
|
322
|
+
if(typed!==null){var v=prompt(c||"Type the name to confirm."); if(v!==typed){e.preventDefault();return;} var inp=f.querySelector("[name=confirm]"); if(inp) inp.value=v; return;}
|
|
323
|
+
if(c&&!confirm(c)) e.preventDefault();
|
|
324
|
+
});
|
|
325
|
+
document.addEventListener("keydown",function(e){
|
|
326
|
+
if(e.key!=="Escape") return;
|
|
327
|
+
document.querySelectorAll("details.menu[open]").forEach(function(d){d.removeAttribute("open");var s=d.querySelector("summary");if(s)s.focus();});
|
|
328
|
+
});
|
|
329
|
+
document.addEventListener("click",function(e){
|
|
330
|
+
document.querySelectorAll("details.menu[open]").forEach(function(d){if(!d.contains(e.target))d.removeAttribute("open");});
|
|
331
|
+
});
|
|
332
|
+
})();
|
|
333
|
+
</script>`;
|
|
334
|
+
}
|
|
335
|
+
const W = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], MO = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
336
|
+
export const shortDay = (ts) => { const d = new Date(ts); return `${d.getUTCDate()} ${MO[d.getUTCMonth()]}`; };
|
|
337
|
+
export const longDay = (ts) => { const d = new Date(ts); return `${W[d.getUTCDay()]} ${d.getUTCDate()} ${MO[d.getUTCMonth()]}`; };
|
|
338
|
+
export const hhmm = (ts) => new Date(ts).toISOString().slice(11, 16);
|
|
339
|
+
export const when = (ts, f = "time") => {
|
|
340
|
+
if (!ts)
|
|
341
|
+
return `<span class="quiet">never</span>`;
|
|
342
|
+
const today = new Date().toISOString().slice(0, 10) === new Date(ts).toISOString().slice(0, 10);
|
|
343
|
+
const fmt = f === "time" && !today ? "full" : f;
|
|
344
|
+
const text = fmt === "date" ? longDay(ts) : fmt === "full" ? `${longDay(ts)} ${hhmm(ts)} UTC` : fmt === "sec" ? `${new Date(ts).toISOString().slice(11, 19)} UTC` : `${hhmm(ts)} UTC`;
|
|
345
|
+
return `<time data-t="${ts}" data-f="${f}" datetime="${new Date(ts).toISOString()}">${text}</time>`;
|
|
346
|
+
};
|
|
347
|
+
export const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
348
|
+
export const pct = (a, b) => (b ? Math.round((a / b) * 100) : 0);
|
|
349
|
+
export const cap = (s) => (s ? s[0].toUpperCase() + s.slice(1) : s);
|
|
350
|
+
export function stackedColumns(o) {
|
|
351
|
+
const legend = `<div class="legend"><span class="w">By a worker</span><span class="p">By a person</span><em class="quiet" style="font-style:normal">days in UTC</em></div>`;
|
|
352
|
+
const k = Math.min(o.narrowDays ?? 14, o.days.length);
|
|
353
|
+
const name = (d) => `${longDay(d.ts)}${d.today ? " (so far)" : ""}`;
|
|
354
|
+
const rows = o.days.map((d) => `<tr><td>${name(d)}</td><td class="r">${d.worker}</td><td class="r">${d.person}</td><td class="r">${d.worker + d.person}</td></tr>`).join("");
|
|
355
|
+
return `<div class="chart">${legend}<div class="wide">${columnsSvg({ ...o, days: o.days })}</div><div class="narrow">${columnsSvg({ ...o, days: o.days.slice(-k), width: 360, height: 170, step: 4 })}</div>
|
|
356
|
+
<details class="tv"><summary>Show as a table</summary><div class="scroll"><table><thead><tr><th>Day</th><th class="r">By a worker</th><th class="r">By a person</th><th class="r">Total</th></tr></thead><tbody>${rows}</tbody></table></div></details></div>`;
|
|
357
|
+
}
|
|
358
|
+
function columnsSvg(o) {
|
|
359
|
+
const days = o.days, height = o.height ?? 180, width = o.width ?? 760, step = Math.max(1, o.step ?? 7);
|
|
360
|
+
const n = Math.max(1, days.length), padL = 34, padB = 22, padT = 8;
|
|
361
|
+
const max = Math.max(1, ...days.map((d) => d.worker + d.person));
|
|
362
|
+
const tstep = max > 300 ? 100 : max > 60 ? 50 : max > 20 ? 10 : max > 8 ? 5 : 2;
|
|
363
|
+
const top = Math.ceil(max / tstep) * tstep;
|
|
364
|
+
const ticks = Array.from({ length: top / tstep + 1 }, (_, i) => i * tstep);
|
|
365
|
+
const plotH = height - padB - padT, plotW = width - padL;
|
|
366
|
+
const band = plotW / n, bw = Math.min(22, band * 0.62);
|
|
367
|
+
const y = (v) => padT + plotH - (v / top) * plotH;
|
|
368
|
+
const roundTop = (x, y0, w, h, r) => {
|
|
369
|
+
if (h <= 0)
|
|
370
|
+
return "";
|
|
371
|
+
r = Math.min(r, h, w / 2);
|
|
372
|
+
return `M${x},${y0 + h}V${y0 + r}Q${x},${y0} ${x + r},${y0}H${x + w - r}Q${x + w},${y0} ${x + w},${y0 + r}V${y0 + h}Z`;
|
|
373
|
+
};
|
|
374
|
+
let g = "";
|
|
375
|
+
for (const t of ticks)
|
|
376
|
+
g += `<line x1="${padL}" x2="${width}" y1="${y(t)}" y2="${y(t)}" stroke="var(--grid)" stroke-width="1"/><text class="axis" x="${padL - 8}" y="${y(t) + 4}" text-anchor="end">${t}</text>`;
|
|
377
|
+
let bars = "";
|
|
378
|
+
days.forEach((d, i) => {
|
|
379
|
+
const x = padL + band * i + (band - bw) / 2;
|
|
380
|
+
const w = d.worker, p = d.person;
|
|
381
|
+
const hw = (w / top) * plotH, hp = (p / top) * plotH;
|
|
382
|
+
const yw = padT + plotH - hw, yp = yw - hp;
|
|
383
|
+
const gap = p > 0 && w > 0 ? 2 : 0;
|
|
384
|
+
const total = w + p;
|
|
385
|
+
const wPath = w > 0 ? (p > 0 ? `<rect x="${x.toFixed(1)}" y="${yw.toFixed(1)}" width="${bw.toFixed(1)}" height="${Math.max(0, hw).toFixed(1)}" fill="var(--worker)"/>` : `<path d="${roundTop(x, yw, bw, hw, 4)}" fill="var(--worker)"/>`) : "";
|
|
386
|
+
const pPath = p > 0 ? `<path d="${roundTop(x, yp, bw, hp - gap, 4)}" fill="var(--person)"/>` : "";
|
|
387
|
+
const nm = `${longDay(d.ts)}${d.today ? " (so far)" : ""}`;
|
|
388
|
+
bars += `<g class="col" data-tip="${nm}|${plural(total, "message")}|${w} by a worker · ${p} by a person" aria-label="${nm}: ${plural(total, "message")}, ${w} by a worker, ${p} by a person"><rect class="hit" x="${(padL + band * i).toFixed(1)}" y="${padT}" width="${band.toFixed(1)}" height="${plotH}"/>${wPath}${pPath}</g>`;
|
|
389
|
+
if (i % step === (n - 1) % step)
|
|
390
|
+
bars += `<text class="axis" x="${(x + bw / 2).toFixed(1)}" y="${height - 5}" text-anchor="middle">${shortDay(d.ts)}</text>`;
|
|
391
|
+
});
|
|
392
|
+
return `<svg viewBox="0 0 ${width} ${height}" role="img" tabindex="0" data-cols aria-label="${esc(o.label)} Use the arrow keys to read each day.">${g}<line x1="${padL}" x2="${width}" y1="${y(0)}" y2="${y(0)}" stroke="var(--edge)" stroke-width="1"/>${bars}</svg>`;
|
|
393
|
+
}
|
|
394
|
+
export function spark(vals, w = 96, h = 26) {
|
|
395
|
+
const max = Math.max(1, ...vals);
|
|
396
|
+
const n = Math.max(2, vals.length);
|
|
397
|
+
const pts = vals.map((v, i) => [2 + (i * (w - 6)) / (n - 1), h - 3 - (v / max) * (h - 7)]);
|
|
398
|
+
const d = pts.map((p, i) => `${i ? "L" : "M"}${p[0].toFixed(1)},${p[1].toFixed(1)}`).join("");
|
|
399
|
+
const last = pts[pts.length - 1] ?? [w - 4, h - 3];
|
|
400
|
+
return `<svg width="${w}" height="${h}" viewBox="0 0 ${w} ${h}" aria-hidden="true" style="display:block"><path d="${d}" fill="none" stroke="var(--quiet)" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round"/><circle cx="${last[0].toFixed(1)}" cy="${last[1].toFixed(1)}" r="3.2" fill="var(--teal)" stroke="var(--surface)" stroke-width="2"/></svg>`;
|
|
401
|
+
}
|
|
402
|
+
export function split(w, p, of, width = 120) {
|
|
403
|
+
const ww = of ? (w / of) * width : 0, pw = of ? (p / of) * width : 0;
|
|
404
|
+
return `<svg width="${width}" height="10" viewBox="0 0 ${width} 10" aria-hidden="true" style="display:inline-block;vertical-align:0"><rect x="0" y="0" width="${width}" height="10" rx="3" fill="var(--surface-2)"/>${ww ? `<rect x="0" y="0" width="${Math.max(0, ww - (pw ? 1 : 0)).toFixed(1)}" height="10" rx="3" fill="var(--worker)"/>` : ""}${pw ? `<rect x="${(ww + 1).toFixed(1)}" y="0" width="${Math.max(0, pw - 1).toFixed(1)}" height="10" rx="3" fill="var(--person)"/>` : ""}</svg>`;
|
|
405
|
+
}
|
|
406
|
+
export function steps(list) {
|
|
407
|
+
return `<div class="steps" role="list">${list.map((x) => { const t = x.subText ?? x.sub; return `<div class="step ${x.state}" role="listitem" aria-label="${esc(x.label)}${x.state === "done" ? (t ? `, ${esc(t)}` : ", done") : x.state === "now" ? ", waiting" : ", not yet"}"><div class="pt"></div><div class="sl">${esc(x.label)}</div><div class="st">${x.sub}</div></div>`; }).join("")}</div>`;
|
|
408
|
+
}
|
|
409
|
+
export function rangeSeg(href, days) {
|
|
410
|
+
const opt = (d, label) => `<a href="${esc(href(d))}"${d === days ? ` aria-current="true"` : ""}>${label}</a>`;
|
|
411
|
+
return `<nav class="seg" aria-label="Time range">${opt(1, "24 hours")}${opt(7, "7 days")}${opt(30, "30 days")}</nav>`;
|
|
412
|
+
}
|
|
413
|
+
export const rangeWords = (days) => (days === 1 ? "in the last 24 hours" : `in the last ${days} days`);
|
|
414
|
+
export const RANGES = [1, 7, 30];
|
|
415
|
+
export const rangeOf = (v) => { const n = Number(v); return RANGES.includes(n) ? n : 7; };
|
|
416
|
+
//# sourceMappingURL=admin-ui.js.map
|
package/dist/board.js
CHANGED
|
@@ -63,6 +63,15 @@ const TOKEN_RE = /^[0-9a-f]{64}$/;
|
|
|
63
63
|
const ID_RE = /^[A-Za-z0-9_-]{1,80}$/;
|
|
64
64
|
const MAX_BODY_BYTES = 64 * 1024;
|
|
65
65
|
const SENT_KEEP_MS = 10 * 60_000;
|
|
66
|
+
async function openInNow(home) {
|
|
67
|
+
try {
|
|
68
|
+
const oi = await import("./open-in.js");
|
|
69
|
+
return oi.effectiveOpenIn({ home, appPresent: () => oi.claudeAppPresent() });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return "terminal";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
66
75
|
export function defaultBoardDeps(home = CONFIG_DIR) {
|
|
67
76
|
return {
|
|
68
77
|
status: async () => (await import("./tray.js")).trayStatus(),
|
|
@@ -389,10 +398,10 @@ export async function startBoardServer(o = {}) {
|
|
|
389
398
|
}
|
|
390
399
|
catch { }
|
|
391
400
|
} };
|
|
392
|
-
const runQueued = (a) => serial(async () => {
|
|
401
|
+
const runQueued = (a, extra = []) => serial(async () => {
|
|
393
402
|
const { text, nonce } = writeAction(a);
|
|
394
403
|
try {
|
|
395
|
-
return { r: await deps.cli(["explain", "--queued", "--only-action", "--action-id", nonce], 30_000), nonce };
|
|
404
|
+
return { r: await deps.cli(["explain", "--queued", "--only-action", "--action-id", nonce, ...extra], 30_000), nonce };
|
|
396
405
|
}
|
|
397
406
|
finally {
|
|
398
407
|
dropOurs(text);
|
|
@@ -601,6 +610,12 @@ export async function startBoardServer(o = {}) {
|
|
|
601
610
|
sendJson(res, 400, { ok: false, error: hud.error });
|
|
602
611
|
return;
|
|
603
612
|
}
|
|
613
|
+
if (op.op === "open" && await openInNow(home) === "app") {
|
|
614
|
+
const q = await runQueued(hud, ["--silent"]);
|
|
615
|
+
const r = explainOutcome(q.r, q.nonce);
|
|
616
|
+
sendJson(res, 200, { ok: r.ok, message: r.ok ? "Opening it in the Claude app — the question is typed in; press Enter there to send it." : r.message });
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
604
619
|
if (op.op === "open") {
|
|
605
620
|
const r = await openQueued(hud);
|
|
606
621
|
sendJson(res, 200, { ok: r.ok, message: r.ok ? "Opening your agent in a terminal…" : (r.why ?? "no terminal could be opened here — copy the question into your agent") });
|
package/dist/byte-lru.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export class ByteLru {
|
|
2
|
+
limit;
|
|
3
|
+
map = new Map();
|
|
4
|
+
held = 0;
|
|
5
|
+
constructor(limit) {
|
|
6
|
+
this.limit = limit;
|
|
7
|
+
}
|
|
8
|
+
get size() { return this.map.size; }
|
|
9
|
+
get bytes() { return this.held; }
|
|
10
|
+
get(key) {
|
|
11
|
+
const e = this.map.get(key);
|
|
12
|
+
if (!e)
|
|
13
|
+
return undefined;
|
|
14
|
+
this.map.delete(key);
|
|
15
|
+
this.map.set(key, e);
|
|
16
|
+
return e.value;
|
|
17
|
+
}
|
|
18
|
+
peek(key) { return this.map.get(key)?.value; }
|
|
19
|
+
has(key) { return this.map.has(key); }
|
|
20
|
+
set(key, value, bytes) {
|
|
21
|
+
const b = Number.isFinite(bytes) && bytes > 0 ? bytes : 0;
|
|
22
|
+
this.delete(key);
|
|
23
|
+
this.map.set(key, { value, bytes: b });
|
|
24
|
+
this.held += b;
|
|
25
|
+
for (const [k, e] of this.map) {
|
|
26
|
+
if (this.held <= this.limit() || k === key)
|
|
27
|
+
break;
|
|
28
|
+
this.map.delete(k);
|
|
29
|
+
this.held -= e.bytes;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
delete(key) {
|
|
33
|
+
const e = this.map.get(key);
|
|
34
|
+
if (!e)
|
|
35
|
+
return false;
|
|
36
|
+
this.map.delete(key);
|
|
37
|
+
this.held -= e.bytes;
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
deleteWhere(test) {
|
|
41
|
+
let n = 0;
|
|
42
|
+
for (const k of [...this.map.keys()])
|
|
43
|
+
if (test(k) && this.delete(k))
|
|
44
|
+
n++;
|
|
45
|
+
return n;
|
|
46
|
+
}
|
|
47
|
+
clear() { this.map.clear(); this.held = 0; }
|
|
48
|
+
keys() { return this.map.keys(); }
|
|
49
|
+
recount() { let n = 0; for (const e of this.map.values())
|
|
50
|
+
n += e.bytes; return n; }
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=byte-lru.js.map
|