import type { MudletColor } from '../mapIO'; import type { LabelSnapshot } from './types'; /** * Drawing context handed to a {@link LabelStyle} hook. It exposes the live * 2D canvas context (already DPR-scaled, so draw in logical px), the label * rect, the label snapshot, the (possibly transformed) text, and helpers for * reusing the built-in rendering. */ export interface LabelDrawContext { /** DPR-scaled 2D context. Draw in logical pixels (0..width, 0..height). */ ctx: CanvasRenderingContext2D; /** Logical width in px (label.size[0] × PX_PER_UNIT). */ width: number; /** Logical height in px. */ height: number; /** The label being rendered. */ label: LabelSnapshot; /** Text after `transformText` has run (defaults to `label.text`). */ text: string; /** Run the built-in centered multi-line text layout (font, outline, underline/strikeout). */ defaultDrawText(): void; /** Convert a Mudlet color to a CSS `rgba()` string. */ colorToCss(c: MudletColor): string; } /** * A registered label appearance. Plugins contribute these via the * `labelStyles()` plugin hook; the label stores the chosen style by `id`. * * Every hook is optional — omitted stages fall back to the default rendering, * so a style only overrides what it cares about. The draw order is: * transformText → drawBackground → drawText → decorate */ export interface LabelStyle { /** Stable id persisted on the label and in area userData. */ id: string; /** Human-readable name shown in the label panel's style dropdown. */ name: string; /** Transform the raw text before layout (e.g. UPPERCASE). */ transformText?(text: string, label: LabelSnapshot): string; /** Replace the default background fill. When omitted, the label bg color fills the rect. */ drawBackground?(c: LabelDrawContext): void; /** Draw the text. Return `true` to fully replace the built-in layout; otherwise the default runs. */ drawText?(c: LabelDrawContext): boolean | void; /** Final pass drawn on top of background + text — borders, glow, shadow, etc. */ decorate?(c: LabelDrawContext): void; } /** The built-in default: plain text, no extra styling. Equivalent to no style. */ export declare const PLAIN_STYLE: LabelStyle; /** * Replace the plugin-contributed styles. Built-ins always come first; plugin * styles are appended. A plugin may override a built-in by reusing its id — * lookup returns the last match. */ export declare function registerLabelStyles(styles: LabelStyle[]): void; /** All registered styles (built-ins first), for populating UI. */ export declare function getLabelStyles(): LabelStyle[]; /** Resolve a style by id, falling back to {@link PLAIN_STYLE}. Last match wins so plugins can override built-ins. */ export declare function getLabelStyle(id: string | undefined): LabelStyle;