import { Config, HostPort, UiElements } from './types'; // Import the React-compatible logLine function import { logLine as reactLogLine } from './lib/react-ui-bridge'; /** * Build the UI elements for the WebIRC chat interface. * * @since 0.1.0 */ export function buildUI( root: HTMLElement, hostPort: HostPort, cfg: Config ): UiElements { root.innerHTML = `
`; const $log = root.querySelector('.irc-log') as HTMLDivElement; const $input = root.querySelector('.irc-input') as HTMLInputElement; const $reconnect = root.querySelector( '.irc-reconnect' ) as HTMLButtonElement; const $nickDisplay = root.querySelector('.irc-nick') as HTMLSpanElement; const $submit = root.querySelector('.irc-submit') as HTMLButtonElement; (root.querySelector('.irc-server') as HTMLElement).textContent = `${hostPort.host}:${hostPort.port}`; (root.querySelector('.irc-channel') as HTMLElement).textContent = cfg.channel; $reconnect.textContent = (cfg.i18n && cfg.i18n.reconnect) || 'Reconnect'; return { root, log: $log, input: $input, reconnect: $reconnect, nickDisplay: $nickDisplay, submit: $submit, }; } /** * Log a line to the chat interface with timestamp and optional class. * This function is now React-compatible and will use React state when available. * * @since 0.1.0 */ export function logLine($log: HTMLElement, text: string, cls = ''): void { // Use the React-compatible version reactLogLine($log, text, cls); }