chirkle 0.4.0 → 0.4.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/README.md +32 -24
- package/bin/release/darwin-amd64/chirkle-server +2 -2
- package/bin/release/darwin-arm64/chirkle-server +0 -0
- package/bin/release/linux-amd64/chirkle-server +0 -0
- package/bin/release/linux-arm64/chirkle-server +0 -0
- package/package.json +2 -1
- package/pb_hooks/lib/account.js +541 -6
- package/pb_hooks/lib/collections.js +4 -4
- package/pb_hooks/lib/dms.js +1 -1
- package/pb_hooks/lib/inbox.js +1 -1
- package/pb_hooks/lib/invites.js +266 -0
- package/pb_hooks/lib/messages.js +11 -2
- package/pb_hooks/lib/moderation.js +1 -1
- package/pb_hooks/lib/retention.js +3 -0
- package/pb_hooks/lib/site.js +1 -1
- package/pb_hooks/lib/users.js +38 -10
- package/pb_hooks/main.pb.js +26 -1
- package/pb_hooks/telegram/api.js +64 -12
- package/pb_hooks/telegram/inbound.js +106 -15
- package/pb_hooks/telegram/outbound.js +63 -37
- package/pb_hooks/telegram/worker.js +59 -15
- package/pb_migrations/1760000052_deleted_accounts.js +19 -0
- package/pb_migrations/1760000053_account_jobs.js +45 -0
- package/pb_migrations/1760000054_room_invites.js +39 -0
- package/pb_migrations/1760000055_invite_barred.js +16 -0
- package/pb_migrations/1760000056_telegram_fetch.js +21 -0
- package/pb_public/assets/{access-PB77EH4F.css → access-GPRLOZOO.css} +2 -2
- package/pb_public/assets/{access-PB77EH4F.css.map → access-GPRLOZOO.css.map} +2 -2
- package/pb_public/assets/access-UK3L54NR.js +2 -0
- package/pb_public/assets/access-UK3L54NR.js.map +7 -0
- package/pb_public/assets/account-CT2BVMAX.css +2 -0
- package/pb_public/assets/account-CT2BVMAX.css.map +7 -0
- package/pb_public/assets/account-api-J6A6IYVX.js +2 -0
- package/pb_public/assets/account-api-J6A6IYVX.js.map +7 -0
- package/pb_public/assets/app-HB3NZHQ2.js +3 -0
- package/pb_public/assets/app-HB3NZHQ2.js.map +7 -0
- package/pb_public/assets/app-XJ73EU5O.css +2 -0
- package/pb_public/assets/app-XJ73EU5O.css.map +7 -0
- package/pb_public/assets/chunk-AG73QNUN.js +2 -0
- package/pb_public/assets/chunk-AG73QNUN.js.map +7 -0
- package/pb_public/assets/chunk-DCLJRQ53.js +2 -0
- package/pb_public/assets/chunk-DCLJRQ53.js.map +7 -0
- package/pb_public/assets/chunk-N2OFGBCZ.js +2 -0
- package/pb_public/assets/{chunk-PWNJABVI.js.map → chunk-N2OFGBCZ.js.map} +4 -4
- package/pb_public/assets/chunk-OKIIBH7O.js +2 -0
- package/pb_public/assets/chunk-OKIIBH7O.js.map +7 -0
- package/pb_public/assets/chunk-UZDXAORM.js +2 -0
- package/pb_public/assets/chunk-UZDXAORM.js.map +7 -0
- package/pb_public/assets/chunk-WR25F7FU.js +2 -0
- package/pb_public/assets/chunk-WR25F7FU.js.map +7 -0
- package/pb_public/assets/invite-OGT5E2MZ.js +2 -0
- package/pb_public/assets/invite-OGT5E2MZ.js.map +7 -0
- package/pb_public/assets/invite-api-7G7XPXQW.js +2 -0
- package/pb_public/assets/invite-api-7G7XPXQW.js.map +7 -0
- package/pb_public/assets/login-TK6K4WGB.js +2 -0
- package/pb_public/assets/{login-ECFBJP6Q.js.map → login-TK6K4WGB.js.map} +1 -1
- package/pb_public/assets/profile-3R6S5QYS.js +2 -0
- package/pb_public/assets/profile-3R6S5QYS.js.map +7 -0
- package/pb_public/assets/stats-GTO2H6PG.js +2 -0
- package/pb_public/assets/stats-GTO2H6PG.js.map +7 -0
- package/pb_public/index.html +7 -5
- package/pb_public/stats.html +1 -1
- package/scripts/service.mjs +201 -0
- package/scripts/start.mjs +7 -1
- package/pb_public/assets/access-LHPD2EHG.js +0 -2
- package/pb_public/assets/access-LHPD2EHG.js.map +0 -7
- package/pb_public/assets/app-6ETOTHXQ.js +0 -3
- package/pb_public/assets/app-6ETOTHXQ.js.map +0 -7
- package/pb_public/assets/app-ZGHECF33.css +0 -2
- package/pb_public/assets/app-ZGHECF33.css.map +0 -7
- package/pb_public/assets/chunk-GXMWOXBX.js +0 -2
- package/pb_public/assets/chunk-GXMWOXBX.js.map +0 -7
- package/pb_public/assets/chunk-IFQGGTSP.js +0 -2
- package/pb_public/assets/chunk-IFQGGTSP.js.map +0 -7
- package/pb_public/assets/chunk-PWNJABVI.js +0 -2
- package/pb_public/assets/login-ECFBJP6Q.js +0 -2
- package/pb_public/assets/profile-NQQLAEDT.js +0 -2
- package/pb_public/assets/profile-NQQLAEDT.js.map +0 -7
- package/pb_public/assets/stats-ARDU576A.js +0 -2
- package/pb_public/assets/stats-ARDU576A.js.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../web/src/dom.ts", "../../web/src/strings/stats-main.ts", "../../web/src/theme.ts", "../../web/src/strings/stats-data.ts", "../../web/src/stats/data.ts", "../../web/src/stats/main.ts"],
|
|
4
|
+
"sourcesContent": ["// Minimal DOM helpers (\u00A77.3). Strings always become text nodes: there is no HTML parsing anywhere.\n\nexport type Child = Node | string | number | null | undefined | false;\n\ntype Listeners = { [K in keyof HTMLElementEventMap]?: (ev: HTMLElementEventMap[K]) => void };\n\nexport interface Attrs {\n class?: string;\n dataset?: Record<string, string>;\n on?: Listeners;\n /** Removes every `on` listener when aborted. */\n signal?: AbortSignal;\n value?: string;\n checked?: boolean;\n [attr: string]: unknown;\n}\n\nconst PROPS = new Set([\"value\", \"checked\"]);\n\nexport function h<K extends keyof HTMLElementTagNameMap>(tag: K, attrs: Attrs = {}, children?: Child | Child[]): HTMLElementTagNameMap[K] {\n const el = document.createElement(tag);\n const { class: cls, dataset, on: listeners, signal, ...rest } = attrs;\n if (cls) el.className = cls;\n if (dataset) Object.assign(el.dataset, dataset);\n for (const [name, v] of Object.entries(rest)) {\n if (v === undefined || v === null || v === false) continue;\n if (PROPS.has(name)) (el as unknown as Record<string, unknown>)[name] = v;\n else el.setAttribute(name, v === true ? \"\" : String(v));\n }\n if (listeners) {\n for (const [type, fn] of Object.entries(listeners)) {\n el.addEventListener(type, fn as EventListener, signal ? { signal } : undefined);\n }\n }\n append(el, children);\n return el;\n}\n\nexport function append(el: Node, children: Child | Child[]): void {\n for (const c of Array.isArray(children) ? children : [children]) {\n if (c === null || c === undefined || c === false) continue;\n el.appendChild(typeof c === \"object\" ? c : document.createTextNode(String(c)));\n }\n}\n\nlet idSeq = 0;\n\n/** A document-unique id for label/aria wiring, e.g. uniqueId(\"room\") \u2192 \"room-3\". */\nexport function uniqueId(prefix: string): string {\n return `${prefix}-${++idSeq}`;\n}\n\nexport function clear(el: Element): void {\n el.replaceChildren();\n}\n\n/**\n * Make `parent`'s children exactly `nodes`, in order, moving only what differs (\u00A77.5: the message list is\n * never fully re-rendered). Nodes already in place keep their identity, focus and scroll anchoring.\n */\nexport function reconcile(parent: Element, nodes: readonly Node[]): void {\n // Drop what goes first: a replaced node left in place would push every node after it down one, and each of them\n // would then be moved (re-inserted, restyled) instead of left alone.\n const keep = new Set(nodes);\n for (const c of [...parent.childNodes]) if (!keep.has(c)) c.remove();\n nodes.forEach((node, i) => {\n const at = parent.childNodes[i];\n if (at !== node) parent.insertBefore(node, at ?? null);\n });\n}\n\n/**\n * Keep what is typed while a lazy chunk loads (a search field that isn't there yet), for the field once it shows:\n * printable keys and Backspace, not shortcuts, and Enter after some text (as \"\\n\": a name typed and Enter pressed before\n * the field showed went nowhere, QA BUG-272). `take()` stops holding and says what was typed (QA BUG-243, BUG-252).\n */\nexport function holdKeys(signal: AbortSignal): { take(): string } {\n let early = \"\";\n const hold = (e: KeyboardEvent) => {\n if (e.ctrlKey || e.metaKey || e.altKey || e.isComposing) return;\n if (e.key === \"Enter\") {\n if (!early.replace(/\\n/g, \"\")) return;\n early += \"\\n\";\n } else if (e.key.length !== 1 && e.key !== \"Backspace\") return;\n else early = e.key === \"Backspace\" ? early.slice(0, -1) : early + e.key;\n e.preventDefault();\n };\n document.addEventListener(\"keydown\", hold, { capture: true, signal });\n return {\n take() {\n document.removeEventListener(\"keydown\", hold, true);\n return early;\n },\n };\n}\n\n/** Put `text` held by holdKeys() in `input`, as if typed there: its characters, then Enter if one was pressed. */\nexport function typeInto(input: HTMLInputElement | null | undefined, text: string): void {\n if (!text || !input) return;\n const chars = text.replace(/\\n/g, \"\");\n if (chars) {\n input.value += chars;\n input.dispatchEvent(new Event(\"input\", { bubbles: true }));\n }\n if (text.includes(\"\\n\")) input.dispatchEvent(new KeyboardEvent(\"keydown\", { key: \"Enter\", bubbles: true, cancelable: true }));\n}\n\n/**\n * A click on an open modal dialog's backdrop (outside its box) closes it, as Escape does: through a cancelable\n * \"cancel\" event, so a dialog that refuses Escape (busy saving, or closing its people search first) does the same\n * here. Both the press and the release must be outside, so a drag that selects text inside and ends outside doesn't\n * close it. One listener for every dialog, installed once by app.ts: the dialogs are in lazy chunks.\n */\nexport function closeDialogsOnBackdrop(): void {\n const outside = (e: MouseEvent): HTMLDialogElement | null => {\n const d = e.target;\n if (!(d instanceof HTMLDialogElement) || !d.open) return null;\n const r = d.getBoundingClientRect();\n return e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom ? d : null;\n };\n let pressed: HTMLDialogElement | null = null;\n document.addEventListener(\"pointerdown\", (e) => (pressed = outside(e)), true);\n document.addEventListener(\n \"click\",\n (e) => {\n const d = outside(e);\n const was = pressed;\n pressed = null;\n if (!d || d !== was) return;\n if (d.dispatchEvent(new Event(\"cancel\", { cancelable: true }))) d.close();\n },\n true,\n );\n}\n", "// The user-facing text of stats/main.ts (docs/REFACTOR.md item 56): one module per source file, so a lazy\n// screen's text stays in its own chunk. Copy changes here; a translation would replace these.\n\nexport const SHOW_AS_A_TABLE = \"Show as a table\";\nexport const TELEGRAM = \"Telegram\";\nexport const LINKED_INSTANCES = \"Linked instances\";\nexport const LINK_PREVIEWS = \"Link previews\";\nexport const THUMBNAILS_TO_MAKE = \"Thumbnails to make\";\nexport const VIDEO_SHAPES_TO_READ = \"Video shapes to read\";\nexport const FILES_TO_MOVE = \"Files to move\";\nexport const STORAGE_TO_CLEAN_UP = \"Storage to clean up\";\nexport const ACCOUNT_JOBS = \"Exports and deleted accounts\";\nexport const MEDIA = \"Media\";\nexport const DAILY_PRUNE = \"Daily prune\";\nexport const SERVER = \"Server\";\nexport const chirklePocketbase = (version: string | number, pocketbase: string | number) => `Chirkle ${version}, PocketBase ${pocketbase}`;\nexport const UP_FOR = \"Up for\";\nexport const CONNECTIONS = \"Connections\";\nexport const LIVE_EVENTS_WAITING = \"Live events waiting\";\nexport const DATABASE = \"Database\";\nexport const MEMORY = \"Memory\";\nexport const QUEUES = \"Queues\";\nexport const ROWS_WAITING_FOR_A_WORKER = \"Rows waiting for a worker\";\nexport const OLDEST = \"Oldest\";\nexport const FAILED_ONCE_OR_MORE = \"Failed once or more\";\nexport const ROWS = \"Rows\";\nexport const QUEUE = \"Queue\";\nexport const WORKERS = \"Workers\";\nexport const WHEN_EACH_WORKER_LAST_DID_ITS = \"When each worker last did its work\";\nexport const LAST_ERROR = \"Last error\";\nexport const LAST_PASS = \"Last pass\";\nexport const WORKER = \"Worker\";\nexport const ONLY_SUPERUSERS_SEE_THIS_ALSO_AT =\n \"Only superusers see this. Also at /api/chat/metrics, in Prometheus's format with ?format=prometheus.\";\nexport const peopleOnlineOverTheLast = (day: boolean) => `People online over the last ${day ? \"24 hours\" : \"7 days\"}`;\nexport const NOT_RECORDED = \"Not recorded.\";\nexport const NO_SAMPLES_YET_ONE_IS_TAKEN = \"No samples yet: one is taken every 5 minutes.\";\nexport const RANGE = \"Range\";\nexport const MOST_PEOPLE_ONLINE_BY_DAY = \"Most people online, by day\";\nexport const MOST_PEOPLE_ONLINE_BY_HOUR = \"Most people online, by hour\";\nexport const PEOPLE = \"People\";\nexport const HOUR = \"Hour\";\nexport const MESSAGES_PER_DAY_THE_LAST_30 = \"Messages per day, the last 30 days\";\nexport const TODAY = \"Today\";\nexport const MESSAGES_PER_DAY = \"Messages per day\";\nexport const PEOPLE_WHO_POSTED = \"People who posted\";\nexport const MESSAGES = \"Messages\";\nexport const RECORDING_IS_OFF_SITE_SETTINGS_NO =\n \"Recording is off (site settings: no_stats). Live numbers and messages are still shown; what was recorded before is dropped as it ages.\";\nexport const PEOPLE_ONLINE = \"People online\";\nexport const ON_THE_WEB = \"On the web\";\nexport const ON_ANDROID = \"On Android\";\nexport const GUESTS = \"Guests\";\nexport const PEAK_TODAY = \"Peak today\";\nexport const PEAK_7_DAYS = \"Peak, 7 days\";\nexport const USAGE = \"Usage\";\nexport const ACTIVE_24_HOURS = \"Active, 24 hours\";\nexport const ACTIVE_7_DAYS = \"Active, 7 days\";\nexport const ACTIVE_30_DAYS = \"Active, 30 days\";\nexport const TIME_ONLINE_TODAY = \"Time online today\";\nexport const TIME_ONLINE_7_DAYS = \"Time online, 7 days\";\nexport const PER_ACTIVE_PERSON = \"Per active person\";\nexport const ACTIVE_ONLINE_AT_LEAST_ONCE_TIME = \"Active: online at least once. Time online is counted every 5 minutes.\";\nexport const IN_DMS = \"In DMs\";\nexport const FILES_SENT = \"Files sent\";\nexport const REACTIONS = \"Reactions\";\nexport const ACCOUNTS = \"Accounts\";\nexport const NEW_7_DAYS = \"New, 7 days\";\nexport const MODERATORS = \"Moderators\";\nexport const BANNED = \"Banned\";\nexport const updated = (time: string | number) => `Updated ${time}`;\nexport const PAGE_NOT_FOUND = \"Page not found\";\nexport const THERE_IS_NO_SUCH_PAGE_OR = \"There is no such page, or you can't see it.\";\nexport const BACK_TO_THE_APP = \"Back to the app\";\nexport const COULDNT_LOAD_RETRYING = \"Couldn't load. Retrying\u2026\";\nexport const couldntRefreshShowing = (time: string | number) => `Couldn't refresh: showing ${time}`;\nexport const TIP_ONLINE = \"people online\";\nexport const TIP_WEB = \"on the web\";\nexport const TIP_ANDROID = \"on Android\";\nexport const TIP_GUESTS = \"guests\";\nexport const tipMessages = (n: number) => (n === 1 ? \"message\" : \"messages\");\nexport const tipPosted = (n: number) => (n === 1 ? \"person posted\" : \"people posted\");\nexport const GUESTS_NOTE = \"open tabs, not signed in\";\nexport const at = (time: string) => `at ${time}`;\nexport const ALL_PEOPLE = \"all people together\";\nexport const WEEK_AVERAGE = \"a week, on average\";\nexport const running = (busy: boolean) => (busy ? \" (running)\" : \"\");\nexport const REALTIME_INCL_GUESTS = \"realtime, incl. guests\";\nexport const slowClientsDroppedSinceTheStart = (n: number, shown: string) =>\n `${shown} slow ${n === 1 ? \"client\" : \"clients\"} dropped since the start`;\nexport const logs = (size: string | number) => `logs ${size}`;\nexport const fromTheSystem = (size: string | number) => `${size} from the system`;\nexport const ofAccounts = (percent: string | number) => `${percent} of accounts`;\nexport const peoplePosted = (n: number, shown: string) => `${shown} ${n === 1 ? \"person\" : \"people\"} posted`;\nexport const HOURS_24 = \"24 hours\";\nexport const DAYS_7 = \"7 days\";\nexport const DAYS_30 = \"30 days\";\nexport const OF_THE_30_DAYS = \"of the 30 days'\";\nexport const ON_THE_30_DAYS_MESSAGES = \"on the 30 days' messages\";\nexport const DAY = \"Day\";\nexport const NOW = \"Now\";\n", "// Light, dark or the system's (auto) theme (\u00A77.8): this device's choice, kept in localStorage. index.html's inline\n// script sets <html data-theme> before the first paint; this keeps it, and the browser's bar color, up to date.\n\nexport const THEMES = [\"auto\", \"light\", \"dark\"] as const;\nexport type Theme = (typeof THEMES)[number];\n\n/** Must match index.html's inline script. */\nexport const THEME_KEY = \"chat.theme\";\n\n/** --surface of each theme (tokens.css), for <meta name=\"theme-color\">. */\nconst BAR = { light: \"#f1eefc\", dark: \"#111214\" } as const;\n\nfunction safeLocalStorage(): Storage | null {\n try {\n return globalThis.localStorage ?? null;\n } catch {\n return null;\n }\n}\n\nexport function savedTheme(storage: Storage | null = safeLocalStorage()): Theme {\n try {\n const v = storage?.getItem(THEME_KEY);\n return v === \"light\" || v === \"dark\" ? v : \"auto\";\n } catch {\n return \"auto\";\n }\n}\n\n/** Show `theme` here: the stylesheet goes by <html data-theme>, the browser's bar by the theme-color metas. */\nexport function applyTheme(theme: Theme, doc: Document = document): void {\n const html = doc.documentElement;\n if (theme === \"auto\") delete html.dataset.theme;\n else html.dataset.theme = theme;\n for (const meta of doc.querySelectorAll<HTMLMetaElement>('meta[name=\"theme-color\"]')) {\n // Each meta's own media query says which theme it is for; a chosen theme gives both its color.\n const forTheme = meta.media.includes(\"dark\") ? \"dark\" : \"light\";\n meta.content = BAR[theme === \"auto\" ? forTheme : theme];\n }\n}\n\n/** Save and show `theme`. Storage can throw (private window, quota): the theme still changes for this page. */\nexport function setTheme(theme: Theme, storage: Storage | null = safeLocalStorage()): void {\n try {\n if (theme === \"auto\") storage?.removeItem(THEME_KEY);\n else storage?.setItem(THEME_KEY, theme);\n } catch {}\n applyTheme(theme);\n}\n\n/** Apply the saved theme and follow another tab's changes. Returns a function that stops following. */\nexport function startTheme(storage: Storage | null = safeLocalStorage()): () => void {\n applyTheme(savedTheme(storage));\n const ac = new AbortController();\n addEventListener(\n \"storage\",\n (e) => {\n if (e.key === THEME_KEY || e.key === null) applyTheme(savedTheme(storage));\n },\n { signal: ac.signal },\n );\n return () => ac.abort();\n}\n", "// The user-facing text of stats/data.ts (docs/REFACTOR.md item 56): one module per source file, so a lazy\n// screen's text stays in its own chunk. Copy changes here; a translation would replace these.\n\nexport const min = (n: number) => `${n} min`;\nexport const hours = (n: string) => `${n} h`;\nexport const sec = (n: number) => `${n} s`;\nexport const days = (n: number) => `${n} d`;\nexport const ago = (span: string) => `${span} ago`;\nexport const NOT_SINCE_START = \"not since the start\";\n", "import * as S from \"../strings/stats-data.ts\";\n// Usage statistics (DESIGN.md \u00A740): what GET /api/chat/stats answers, and the figures the page works out from it.\n// Pure, so tests/unit can check them.\n\n/** A sample: [time (epoch ms), people online, guests, people on the web, people on Android]. */\nexport type Sample = [number, number, number, number, number];\n\nexport interface Stats {\n at: number;\n /** Recording (samples, activity) is on: site.no_stats isn't ticked. */\n history: boolean;\n sample_minutes: number;\n now: { online: number; guests: number; web: number; android: number };\n /** Accounts online in the last 24 hours, 7 days and 30 days. */\n active: { day: number; week: number; month: number };\n accounts: { total: number; new_week: number; moderators: number; banned: number };\n messages: {\n /** The viewer's days (YYYY-MM-DD) with any messages, the last 30. */\n days: { day: string; messages: number; people: number }[];\n people_week: number;\n people_month: number;\n dms_month: number;\n files_month: number;\n reactions_month: number;\n };\n /** The last 7 days', oldest first. */\n samples: Sample[];\n}\n\nexport const DAY_MS = 86_400_000;\n\n/** `t`'s day in this browser's time zone, as YYYY-MM-DD. */\nexport function dayKey(t: number): string {\n const d = new Date(t);\n return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, \"0\")}-${String(d.getDate()).padStart(2, \"0\")}`;\n}\n\n/** Midnight today in this browser's time zone, `back` days before it. */\nexport function midnight(now: number, back = 0): number {\n const d = new Date(now);\n d.setHours(0, 0, 0, 0);\n d.setDate(d.getDate() - back);\n return d.getTime();\n}\n\n/** The last `n` days, oldest first, each with its messages and posters (none for a day without). */\nexport function lastDays(days: Stats[\"messages\"][\"days\"], now: number, n = 30): { day: string; messages: number; people: number }[] {\n const by = new Map(days.map((d) => [d.day, d]));\n const out = [];\n for (let i = n - 1; i >= 0; i--) {\n const day = dayKey(midnight(now, i) + 12 * 3_600_000); // noon: safe across a DST change\n const d = by.get(day);\n out.push({ day, messages: d?.messages ?? 0, people: d?.people ?? 0 });\n }\n return out;\n}\n\n/** Person-hours online since `from`: each sample stands for its interval. */\nexport function personHours(samples: readonly Sample[], from: number, minutes: number): number {\n let sum = 0;\n for (const s of samples) if (s[0] >= from) sum += s[1];\n return (sum * minutes) / 60;\n}\n\n/** The most people online at once since `from`, and when (the first time it was reached); null without samples. */\nexport function peak(samples: readonly Sample[], from: number): { online: number; at: number } | null {\n let best: { online: number; at: number } | null = null;\n for (const s of samples) if (s[0] >= from && (!best || s[1] > best.online)) best = { online: s[1], at: s[0] };\n // Nobody at any time: no time to name (it said \"0 at 02:45 AM\", QA BUG-263).\n return best && !best.online ? { online: 0, at: 0 } : best;\n}\n\n/**\n * The samples since `from` as runs of a line: a gap longer than two intervals (the server was down, or recording was\n * off) ends a run, so the chart doesn't draw a line across it.\n */\nexport function runs(samples: readonly Sample[], from: number, minutes: number): Sample[][] {\n const out: Sample[][] = [];\n let run: Sample[] = [];\n let last = -Infinity;\n for (const s of samples) {\n if (s[0] < from) continue;\n if (s[0] - last > 2 * minutes * 60_000 && run.length) {\n out.push(run);\n run = [];\n }\n run.push(s);\n last = s[0];\n }\n if (run.length) out.push(run);\n return out;\n}\n\n/** A tidy top for an axis from 0: 1, 2 or 5 times a power of ten, at least `max` (and at least `min`). */\nexport function niceMax(max: number, min = 4): number {\n const v = Math.max(max, min);\n const p = 10 ** Math.floor(Math.log10(v));\n for (const m of [1, 2, 5, 10]) if (m * p >= v) return m * p;\n return 10 * p;\n}\n\n/** \"1.5 h\", \"40 min\", \"12 h\": person-time for a tile. */\nexport function formatHours(h: number): string {\n if (h < 1) return `${Math.round(h * 60)} min`;\n if (h < 10) return S.hours((Math.round(h * 10) / 10).toLocaleString());\n return `${Math.round(h).toLocaleString()} h`;\n}\n\n/** `part` of `whole` as a whole percent (\"\u2013\" with nothing to divide). */\nexport function percent(part: number, whole: number): string {\n return whole > 0 ? `${Math.round((part / whole) * 100)}%` : \"\u2013\";\n}\n\n/** What GET /api/chat/metrics answers a superuser (REFACTOR item 51, server/metrics.go). */\nexport interface Metrics {\n at: string;\n version: string;\n pocketbase: string;\n uptime_seconds: number;\n queues: Record<string, { rows: number; failing: number; oldest_seconds: number }>;\n /** last_pass, last_error_at: RFC 3339, \"\" for not since the start. */\n workers: Record<string, { last_pass: string; last_error: string; last_error_at: string; running: boolean }>;\n realtime: { clients: number; senders: number; queued: number; dropped: number };\n db: Record<string, number>;\n process: { goroutines: number; heap_bytes: number; sys_bytes: number; gc_runs: number };\n}\n\n/** \"12 KB\", \"3.4 MB\", \"1.2 GB\". */\nexport function formatBytes(n: number): string {\n const units = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n let i = 0;\n while (n >= 1024 && i < units.length - 1) {\n n /= 1024;\n i++;\n }\n return `${i && n < 10 ? (Math.round(n * 10) / 10).toLocaleString() : Math.round(n).toLocaleString()} ${units[i]}`;\n}\n\n/** A span of seconds, short: \"40 s\", \"12 min\", \"5 h\", \"3 d\". */\nexport function formatSpan(s: number): string {\n if (s < 60) return `${Math.round(s)} s`;\n if (s < 3600) return S.min(Math.round(s / 60));\n if (s < 86_400) return S.hours(String(Math.round(s / 3600)));\n return S.days(Math.round(s / 86_400));\n}\n\n/** How long before `now` (epoch ms) an RFC 3339 time was, \"12 min ago\"; `never` when there is none. */\nexport function ago(at: string, now: number, never = \"not since the start\"): string {\n const t = Date.parse(at);\n return at && !Number.isNaN(t) ? S.ago(formatSpan(Math.max(0, (now - t) / 1000))) : never;\n}\n", "// The usage statistics page (DESIGN.md \u00A740), /stats: a page of its own (stats.html), not the app's. It asks\n// GET /api/chat/stats with the session this browser has: the app's (a moderator), else the admin UI's (a superuser,\n// signed in at /_/ on this server). Anyone else is told there is no such page. Counts only; refreshed every 30 s\n// while the tab is visible. A superuser also sees the server's state (GET /api/chat/metrics, REFACTOR item 51).\n\nimport { type Child, clear, h } from \"../dom.ts\";\nimport * as S from \"../strings/stats-main.ts\";\nimport { applyTheme, savedTheme } from \"../theme.ts\";\nimport {\n ago,\n DAY_MS,\n formatBytes,\n formatHours,\n formatSpan,\n lastDays,\n type Metrics,\n midnight,\n niceMax,\n peak,\n percent,\n personHours,\n runs,\n type Sample,\n type Stats,\n} from \"./data.ts\";\n\nconst REFRESH_MS = 30_000;\n/** The app's session (web/src/pb.ts), and PocketBase's admin UI's (0.40: \"__pb_superusers__\" + its base path). */\nconst SESSIONS = [\"pocketbase_auth\", \"__pb_superusers__/_\"];\nconst SVG = \"http://www.w3.org/2000/svg\";\n\nconst root = document.getElementById(\"stats\") as HTMLElement;\nconst updated = document.getElementById(\"stats-updated\") as HTMLElement;\nconst num = new Intl.NumberFormat();\nconst time = new Intl.DateTimeFormat(undefined, { hour: \"2-digit\", minute: \"2-digit\" });\nconst dayTime = new Intl.DateTimeFormat(undefined, { weekday: \"short\", hour: \"2-digit\", minute: \"2-digit\" });\nconst dayName = new Intl.DateTimeFormat(undefined, { weekday: \"short\", day: \"numeric\", month: \"short\" });\nconst shortDay = new Intl.DateTimeFormat(undefined, { day: \"numeric\", month: \"short\" });\n\nlet range: \"day\" | \"week\" = \"day\";\nlet last: Stats | null = null;\nlet metrics: Metrics | null = null;\nlet refocus = false;\n\n/** The stored sessions' tokens; `superusers`: only superusers' (QA BUG-275: a moderator was refused the metrics every 30 s). */\nfunction tokens(superusers = false): string[] {\n const out: string[] = [];\n for (const key of SESSIONS) {\n try {\n const session = JSON.parse(localStorage.getItem(key) || \"{}\");\n const token = session?.token;\n if (superusers && session?.record?.collectionName !== \"_superusers\") continue;\n if (typeof token === \"string\" && token) out.push(token);\n } catch {}\n }\n return out;\n}\n\n/** The statistics, with the first session that may see them; \"denied\" when none may; null when it failed. */\nasync function load(): Promise<Stats | \"denied\" | null> {\n const tz = -new Date().getTimezoneOffset();\n for (const token of tokens()) {\n try {\n const res = await fetch(`/api/chat/stats?tz=${tz}`, { headers: { Authorization: token } });\n if (res.ok) return (await res.json()) as Stats;\n if (res.status !== 401 && res.status !== 403) return null;\n } catch {\n return null;\n }\n }\n return \"denied\";\n}\n\n/** The server's metrics, for a superuser's session; null for anyone else, or when they couldn't be had. */\nasync function loadMetrics(): Promise<Metrics | null> {\n for (const token of tokens(true)) {\n try {\n const res = await fetch(\"/api/chat/metrics\", { headers: { Authorization: token, Accept: \"application/json\" } });\n if (res.ok) return (await res.json()) as Metrics;\n } catch {\n return null;\n }\n }\n return null;\n}\n\n// ---- pieces ----\n\nfunction tile(label: string, value: string, note?: string, big = false): HTMLElement {\n return h(\"div\", { class: big ? \"tile big\" : \"tile\" }, [\n h(\"div\", { class: \"tile-label\" }, label),\n h(\"div\", { class: \"tile-value\" }, value),\n note ? h(\"div\", { class: \"tile-note\" }, note) : null,\n ]);\n}\n\nfunction section(title: string, children: Child[], hint?: string): HTMLElement {\n return h(\"section\", { class: \"card\" }, [h(\"h2\", {}, title), hint ? h(\"p\", { class: \"hint\" }, hint) : null, ...children]);\n}\n\nfunction svg<K extends keyof SVGElementTagNameMap>(tag: K, attrs: Record<string, string | number> = {}): SVGElementTagNameMap[K] {\n const el = document.createElementNS(SVG, tag);\n for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, String(v));\n return el;\n}\n\n/** A table of the chart's numbers, folded away: the values without hovering. */\nfunction table(caption: string, head: string[], rows: (string | number)[][]): HTMLElement {\n return h(\"details\", { class: \"chart-table\" }, [h(\"summary\", {}, \"Show as a table\"), grid(caption, head, rows)]);\n}\n\nfunction grid(caption: string, head: string[], rows: (string | number)[][]): HTMLElement {\n return h(\"table\", {}, [\n h(\"caption\", {}, caption),\n h(\n \"thead\",\n {},\n h(\n \"tr\",\n {},\n head.map((c) => h(\"th\", { scope: \"col\" }, c)),\n ),\n ),\n h(\n \"tbody\",\n {},\n rows.map((r) =>\n h(\n \"tr\",\n {},\n r.map((c, i) => (i ? h(\"td\", {}, typeof c === \"number\" ? num.format(c) : c) : h(\"th\", { scope: \"row\" }, String(c)))),\n ),\n ),\n ),\n ]);\n}\n\n/** The queues' and workers' names as people read them. */\nconst LABELS: Record<string, string> = {\n telegram: \"Telegram\",\n federation: \"Linked instances\",\n link_previews: \"Link previews\",\n media_thumbs: \"Thumbnails to make\",\n media_sizes: \"Video shapes to read\",\n media_moves: \"Files to move\",\n storage_cleanup: \"Storage to clean up\",\n account_jobs: \"Exports and deleted accounts\",\n account: \"Exports and deleted accounts\",\n previews: \"Link previews\",\n media: \"Media\",\n retention: \"Daily prune\",\n};\nconst named = (k: string) => LABELS[k] ?? k;\n\n/** The server's state, for a superuser (GET /api/chat/metrics). */\nfunction serverSection(m: Metrics): HTMLElement {\n const now = Date.parse(m.at) || Date.now();\n const db = (m.db[\"data.db\"] ?? 0) + (m.db[\"data.db-wal\"] ?? 0);\n const logs = (m.db[\"auxiliary.db\"] ?? 0) + (m.db[\"auxiliary.db-wal\"] ?? 0);\n const queues = Object.entries(m.queues).sort(([a], [b]) => named(a).localeCompare(named(b)));\n const workers = Object.entries(m.workers).sort(([a], [b]) => named(a).localeCompare(named(b)));\n return section(\n \"Server\",\n [\n h(\"div\", { class: \"tiles\" }, [\n tile(\"Up for\", formatSpan(m.uptime_seconds), `Chirkle ${m.version}, PocketBase ${m.pocketbase}`),\n tile(\"Connections\", num.format(m.realtime.clients), \"realtime, incl. guests\"),\n tile(\n \"Live events waiting\",\n num.format(m.realtime.queued),\n S.slowClientsDroppedSinceTheStart(m.realtime.dropped, num.format(m.realtime.dropped)),\n ),\n tile(\"Database\", formatBytes(db), `logs ${formatBytes(logs)}`),\n tile(\"Memory\", formatBytes(m.process.heap_bytes), `${formatBytes(m.process.sys_bytes)} from the system`),\n ]),\n h(\"h3\", {}, \"Queues\"),\n h(\n \"div\",\n { class: \"chart-table\" },\n grid(\n \"Rows waiting for a worker\",\n [\"Queue\", \"Rows\", \"Failed once or more\", \"Oldest\"],\n queues.map(([k, q]) => [named(k), q.rows, q.failing, q.rows ? formatSpan(q.oldest_seconds) : \"\u2013\"]),\n ),\n ),\n h(\"h3\", {}, \"Workers\"),\n h(\n \"div\",\n { class: \"chart-table\" },\n grid(\n \"When each worker last did its work\",\n [\"Worker\", \"Last pass\", \"Last error\"],\n workers.map(([k, w]) => [\n named(k),\n `${ago(w.last_pass, now)}${S.running(w.running)}`,\n w.last_error ? `${w.last_error} (${ago(w.last_error_at, now)})` : \"\u2013\",\n ]),\n ),\n ),\n ],\n \"Only superusers see this. Also at /api/chat/metrics, in Prometheus's format with ?format=prometheus.\",\n );\n}\n\n// The charts are drawn at their box's own width (set by render), so their text stays its size on a phone.\nlet W = 720;\nlet H = 220;\n/** Narrow: fewer labels along the bottom. */\nconst narrow = () => W < 520;\nconst PAD = { top: 12, right: 12, bottom: 26, left: 36 };\n\n/** Gridlines and y labels at 0, half (when a whole number) and the top. */\nfunction yAxis(g: SVGGElement, top: number) {\n for (const v of [0, top / 2, top].filter(Number.isInteger)) {\n const y = PAD.top + (H - PAD.top - PAD.bottom) * (1 - v / top);\n g.append(svg(\"line\", { x1: PAD.left, x2: W - PAD.right, y1: y, y2: y, class: \"grid\" }));\n const t = svg(\"text\", { x: PAD.left - 6, y: y + 4, \"text-anchor\": \"end\", class: \"axis\" });\n t.textContent = num.format(v);\n g.append(t);\n }\n}\n\n/** A label along the bottom at `x`; near an edge it is anchored inward, so it isn't cut off. */\nfunction xLabel(g: SVGGElement, x: number, text: string) {\n const anchor = x > W - PAD.right - 32 ? \"end\" : x < PAD.left + 32 ? \"start\" : \"middle\";\n const t = svg(\"text\", { x: anchor === \"end\" ? Math.min(x + 6, W - 2) : x, y: H - 8, \"text-anchor\": anchor, class: \"axis\" });\n t.textContent = text;\n g.append(t);\n}\n\n/** The tooltip of a chart, placed over its box at `x` (0..1 of the width). */\nfunction tooltip(box: HTMLElement) {\n const tip = h(\"div\", { class: \"tip\", role: \"status\", hidden: true });\n box.append(tip);\n return {\n show(x: number, lines: [string, string][], title: string) {\n clear(tip);\n tip.append(h(\"div\", { class: \"tip-title\" }, title));\n for (const [value, label] of lines) tip.append(h(\"div\", {}, [h(\"strong\", {}, value), ` ${label}`]));\n tip.hidden = false;\n const left = Math.min(Math.max(x * box.clientWidth, tip.offsetWidth / 2 + 4), box.clientWidth - tip.offsetWidth / 2 - 4);\n tip.style.left = `${left}px`;\n },\n hide() {\n tip.hidden = true;\n },\n };\n}\n\n/** People online over the last 24 hours or 7 days: a line with a light area under it, and a crosshair. */\nfunction onlineChart(s: Stats): HTMLElement {\n const now = s.at;\n const from = now - (range === \"day\" ? DAY_MS : 7 * DAY_MS);\n const parts = runs(s.samples, from, s.sample_minutes);\n const shown = parts.flat();\n const top = niceMax(Math.max(0, ...shown.map((x) => x[1])));\n const plotW = W - PAD.left - PAD.right;\n const plotH = H - PAD.top - PAD.bottom;\n const xOf = (t: number) => PAD.left + ((t - from) / (now - from)) * plotW;\n const yOf = (v: number) => PAD.top + plotH * (1 - v / top);\n\n const chart = svg(\"svg\", { viewBox: `0 0 ${W} ${H}`, class: \"chart\", role: \"img\" });\n chart.setAttribute(\"aria-label\", S.peopleOnlineOverTheLast(range === \"day\"));\n const g = svg(\"g\");\n chart.append(g);\n yAxis(g, top);\n // x labels: every 6 hours, or each day at midnight.\n const ticks: number[] = [];\n if (range === \"day\") {\n const first = Math.ceil(from / (6 * 3_600_000)) * 6 * 3_600_000;\n for (let t = first; t <= now; t += 6 * 3_600_000) ticks.push(t);\n } else {\n for (let i = 6; i >= 0; i--) if (!narrow() || i % 2 === 0) ticks.push(midnight(now, i));\n }\n for (const t of ticks) {\n // A tick at either edge goes unlabeled: its label would run off or into the next.\n if (t < from || xOf(t) > W - PAD.right - 28) continue;\n xLabel(g, xOf(t), range === \"day\" ? time.format(t) : shortDay.format(t));\n }\n const base = yOf(0);\n for (const run of parts) {\n const pts = run.map((x) => `${xOf(x[0]).toFixed(1)},${yOf(x[1]).toFixed(1)}`);\n if (run.length === 1) {\n g.append(svg(\"circle\", { cx: xOf(run[0]![0]), cy: yOf(run[0]![1]), r: 3, class: \"dot\" }));\n continue;\n }\n g.append(svg(\"polygon\", { points: `${xOf(run[0]![0])},${base} ${pts.join(\" \")} ${xOf(run.at(-1)![0])},${base}`, class: \"area\" }));\n g.append(svg(\"polyline\", { points: pts.join(\" \"), class: \"line\" }));\n }\n const cross = svg(\"line\", { y1: PAD.top, y2: base, class: \"cross\", visibility: \"hidden\" });\n const mark = svg(\"circle\", { r: 4.5, class: \"mark\", visibility: \"hidden\" });\n g.append(cross, mark);\n\n const box = h(\"div\", { class: \"chart-box\" }, [chart]);\n if (!shown.length) box.append(h(\"p\", { class: \"empty\" }, s.history ? \"No samples yet: one is taken every 5 minutes.\" : \"Not recorded.\"));\n const tip = tooltip(box);\n const nearest = (clientX: number): Sample | null => {\n const r = chart.getBoundingClientRect();\n const t = from + ((((clientX - r.left) / r.width) * W - PAD.left) / plotW) * (now - from);\n let best: Sample | null = null;\n for (const x of shown) if (!best || Math.abs(x[0] - t) < Math.abs(best[0] - t)) best = x;\n return best;\n };\n const show = (x: Sample | null) => {\n if (!x) return;\n const cx = xOf(x[0]);\n for (const el of [cross, mark]) el.setAttribute(\"visibility\", \"visible\");\n cross.setAttribute(\"x1\", String(cx));\n cross.setAttribute(\"x2\", String(cx));\n mark.setAttribute(\"cx\", String(cx));\n mark.setAttribute(\"cy\", String(yOf(x[1])));\n tip.show(\n cx / W,\n [\n [num.format(x[1]), \"people online\"],\n [num.format(x[3]), \"on the web\"],\n [num.format(x[4]), \"on Android\"],\n [num.format(x[2]), \"guests\"],\n ],\n (range === \"day\" ? time : dayTime).format(x[0]),\n );\n };\n const hide = () => {\n for (const el of [cross, mark]) el.setAttribute(\"visibility\", \"hidden\");\n tip.hide();\n };\n chart.addEventListener(\"pointermove\", (e) => show(nearest(e.clientX)));\n chart.addEventListener(\"pointerleave\", hide);\n // Keys: the chart takes focus, and \u2190 \u2192 step through the samples.\n let at = shown.length - 1;\n chart.setAttribute(\"tabindex\", \"0\");\n chart.addEventListener(\"focus\", () => show(shown[at] ?? null));\n chart.addEventListener(\"blur\", hide);\n chart.addEventListener(\"keydown\", (e) => {\n if (e.key !== \"ArrowLeft\" && e.key !== \"ArrowRight\") return;\n e.preventDefault();\n at = Math.max(0, Math.min(shown.length - 1, at + (e.key === \"ArrowLeft\" ? -1 : 1)));\n show(shown[at] ?? null);\n });\n\n // The table: hourly in the last 24 hours, else daily peaks.\n const rows: (string | number)[][] = [];\n if (range === \"day\") {\n for (let t = Math.floor(from / 3_600_000) * 3_600_000; t <= now; t += 3_600_000) {\n const p = peak(\n shown.filter((x) => x[0] < t + 3_600_000),\n t,\n );\n if (p) rows.push([time.format(t), p.online]);\n }\n } else {\n for (let i = 6; i >= 0; i--) {\n const start = midnight(now, i);\n const p = peak(\n shown.filter((x) => x[0] < start + DAY_MS),\n start,\n );\n if (p) rows.push([dayName.format(start), p.online]);\n }\n }\n\n const picker = h(\"div\", { class: \"seg\", role: \"group\", \"aria-label\": \"Range\" }, [\n rangeButton(\"day\", \"24 hours\"),\n rangeButton(\"week\", \"7 days\"),\n ]);\n return h(\"div\", {}, [\n picker,\n box,\n table(range === \"day\" ? \"Most people online, by hour\" : \"Most people online, by day\", [range === \"day\" ? \"Hour\" : \"Day\", \"People\"], rows),\n ]);\n}\n\nfunction rangeButton(value: typeof range, label: string): HTMLElement {\n return h(\n \"button\",\n {\n type: \"button\",\n \"aria-pressed\": String(range === value),\n on: {\n click: () => {\n range = value;\n refocus = true;\n if (last) render(last);\n },\n },\n },\n label,\n );\n}\n\n/** Messages per day, the last 30 days: columns, each with its tooltip. */\nfunction messagesChart(s: Stats): HTMLElement {\n const days = lastDays(s.messages.days, s.at);\n const top = niceMax(Math.max(0, ...days.map((d) => d.messages)));\n const plotW = W - PAD.left - PAD.right;\n const plotH = H - PAD.top - PAD.bottom;\n const slot = plotW / days.length;\n const bw = Math.min(16, slot - 2);\n const chart = svg(\"svg\", { viewBox: `0 0 ${W} ${H}`, class: \"chart\", role: \"img\" });\n chart.setAttribute(\"aria-label\", \"Messages per day, the last 30 days\");\n const g = svg(\"g\");\n chart.append(g);\n yAxis(g, top);\n const box = h(\"div\", { class: \"chart-box\" }, [chart]);\n const tip = tooltip(box);\n days.forEach((d, i) => {\n const x = PAD.left + i * slot + (slot - bw) / 2;\n const bh = (d.messages / top) * plotH;\n const y = PAD.top + plotH - bh;\n const r = Math.min(4, bw / 2, bh);\n // A column, rounded at the top, square at the baseline.\n if (bh > 0) {\n g.append(\n svg(\"path\", {\n d: `M${x},${y + bh}V${y + r}Q${x},${y} ${x + r},${y}H${x + bw - r}Q${x + bw},${y} ${x + bw},${y + r}V${y + bh}Z`,\n class: \"bar\",\n }),\n );\n }\n const date = new Date(`${d.day}T12:00:00`);\n const every = narrow() ? 10 : 5;\n if (i % every === every - 1 || i === days.length - 1) {\n xLabel(g, x + bw / 2, i === days.length - 1 ? \"Today\" : shortDay.format(date));\n }\n // The hit target: the whole slot, top to bottom.\n const hit = svg(\"rect\", { x: PAD.left + i * slot, y: PAD.top, width: slot, height: plotH, class: \"hit\" });\n const show = () =>\n tip.show(\n (x + bw / 2) / W,\n [\n [num.format(d.messages), S.tipMessages(d.messages)],\n [num.format(d.people), S.tipPosted(d.people)],\n ],\n dayName.format(date),\n );\n hit.addEventListener(\"pointerenter\", show);\n hit.addEventListener(\"pointerleave\", () => tip.hide());\n g.append(hit);\n });\n return h(\"div\", {}, [\n box,\n table(\n \"Messages per day\",\n [\"Day\", \"Messages\", \"People who posted\"],\n days.map((d) => [dayName.format(new Date(`${d.day}T12:00:00`)), d.messages, d.people]),\n ),\n ]);\n}\n\n// ---- the page ----\n\nfunction render(s: Stats) {\n last = s;\n // The card's inner width: the page's, less its padding and the card's.\n W = Math.round(Math.min(928, Math.max(280, root.clientWidth - 66)));\n H = narrow() ? 180 : 220;\n const now = s.at;\n const today = midnight(now);\n const days = lastDays(s.messages.days, now);\n const sum = (n: number) => days.slice(-n).reduce((a, d) => a + d.messages, 0);\n const month = sum(30);\n const peakToday = peak(s.samples, today);\n const peakWeek = peak(s.samples, now - 7 * DAY_MS);\n const hoursToday = personHours(s.samples, today, s.sample_minutes);\n const hoursWeek = personHours(s.samples, now - 7 * DAY_MS, s.sample_minutes);\n const recorded = (v: string) => (s.history || s.samples.length ? v : \"\u2013\");\n\n const sections = [\n !s.history ? h(\"p\", { class: \"notice\", role: \"note\" }, \"Recording is off (site settings: no_stats). Live numbers and messages are still shown; what was recorded before is dropped as it ages.\") : null,\n section(\"Now\", [\n h(\"div\", { class: \"tiles\" }, [\n tile(\"People online\", num.format(s.now.online), undefined, true),\n tile(\"On the web\", num.format(s.now.web)),\n tile(\"On Android\", num.format(s.now.android)),\n tile(\"Guests\", num.format(s.now.guests), \"open tabs, not signed in\"),\n tile(\n \"Peak today\",\n recorded(peakToday ? num.format(peakToday.online) : \"\u2013\"),\n peakToday?.at ? `at ${time.format(peakToday.at)}` : undefined,\n ),\n tile(\"Peak, 7 days\", recorded(peakWeek ? num.format(peakWeek.online) : \"\u2013\"), peakWeek?.at ? dayTime.format(peakWeek.at) : undefined),\n ]),\n ]),\n section(\n \"Usage\",\n [\n h(\"div\", { class: \"tiles\" }, [\n tile(\"Active, 24 hours\", num.format(s.active.day), `${percent(s.active.day, s.accounts.total)} of accounts`),\n tile(\"Active, 7 days\", num.format(s.active.week), `${percent(s.active.week, s.accounts.total)} of accounts`),\n tile(\"Active, 30 days\", num.format(s.active.month), `${percent(s.active.month, s.accounts.total)} of accounts`),\n tile(\"Time online today\", recorded(formatHours(hoursToday)), \"all people together\"),\n tile(\"Time online, 7 days\", recorded(formatHours(hoursWeek)), \"all people together\"),\n tile(\"Per active person\", recorded(s.active.week ? formatHours(hoursWeek / s.active.week) : \"\u2013\"), \"a week, on average\"),\n ]),\n h(\"h3\", {}, \"People online\"),\n onlineChart(s),\n ],\n \"Active: online at least once. Time online is counted every 5 minutes.\",\n ),\n section(\"Messages\", [\n h(\"div\", { class: \"tiles\" }, [\n tile(\"Today\", num.format(days.at(-1)?.messages ?? 0)),\n tile(\"7 days\", num.format(sum(7)), S.peoplePosted(s.messages.people_week, num.format(s.messages.people_week))),\n tile(\"30 days\", num.format(month), S.peoplePosted(s.messages.people_month, num.format(s.messages.people_month))),\n tile(\"In DMs\", percent(s.messages.dms_month, month), \"of the 30 days'\"),\n tile(\"Files sent\", num.format(s.messages.files_month), \"30 days\"),\n tile(\"Reactions\", num.format(s.messages.reactions_month), \"on the 30 days' messages\"),\n ]),\n h(\"h3\", {}, \"Messages per day\"),\n messagesChart(s),\n ]),\n section(\"Accounts\", [\n h(\"div\", { class: \"tiles\" }, [\n tile(\"Accounts\", num.format(s.accounts.total)),\n tile(\"New, 7 days\", num.format(s.accounts.new_week)),\n tile(\"Moderators\", num.format(s.accounts.moderators)),\n tile(\"Banned\", num.format(s.accounts.banned)),\n ]),\n ]),\n metrics ? serverSection(metrics) : null,\n ];\n // Keep the open tables open across a refresh.\n const open = [...root.querySelectorAll(\"details\")].map((d) => d.open);\n clear(root);\n for (const el of sections) if (el) root.append(el);\n root.querySelectorAll(\"details\").forEach((d, i) => {\n d.open = !!open[i];\n });\n // A range button was pressed: it is a new one now, focused as the old one was.\n if (refocus) root.querySelector<HTMLElement>(\".seg [aria-pressed='true']\")?.focus();\n refocus = false;\n updated.textContent = `Updated ${new Date(now).toLocaleTimeString()}`;\n}\n\nfunction denied() {\n document.title = \"Page not found\";\n clear(root);\n root.append(\n h(\"section\", { class: \"card missing\" }, [\n h(\"h2\", {}, \"Page not found\"),\n h(\"p\", {}, \"There is no such page, or you can't see it.\"),\n h(\"a\", { href: \"/\" }, \"Back to the app\"),\n ]),\n );\n updated.textContent = \"\";\n}\n\nlet timer = 0;\nasync function refresh() {\n clearTimeout(timer);\n const [got, m] = await Promise.all([load(), loadMetrics()]);\n if (got === \"denied\") return denied();\n metrics = m;\n if (got) render(got);\n else updated.textContent = last ? `Couldn't refresh: showing ${new Date(last.at).toLocaleTimeString()}` : \"Couldn't load. Retrying\u2026\";\n if (!document.hidden) timer = window.setTimeout(refresh, REFRESH_MS);\n}\n\napplyTheme(savedTheme());\nlet drawnFor = root.clientWidth;\nlet resizing = 0;\naddEventListener(\"resize\", () => {\n clearTimeout(resizing);\n resizing = window.setTimeout(() => {\n if (!last || Math.abs(root.clientWidth - drawnFor) < 8) return;\n drawnFor = root.clientWidth;\n render(last);\n }, 150);\n});\ndocument.addEventListener(\"visibilitychange\", () => {\n if (!document.hidden) void refresh();\n else clearTimeout(timer);\n});\nvoid refresh();\n"],
|
|
5
|
+
"mappings": "AAiBA,IAAMA,GAAQ,IAAI,IAAI,CAAC,QAAS,SAAS,CAAC,EAEnC,SAASC,EAAyCC,EAAQC,EAAe,CAAC,EAAGC,EAAsD,CACxI,IAAMC,EAAK,SAAS,cAAcH,CAAG,EAC/B,CAAE,MAAOI,EAAK,QAAAC,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AAiB,CACzC,CAAC,CACH,EACAzB,GAAQ,YAAc,EACxB,CAEA,IAAIiJ,GAAQ,EACZ,eAAeC,IAAU,CACvB,aAAaD,EAAK,EAClB,GAAM,CAACE,EAAKpG,CAAC,EAAI,MAAM,QAAQ,IAAI,CAAC/B,GAAK,EAAGG,GAAY,CAAC,CAAC,EAC1D,GAAIgI,IAAQ,SAAU,OAAOH,GAAO,EACpCxI,GAAUuC,EACNoG,EAAK/B,GAAO+B,CAAG,EACdnJ,GAAQ,YAAcO,EAAO,6BAA6B,IAAI,KAAKA,EAAK,EAAE,EAAE,mBAAmB,CAAC,GAAK,gCACrG,SAAS,SAAQ0I,GAAQ,OAAO,WAAWC,GAAStJ,EAAU,EACrE,CAEAwJ,GAAWC,GAAW,CAAC,EACvB,IAAIC,GAAWvJ,EAAK,YAChBwJ,GAAW,EACf,iBAAiB,SAAU,IAAM,CAC/B,aAAaA,EAAQ,EACrBA,GAAW,OAAO,WAAW,IAAM,CAC7B,CAAChJ,GAAQ,KAAK,IAAIR,EAAK,YAAcuJ,EAAQ,EAAI,IACrDA,GAAWvJ,EAAK,YAChBqH,GAAO7G,CAAI,EACb,EAAG,GAAG,CACR,CAAC,EACD,SAAS,iBAAiB,mBAAoB,IAAM,CAC7C,SAAS,OACT,aAAa0I,EAAK,EADIC,GAAQ,CAErC,CAAC,EACIA,GAAQ",
|
|
6
|
+
"names": ["PROPS", "h", "tag", "attrs", "children", "el", "cls", "dataset", "listeners", "signal", "rest", "name", "v", "type", "fn", "append", "c", "clear", "el", "peopleOnlineOverTheLast", "day", "tipMessages", "n", "tipPosted", "running", "busy", "slowClientsDroppedSinceTheStart", "n", "shown", "peoplePosted", "n", "shown", "THEME_KEY", "BAR", "safeLocalStorage", "savedTheme", "storage", "v", "applyTheme", "theme", "doc", "html", "meta", "forTheme", "min", "n", "hours", "days", "n", "ago", "span", "DAY_MS", "dayKey", "t", "d", "midnight", "now", "back", "lastDays", "days", "by", "out", "i", "day", "personHours", "samples", "from", "minutes", "sum", "peak", "best", "s", "runs", "run", "last", "niceMax", "max", "min", "v", "p", "m", "formatHours", "h", "hours", "percent", "part", "whole", "formatBytes", "n", "units", "formatSpan", "ago", "at", "never", "REFRESH_MS", "SESSIONS", "SVG", "root", "updated", "num", "time", "dayTime", "dayName", "shortDay", "range", "last", "metrics", "refocus", "tokens", "superusers", "out", "key", "session", "token", "load", "tz", "res", "loadMetrics", "tile", "label", "value", "note", "big", "h", "section", "title", "children", "hint", "svg", "tag", "attrs", "el", "k", "v", "table", "caption", "head", "rows", "grid", "c", "r", "i", "LABELS", "named", "serverSection", "m", "now", "db", "logs", "queues", "a", "b", "workers", "formatSpan", "slowClientsDroppedSinceTheStart", "formatBytes", "q", "w", "ago", "running", "W", "H", "narrow", "PAD", "yAxis", "g", "top", "y", "t", "xLabel", "x", "text", "anchor", "tooltip", "box", "tip", "lines", "clear", "left", "onlineChart", "s", "from", "DAY_MS", "parts", "runs", "shown", "niceMax", "plotW", "plotH", "xOf", "yOf", "chart", "peopleOnlineOverTheLast", "ticks", "first", "midnight", "base", "run", "pts", "cross", "mark", "nearest", "clientX", "best", "show", "cx", "hide", "e", "at", "p", "peak", "start", "picker", "rangeButton", "render", "messagesChart", "days", "lastDays", "d", "slot", "bw", "bh", "date", "every", "hit", "tipMessages", "tipPosted", "today", "sum", "n", "month", "peakToday", "peakWeek", "hoursToday", "personHours", "hoursWeek", "recorded", "sections", "percent", "formatHours", "peoplePosted", "open", "denied", "timer", "refresh", "got", "applyTheme", "savedTheme", "drawnFor", "resizing"]
|
|
7
|
+
}
|
package/pb_public/index.html
CHANGED
|
@@ -12,16 +12,18 @@
|
|
|
12
12
|
<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png">
|
|
13
13
|
<link rel="icon" type="image/svg+xml" href="/icons/icon.svg">
|
|
14
14
|
<link rel="preload" href="/assets/inter-latin-NRMW37G5.woff2" as="font" type="font/woff2" crossorigin>
|
|
15
|
-
<link rel="stylesheet" href="/assets/app-
|
|
15
|
+
<link rel="stylesheet" href="/assets/app-XJ73EU5O.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
|
18
18
|
<div id="app"><header class="app-bar"><span class="brand">Chirkle</span></header><main class="app-main"></main></div>
|
|
19
|
-
<script type="module" src="/assets/app-
|
|
19
|
+
<script type="module" src="/assets/app-HB3NZHQ2.js"></script>
|
|
20
|
+
<link rel="modulepreload" href="/assets/chunk-AG73QNUN.js">
|
|
20
21
|
<link rel="modulepreload" href="/assets/chunk-DZC4SY4M.js">
|
|
21
|
-
<link rel="modulepreload" href="/assets/chunk-
|
|
22
|
-
<link rel="modulepreload" href="/assets/chunk-
|
|
23
|
-
<link rel="modulepreload" href="/assets/chunk-PWNJABVI.js">
|
|
22
|
+
<link rel="modulepreload" href="/assets/chunk-N2OFGBCZ.js">
|
|
23
|
+
<link rel="modulepreload" href="/assets/chunk-OKIIBH7O.js">
|
|
24
24
|
<link rel="modulepreload" href="/assets/chunk-RPCBA7VF.js">
|
|
25
|
+
<link rel="modulepreload" href="/assets/chunk-UZDXAORM.js">
|
|
25
26
|
<link rel="modulepreload" href="/assets/chunk-VTOUI25E.js">
|
|
27
|
+
<link rel="modulepreload" href="/assets/chunk-WR25F7FU.js">
|
|
26
28
|
</body>
|
|
27
29
|
</html>
|
package/pb_public/stats.html
CHANGED
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
<span id="stats-updated" class="stats-updated" aria-live="polite"></span>
|
|
21
21
|
</header>
|
|
22
22
|
<main id="stats" class="stats"><p class="loading">Loading…</p></main>
|
|
23
|
-
<script type="module" src="/assets/stats-
|
|
23
|
+
<script type="module" src="/assets/stats-GTO2H6PG.js"></script>
|
|
24
24
|
</body>
|
|
25
25
|
</html>
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// `chirkle install-service` / `chirkle uninstall-service` (scripts/start.mjs): run Chirkle under systemd in one command.
|
|
2
|
+
//
|
|
3
|
+
// sudo npx chirkle install-service chat.example.com HTTPS (Let's Encrypt) on :80/:443
|
|
4
|
+
// sudo npx chirkle install-service --http=127.0.0.1:8090 behind a reverse proxy (TRUSTED_PROXY=X-Forwarded-For)
|
|
5
|
+
// npx chirkle install-service ... --dry-run print what it would do, change nothing
|
|
6
|
+
// sudo npx chirkle uninstall-service stop, disable and remove the unit (the data stays)
|
|
7
|
+
//
|
|
8
|
+
// It copies this version of the server, pb_public/, pb_migrations/ and pb_hooks/ to --prefix (/opt/chirkle), creates
|
|
9
|
+
// the system user --user (chirkle) that owns the data directory (<prefix>/pb_data, or --data), writes
|
|
10
|
+
// /etc/systemd/system/<--name>.service, and enables and (re)starts it. Running it again with a newer version upgrades
|
|
11
|
+
// in place: the files are replaced and the service restarted, the data is kept. Any other flags go to `serve`.
|
|
12
|
+
|
|
13
|
+
import { spawnSync } from "node:child_process";
|
|
14
|
+
import { chownSync, cpSync, existsSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
16
|
+
|
|
17
|
+
const UNIT_DIR = "/etc/systemd/system";
|
|
18
|
+
|
|
19
|
+
/** @param {string} message @returns {never} */
|
|
20
|
+
function fail(message) {
|
|
21
|
+
console.error(`chirkle: ${message}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Split `args` into our options and the flags passed through to `serve`.
|
|
27
|
+
* @param {string[]} args
|
|
28
|
+
*/
|
|
29
|
+
export function parseArgs(args) {
|
|
30
|
+
/** @type {{ prefix: string, user: string, name: string, data: string | undefined, dryRun: boolean, serve: string[] }} */
|
|
31
|
+
const opts = { prefix: "/opt/chirkle", user: "chirkle", name: "chirkle", data: undefined, dryRun: false, serve: [] };
|
|
32
|
+
for (let i = 0; i < args.length; i++) {
|
|
33
|
+
const arg = /** @type {string} */ (args[i]);
|
|
34
|
+
const m = /^--(prefix|user|name|data)(?:=(.*))?$/.exec(arg);
|
|
35
|
+
if (m) {
|
|
36
|
+
const value = m[2] ?? args[++i];
|
|
37
|
+
if (!value) fail(`--${m[1]} needs a value`);
|
|
38
|
+
opts[/** @type {"prefix" | "user" | "name" | "data"} */ (m[1])] = value;
|
|
39
|
+
} else if (arg === "--dry-run" || arg === "-n") {
|
|
40
|
+
opts.dryRun = true;
|
|
41
|
+
} else {
|
|
42
|
+
opts.serve.push(arg);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!isAbsolute(opts.prefix)) opts.prefix = resolve(opts.prefix);
|
|
46
|
+
opts.data = opts.data ? resolve(opts.data) : join(opts.prefix, "pb_data");
|
|
47
|
+
if (!/^[a-z_][a-z0-9_-]*$/.test(opts.user)) fail(`not a valid user name: ${opts.user}`);
|
|
48
|
+
if (!/^[A-Za-z0-9_.@-]+$/.test(opts.name)) fail(`not a valid unit name: ${opts.name}`);
|
|
49
|
+
return /** @type {typeof opts & { data: string }} */ (opts);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** systemd's quoting for one ExecStart word. @param {string} s */
|
|
53
|
+
const quote = (s) => (/^[A-Za-z0-9_@%+=:,./-]+$/.test(s) ? s : `"${s.replace(/[\\"]/g, "\\$&").replace(/%/g, "%%")}"`);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The unit file.
|
|
57
|
+
* @param {ReturnType<typeof parseArgs>} opts
|
|
58
|
+
*/
|
|
59
|
+
export function unitFile(opts) {
|
|
60
|
+
const { prefix, data, user, serve } = opts;
|
|
61
|
+
/** @param {string} flag */
|
|
62
|
+
const has = (flag) => serve.some((a) => a === flag || a.startsWith(`${flag}=`));
|
|
63
|
+
const domain = serve.find((a) => !a.startsWith("-"));
|
|
64
|
+
const flags = [];
|
|
65
|
+
if (!domain && !has("--https") && !has("--http")) flags.push("--http=127.0.0.1:8090");
|
|
66
|
+
const defaults = {
|
|
67
|
+
"--dir": data,
|
|
68
|
+
"--publicDir": join(prefix, "pb_public"),
|
|
69
|
+
"--migrationsDir": join(prefix, "pb_migrations"),
|
|
70
|
+
"--hooksDir": join(prefix, "pb_hooks"),
|
|
71
|
+
"--hooksPool": "100",
|
|
72
|
+
// Upgrades replace pb_hooks/ and then restart: no reload in between against the old binary.
|
|
73
|
+
"--hooksWatch": "false",
|
|
74
|
+
};
|
|
75
|
+
for (const [flag, value] of Object.entries(defaults)) if (!has(flag)) flags.push(`${flag}=${value}`);
|
|
76
|
+
const argv = [join(prefix, "chirkle-server"), "serve", ...serve, ...flags];
|
|
77
|
+
|
|
78
|
+
// On loopback only a proxy on this machine can reach it, so trust the client IP it forwards (README "Deploying").
|
|
79
|
+
const http = [...serve, ...flags].find((a) => a.startsWith("--http="))?.slice("--http=".length) ?? "";
|
|
80
|
+
const loopback = !domain && /^(127\.|localhost:|\[::1\]:)/.test(http);
|
|
81
|
+
const port = Number(/:(\d+)$/.exec(http)?.[1] ?? 0);
|
|
82
|
+
const lowPorts = Boolean(domain) || has("--https") || (port > 0 && port < 1024);
|
|
83
|
+
|
|
84
|
+
return `# Written by \`chirkle install-service\`; running it again rewrites this file.
|
|
85
|
+
[Unit]
|
|
86
|
+
Description=Chirkle chat
|
|
87
|
+
After=network-online.target
|
|
88
|
+
Wants=network-online.target
|
|
89
|
+
|
|
90
|
+
[Service]
|
|
91
|
+
User=${user}
|
|
92
|
+
Group=${user}
|
|
93
|
+
WorkingDirectory=${prefix}
|
|
94
|
+
ExecStart=${argv.map(quote).join(" ")}
|
|
95
|
+
${loopback ? "Environment=TRUSTED_PROXY=X-Forwarded-For\n" : ""}Restart=on-failure
|
|
96
|
+
RestartSec=2
|
|
97
|
+
LimitNOFILE=65536
|
|
98
|
+
${lowPorts ? "AmbientCapabilities=CAP_NET_BIND_SERVICE\nCapabilityBoundingSet=CAP_NET_BIND_SERVICE\n" : "CapabilityBoundingSet=\n"}NoNewPrivileges=true
|
|
99
|
+
PrivateTmp=true
|
|
100
|
+
ProtectSystem=full
|
|
101
|
+
ProtectHome=true
|
|
102
|
+
ReadWritePaths=${quote(data)}
|
|
103
|
+
|
|
104
|
+
[Install]
|
|
105
|
+
WantedBy=multi-user.target
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param {string[]} args what followed `install-service`
|
|
111
|
+
* @param {{ root: string, bin: string }} app where this version's files are
|
|
112
|
+
*/
|
|
113
|
+
export function install(args, { root, bin }) {
|
|
114
|
+
const opts = parseArgs(args);
|
|
115
|
+
const { prefix, data, user, name, dryRun } = opts;
|
|
116
|
+
const unitPath = join(UNIT_DIR, `${name}.service`);
|
|
117
|
+
const unit = unitFile(opts);
|
|
118
|
+
const server = join(prefix, "chirkle-server");
|
|
119
|
+
|
|
120
|
+
if (dryRun) {
|
|
121
|
+
console.log(`would copy ${bin} and ${root}/{pb_public,pb_migrations,pb_hooks} to ${prefix}/`);
|
|
122
|
+
console.log(`would create the system user ${user} (if missing) and the data directory ${data}, owned by it`);
|
|
123
|
+
console.log(`would write ${unitPath}, then: systemctl daemon-reload && systemctl enable ${name} && systemctl restart ${name}\n`);
|
|
124
|
+
process.stdout.write(unit);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
preflight();
|
|
128
|
+
|
|
129
|
+
// ---- the user ----
|
|
130
|
+
if (spawnSync("id", ["-u", user], { stdio: "ignore" }).status !== 0) {
|
|
131
|
+
const shell = ["/usr/sbin/nologin", "/sbin/nologin", "/bin/false"].find((s) => existsSync(s)) ?? "/bin/false";
|
|
132
|
+
sh("useradd", ["--system", "--user-group", "--home-dir", data, "--no-create-home", "--shell", shell, user]);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ---- the files: each staged next to its place and renamed over it, so a running server keeps its old binary ----
|
|
136
|
+
mkdirSync(prefix, { recursive: true });
|
|
137
|
+
const staged = `${server}.new`;
|
|
138
|
+
cpSync(bin, staged);
|
|
139
|
+
renameSync(staged, server);
|
|
140
|
+
for (const dir of ["pb_public", "pb_migrations", "pb_hooks"]) {
|
|
141
|
+
const dest = join(prefix, dir);
|
|
142
|
+
const next = `${dest}.new`;
|
|
143
|
+
const old = `${dest}.old`;
|
|
144
|
+
rmSync(next, { recursive: true, force: true });
|
|
145
|
+
rmSync(old, { recursive: true, force: true });
|
|
146
|
+
cpSync(join(root, dir), next, { recursive: true });
|
|
147
|
+
if (existsSync(dest)) renameSync(dest, old);
|
|
148
|
+
renameSync(next, dest);
|
|
149
|
+
rmSync(old, { recursive: true, force: true });
|
|
150
|
+
}
|
|
151
|
+
if (!existsSync(data)) {
|
|
152
|
+
mkdirSync(data, { recursive: true, mode: 0o750 });
|
|
153
|
+
const ids = (/** @type {string} */ flag) => Number(spawnSync("id", [flag, user], { encoding: "utf8" }).stdout.trim());
|
|
154
|
+
chownSync(data, ids("-u"), ids("-g"));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ---- the unit ----
|
|
158
|
+
const upgrade = existsSync(unitPath);
|
|
159
|
+
writeFileSync(unitPath, unit);
|
|
160
|
+
sh("systemctl", ["daemon-reload"]);
|
|
161
|
+
sh("systemctl", ["enable", "--quiet", name]);
|
|
162
|
+
sh("systemctl", ["restart", name]);
|
|
163
|
+
|
|
164
|
+
const active = spawnSync("systemctl", ["is-active", "--quiet", name]).status === 0;
|
|
165
|
+
console.log(`
|
|
166
|
+
${upgrade ? "Upgraded" : "Installed"} ${name}.service (${prefix}, data in ${data}): ${active ? "running" : "NOT running"}.
|
|
167
|
+
${active ? "" : ` See why: journalctl -u ${name} -e\n`} Logs: journalctl -u ${name} -f
|
|
168
|
+
Admin account: sudo -u ${user} ${server} superuser upsert you@example.com <password> --dir=${data}
|
|
169
|
+
Upgrade: sudo npx chirkle@latest install-service ${args.join(" ")}
|
|
170
|
+
Remove: sudo npx chirkle uninstall-service${name === "chirkle" ? "" : ` --name=${name}`}`);
|
|
171
|
+
if (!active) process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** @param {string[]} args */
|
|
175
|
+
export function uninstall(args) {
|
|
176
|
+
const { name, prefix, data, dryRun } = parseArgs(args);
|
|
177
|
+
const unitPath = join(UNIT_DIR, `${name}.service`);
|
|
178
|
+
if (dryRun) {
|
|
179
|
+
console.log(`would stop and disable ${name}, then remove ${unitPath}`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
preflight();
|
|
183
|
+
if (!existsSync(unitPath)) fail(`${unitPath} does not exist`);
|
|
184
|
+
sh("systemctl", ["disable", "--now", "--quiet", name]);
|
|
185
|
+
rmSync(unitPath);
|
|
186
|
+
sh("systemctl", ["daemon-reload"]);
|
|
187
|
+
console.log(`Removed ${name}.service. The files are still in ${prefix} and the data in ${data}: delete them yourself.`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function preflight() {
|
|
191
|
+
if (process.platform !== "linux") fail("install-service needs Linux with systemd");
|
|
192
|
+
if (spawnSync("systemctl", ["--version"], { stdio: "ignore" }).status !== 0) fail("systemctl not found: is this a systemd system?");
|
|
193
|
+
if (process.getuid?.() !== 0) fail("run it as root: sudo npx chirkle install-service ... (or --dry-run to see what it does)");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** @param {string} cmd @param {string[]} argv */
|
|
197
|
+
function sh(cmd, argv) {
|
|
198
|
+
const r = spawnSync(cmd, argv, { stdio: "inherit" });
|
|
199
|
+
if (r.error) fail(`${cmd}: ${r.error.message}`);
|
|
200
|
+
if (r.status !== 0) fail(`${cmd} ${argv.join(" ")} failed (exit ${r.status})`);
|
|
201
|
+
}
|
package/scripts/start.mjs
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
// chirkle chat.example.com serve with HTTPS (Let's Encrypt) on :80/:443; any other `pocketbase serve` flags
|
|
8
8
|
// chirkle superuser upsert <email> <password>
|
|
9
9
|
// the other PocketBase commands, on the same data directory
|
|
10
|
+
// sudo chirkle install-service chat.example.com
|
|
11
|
+
// install it under systemd (scripts/service.mjs); uninstall-service removes it
|
|
10
12
|
|
|
11
13
|
import { spawn, spawnSync } from "node:child_process";
|
|
12
14
|
import { existsSync } from "node:fs";
|
|
@@ -57,7 +59,11 @@ const exec = (argv) => {
|
|
|
57
59
|
pb.on("error", (err) => fail(err.message));
|
|
58
60
|
pb.on("exit", (code, signal) => process.exit(code ?? (signal ? 1 : 0)));
|
|
59
61
|
};
|
|
60
|
-
if ([
|
|
62
|
+
if (args[0] === "install-service" || args[0] === "uninstall-service") {
|
|
63
|
+
const service = await import("./service.mjs");
|
|
64
|
+
if (args[0] === "install-service") service.install(args.slice(1), { root: ROOT, bin });
|
|
65
|
+
else service.uninstall(args.slice(1));
|
|
66
|
+
} else if (["--version", "-v", "--help", "-h", "help"].includes(args[0] ?? "")) {
|
|
61
67
|
exec(args);
|
|
62
68
|
} else {
|
|
63
69
|
serve();
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as se,c as ie}from"./chunk-56ACD3V5.js";import{c as L,d as Z,g as ee,i as te}from"./chunk-DZC4SY4M.js";import{m as Q,o as oe}from"./chunk-PWNJABVI.js";import{a as ne}from"./chunk-RPCBA7VF.js";import{a as t,b as X}from"./chunk-VTOUI25E.js";var re=a=>`Only ${a?"you and the people you add":"its creator and the people added"} will see this room. Everyone else loses it from their list.`;var H=(a,i)=>`A room can have up to ${a} ${i?"members":"people who post"}.`,le=(a,i)=>`Shared with ${a.join(", ")}: its messages are kept there too.${i?` Add people there by their address, like ann@${a[0]}.`:""}`;var W=null;function ye(a){return W??=new Promise(i=>{let u=a("link",{rel:"stylesheet",href:"/assets/access-PB77EH4F.css",on:{load:()=>i(),error:()=>{u.remove(),W=null,i()}}});document.head.append(u)}),W}var fe=["private","public","open"],ae={private:"ic i-lock",open:"ic i-globe",everyone:"ic i-users",selected:"ic i-check"},Ee={everyone:{label:"Everyone who can see it",icon:"",hint:"Guests of an Open Air room only read."},selected:{label:"Only people you choose",icon:"",hint:"Everyone else reads and reacts, but can't post."}};function ge(a,i,g){return a===i?"":i==="open"?"Everything ever written here, and everything to come, becomes readable by anyone on the web.":a==="private"?"Everyone with an account will be able to read the whole history.":i==="private"?re(g):"People without an account won't see this room any more."}function Oe(a){let{signal:i}=a,g=oe.roomMembers,u=X("access"),$=t("h2",{id:`${u}-title`}),V=t("p",{class:"dialog-sub"});function D(e,n,o){let r=t("legend",{}),c=new Map;return{el:t("fieldset",{class:"vis-choices"},[r,...e.map(s=>{let _=t("input",{type:"radio",name:`${u}-${e[0]}`,value:s,"aria-labelledby":`${u}-${s}-label`,"aria-describedby":`${u}-${s}-hint`,on:{change:()=>o(s)},signal:i});return c.set(s,_),t("label",{class:`vis-choice vis-${s}`},[_,t("span",{class:`vis-icon ${ae[s]??""}`,"aria-hidden":"true"},ae[s]?"":n[s].icon),t("span",{class:"vis-text"},[t("span",{id:`${u}-${s}-label`,class:"vis-label"},n[s].label),t("span",{id:`${u}-${s}-hint`,class:"vis-hint"},n[s].hint)])])})]),legend:r,radios:c}}let x=D(fe,ee,e=>{y=e,q()});x.legend.textContent="Who can see it";let U=D(["everyone","selected"],Ee,e=>{A=e,q()});U.legend.textContent="Who can post";function B(e,n,o){let r=t("h3",{}),c=t("ul",{class:"member-list","aria-label":e}),l=t("button",{type:"button",class:"add-member ic i-plus",on:{click:()=>w(S)},signal:i},"Add people"),s=t("div",{class:"member-search"}),_=t("section",{class:n},[t("div",{class:"people-head"},[r,l]),s,c]),S={el:_,addBtn:l,slot:s,pickable:o,list:[],render(){let K=_.hidden?[]:S.list.filter(F);r.textContent=`${e} \xB7 ${K.length}`;let z=S.list.length>=g;l.hidden=!p||f?.p===S,l.disabled=z,l.title=z?H(g,S===d):"",c.replaceChildren(...K.map(E=>{let J=E.id===m?.created_by;return t("li",{class:"member",dataset:{userId:E.id}},[ne(E,32,a.avatarUrl),t("span",{class:"member-name"},[E.name,E.id===R?t("span",{}," (you)"):null]),J?t("span",{class:"member-role"},"Creator"):null,E.instance?t("span",{class:"member-role"},E.instance):null,p&&!J?t("button",{type:"button",class:"remove-member","aria-label":`Remove ${E.name}`,on:{click:()=>he(S,E.id)},signal:i},"Remove"):null])}))}};return S}let d=B("Members","members",()=>!0),h=B("Who can post","writers",e=>y!=="private"||N(d,e)),Y=t("p",{class:"access-warning",role:"status"}),M=t("p",{class:"access-shared"}),v=t("p",{class:"field-error",role:"alert"}),O=t("button",{type:"button",class:"cancel",on:{click:()=>T()},signal:i},"Cancel"),P=t("button",{type:"button",class:"primary save",on:{click:()=>{ue()}},signal:i},"Save"),ce=t("div",{class:"dialog-actions"},[O,P]),k=t("button",{type:"button",class:"icon-button ic i-x",tabindex:"-1","aria-hidden":"true",on:{click:()=>T()},signal:i}),de=t("div",{class:"dialog-head"},[t("div",{},[$,V]),k]),me=t("div",{class:"access-body"},[M,x.el,d.el,U.el,h.el,Y,v]),b=t("dialog",{class:"access","aria-labelledby":$.id},[de,me,ce]),m=null,R,p=!1,y="public",A="everyone",N=(e,n)=>e.list.some(o=>o.id===n.id),F=e=>!e.no_dms||!!e.instance,G=()=>m?.shared?.with??[],f=null,I=!1;function q(){v.textContent="",y==="private"&&(h.list=h.list.filter(e=>N(d,e))),C()}function C(){if(!m)return;for(let[n,o]of x.radios)o.checked=n===y;for(let[n,o]of U.radios)o.checked=n===A;x.el.hidden=U.el.hidden=!p,d.el.hidden=y!=="private",h.el.hidden=A!=="selected",d.render(),h.render(),Y.textContent=p?ge(L(m),y,m.created_by===R):"";let e=G();M.hidden=!e.length,M.textContent=e.length?m.shared?.home?`This room's home is ${m.shared.home}: who is in it is decided there.`:le(e,p):"",P.hidden=!p,O.textContent=p?"Cancel":"Close"}function he(e,n){let o=e.el.querySelector("ul"),r=[...o.children].findIndex(l=>l.dataset.userId===n);e.list=e.list.filter(l=>l.id!==n),e===d&&(h.list=h.list.filter(l=>l.id!==n)),C();let c=[...o.querySelectorAll("button.remove-member")];(c[Math.min(r-1,c.length-1)]??e.addBtn).focus()}function pe(e,n){if(N(e,n))e.list=e.list.filter(o=>o.id!==n.id),e===d&&(h.list=h.list.filter(o=>o.id!==n.id));else if(e.list.length>=g){v.textContent=H(g,e===d);return}else e.list=[...e.list,n];v.textContent="",C(),f?.ui.mark()}function w(e){if(e!==(f?.p??null))if(f?.ac.abort(),f?.p.slot.replaceChildren(),f=null,e){let n=new AbortController;i.addEventListener("abort",()=>n.abort(),{once:!0});let o=ie({search:async(r,c)=>{if(!te(r)||!m||!G().length||!a.remoteUser)return(await a.searchUsers(r,c)).filter(l=>F(l)&&e.pickable(l));try{let l=await a.remoteUser(r,m.id);return e.pickable(l)?[l]:[]}catch(l){throw new se(Q(l))}},avatarUrl:a.avatarUrl,onPick:r=>pe(e,r),isPicked:r=>N(e,r),label:e===d?"Find someone to add as a member":"Find someone who can post",onClose:()=>{w(null),e.addBtn.focus()},signal:n.signal});f={ac:n,ui:o,p:e},e.slot.replaceChildren(o.el),C(),o.focus(),e.el.firstElementChild?.scrollIntoView?.({block:"start"})}else C()}async function ue(){if(I||!m||!p)return;I=!0,P.disabled=O.disabled=k.disabled=!0,v.textContent="";let e=o=>o.list.map(r=>r.id),n=await a.onSave(y,e(d),A,e(h));if(I=!1,P.disabled=O.disabled=k.disabled=!1,!i.aborted){if(n===null)return T();v.textContent=n,b.open||b.showModal()}}function T(){w(null),b.open&&b.close()}b.addEventListener("cancel",e=>{if(I)e.preventDefault();else if(f){e.preventDefault();let n=f.p;w(null),n.addBtn.focus()}},{signal:i}),b.addEventListener("close",()=>w(null),{signal:i}),i.addEventListener("abort",T,{once:!0});function j(e,n,o,r){let c=new Map([...e.expand?.members??[],...o??[]].map(s=>[s.id,s]));return r&&!c.has(r.id)&&c.set(r.id,r),[...new Set(n.length?n:[e.created_by,R||e.created_by])].map(s=>c.get(s)??{id:s,name:"Unknown"}).sort((s,_)=>+(_.id===e.created_by)-+(s.id===e.created_by))}return{el:b,open(e,n,o){m=e,R=o?.id,p=n,y=L(e),A=Z(e),d.list=j(e,e.members??[],void 0,o),h.list=j(e,e.writers??[],e.expand?.writers,o),$.textContent=p?"Room access":"Members",V.textContent=`#${e.name}`,v.textContent="",w(null),C(),ye(t).then(()=>{i.aborted||m!==e||(b.open||b.showModal(),(p?x.radios.get(y):O)?.focus())})},close:T}}export{Oe as createAccessDialog};
|
|
2
|
-
//# sourceMappingURL=access-LHPD2EHG.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../web/src/strings/room-access.ts", "../../web/src/views/room/access.ts"],
|
|
4
|
-
"sourcesContent": ["// The user-facing text of views/room/access.ts (docs/REFACTOR.md item 56): one module per source file, so a lazy\n// screen's text stays in its own chunk. Copy changes here; a translation would replace these.\n\nexport const GUESTS_OF_AN_OPEN_AIR_ROOM = \"Guests of an Open Air room only read.\";\nexport const EVERYONE_WHO_CAN_SEE_IT = \"Everyone who can see it\";\nexport const EVERYONE_ELSE_READS_AND_REACTS_BUT = \"Everyone else reads and reacts, but can't post.\";\nexport const ONLY_PEOPLE_YOU_CHOOSE = \"Only people you choose\";\nexport const EVERYTHING_EVER_WRITTEN_HERE_AND_EVERYTHING =\n \"Everything ever written here, and everything to come, becomes readable by anyone on the web.\";\nexport const EVERYONE_WITH_AN_ACCOUNT_WILL_BE = \"Everyone with an account will be able to read the whole history.\";\nexport const onlyWillSeeThisRoomEveryone = (mine: boolean) =>\n `Only ${mine ? \"you and the people you add\" : \"its creator and the people added\"} will see this room. Everyone else loses it from their list.`;\nexport const PEOPLE_WITHOUT_AN_ACCOUNT_WONT_SEE = \"People without an account won't see this room any more.\";\nexport const WHO_CAN_SEE_IT = \"Who can see it\";\nexport const WHO_CAN_POST = \"Who can post\";\nexport const ADD_PEOPLE = \"Add people\";\nexport const CREATOR = \"Creator\";\nexport const remove = (name: string | number) => `Remove ${name}`;\nexport const REMOVE = \"Remove\";\nexport const MEMBERS = \"Members\";\nexport const CANCEL = \"Cancel\";\nexport const SAVE = \"Save\";\nexport const thisRoomsHomeIsWhoIs = (home: string | number) => `This room's home is ${home}: who is in it is decided there.`;\nexport const CLOSE = \"Close\";\nexport const FIND_SOMEONE_WHO_CAN_POST = \"Find someone who can post\";\nexport const FIND_SOMEONE_TO_ADD_AS_A = \"Find someone to add as a member\";\nexport const UNKNOWN = \"Unknown\";\nexport const ROOM_ACCESS = \"Room access\";\nexport const upTo = (max: number, members: boolean) => `A room can have up to ${max} ${members ? \"members\" : \"people who post\"}.`;\n/** A linked room's hosts; who may add people is told how to add someone from there. */\nexport const sharedWith = (hosts: string[], editable: boolean) =>\n `Shared with ${hosts.join(\", \")}: its messages are kept there too.${editable ? ` Add people there by their address, like ann@${hosts[0]}.` : \"\"}`;\n", "// Room access dialog (\u00A723.2, \u00A723.6): the creator (or a moderator, \u00A736) chooses who can see the room (Private, Public or Open Air) and, for a\n// private room, who its members are; then who can post: everyone who can see it, or only the people they choose.\n// Anyone else in a private room gets the same dialog to see who is in it (and who can post), read-only.\n// Telegram stand-ins (no_dms, \u00A726.3) are left out of it: the bridge adds them itself, so adding or removing one does\n// nothing. They stay members (and writers) when it is saved. People on linked instances (\u00A733) are listed with their\n// instance; in a room shared with theirs, the creator adds them by address (\"ann@b.example\"), and the dialog says\n// where else the room's messages are kept (\u00A733.9).\n// A modal <dialog>: it keeps focus inside, Escape closes it, and focus goes back to where it was.\n//\n// A lazy chunk, like search (\u00A729): the room view import()s it when the dialog is first opened, and it links its own\n// stylesheet (web/styles/access.css) before showing. Members are added with the people search (ui/user-search.ts).\n\nimport { reasonOf } from \"../../api.ts\";\nimport { h, uniqueId } from \"../../dom.ts\";\nimport { LIMITS } from \"../../lib/limits.ts\";\nimport { isAddress, postingOf, VISIBILITY, visibilityOf } from \"../../lib/rooms.ts\";\nimport type { Posting, Room, User, Visibility } from \"../../lib/types.ts\";\nimport * as S from \"../../strings/room-access.ts\";\nimport { type AvatarUrl, avatar } from \"../../ui/avatar.ts\";\nimport { createUserSearch, SearchError, type UserSearch } from \"../../ui/user-search.ts\";\n\nexport interface AccessDialog {\n readonly el: HTMLDialogElement;\n /** Open it for `room`: to change its access when `editable`, else to see its members. `me` names you in the list. */\n open(room: Room, editable: boolean, me: User | null): void;\n close(): void;\n}\n\ndeclare const ACCESS_CSS: string;\n\nlet stylesheet: Promise<void> | null = null;\n/** The dialog's stylesheet, linked once, like the media grid's: a failed load is tried again next time, and it opens anyway. */\nfunction loadStylesheet(h: typeof import(\"../../dom.ts\")[\"h\"]): Promise<void> {\n stylesheet ??= new Promise((resolve) => {\n const failed = () => {\n link.remove();\n stylesheet = null;\n resolve();\n };\n const link = h(\"link\", { rel: \"stylesheet\", href: ACCESS_CSS, on: { load: () => resolve(), error: failed } });\n document.head.append(link);\n });\n return stylesheet;\n}\n\nconst CHOICES: readonly Visibility[] = [\"private\", \"public\", \"open\"];\n\n/** Who can post (\u00A723.6), shown like the visibilities. */\n/** The choices' icons (.i-* in icons.css); Public keeps its \"#\". */\nconst ICONS: Record<string, string> = { private: \"ic i-lock\", open: \"ic i-globe\", everyone: \"ic i-users\", selected: \"ic i-check\" };\n\nconst POSTING: Record<Posting, { label: string; icon: string; hint: string }> = {\n everyone: { label: \"Everyone who can see it\", icon: \"\", hint: \"Guests of an Open Air room only read.\" },\n selected: { label: \"Only people you choose\", icon: \"\", hint: \"Everyone else reads and reacts, but can't post.\" },\n};\n\n/** What a change of visibility does that may not be obvious, or \"\". */\nfunction warning(from: Visibility, to: Visibility, mine: boolean): string {\n if (from === to) return \"\";\n if (to === \"open\") return \"Everything ever written here, and everything to come, becomes readable by anyone on the web.\";\n if (from === \"private\") return \"Everyone with an account will be able to read the whole history.\";\n if (to === \"private\") return S.onlyWillSeeThisRoomEveryone(mine);\n return \"People without an account won't see this room any more.\";\n}\n\n/** A list of people with Add and Remove: the members, or who can post. */\ninterface People {\n readonly el: HTMLElement;\n readonly addBtn: HTMLButtonElement;\n /** Where its search goes. */\n readonly slot: HTMLElement;\n /** Who its search offers. */\n pickable(u: User): boolean;\n list: User[];\n render(): void;\n}\n\nexport function createAccessDialog(opts: {\n searchUsers: (query: string, signal: AbortSignal) => Promise<User[]>;\n /** Someone on a linked instance by address, to add to this shared room (\u00A733.5). */\n remoteUser?: (address: string, room: string) => Promise<User>;\n avatarUrl: AvatarUrl;\n /** Save. Resolves to what went wrong, or null once it is saved (the dialog then closes). */\n onSave: (visibility: Visibility, members: string[], posting: Posting, writers: string[]) => Promise<string | null>;\n signal: AbortSignal;\n}): AccessDialog {\n const { signal } = opts;\n const maxMembers = LIMITS.roomMembers;\n const id = uniqueId(\"access\");\n const title = h(\"h2\", { id: `${id}-title` });\n const sub = h(\"p\", { class: \"dialog-sub\" });\n\n /** Radio cards: one fieldset of `values`, each with its icon, label and hint. */\n function cards<T extends string>(\n values: readonly T[],\n info: Record<T, { label: string; icon: string; hint: string }>,\n set: (v: T) => void,\n ) {\n const legend = h(\"legend\", {});\n const radios = new Map<T, HTMLInputElement>();\n const el = h(\"fieldset\", { class: \"vis-choices\" }, [\n legend,\n ...values.map((v) => {\n const input = h(\"input\", {\n type: \"radio\",\n name: `${id}-${values[0]}`,\n value: v,\n \"aria-labelledby\": `${id}-${v}-label`,\n \"aria-describedby\": `${id}-${v}-hint`,\n on: { change: () => set(v) },\n signal,\n });\n radios.set(v, input);\n return h(\"label\", { class: `vis-choice vis-${v}` }, [\n input,\n h(\"span\", { class: `vis-icon ${ICONS[v] ?? \"\"}`, \"aria-hidden\": \"true\" }, ICONS[v] ? \"\" : info[v].icon),\n h(\"span\", { class: \"vis-text\" }, [\n h(\"span\", { id: `${id}-${v}-label`, class: \"vis-label\" }, info[v].label),\n h(\"span\", { id: `${id}-${v}-hint`, class: \"vis-hint\" }, info[v].hint),\n ]),\n ]);\n }),\n ]);\n return { el, legend, radios };\n }\n\n const choices = cards(CHOICES, VISIBILITY, (v) => {\n visibility = v;\n changed();\n });\n choices.legend.textContent = \"Who can see it\";\n const postingChoices = cards([\"everyone\", \"selected\"] as const, POSTING, (p) => {\n posting = p;\n changed();\n });\n postingChoices.legend.textContent = \"Who can post\";\n\n /**\n * One list of people. `pickable` says who its search offers: the members are anyone; who can post, in a private\n * room, only its members.\n */\n function people(label: string, cls: string, pickable: (u: User) => boolean): People {\n const head = h(\"h3\", {});\n const ul = h(\"ul\", { class: \"member-list\", \"aria-label\": label });\n const addBtn = h(\n \"button\",\n { type: \"button\", class: \"add-member ic i-plus\", on: { click: () => toggleSearch(p) }, signal },\n \"Add people\",\n );\n const slot = h(\"div\", { class: \"member-search\" });\n // Search above the list, so it stays in reach however many people there are.\n const el = h(\"section\", { class: cls }, [h(\"div\", { class: \"people-head\" }, [head, addBtn]), slot, ul]);\n const p: People = {\n el,\n addBtn,\n slot,\n pickable,\n list: [],\n render() {\n // Hidden, it lists nobody: only the lists in use are in the page.\n const shown = el.hidden ? [] : p.list.filter(listed);\n head.textContent = `${label} \u00B7 ${shown.length}`;\n const full = p.list.length >= maxMembers;\n addBtn.hidden = !editable || search?.p === p;\n addBtn.disabled = full;\n addBtn.title = full ? S.upTo(maxMembers, p === members) : \"\";\n ul.replaceChildren(\n ...shown.map((u) => {\n const owner = u.id === room?.created_by;\n return h(\"li\", { class: \"member\", dataset: { userId: u.id } }, [\n avatar(u, 32, opts.avatarUrl),\n h(\"span\", { class: \"member-name\" }, [u.name, u.id === myId ? h(\"span\", {}, \" (you)\") : null]),\n owner ? h(\"span\", { class: \"member-role\" }, \"Creator\") : null,\n u.instance ? h(\"span\", { class: \"member-role\" }, u.instance) : null,\n editable && !owner\n ? h(\n \"button\",\n {\n type: \"button\",\n class: \"remove-member\",\n \"aria-label\": `Remove ${u.name}`,\n on: { click: () => remove(p, u.id) },\n signal,\n },\n \"Remove\",\n )\n : null,\n ]);\n }),\n );\n },\n };\n return p;\n }\n\n const members = people(\"Members\", \"members\", () => true);\n const writers = people(\"Who can post\", \"writers\", (u) => visibility !== \"private\" || has(members, u));\n const warn = h(\"p\", { class: \"access-warning\", role: \"status\" });\n const sharedEl = h(\"p\", { class: \"access-shared\" });\n const error = h(\"p\", { class: \"field-error\", role: \"alert\" });\n const cancel = h(\"button\", { type: \"button\", class: \"cancel\", on: { click: () => close() }, signal }, \"Cancel\");\n const save = h(\"button\", { type: \"button\", class: \"primary save\", on: { click: () => void submit() }, signal }, \"Save\");\n const buttons = h(\"div\", { class: \"dialog-actions\" }, [cancel, save]);\n // For the pointer only: the footer's Cancel/Close and Escape do the same, so it isn't a second \"Close\" to tab to or hear.\n const x = h(\"button\", {\n type: \"button\",\n class: \"icon-button ic i-x\",\n tabindex: \"-1\",\n \"aria-hidden\": \"true\",\n on: { click: () => close() },\n signal,\n });\n const head = h(\"div\", { class: \"dialog-head\" }, [h(\"div\", {}, [title, sub]), x]);\n // The body scrolls; the title and the buttons stay put.\n const body = h(\"div\", { class: \"access-body\" }, [sharedEl, choices.el, members.el, postingChoices.el, writers.el, warn, error]);\n const el = h(\"dialog\", { class: \"access\", \"aria-labelledby\": title.id }, [head, body, buttons]);\n\n let room: Room | null = null;\n let myId: string | undefined;\n let editable = false;\n let visibility: Visibility = \"public\";\n let posting: Posting = \"everyone\";\n const has = (p: People, u: User) => p.list.some((x) => x.id === u.id);\n /** Who the lists show: not Telegram's stand-ins, but people on linked instances (\u00A733.4) even without DMs. */\n const listed = (u: User) => !u.no_dms || !!u.instance;\n const sharedHosts = () => room?.shared?.with ?? [];\n let search: { ac: AbortController; ui: UserSearch; p: People } | null = null;\n let busy = false;\n\n function changed() {\n error.textContent = \"\";\n // Made private: only members can post.\n if (visibility === \"private\") writers.list = writers.list.filter((u) => has(members, u));\n render();\n }\n\n function render() {\n if (!room) return;\n for (const [v, input] of choices.radios) input.checked = v === visibility;\n for (const [v, input] of postingChoices.radios) input.checked = v === posting;\n choices.el.hidden = postingChoices.el.hidden = !editable;\n members.el.hidden = visibility !== \"private\";\n writers.el.hidden = posting !== \"selected\";\n members.render();\n writers.render();\n warn.textContent = editable ? warning(visibilityOf(room), visibility, room.created_by === myId) : \"\";\n const hosts = sharedHosts();\n sharedEl.hidden = !hosts.length;\n sharedEl.textContent = !hosts.length\n ? \"\"\n : room.shared?.home\n ? `This room's home is ${room.shared.home}: who is in it is decided there.`\n : S.sharedWith(hosts, editable);\n save.hidden = !editable;\n cancel.textContent = editable ? \"Cancel\" : \"Close\";\n }\n\n function remove(p: People, userId: string) {\n const ul = p.el.querySelector(\"ul\")!;\n const at = [...ul.children].findIndex((li) => (li as HTMLElement).dataset.userId === userId);\n p.list = p.list.filter((u) => u.id !== userId);\n // A member taken out can't post either.\n if (p === members) writers.list = writers.list.filter((u) => u.id !== userId);\n render();\n // Focus stays in the list: on the next person's Remove, else the previous one's, else Add people.\n const buttons = [...ul.querySelectorAll<HTMLButtonElement>(\"button.remove-member\")];\n (buttons[Math.min(at - 1, buttons.length - 1)] ?? p.addBtn).focus();\n }\n\n /** A search result picked: add them, or take them out again when they are in. */\n function toggle(p: People, u: User) {\n if (has(p, u)) {\n p.list = p.list.filter((x) => x.id !== u.id);\n if (p === members) writers.list = writers.list.filter((x) => x.id !== u.id);\n } else if (p.list.length >= maxMembers) {\n error.textContent = S.upTo(maxMembers, p === members);\n return;\n } else p.list = [...p.list, u];\n error.textContent = \"\";\n render();\n search?.ui.mark();\n }\n\n /** Open the people search under `p`'s Add button (closing any other), or close it (null). */\n function toggleSearch(p: People | null) {\n if (p === (search?.p ?? null)) return;\n search?.ac.abort();\n search?.p.slot.replaceChildren();\n search = null;\n if (p) {\n const ac = new AbortController();\n signal.addEventListener(\"abort\", () => ac.abort(), { once: true });\n const ui = createUserSearch({\n search: async (q, sig) => {\n if (!isAddress(q) || !room || !sharedHosts().length || !opts.remoteUser) {\n return (await opts.searchUsers(q, sig)).filter((u) => listed(u) && p.pickable(u));\n }\n try {\n const u = await opts.remoteUser(q, room.id);\n return p.pickable(u) ? [u] : [];\n } catch (e) {\n throw new SearchError(reasonOf(e));\n }\n },\n avatarUrl: opts.avatarUrl,\n onPick: (u) => toggle(p, u),\n isPicked: (u) => has(p, u),\n label: p === members ? \"Find someone to add as a member\" : \"Find someone who can post\",\n onClose: () => {\n toggleSearch(null);\n p.addBtn.focus();\n },\n signal: ac.signal,\n });\n search = { ac, ui, p };\n p.slot.replaceChildren(ui.el);\n render();\n ui.focus();\n // Room for the results under it, on a small screen too.\n p.el.firstElementChild?.scrollIntoView?.({ block: \"start\" });\n } else render();\n }\n\n async function submit() {\n if (busy || !room || !editable) return;\n busy = true;\n save.disabled = cancel.disabled = x.disabled = true;\n error.textContent = \"\";\n const ids = (p: People) => p.list.map((u) => u.id);\n const problem = await opts.onSave(visibility, ids(members), posting, ids(writers));\n busy = false;\n save.disabled = cancel.disabled = x.disabled = false;\n if (signal.aborted) return;\n if (problem === null) return close();\n error.textContent = problem;\n if (!el.open) el.showModal();\n }\n\n function close() {\n toggleSearch(null);\n if (el.open) el.close();\n }\n\n // Escape in the people search closes the search, not the dialog; while saving, nothing closes it.\n el.addEventListener(\n \"cancel\",\n (e) => {\n if (busy) e.preventDefault();\n else if (search) {\n e.preventDefault();\n const p = search.p;\n toggleSearch(null);\n p.addBtn.focus();\n }\n },\n { signal },\n );\n el.addEventListener(\"close\", () => toggleSearch(null), { signal });\n signal.addEventListener(\"abort\", close, { once: true });\n\n /** The people `ids` names, as expanded, the creator first (as the server keeps them). */\n function users(r: Room, ids: string[], expanded: User[] | undefined, me: User | null) {\n const known = new Map([...(r.expand?.members ?? []), ...(expanded ?? [])].map((u) => [u.id, u]));\n // A room made private (or posting chosen) starts with its creator, who isn't expanded yet, and a moderator making\n // it so with themselves (\u00A736), who would otherwise lose it.\n if (me && !known.has(me.id)) known.set(me.id, me);\n const list = [...new Set(ids.length ? ids : [r.created_by, myId || r.created_by])].map(\n (uid) => known.get(uid) ?? { id: uid, name: \"Unknown\" },\n );\n return list.sort((a, b) => Number(b.id === r.created_by) - Number(a.id === r.created_by));\n }\n\n return {\n el,\n open(r, canEdit, me) {\n room = r;\n myId = me?.id;\n editable = canEdit;\n visibility = visibilityOf(r);\n posting = postingOf(r);\n members.list = users(r, r.members ?? [], undefined, me);\n writers.list = users(r, r.writers ?? [], r.expand?.writers, me);\n title.textContent = editable ? \"Room access\" : \"Members\";\n sub.textContent = `#${r.name}`;\n error.textContent = \"\";\n toggleSearch(null);\n render();\n void loadStylesheet(h).then(() => {\n if (signal.aborted || room !== r) return;\n if (!el.open) el.showModal();\n (editable ? choices.radios.get(visibility) : cancel)?.focus();\n });\n },\n close,\n };\n}\n"],
|
|
5
|
-
"mappings": "wPAUO,IAAMA,GAA+BC,GAC1C,QAAQA,EAAO,6BAA+B,kCAAkC,+DAiB3E,IAAMC,EAAO,CAACC,EAAaC,IAAqB,yBAAyBD,CAAG,IAAIC,EAAU,UAAY,iBAAiB,IAEjHC,GAAa,CAACC,EAAiBC,IAC1C,eAAeD,EAAM,KAAK,IAAI,CAAC,qCAAqCC,EAAW,gDAAgDD,EAAM,CAAC,CAAC,IAAM,EAAE,GCDjJ,IAAIE,EAAmC,KAEvC,SAASC,GAAeC,EAAsD,CAC5E,OAAAF,IAAe,IAAI,QAASG,GAAY,CAMtC,IAAMC,EAAOF,EAAE,OAAQ,CAAE,IAAK,aAAc,KAAM,8BAAY,GAAI,CAAE,KAAM,IAAMC,EAAQ,EAAG,MAL5E,IAAM,CACnBC,EAAK,OAAO,EACZJ,EAAa,KACbG,EAAQ,CACV,CACyG,CAAE,CAAC,EAC5G,SAAS,KAAK,OAAOC,CAAI,CAC3B,CAAC,EACMJ,CACT,CAEA,IAAMK,GAAiC,CAAC,UAAW,SAAU,MAAM,EAI7DC,GAAgC,CAAE,QAAS,YAAa,KAAM,aAAc,SAAU,aAAc,SAAU,YAAa,EAE3HC,GAA0E,CAC9E,SAAU,CAAE,MAAO,0BAA2B,KAAM,GAAI,KAAM,uCAAwC,EACtG,SAAU,CAAE,MAAO,yBAA0B,KAAM,GAAI,KAAM,iDAAkD,CACjH,EAGA,SAASC,GAAQC,EAAkBC,EAAgBC,EAAuB,CACxE,OAAIF,IAASC,EAAW,GACpBA,IAAO,OAAe,+FACtBD,IAAS,UAAkB,mEAC3BC,IAAO,UAAoBE,GAA4BD,CAAI,EACxD,yDACT,CAcO,SAASE,GAAmBC,EAQlB,CACf,GAAM,CAAE,OAA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D,CAAC,CACH,EACA,MAAAC,CACF,CACF",
|
|
6
|
-
"names": ["onlyWillSeeThisRoomEveryone", "mine", "upTo", "max", "members", "sharedWith", "hosts", "editable", "stylesheet", "loadStylesheet", "h", "resolve", "link", "CHOICES", "ICONS", "POSTING", "warning", "from", "to", "mine", "onlyWillSeeThisRoomEveryone", "createAccessDialog", "opts", "signal", "maxMembers", "LIMITS", "id", "uniqueId", "title", "sub", "cards", "values", "info", "set", "legend", "radios", "v", "input", "choices", "VISIBILITY", "visibility", "changed", "postingChoices", "p", "posting", "people", "label", "cls", "pickable", "head", "ul", "addBtn", "toggleSearch", "slot", "el", "shown", "listed", "full", "editable", "search", "upTo", "members", "u", "owner", "room", "avatar", "myId", "remove", "writers", "has", "warn", "sharedEl", "error", "cancel", "close", "save", "submit", "buttons", "x", "body", "sharedHosts", "busy", "render", "visibilityOf", "hosts", "sharedWith", "userId", "at", "li", "toggle", "ac", "ui", "createUserSearch", "q", "sig", "isAddress", "e", "SearchError", "reasonOf", "ids", "problem", "users", "r", "expanded", "me", "known", "uid", "a", "b", "canEdit", "postingOf"]
|
|
7
|
-
}
|