feat(rust): chat titles, BetterChat group styles, the voice and popups (phase 17)
PLAN.md §33, D134-D143. Protocol 12. - Chat titles (D135-D137): per-server rules (stat, top N, text, colour) that rank the current wipe, and a mode (first | all | up to N). Worked out once in model/titles and read three ways: pushed whole to the game by a new titleSync loop (on change, restart or wipe), and on every leaderboard row as `titles`. Admin: PUT /servers/:id/titles. - Group styles (D138, D139): a site group may carry all twelve BetterChat fields (rust_perm_group_chat). They ride perm.sync with `expect` from the pushed ledger, which gains a value column; a field changed in game is a `chat-field` drift row with the game's value, adopted into the style or put back. A withdrawn style is one `chat-group` retirement, never for `default`, cleared from the ledger only once BetterChat removed it. - The voice (D140): one fleet setting naming a styled group; news and rust.announce chat lines carry its format and the plugin says them with no sender. Admin: GET/PUT /voice. - Popups (D141, D142): rust.announce gains `delivery` (still version 1, from rust.options.delivery); each server gains news_delivery beside the news switch; `popup-unavailable` is not retried. - GET /servers/:id/integrations reads, live, which optional mods a server has loaded. README lists BetterChat and PopupNotifications as optional. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -156,4 +156,24 @@ function toMillis(value) {
|
||||
return Number.isNaN(parsed) ? null : parsed
|
||||
}
|
||||
|
||||
export default { ago, clock, day, duration, count, prefab, shortId, nextWipe }
|
||||
/**
|
||||
* The ink that reads on a background of `hex` — black or white, whichever has
|
||||
* the higher WCAG contrast. A chat title's colour is the operator's, chosen for
|
||||
* a dark game chat, and this page is drawn in the reader's theme: yellow text on
|
||||
* a white page is unreadable, so the colour becomes the chip and the text is
|
||||
* picked for it (phase 17, D137). Anything that is not `#rrggbb` gets black on
|
||||
* the caller's fallback.
|
||||
*/
|
||||
export function contrastInk(hex) {
|
||||
const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(String(hex || ''))
|
||||
if (!m) return '#000000'
|
||||
const linear = (c) => {
|
||||
const v = parseInt(c, 16) / 255
|
||||
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4
|
||||
}
|
||||
const L = 0.2126 * linear(m[1]) + 0.7152 * linear(m[2]) + 0.0722 * linear(m[3])
|
||||
// Contrast against white is 1.05 / (L + 0.05); against black (L + 0.05) / 0.05.
|
||||
return (L + 0.05) / 0.05 >= 1.05 / (L + 0.05) ? '#000000' : '#ffffff'
|
||||
}
|
||||
|
||||
export default { ago, clock, day, duration, count, prefab, shortId, nextWipe, contrastInk }
|
||||
|
||||
Reference in New Issue
Block a user