// ============================================================================ // SVELTUI - PUBLIC API // Framework exports // ============================================================================ // SVELTUI INITIALIZATION // Sets up the environment before any components load // Register Happy DOM globals immediately when sveltui is imported // This ensures DOM is available for all Svelte operations // // IMPORTANT: We preserve native fetch because happy-dom's fetch enforces CORS // and strips Authorization headers, breaking OAuth and API calls in CLI apps. // SvelTUI only needs DOM globals (document, window) - not browser fetch behavior. // Save native fetch BEFORE happy-dom overwrites it const nativeFetch = globalThis.fetch import { GlobalRegistrator } from '@happy-dom/global-registrator' GlobalRegistrator.register() // Restore native fetch - we only need happy-dom for DOM, not HTTP globalThis.fetch = nativeFetch // Ensure we have what Svelte needs if (!global.document || !global.window) { throw new Error('SvelTUI: Failed to initialize Happy DOM environment') } // Mount function export { mount, type MountOptions } from './mount.svelte.ts' // Keyboard - clean event emitter API export { keyboard, type KeyboardEvent } from './input/keyboard.svelte.ts' // Cursor - native terminal cursor control export { cursor, type CursorStyle, type CursorOptions, type CursorVisibility } from './input/cursor.svelte.ts' // Components - export the actual Svelte components export { default as Text } from './components/Text.svelte' export { default as Box } from './components/Box.svelte' export { default as Canvas } from './components/Canvas.svelte' export { default as Cursor } from './components/Cursor.svelte' // Canvas utilities export { PixelBuffer, type Color, type TerminalCell } from './canvas/index.ts' export type { CanvasContext } from './components/Canvas.svelte' // Theme system export { getTheme, type Theme, type ThemeColors } from './theme/theme.svelte.ts'