@sigx/runtime-terminal 0.1.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["plugins: ComponentPlugin[]","defaultMountFn: MountFn<any> | null","currentComponentContext: ComponentSetupContext<any, any, any> | null","activeEffect: ReactiveEffect | null","effect","effect: ReactiveEffect","accessObserver: ((target: any, key: string | symbol) => void) | null","result: [any, string | symbol] | null","arrayInstrumentations: Record<string, Function>","Fragment","Text","currentAppContext: AppContext | null","render","vnode: VNode | null","Text","Fragment","newProps","oldKeyToIdx: Map<string | number, number> | undefined","exposed: any","mountHooks: ((ctx: MountContext) => void)[]","cleanupHooks: ((ctx: MountContext) => void)[]","ctx: ComponentSetupContext","componentInstance: ComponentInstance","renderFn: ViewFn | undefined","defaultChildren: any[]","namedSlots: Record<string, any[]>","container: HostElement | null","newValue","keyCleanup: (() => void) | null","keyCleanup: (() => void) | null","pressTimer: ReturnType<typeof setTimeout> | null","keyCleanup: (() => void) | null","rootNode: TerminalNode | null","lines: string[]","result: string[]"],"sources":["../../runtime-core/src/plugins.ts","../../runtime-core/src/app.ts","../../runtime-core/src/component.ts","../../reactivity/src/index.ts","../../runtime-core/src/jsx-runtime.ts","../../runtime-core/src/renderer.ts","../src/focus.ts","../src/utils.ts","../../runtime-core/dist/index.js","../src/components/Input.tsx","../src/components/ProgressBar.tsx","../src/components/Button.tsx","../src/components/Checkbox.tsx","../src/index.ts"],"sourcesContent":["/**\r\n * Component plugin registry for runtime-core.\r\n * \r\n * This module has NO IMPORTS to ensure it's fully initialized before\r\n * any other module can import from it. This avoids circular dependency\r\n * issues with ES module initialization.\r\n */\r\n\r\n/**\r\n * Plugin system for components (used by HMR, DevTools, etc.)\r\n * Note: SetupFn type is duplicated here to avoid circular imports\r\n */\r\nexport type ComponentPlugin = {\r\n onDefine?: (name: string | undefined, factory: any, setup: Function) => void;\r\n};\r\n\r\nconst plugins: ComponentPlugin[] = [];\r\n\r\nexport function registerComponentPlugin(plugin: ComponentPlugin): void {\r\n plugins.push(plugin);\r\n}\r\n\r\n/**\r\n * Get all registered plugins (internal use)\r\n */\r\nexport function getComponentPlugins(): readonly ComponentPlugin[] {\r\n return plugins;\r\n}\r\n","/**\r\n * Application instance and plugin system for sigx.\r\n * \r\n * This module provides a renderer-agnostic way to configure and bootstrap\r\n * sigx applications with plugins, dependency injection, and lifecycle hooks.\r\n */\r\n\r\n// Re-export all types from the types file\r\nexport type {\r\n ComponentInstance,\r\n AppConfig,\r\n AppLifecycleHooks,\r\n AppContext,\r\n Plugin,\r\n PluginInstallFn,\r\n MountFn,\r\n UnmountFn,\r\n App\r\n} from './app-types.js';\r\n\r\n// Import types for internal use\r\nimport type {\r\n ComponentInstance,\r\n AppConfig,\r\n AppContext,\r\n Plugin,\r\n PluginInstallFn,\r\n MountFn,\r\n App\r\n} from './app-types.js';\r\n\r\n// ============================================================================\r\n// Dev mode flag - must be at top before any usage\r\n// ============================================================================\r\n\r\nconst isDev = typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production' || true;\r\n\r\n// ============================================================================\r\n// Constants\r\n// ============================================================================\r\n\r\n/**\r\n * Unique symbol for app context injection\r\n */\r\nexport const AppContextKey = Symbol('sigx:app');\r\n\r\n// ============================================================================\r\n// Default Mount Function (set by platform packages)\r\n// ============================================================================\r\n\r\nlet defaultMountFn: MountFn<any> | null = null;\r\n\r\n/**\r\n * Set the default mount function for the platform.\r\n * Called by platform packages (runtime-dom, runtime-terminal) on import.\r\n * \r\n * @example\r\n * ```typescript\r\n * // In @sigx/runtime-dom\r\n * import { setDefaultMount } from '@sigx/runtime-core';\r\n * setDefaultMount(domMount);\r\n * ```\r\n */\r\nexport function setDefaultMount<TContainer = any>(mountFn: MountFn<TContainer>): void {\r\n defaultMountFn = mountFn;\r\n}\r\n\r\n/**\r\n * Get the current default mount function.\r\n * @internal\r\n */\r\nexport function getDefaultMount(): MountFn<any> | null {\r\n return defaultMountFn;\r\n}\r\n\r\n// ============================================================================\r\n// Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * Create an application instance.\r\n * \r\n * @example\r\n * ```tsx\r\n * import { defineApp, defineInjectable } from '@sigx/runtime-core';\r\n * import { render } from '@sigx/runtime-dom';\r\n * \r\n * // Define an injectable service\r\n * const useApiConfig = defineInjectable(() => ({ baseUrl: 'https://api.example.com' }));\r\n * \r\n * const app = defineApp(<App />);\r\n * \r\n * app.use(myPlugin, { option: 'value' });\r\n * \r\n * // Provide using the injectable token (works with inject())\r\n * app.provide(useApiConfig, { baseUrl: 'https://custom.api.com' });\r\n * \r\n * app.mount(document.getElementById('app')!, render);\r\n * ```\r\n */\r\nexport function defineApp<TContainer = any>(rootComponent: any): App<TContainer> {\r\n const installedPlugins = new Set<Plugin | PluginInstallFn>();\r\n\r\n const context: AppContext = {\r\n app: null!, // Will be set below\r\n provides: new Map(),\r\n config: {},\r\n hooks: []\r\n };\r\n\r\n let isMounted = false;\r\n let container: TContainer | null = null;\r\n let unmountFn: (() => void) | null = null;\r\n\r\n const app: App<TContainer> = {\r\n config: context.config,\r\n\r\n use(plugin, options) {\r\n if (installedPlugins.has(plugin)) {\r\n // Plugin already installed, skip\r\n if (isDev) {\r\n console.warn(`Plugin ${(plugin as Plugin).name || 'anonymous'} is already installed.`);\r\n }\r\n return app;\r\n }\r\n\r\n installedPlugins.add(plugin);\r\n\r\n if (typeof plugin === 'function') {\r\n // Function-style plugin\r\n plugin(app, options);\r\n } else if (plugin && typeof plugin.install === 'function') {\r\n // Object-style plugin\r\n plugin.install(app, options);\r\n } else if (isDev) {\r\n console.warn('Invalid plugin: must be a function or have an install() method.');\r\n }\r\n\r\n return app;\r\n },\r\n\r\n provide(token, value) {\r\n // Support defineInjectable tokens - extract the actual token\r\n const actualToken = (token as any)?._token ?? token;\r\n\r\n if (isDev && context.provides.has(actualToken)) {\r\n console.warn(`App-level provide: token is being overwritten.`);\r\n }\r\n context.provides.set(actualToken, value);\r\n return app;\r\n },\r\n\r\n hook(hooks) {\r\n context.hooks.push(hooks);\r\n return app;\r\n },\r\n\r\n mount(target, renderFn?) {\r\n if (isMounted) {\r\n if (isDev) {\r\n console.warn('App is already mounted. Call app.unmount() first.');\r\n }\r\n return app;\r\n }\r\n\r\n // Use provided mount function or fall back to platform default\r\n const mountFn = renderFn ?? defaultMountFn;\r\n\r\n if (!mountFn) {\r\n throw new Error(\r\n 'No mount function provided and no default mount function set. ' +\r\n 'Either pass a mount function to app.mount(), or import a platform package ' +\r\n '(e.g., @sigx/runtime-dom or @sigx/runtime-terminal) that sets the default.'\r\n );\r\n }\r\n\r\n container = target;\r\n isMounted = true;\r\n\r\n // Call the platform-specific render function with our app context\r\n // The render function may return an unmount callback\r\n const result = mountFn(rootComponent, target, context);\r\n if (typeof result === 'function') {\r\n unmountFn = result;\r\n }\r\n\r\n return app;\r\n },\r\n\r\n unmount() {\r\n if (!isMounted) {\r\n if (isDev) {\r\n console.warn('App is not mounted.');\r\n }\r\n return;\r\n }\r\n\r\n if (unmountFn) {\r\n unmountFn();\r\n }\r\n\r\n // Clear provides to help GC\r\n context.provides.clear();\r\n\r\n isMounted = false;\r\n container = null;\r\n },\r\n\r\n get _context() {\r\n return context;\r\n },\r\n\r\n get _isMounted() {\r\n return isMounted;\r\n },\r\n\r\n get _container() {\r\n return container;\r\n }\r\n };\r\n\r\n // Set the app reference in context\r\n context.app = app;\r\n\r\n return app;\r\n}\r\n\r\n// ============================================================================\r\n// Hooks API - Called by renderers to notify plugins\r\n// ============================================================================\r\n\r\n/**\r\n * Notify all app hooks that a component was created.\r\n * Called by the renderer after setup() returns.\r\n */\r\nexport function notifyComponentCreated(context: AppContext | null, instance: ComponentInstance): void {\r\n if (!context) return;\r\n for (const hooks of context.hooks) {\r\n try {\r\n hooks.onComponentCreated?.(instance);\r\n } catch (err) {\r\n handleHookError(context, err as Error, instance, 'onComponentCreated');\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Notify all app hooks that a component was mounted.\r\n * Called by the renderer after mount hooks run.\r\n */\r\nexport function notifyComponentMounted(context: AppContext | null, instance: ComponentInstance): void {\r\n if (!context) return;\r\n for (const hooks of context.hooks) {\r\n try {\r\n hooks.onComponentMounted?.(instance);\r\n } catch (err) {\r\n handleHookError(context, err as Error, instance, 'onComponentMounted');\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Notify all app hooks that a component was unmounted.\r\n * Called by the renderer before cleanup.\r\n */\r\nexport function notifyComponentUnmounted(context: AppContext | null, instance: ComponentInstance): void {\r\n if (!context) return;\r\n for (const hooks of context.hooks) {\r\n try {\r\n hooks.onComponentUnmounted?.(instance);\r\n } catch (err) {\r\n handleHookError(context, err as Error, instance, 'onComponentUnmounted');\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Notify all app hooks that a component updated.\r\n * Called by the renderer after re-render.\r\n */\r\nexport function notifyComponentUpdated(context: AppContext | null, instance: ComponentInstance): void {\r\n if (!context) return;\r\n for (const hooks of context.hooks) {\r\n try {\r\n hooks.onComponentUpdated?.(instance);\r\n } catch (err) {\r\n handleHookError(context, err as Error, instance, 'onComponentUpdated');\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Handle an error in a component. Returns true if the error was handled.\r\n * Called by the renderer when an error occurs in setup or render.\r\n */\r\nexport function handleComponentError(\r\n context: AppContext | null,\r\n err: Error,\r\n instance: ComponentInstance | null,\r\n info: string\r\n): boolean {\r\n if (!context) return false;\r\n\r\n // First, try plugin hooks\r\n for (const hooks of context.hooks) {\r\n try {\r\n const handled = hooks.onComponentError?.(err, instance!, info);\r\n if (handled === true) return true;\r\n } catch (hookErr) {\r\n // Hook itself threw - log and continue\r\n console.error('Error in onComponentError hook:', hookErr);\r\n }\r\n }\r\n\r\n // Then, try app-level error handler\r\n if (context.config.errorHandler) {\r\n try {\r\n const handled = context.config.errorHandler(err, instance, info);\r\n if (handled === true) return true;\r\n } catch (handlerErr) {\r\n console.error('Error in app.config.errorHandler:', handlerErr);\r\n }\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Handle errors that occur in hooks themselves\r\n */\r\nfunction handleHookError(context: AppContext, err: Error, instance: ComponentInstance, hookName: string): void {\r\n console.error(`Error in ${hookName} hook:`, err);\r\n\r\n // Try the app error handler\r\n if (context.config.errorHandler) {\r\n try {\r\n context.config.errorHandler(err, instance, `plugin hook: ${hookName}`);\r\n } catch {\r\n // Give up - we've done our best\r\n }\r\n }\r\n}\r\n","import { JSXElement } from \"./jsx-runtime.js\";\r\nimport { signal } from \"@sigx/reactivity\";\r\nimport { getComponentPlugins } from \"./plugins.js\";\r\n\r\n// Dev mode - can be set to false in production builds\r\nconst DEV = true;\r\n\r\n/**\r\n * Define a single prop with type, required/optional status\r\n */\r\nexport type DefineProp<TName extends string, TType, Required extends boolean = false> = Required extends false\r\n ? { [K in TName]?: TType }\r\n : { [K in TName]: TType };\r\n\r\n/**\r\n * Define a 2-way bound prop (sync).\r\n */\r\nexport type DefineSync<TNameOrType, TType = void> = TType extends void\r\n ? DefineProp<\"value\", TNameOrType> & DefineEvent<\"update:value\", TNameOrType>\r\n : TNameOrType extends string\r\n ? DefineProp<TNameOrType, TType> & DefineEvent<`update:${TNameOrType}`, TType>\r\n : never;\r\n\r\nexport type EventDefinition<T> = { __eventDetail: T };\r\n\r\n/**\r\n * Define a single custom event with its detail type\r\n */\r\nexport type DefineEvent<TName extends string, TDetail = void> = {\r\n [K in TName]?: EventDefinition<TDetail>;\r\n};\r\n\r\n/**\r\n * Define a slot with optional scoped props.\r\n * - DefineSlot<\"header\"> - a simple slot named \"header\"\r\n * - DefineSlot<\"item\", { item: T; index: number }> - a scoped slot with props\r\n */\r\nexport type DefineSlot<TName extends string, TProps = void> = {\r\n __slots?: {\r\n [K in TName]: TProps extends void\r\n ? () => JSXElement | JSXElement[] | null\r\n : (props: TProps) => JSXElement | JSXElement[] | null\r\n }\r\n};\r\n\r\n/**\r\n * Extract slot definitions from a combined type\r\n */\r\ntype ExtractSlots<T> = T extends { __slots?: infer S } ? S : {};\r\n\r\n/**\r\n * Default slot function type\r\n */\r\ntype DefaultSlot = () => JSXElement[];\r\n\r\n/**\r\n * Slots object passed to components - always has default, plus any declared slots\r\n */\r\nexport type SlotsObject<TSlots = {}> = {\r\n default: DefaultSlot;\r\n} & TSlots;\r\n\r\n/**\r\n * Extract event names from an event definition\r\n */\r\ntype EventNames<TEvents> = {\r\n [K in keyof TEvents]: TEvents[K] extends EventDefinition<any> | undefined ? K : never\r\n}[keyof TEvents] & string;\r\n\r\n/**\r\n * Extract event detail type for a specific event name\r\n */\r\ntype EventDetail<TEvents, TName extends EventNames<TEvents>> = TEvents extends { [K in TName]?: EventDefinition<infer TDetail> }\r\n ? TDetail\r\n : never;\r\n\r\n/**\r\n * Typed emit function for dispatching custom events\r\n */\r\nexport type EmitFn<TEvents extends Record<string, any>> = <TName extends EventNames<TEvents>>(\r\n eventName: TName,\r\n ...args: EventDetail<TEvents, TName> extends void ? [] : [detail: EventDetail<TEvents, TName>]\r\n) => void;\r\n\r\n/**\r\n * Capitalize the first letter of a string\r\n */\r\ntype Capitalize<S extends string> = S extends `${infer First}${infer Rest}`\r\n ? `${Uppercase<First>}${Rest}`\r\n : S;\r\n\r\n/**\r\n * Convert events to event handler props (on{EventName})\r\n */\r\ntype EventHandlers<TEvents extends Record<string, any>> = {\r\n [K in keyof TEvents as TEvents[K] extends EventDefinition<any> | undefined\r\n ? `on${Capitalize<string & K>}`\r\n : never\r\n ]?: (detail: TEvents[K] extends EventDefinition<infer D> | undefined ? D : never) => void;\r\n};\r\n\r\n/**\r\n * Platform registry - platforms add their element type here via declaration merging\r\n */\r\nexport interface PlatformTypes {\r\n // Platforms add: element: HTMLElement (or other element type)\r\n}\r\n\r\n/** Resolves to the platform's element type, or 'any' if not defined */\r\nexport type PlatformElement = PlatformTypes extends { element: infer E } ? E : any;\r\n\r\n/**\r\n * Base mount context - platforms can extend this via declaration merging\r\n */\r\nexport interface MountContext<TElement = PlatformElement> {\r\n el: TElement;\r\n}\r\n\r\n/**\r\n * Base setup context - platforms can extend this via declaration merging\r\n */\r\nexport interface SetupContext {\r\n // Platforms add properties here via module augmentation\r\n}\r\n\r\nexport interface ComponentSetupContext<\r\n TElement = PlatformElement,\r\n TProps extends Record<string, any> = {},\r\n TEvents extends Record<string, any> = {},\r\n TRef = any,\r\n TSlots = {}\r\n> extends SetupContext {\r\n el: TElement;\r\n signal: typeof signal;\r\n props: TProps;\r\n slots: SlotsObject<TSlots>;\r\n emit: EmitFn<TEvents>;\r\n parent: any | null;\r\n onMount(fn: (ctx: MountContext<TElement>) => void): void;\r\n onCleanup(fn: (ctx: MountContext<TElement>) => void): void;\r\n expose(exposed: TRef): void;\r\n}\r\n\r\nlet currentComponentContext: ComponentSetupContext<any, any, any> | null = null;\r\n\r\nexport function getCurrentInstance() {\r\n return currentComponentContext;\r\n}\r\n\r\nexport function setCurrentInstance(ctx: ComponentSetupContext<any, any, any> | null) {\r\n const prev = currentComponentContext;\r\n currentComponentContext = ctx;\r\n return prev;\r\n}\r\n\r\nexport function onMount(fn: (ctx: MountContext) => void) {\r\n if (currentComponentContext) {\r\n currentComponentContext.onMount(fn);\r\n } else {\r\n console.warn(\"onMount called outside of component setup\");\r\n }\r\n}\r\n\r\nexport function onCleanup(fn: (ctx: MountContext) => void) {\r\n if (currentComponentContext) {\r\n currentComponentContext.onCleanup(fn);\r\n } else {\r\n console.warn(\"onCleanup called outside of component setup\");\r\n }\r\n}\r\n\r\nexport type ViewFn = () => JSXElement | JSXElement[] | undefined;\r\n\r\n/**\r\n * Type for component setup functions.\r\n */\r\nexport type SetupFn<TSlots = {}> = (ctx: ComponentSetupContext<any, any, any, any, TSlots>) => ViewFn;\r\n\r\n// Component registry for DevTools and debugging\r\nconst componentRegistry = new Map<Function, { name?: string; setup: SetupFn<any> }>();\r\n\r\n/**\r\n * Get component metadata (for DevTools)\r\n */\r\nexport function getComponentMeta(factory: Function) {\r\n return componentRegistry.get(factory);\r\n}\r\n\r\n/**\r\n * Helper to create a proxy that tracks property access\r\n */\r\nexport function createPropsProxy<T extends Record<string, any>>(target: T, onAccess?: (key: string) => void): T {\r\n return new Proxy(target, {\r\n get(obj, prop) {\r\n if (typeof prop === 'string' && onAccess) {\r\n onAccess(prop);\r\n }\r\n return obj[prop as keyof T];\r\n }\r\n });\r\n}\r\n\r\nexport type DefineExpose<T> = {\r\n __exposed?: { __type: T };\r\n};\r\n\r\ntype ExtractExposed<T> = \"__exposed\" extends keyof T\r\n ? (NonNullable<T[\"__exposed\"]> extends { __type: infer E } ? E : void)\r\n : void;\r\n\r\nexport type Ref<T> = { current: T | null } | ((instance: T | null) => void);\r\n\r\n/**\r\n * Extract the exposed API type from a component.\r\n * Use this to type variables that will hold a component's exposed interface.\r\n * \r\n * @example\r\n * ```tsx\r\n * let api: Exposed<typeof MyComponent>;\r\n * <MyComponent ref={r => api = r!} />\r\n * api.exposedMethod();\r\n * ```\r\n */\r\nexport type Exposed<T extends { __ref: any }> = T[\"__ref\"];\r\n\r\n/**\r\n * Extract the ref (exposed) type from a component (includes function ref option).\r\n * \r\n * @example\r\n * ```tsx\r\n * const myRef = { current: null } as ComponentRef<typeof MyComponent>;\r\n * ```\r\n */\r\nexport type ComponentRef<T extends { __ref: any }> = Ref<T[\"__ref\"]>;\r\n\r\n\r\n/**\r\n * Strip internal type markers from props\r\n */\r\ntype StripInternalMarkers<T> = Omit<T, \"__exposed\" | \"__slots\">;\r\n\r\n/**\r\n * Component options (optional second param)\r\n */\r\nexport interface ComponentOptions {\r\n /** Component name for DevTools debugging */\r\n name?: string;\r\n}\r\n\r\n/**\r\n * Slot props type - converts slot definitions to a slots prop object\r\n */\r\ntype SlotProps<TSlots> = TSlots extends Record<string, any>\r\n ? { slots?: Partial<TSlots> }\r\n : {};\r\n\r\n// Return type for defineComponent - the function IS the component\r\nexport type ComponentFactory<TCombined extends Record<string, any>, TRef, TSlots> = ((props: StripInternalMarkers<Omit<TCombined, EventNames<TCombined>>> & EventHandlers<TCombined> & SlotProps<TSlots> & JSX.IntrinsicAttributes & {\r\n ref?: Ref<TRef>;\r\n children?: any;\r\n}) => JSXElement) & {\r\n /** @internal Setup function for the renderer */\r\n __setup: SetupFn<TSlots>;\r\n /** @internal Component name for debugging */\r\n __name?: string;\r\n /** @internal Type brand for props */\r\n __props: StripInternalMarkers<TCombined>;\r\n /** @internal Type brand for events */\r\n __events: TCombined;\r\n /** @internal Type brand for ref */\r\n __ref: TRef;\r\n /** @internal Type brand for slots */\r\n __slots: TSlots;\r\n};\r\n\r\n/**\r\n * Define a component. Returns a JSX factory function.\r\n * \r\n * @param setup - Setup function that receives context and returns a render function\r\n * @param options - Optional configuration (e.g., name for DevTools)\r\n * \r\n * @example\r\n * ```tsx\r\n * type CardProps = DefineProp<\"title\", string> & DefineSlot<\"header\">;\r\n * \r\n * export const Card = defineComponent<CardProps>((ctx) => {\r\n * const { title } = ctx.props;\r\n * const { slots } = ctx;\r\n * \r\n * return () => (\r\n * <div class=\"card\">\r\n * {slots.header?.() ?? <h2>{title}</h2>}\r\n * {slots.default()}\r\n * </div>\r\n * );\r\n * });\r\n * ```\r\n */\r\nexport function defineComponent<\r\n TCombined extends Record<string, any> = {},\r\n TRef = ExtractExposed<TCombined>,\r\n TSlots = ExtractSlots<TCombined>\r\n>(\r\n setup: (ctx: ComponentSetupContext<PlatformElement, StripInternalMarkers<TCombined>, TCombined, TRef, TSlots>) => ViewFn,\r\n options?: ComponentOptions\r\n): ComponentFactory<TCombined, TRef, TSlots> {\r\n // Create the factory function - when called in JSX, it returns itself as a marker\r\n // The renderer will detect __setup and handle it as a component\r\n const factory = function (props: any) {\r\n // Return a VNode-like structure that the renderer can detect\r\n return {\r\n type: factory,\r\n props: props || {},\r\n key: props?.key || null,\r\n children: [],\r\n dom: null\r\n };\r\n } as unknown as ComponentFactory<TCombined, TRef, TSlots>;\r\n\r\n factory.__setup = setup as SetupFn<TSlots>;\r\n factory.__name = options?.name;\r\n factory.__props = null as any;\r\n factory.__events = null as any;\r\n factory.__ref = null as any;\r\n factory.__slots = null as any;\r\n\r\n // Register in component registry for DevTools\r\n componentRegistry.set(factory, { name: options?.name, setup: setup as SetupFn<any> });\r\n\r\n // Notify plugins\r\n getComponentPlugins().forEach(p => p.onDefine?.(options?.name, factory, setup as SetupFn<any>));\r\n\r\n return factory;\r\n}\r\n","// signals.ts\r\n\r\nexport type EffectFn = () => void;\r\n\r\nexport interface ReactiveEffect extends EffectFn {\r\n deps: Set<ReactiveEffect>[];\r\n}\r\n\r\nlet activeEffect: ReactiveEffect | null = null;\r\nlet batchDepth = 0;\r\nconst pendingEffects = new Set<ReactiveEffect>();\r\n\r\nexport function batch(fn: () => void) {\r\n batchDepth++;\r\n try {\r\n fn();\r\n } finally {\r\n batchDepth--;\r\n if (batchDepth === 0) {\r\n const effects = Array.from(pendingEffects);\r\n pendingEffects.clear();\r\n for (const effect of effects) {\r\n effect();\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction runEffect(fn: EffectFn): () => void {\r\n const effect: ReactiveEffect = function () {\r\n cleanup(effect);\r\n activeEffect = effect;\r\n fn();\r\n activeEffect = null;\r\n } as ReactiveEffect;\r\n\r\n effect.deps = [];\r\n effect();\r\n\r\n // disposer\r\n return () => cleanup(effect);\r\n}\r\n\r\nfunction cleanup(effect: ReactiveEffect): void {\r\n if (!effect.deps) return;\r\n for (const dep of effect.deps) {\r\n dep.delete(effect);\r\n }\r\n effect.deps.length = 0;\r\n}\r\n\r\nfunction track(depSet: Set<ReactiveEffect>): void {\r\n if (!activeEffect) return;\r\n depSet.add(activeEffect);\r\n activeEffect.deps.push(depSet);\r\n}\r\n\r\nfunction trigger(depSet: Set<ReactiveEffect>): void {\r\n const effects = Array.from(depSet);\r\n for (const effect of effects) {\r\n if (batchDepth > 0) {\r\n pendingEffects.add(effect);\r\n } else {\r\n effect();\r\n }\r\n }\r\n}\r\n\r\nexport type Signal<T> = T & {\r\n $set: (newValue: T) => void;\r\n};\r\n\r\nlet accessObserver: ((target: any, key: string | symbol) => void) | null = null;\r\n\r\nexport function detectAccess(selector: () => any): [any, string | symbol] | null {\r\n let result: [any, string | symbol] | null = null;\r\n const prev = accessObserver;\r\n\r\n accessObserver = (target, key) => {\r\n result = [target, key];\r\n };\r\n\r\n try {\r\n selector();\r\n } finally {\r\n accessObserver = prev;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport function untrack<T>(fn: () => T): T {\r\n const prev = activeEffect;\r\n activeEffect = null;\r\n try {\r\n return fn();\r\n } finally {\r\n activeEffect = prev;\r\n }\r\n}\r\n\r\nexport function signal<T extends object>(target: T): Signal<T> {\r\n const depsMap = new Map<string | symbol, Set<ReactiveEffect>>();\r\n const reactiveCache = new WeakMap<object, any>();\r\n\r\n return new Proxy(target, {\r\n get(obj, prop, receiver) {\r\n if (prop === '$set') {\r\n return (newValue: T) => {\r\n batch(() => {\r\n if (Array.isArray(obj) && Array.isArray(newValue)) {\r\n const len = newValue.length;\r\n for (let i = 0; i < len; i++) {\r\n Reflect.set(receiver, String(i), newValue[i]);\r\n }\r\n Reflect.set(receiver, 'length', len);\r\n } else {\r\n const newKeys = Object.keys(newValue);\r\n const oldKeys = Object.keys(obj);\r\n for (const key of newKeys) {\r\n Reflect.set(receiver, key, (newValue as any)[key]);\r\n }\r\n for (const key of oldKeys) {\r\n if (!(key in newValue)) {\r\n Reflect.deleteProperty(receiver, key);\r\n }\r\n }\r\n }\r\n });\r\n };\r\n }\r\n\r\n if (Array.isArray(obj) && typeof prop === 'string' && arrayInstrumentations.hasOwnProperty(prop)) {\r\n return arrayInstrumentations[prop];\r\n }\r\n\r\n const value = Reflect.get(obj, prop);\r\n\r\n if (accessObserver) {\r\n accessObserver(receiver, prop);\r\n }\r\n\r\n // Track this property access\r\n let dep = depsMap.get(prop);\r\n if (!dep) {\r\n dep = new Set<ReactiveEffect>();\r\n depsMap.set(prop, dep);\r\n }\r\n track(dep);\r\n\r\n // If the value is an object, make it reactive too (with caching)\r\n if (value && typeof value === 'object') {\r\n let cached = reactiveCache.get(value);\r\n if (!cached) {\r\n cached = signal(value);\r\n reactiveCache.set(value, cached);\r\n }\r\n return cached;\r\n }\r\n\r\n return value;\r\n },\r\n set(obj, prop, newValue) {\r\n const oldLength = Array.isArray(obj) ? obj.length : 0;\r\n const oldValue = Reflect.get(obj, prop);\r\n const result = Reflect.set(obj, prop, newValue);\r\n\r\n // Only trigger if value actually changed\r\n if (!Object.is(oldValue, newValue)) {\r\n const dep = depsMap.get(prop);\r\n if (dep) {\r\n trigger(dep);\r\n }\r\n\r\n // Special handling for Arrays\r\n if (Array.isArray(obj)) {\r\n // If we set an index and length changed, trigger length dependency\r\n if (prop !== 'length' && obj.length !== oldLength) {\r\n const lengthDep = depsMap.get('length');\r\n if (lengthDep) {\r\n trigger(lengthDep);\r\n }\r\n }\r\n // If we set length, trigger indices that are now out of bounds\r\n if (prop === 'length' && typeof newValue === 'number' && newValue < oldLength) {\r\n for (let i = newValue; i < oldLength; i++) {\r\n const idxDep = depsMap.get(String(i));\r\n if (idxDep) trigger(idxDep);\r\n }\r\n }\r\n }\r\n }\r\n\r\n return result;\r\n },\r\n deleteProperty(obj, prop) {\r\n const hasKey = Object.prototype.hasOwnProperty.call(obj, prop);\r\n const result = Reflect.deleteProperty(obj, prop);\r\n\r\n if (result && hasKey) {\r\n const dep = depsMap.get(prop);\r\n if (dep) {\r\n trigger(dep);\r\n }\r\n }\r\n return result;\r\n }\r\n }) as Signal<T>;\r\n}\r\n\r\nexport function effect(fn: EffectFn): () => void {\r\n return runEffect(fn);\r\n}\r\n\r\nconst arrayInstrumentations: Record<string, Function> = {};\r\n['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'].forEach(method => {\r\n arrayInstrumentations[method] = function (this: any, ...args: any[]) {\r\n let res;\r\n batch(() => {\r\n res = (Array.prototype as any)[method].apply(this, args);\r\n });\r\n return res;\r\n };\r\n});\r\n\r\nexport type WatchSource<T = any> = T | (() => T);\r\nexport type WatchCallback<V = any, OV = any> = (value: V, oldValue: OV, onCleanup: (fn: () => void) => void) => any;\r\nexport interface WatchOptions<Immediate = boolean> {\r\n immediate?: Immediate;\r\n deep?: boolean | number;\r\n once?: boolean;\r\n}\r\n\r\nexport interface WatchHandle {\r\n (): void; // stop\r\n pause: () => void;\r\n resume: () => void;\r\n stop: () => void;\r\n}\r\n\r\nexport function watch<T>(source: WatchSource<T>, cb: WatchCallback<T>, options?: WatchOptions): WatchHandle {\r\n let oldValue: T | undefined;\r\n let isFirst = true;\r\n let cleanupFn: (() => void) | null = null;\r\n\r\n const runner = effect(() => {\r\n const newValue = typeof source === 'function' ? (source as () => T)() : source;\r\n\r\n if (isFirst) {\r\n if (options?.immediate) {\r\n if (cleanupFn) cleanupFn();\r\n cb(newValue, oldValue, (fn) => cleanupFn = fn);\r\n }\r\n isFirst = false;\r\n } else {\r\n if (cleanupFn) cleanupFn();\r\n cb(newValue, oldValue, (fn) => cleanupFn = fn);\r\n }\r\n oldValue = newValue;\r\n });\r\n\r\n const stop = () => {\r\n runner();\r\n if (cleanupFn) cleanupFn();\r\n };\r\n\r\n const handle = stop as unknown as WatchHandle;\r\n handle.stop = stop;\r\n handle.pause = () => { }; // Not implemented\r\n handle.resume = () => { }; // Not implemented\r\n\r\n return handle;\r\n}\r\n\r\nexport type EffectScope = {\r\n run<T>(fn: () => T): T | undefined;\r\n stop(fromParent?: boolean): void;\r\n}\r\n\r\nexport function effectScope(detached?: boolean): EffectScope {\r\n const effects: (() => void)[] = [];\r\n let active = true;\r\n\r\n return {\r\n run<T>(fn: () => T): T | undefined {\r\n if (!active) return undefined;\r\n return fn();\r\n },\r\n stop() {\r\n active = false;\r\n effects.forEach(e => e());\r\n }\r\n };\r\n}\r\n","// JSX runtime for @sigx/runtime-core\r\n\r\nimport { detectAccess } from '@sigx/reactivity';\r\nimport { getPlatformSyncProcessor } from './platform.js';\r\n\r\n// Re-export platform types and functions for backwards compatibility\r\nexport { setPlatformSyncProcessor, getPlatformSyncProcessor } from './platform.js';\r\nexport type { SyncProcessor } from './platform.js';\r\n\r\nexport type VNode = {\r\n type: string | typeof Fragment | typeof Text | Function;\r\n props: Record<string, any>;\r\n key: string | number | null;\r\n children: VNode[];\r\n dom: any | null;\r\n text?: string | number;\r\n parent?: VNode | null;\r\n cleanup?: () => void;\r\n};\r\n\r\nexport type JSXChild = VNode | string | number | boolean | null | undefined | JSXChild[];\r\nexport type JSXChildren = JSXChild;\r\nexport type JSXElement = VNode | string | number | boolean | null;\r\n\r\ninterface JSXProps {\r\n children?: JSXChildren;\r\n [key: string]: any;\r\n}\r\n\r\nexport const Fragment = Symbol.for('sigx.Fragment');\r\nexport const Text = Symbol.for('sigx.Text');\r\n\r\nfunction normalizeChildren(children: JSXChildren): VNode[] {\r\n if (children == null || children === false || children === true) {\r\n return [];\r\n }\r\n\r\n if (Array.isArray(children)) {\r\n return children.flatMap(c => normalizeChildren(c));\r\n }\r\n\r\n if (typeof children === 'string' || typeof children === 'number') {\r\n return [{\r\n type: Text,\r\n props: {},\r\n key: null,\r\n children: [],\r\n dom: null,\r\n text: children\r\n }];\r\n }\r\n\r\n if ((children as VNode).type) {\r\n return [children as VNode];\r\n }\r\n\r\n return [];\r\n}\r\n\r\n/**\r\n * Check if a type is a sigx component (has __setup)\r\n */\r\nfunction isComponent(type: any): boolean {\r\n return typeof type === 'function' && '__setup' in type;\r\n}\r\n\r\n/**\r\n * Create a JSX element - this is the core function called by TSX transpilation\r\n */\r\nexport function jsx(\r\n type: string | Function | typeof Fragment,\r\n props: JSXProps | null,\r\n key?: string\r\n): JSXElement {\r\n const processedProps = { ...(props || {}) };\r\n\r\n // Handle sync props\r\n if (props) {\r\n for (const propKey in props) {\r\n if (propKey === 'sync') {\r\n let syncBinding = props[propKey];\r\n\r\n if (typeof syncBinding === 'function') {\r\n const detected = detectAccess(syncBinding);\r\n if (detected) {\r\n syncBinding = detected;\r\n }\r\n }\r\n\r\n // Expecting [object, key] tuple\r\n if (Array.isArray(syncBinding) && syncBinding.length === 2) {\r\n const [stateObj, key] = syncBinding;\r\n let handled = false;\r\n\r\n // Let platform handle intrinsic element sync (e.g., DOM checkbox/radio)\r\n const platformProcessor = getPlatformSyncProcessor();\r\n if (typeof type === 'string' && platformProcessor) {\r\n handled = platformProcessor(type, processedProps, [stateObj, key], props);\r\n }\r\n\r\n // Generic fallback: standard value binding\r\n if (!handled) {\r\n processedProps.value = stateObj[key];\r\n const existingHandler = processedProps['onUpdate:value'];\r\n processedProps['onUpdate:value'] = (v: any) => {\r\n stateObj[key] = v;\r\n if (existingHandler) existingHandler(v);\r\n };\r\n }\r\n delete processedProps.sync;\r\n }\r\n } else if (propKey.startsWith('sync:')) {\r\n const syncBinding = props[propKey];\r\n if (Array.isArray(syncBinding) && syncBinding.length === 2) {\r\n const [stateObj, key] = syncBinding;\r\n const name = propKey.slice(5);\r\n\r\n processedProps[name] = stateObj[key];\r\n const eventName = `onUpdate:${name}`;\r\n const existingHandler = processedProps[eventName];\r\n processedProps[eventName] = (v: any) => {\r\n stateObj[key] = v;\r\n if (existingHandler) existingHandler(v);\r\n };\r\n delete processedProps[propKey];\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Handle sigx components - create a VNode with the component factory as type\r\n // The renderer will detect __setup and call mountComponent\r\n if (isComponent(type)) {\r\n const { children, ...rest } = processedProps;\r\n return {\r\n type: type as Function,\r\n props: { ...rest, children },\r\n key: key || rest.key || null,\r\n children: [], // Children are passed via props for components\r\n dom: null\r\n };\r\n }\r\n\r\n // Handle plain function components (not sigx defineComponent)\r\n if (typeof type === 'function' && (type as any) !== Fragment) {\r\n return type(processedProps);\r\n }\r\n\r\n const { children, ...rest } = processedProps;\r\n\r\n return {\r\n type: type as string | typeof Fragment,\r\n props: rest,\r\n key: key || rest.key || null,\r\n children: normalizeChildren(children),\r\n dom: null\r\n };\r\n}\r\n\r\n/**\r\n * JSX Factory for fragments\r\n */\r\nexport function jsxs(type: any, props: any, key?: any) {\r\n return jsx(type, props, key);\r\n}\r\n\r\nexport const jsxDEV = jsx;\r\n","import { VNode, Fragment, JSXElement, Text } from './jsx-runtime.js';\r\nimport { effect, signal, untrack } from '@sigx/reactivity';\r\nimport { ComponentSetupContext, setCurrentInstance, getCurrentInstance, MountContext, SlotsObject, ViewFn, SetupFn } from './component.js';\r\nimport {\r\n AppContext,\r\n ComponentInstance,\r\n notifyComponentCreated,\r\n notifyComponentMounted,\r\n notifyComponentUnmounted,\r\n notifyComponentUpdated,\r\n handleComponentError\r\n} from './app.js';\r\n\r\n/**\r\n * Check if a vnode type is a component (has __setup)\r\n */\r\nfunction isComponent(type: any): type is { __setup: SetupFn<any>; __name?: string } {\r\n return typeof type === 'function' && '__setup' in type;\r\n}\r\n\r\nexport interface RendererOptions<HostNode = any, HostElement = any> {\r\n patchProp(el: HostElement, key: string, prevValue: any, nextValue: any, isSVG?: boolean): void;\r\n insert(child: HostNode, parent: HostElement, anchor?: HostNode | null): void;\r\n remove(child: HostNode): void;\r\n createElement(type: string, isSVG?: boolean, isCustomizedBuiltIn?: string): HostElement;\r\n createText(text: string): HostNode;\r\n createComment(text: string): HostNode;\r\n setText(node: HostNode, text: string): void;\r\n setElementText(node: HostElement, text: string): void;\r\n parentNode(node: HostNode): HostElement | null;\r\n nextSibling(node: HostNode): HostNode | null;\r\n querySelector?(selector: string): HostElement | null;\r\n setScopeId?(el: HostElement, id: string): void;\r\n cloneNode?(node: HostNode): HostNode;\r\n insertStaticContent?(content: string, parent: HostElement, anchor: HostNode | null, isSVG: boolean): [HostNode, HostNode];\r\n}\r\n\r\nexport type RootRenderFunction<HostNode = any, HostElement = any> = (\r\n vnode: JSXElement,\r\n container: HostElement,\r\n isSVG?: boolean\r\n) => void;\r\n\r\nexport function createRenderer<HostNode = any, HostElement = any>(\r\n options: RendererOptions<HostNode, HostElement>\r\n) {\r\n const {\r\n insert: hostInsert,\r\n remove: hostRemove,\r\n patchProp: hostPatchProp,\r\n createElement: hostCreateElement,\r\n createText: hostCreateText,\r\n createComment: hostCreateComment,\r\n setText: hostSetText,\r\n setElementText: hostSetElementText,\r\n parentNode: hostParentNode,\r\n nextSibling: hostNextSibling,\r\n cloneNode: hostCloneNode,\r\n insertStaticContent: hostInsertStaticContent\r\n } = options;\r\n\r\n // Flag to track if we're currently patching (to prevent infinite loops)\r\n let isPatching = false;\r\n\r\n // Current app context (set when rendering via defineApp)\r\n let currentAppContext: AppContext | null = null;\r\n\r\n function render(element: JSXElement, container: HostElement, appContext?: AppContext): void {\r\n // Store app context for this render tree\r\n const prevAppContext = currentAppContext;\r\n if (appContext) {\r\n currentAppContext = appContext;\r\n }\r\n\r\n const oldVNode = (container as any)._vnode;\r\n\r\n // Normalize element to VNode if it's not\r\n let vnode: VNode | null = null;\r\n if (element != null && element !== false && element !== true) {\r\n if (typeof element === 'string' || typeof element === 'number') {\r\n vnode = {\r\n type: Text,\r\n props: {},\r\n key: null,\r\n children: [],\r\n dom: null,\r\n text: element\r\n };\r\n } else {\r\n vnode = element as VNode;\r\n }\r\n }\r\n\r\n if (vnode) {\r\n if (oldVNode) {\r\n patch(oldVNode, vnode, container);\r\n } else {\r\n mount(vnode, container);\r\n }\r\n (container as any)._vnode = vnode;\r\n } else {\r\n if (oldVNode) {\r\n unmount(oldVNode, container);\r\n (container as any)._vnode = null;\r\n }\r\n }\r\n }\r\n\r\n function mount(vnode: VNode, container: HostElement, before: HostNode | null = null): void {\r\n if (vnode.type === Text) {\r\n const node = hostCreateText(String(vnode.text));\r\n vnode.dom = node;\r\n (node as any).__vnode = vnode;\r\n hostInsert(node, container, before);\r\n return;\r\n }\r\n\r\n if (vnode.type === Fragment) {\r\n // For fragments, we need a way to track the children's DOM nodes\r\n // Store the anchor comment for fragments\r\n const anchor = hostCreateComment('');\r\n vnode.dom = anchor;\r\n hostInsert(anchor, container, before);\r\n vnode.children.forEach((child: VNode) => mount(child, container, anchor));\r\n return;\r\n }\r\n\r\n // Check for component (function with __setup)\r\n if (isComponent(vnode.type)) {\r\n mountComponent(vnode, container, before, vnode.type.__setup);\r\n return;\r\n }\r\n\r\n const element = hostCreateElement(vnode.type as string);\r\n vnode.dom = element;\r\n (element as any).__vnode = vnode;\r\n\r\n // Props\r\n if (vnode.props) {\r\n for (const key in vnode.props) {\r\n if (key !== 'children' && key !== 'key' && key !== 'ref') {\r\n hostPatchProp(element, key, null, vnode.props[key]);\r\n }\r\n }\r\n }\r\n\r\n // Handle ref\r\n if (vnode.props.ref) {\r\n if (typeof vnode.props.ref === 'function') {\r\n vnode.props.ref(element);\r\n } else if (vnode.props.ref && typeof vnode.props.ref === 'object') {\r\n vnode.props.ref.current = element;\r\n }\r\n }\r\n\r\n // Children\r\n vnode.children.forEach((child: VNode) => {\r\n child.parent = vnode;\r\n mount(child, element)\r\n });\r\n\r\n hostInsert(element as unknown as HostNode, container, before);\r\n }\r\n\r\n function unmount(vnode: VNode, container: HostElement): void {\r\n if ((vnode as any)._effect) {\r\n (vnode as any)._effect(); // Stop effect\r\n }\r\n\r\n if (vnode.cleanup) {\r\n vnode.cleanup();\r\n }\r\n\r\n // Handle component unmount - unmount its subTree\r\n if (isComponent(vnode.type)) {\r\n const subTree = (vnode as any)._subTree;\r\n if (subTree) {\r\n unmount(subTree, container);\r\n }\r\n // Remove the anchor comment\r\n if (vnode.dom) {\r\n hostRemove(vnode.dom);\r\n }\r\n // Handle ref cleanup\r\n if (vnode.props?.ref) {\r\n if (typeof vnode.props.ref === 'function') {\r\n vnode.props.ref(null);\r\n } else if (typeof vnode.props.ref === 'object') {\r\n vnode.props.ref.current = null;\r\n }\r\n }\r\n return;\r\n }\r\n\r\n if (vnode.type === Fragment) {\r\n vnode.children.forEach((child: VNode) => unmount(child, container));\r\n // Remove anchor comment if exists\r\n if (vnode.dom) {\r\n hostRemove(vnode.dom);\r\n }\r\n return;\r\n }\r\n\r\n // Handle ref cleanup\r\n if (vnode.props?.ref) {\r\n if (typeof vnode.props.ref === 'function') {\r\n vnode.props.ref(null);\r\n } else if (vnode.props.ref && typeof vnode.props.ref === 'object') {\r\n vnode.props.ref.current = null;\r\n }\r\n }\r\n\r\n // Recursively unmount children for regular elements\r\n if (vnode.children && vnode.children.length > 0) {\r\n vnode.children.forEach((child: VNode) => unmount(child, vnode.dom as HostElement));\r\n }\r\n\r\n if (vnode.dom) {\r\n hostRemove(vnode.dom);\r\n }\r\n }\r\n\r\n function patch(oldVNode: VNode, newVNode: VNode, container: HostElement): void {\r\n if (oldVNode === newVNode) return;\r\n\r\n // If types are different, replace completely\r\n if (!isSameVNode(oldVNode, newVNode)) {\r\n const parent = hostParentNode(oldVNode.dom) || container;\r\n const nextSibling = hostNextSibling(oldVNode.dom);\r\n unmount(oldVNode, parent as HostElement);\r\n mount(newVNode, parent as HostElement, nextSibling);\r\n return;\r\n }\r\n\r\n // If component\r\n if ((oldVNode as any)._effect) {\r\n newVNode.dom = oldVNode.dom;\r\n (newVNode as any)._effect = (oldVNode as any)._effect;\r\n (newVNode as any)._subTree = (oldVNode as any)._subTree;\r\n (newVNode as any)._slots = (oldVNode as any)._slots;\r\n\r\n const props = (oldVNode as any)._componentProps;\r\n (newVNode as any)._componentProps = props;\r\n\r\n if (props) {\r\n const newProps = newVNode.props || {};\r\n // Update props (excluding children, key, ref)\r\n untrack(() => {\r\n for (const key in newProps) {\r\n if (key !== 'children' && key !== 'key' && key !== 'ref') {\r\n if (props[key] !== newProps[key]) {\r\n props[key] = newProps[key];\r\n }\r\n }\r\n }\r\n // Handle removed props (optional but good)\r\n for (const key in props) {\r\n if (!(key in newProps) && key !== 'children' && key !== 'key' && key !== 'ref') {\r\n delete props[key];\r\n }\r\n }\r\n });\r\n }\r\n\r\n // Update slots with new children and slot functions\r\n const slotsRef = (oldVNode as any)._slots;\r\n const newChildren = newVNode.props?.children;\r\n const newSlotsFromProps = newVNode.props?.slots;\r\n\r\n if (slotsRef) {\r\n // Update children for default slot\r\n if (newChildren !== undefined) {\r\n slotsRef._children = newChildren;\r\n }\r\n\r\n // Update slot functions from the slots prop\r\n if (newSlotsFromProps !== undefined) {\r\n slotsRef._slotsFromProps = newSlotsFromProps;\r\n }\r\n\r\n // Trigger component re-render if not already patching\r\n // This is needed to update the slot content in the component's subTree\r\n if (!isPatching) {\r\n isPatching = true;\r\n try {\r\n // Bump version to trigger effect - wrapped in untrack to not track this update\r\n untrack(() => {\r\n slotsRef._version.v++;\r\n });\r\n } finally {\r\n isPatching = false;\r\n }\r\n }\r\n }\r\n\r\n return;\r\n }\r\n\r\n // If text node\r\n if (newVNode.type === Text) {\r\n newVNode.dom = oldVNode.dom;\r\n if (oldVNode.text !== newVNode.text) {\r\n hostSetText(newVNode.dom, String(newVNode.text));\r\n }\r\n return;\r\n }\r\n\r\n // If Fragment\r\n if (newVNode.type === Fragment) {\r\n patchChildren(oldVNode, newVNode, container);\r\n return;\r\n }\r\n\r\n // Element\r\n const element = (newVNode.dom = oldVNode.dom) as HostElement;\r\n\r\n // Update props\r\n const oldProps = oldVNode.props || {};\r\n const newProps = newVNode.props || {};\r\n\r\n // Remove old props\r\n for (const key in oldProps) {\r\n if (!(key in newProps) && key !== 'children' && key !== 'key' && key !== 'ref') {\r\n hostPatchProp(element, key, oldProps[key], null);\r\n }\r\n }\r\n\r\n // Set new props\r\n for (const key in newProps) {\r\n const oldValue = oldProps[key];\r\n const newValue = newProps[key];\r\n if (key !== 'children' && key !== 'key' && key !== 'ref' && oldValue !== newValue) {\r\n hostPatchProp(element, key, oldValue, newValue);\r\n }\r\n }\r\n\r\n // Update children\r\n patchChildren(oldVNode, newVNode, element);\r\n }\r\n\r\n function patchChildren(oldVNode: VNode, newVNode: VNode, container: HostElement) {\r\n const oldChildren = oldVNode.children;\r\n const newChildren = newVNode.children;\r\n\r\n newChildren.forEach((c: VNode) => c.parent = newVNode);\r\n\r\n reconcileChildrenArray(container, oldChildren, newChildren);\r\n }\r\n\r\n function reconcileChildrenArray(parent: HostElement, oldChildren: VNode[], newChildren: VNode[]) {\r\n let oldStartIdx = 0;\r\n let oldEndIdx = oldChildren.length - 1;\r\n let oldStartVNode = oldChildren[0];\r\n let oldEndVNode = oldChildren[oldEndIdx];\r\n\r\n let newStartIdx = 0;\r\n let newEndIdx = newChildren.length - 1;\r\n let newStartVNode = newChildren[0];\r\n let newEndVNode = newChildren[newEndIdx];\r\n\r\n let oldKeyToIdx: Map<string | number, number> | undefined;\r\n\r\n while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {\r\n if (oldStartVNode == null) {\r\n oldStartVNode = oldChildren[++oldStartIdx];\r\n } else if (oldEndVNode == null) {\r\n oldEndVNode = oldChildren[--oldEndIdx];\r\n } else if (isSameVNode(oldStartVNode, newStartVNode)) {\r\n patch(oldStartVNode, newStartVNode, parent);\r\n oldStartVNode = oldChildren[++oldStartIdx];\r\n newStartVNode = newChildren[++newStartIdx];\r\n } else if (isSameVNode(oldEndVNode, newEndVNode)) {\r\n patch(oldEndVNode, newEndVNode, parent);\r\n oldEndVNode = oldChildren[--oldEndIdx];\r\n newEndVNode = newChildren[--newEndIdx];\r\n } else if (isSameVNode(oldStartVNode, newEndVNode)) {\r\n patch(oldStartVNode, newEndVNode, parent);\r\n const nodeToMove = oldStartVNode.dom;\r\n const anchor = hostNextSibling(oldEndVNode.dom);\r\n if (nodeToMove) {\r\n hostInsert(nodeToMove, parent, anchor);\r\n }\r\n oldStartVNode = oldChildren[++oldStartIdx];\r\n newEndVNode = newChildren[--newEndIdx];\r\n } else if (isSameVNode(oldEndVNode, newStartVNode)) {\r\n patch(oldEndVNode, newStartVNode, parent);\r\n const nodeToMove = oldEndVNode.dom;\r\n const anchor = oldStartVNode.dom;\r\n if (nodeToMove) {\r\n hostInsert(nodeToMove, parent, anchor);\r\n }\r\n oldEndVNode = oldChildren[--oldEndIdx];\r\n newStartVNode = newChildren[++newStartIdx];\r\n } else {\r\n if (!oldKeyToIdx) {\r\n oldKeyToIdx = createKeyToKeyIndexMap(oldChildren, oldStartIdx, oldEndIdx);\r\n }\r\n const idxInOld = newStartVNode.key != null\r\n ? oldKeyToIdx.get(String(newStartVNode.key))\r\n : findIndexInOld(oldChildren, newStartVNode, oldStartIdx, oldEndIdx);\r\n\r\n if (idxInOld != null) {\r\n const vnodeToMove = oldChildren[idxInOld];\r\n patch(vnodeToMove, newStartVNode, parent);\r\n oldChildren[idxInOld] = undefined as any;\r\n if (vnodeToMove.dom && oldStartVNode.dom) {\r\n hostInsert(vnodeToMove.dom, parent, oldStartVNode.dom);\r\n }\r\n } else {\r\n mount(newStartVNode, parent, oldStartVNode.dom);\r\n }\r\n newStartVNode = newChildren[++newStartIdx];\r\n }\r\n }\r\n\r\n if (oldStartIdx > oldEndIdx) {\r\n if (newStartIdx <= newEndIdx) {\r\n const anchor = newChildren[newEndIdx + 1] == null ? null : newChildren[newEndIdx + 1].dom;\r\n for (let i = newStartIdx; i <= newEndIdx; i++) {\r\n mount(newChildren[i], parent, anchor);\r\n }\r\n }\r\n } else if (newStartIdx > newEndIdx) {\r\n for (let i = oldStartIdx; i <= oldEndIdx; i++) {\r\n if (oldChildren[i]) {\r\n unmount(oldChildren[i], parent);\r\n }\r\n }\r\n }\r\n }\r\n\r\n function isSameVNode(n1: VNode, n2: VNode): boolean {\r\n const k1 = n1.key == null ? null : n1.key;\r\n const k2 = n2.key == null ? null : n2.key;\r\n if (n1.type !== n2.type) return false;\r\n if (k1 === k2) return true;\r\n\r\n return String(k1) === String(k2);\r\n }\r\n\r\n function createKeyToKeyIndexMap(children: VNode[], beginIdx: number, endIdx: number) {\r\n const map = new Map<string | number, number>();\r\n for (let i = beginIdx; i <= endIdx; i++) {\r\n const key = children[i]?.key;\r\n if (key != null) map.set(String(key), i);\r\n }\r\n return map;\r\n }\r\n\r\n function findIndexInOld(children: VNode[], newChild: VNode, beginIdx: number, endIdx: number): number | null {\r\n for (let i = beginIdx; i <= endIdx; i++) {\r\n if (children[i] && isSameVNode(children[i], newChild)) return i;\r\n }\r\n return null;\r\n }\r\n\r\n function mountComponent(vnode: VNode, container: HostElement, before: HostNode | null, setup: SetupFn<any>) {\r\n // No wrapper element - we render directly into the container\r\n // Use an anchor comment to track the component's position\r\n const anchor = hostCreateComment('');\r\n vnode.dom = anchor; // The anchor serves as the component's \"DOM\" marker\r\n (anchor as any).__vnode = vnode;\r\n hostInsert(anchor, container, before);\r\n\r\n let exposed: any = null;\r\n let exposeCalled = false;\r\n\r\n const initialProps = vnode.props || {};\r\n // Create reactive props - exclude children and slots to avoid deep recursion on VNodes\r\n const { children, slots: slotsFromProps, ...propsData } = initialProps;\r\n const reactiveProps = signal(propsData);\r\n (vnode as any)._componentProps = reactiveProps;\r\n\r\n // Create slots object from children and the slots prop\r\n const slots = createSlots(children, slotsFromProps);\r\n (vnode as any)._slots = slots;\r\n\r\n const mountHooks: ((ctx: MountContext) => void)[] = [];\r\n const cleanupHooks: ((ctx: MountContext) => void)[] = [];\r\n\r\n // Capture the parent component context BEFORE creating the new one\r\n // This is crucial for Provide/Inject to work\r\n const parentInstance = getCurrentInstance();\r\n\r\n // Get component name from the factory (if set via options)\r\n const componentName = (vnode.type as any).__name;\r\n\r\n const ctx: ComponentSetupContext = {\r\n el: container, // The parent container (since we don't have a wrapper)\r\n signal: signal,\r\n props: reactiveProps,\r\n slots: slots,\r\n emit: (event: string, ...args: any[]) => {\r\n const eventName = `on${event[0].toUpperCase() + event.slice(1)}`;\r\n const handler = reactiveProps[eventName];\r\n if (handler && typeof handler === 'function') {\r\n handler(...args);\r\n }\r\n },\r\n parent: parentInstance, // Link to parent for DI traversal\r\n onMount: (fn) => { mountHooks.push(fn); },\r\n onCleanup: (fn) => { cleanupHooks.push(fn); },\r\n expose: (exposedValue) => {\r\n exposed = exposedValue;\r\n exposeCalled = true;\r\n }\r\n };\r\n\r\n // Store the component name on the context for debugging\r\n (ctx as any).__name = componentName;\r\n\r\n // Store app context on the component context for DI to find\r\n if (currentAppContext) {\r\n (ctx as any)._appContext = currentAppContext;\r\n }\r\n\r\n // Create component instance info for lifecycle hooks\r\n const componentInstance: ComponentInstance = {\r\n name: componentName,\r\n ctx,\r\n vnode\r\n };\r\n\r\n const prev = setCurrentInstance(ctx);\r\n let renderFn: ViewFn | undefined;\r\n try {\r\n renderFn = setup(ctx);\r\n // Notify plugins that component was created (setup completed)\r\n notifyComponentCreated(currentAppContext, componentInstance);\r\n } catch (err) {\r\n // Handle setup errors\r\n const handled = handleComponentError(currentAppContext, err as Error, componentInstance, 'setup');\r\n if (!handled) {\r\n throw err;\r\n }\r\n } finally {\r\n setCurrentInstance(prev);\r\n }\r\n\r\n // Handle ref\r\n if (vnode.props.ref) {\r\n const refValue = exposeCalled ? exposed : null;\r\n if (typeof vnode.props.ref === 'function') {\r\n vnode.props.ref(refValue);\r\n } else if (vnode.props.ref && typeof vnode.props.ref === 'object') {\r\n vnode.props.ref.current = refValue;\r\n }\r\n }\r\n\r\n if (renderFn) {\r\n let isFirstRender = true;\r\n const componentEffect = effect(() => {\r\n // Set current instance during render so child components can find their parent\r\n const prevInstance = setCurrentInstance(ctx);\r\n try {\r\n const subTreeResult = renderFn!();\r\n if (subTreeResult == null) return;\r\n\r\n // Handle arrays (fragments) or single vnodes\r\n const subTree = normalizeSubTree(subTreeResult);\r\n const prevSubTree = (vnode as any)._subTree;\r\n\r\n if (prevSubTree) {\r\n patch(prevSubTree, subTree, container);\r\n // Notify plugins of component update (re-render)\r\n notifyComponentUpdated(currentAppContext, componentInstance);\r\n } else {\r\n mount(subTree, container, anchor);\r\n }\r\n (vnode as any)._subTree = subTree;\r\n isFirstRender = false;\r\n } catch (err) {\r\n // Handle render errors\r\n const handled = handleComponentError(currentAppContext, err as Error, componentInstance, 'render');\r\n if (!handled) {\r\n throw err;\r\n }\r\n } finally {\r\n setCurrentInstance(prevInstance);\r\n }\r\n });\r\n (vnode as any)._effect = componentEffect;\r\n }\r\n\r\n // Run mount hooks\r\n const mountCtx = { el: container };\r\n mountHooks.forEach(hook => hook(mountCtx));\r\n\r\n // Notify plugins that component was mounted\r\n notifyComponentMounted(currentAppContext, componentInstance);\r\n\r\n // Store cleanup hooks on vnode for unmount\r\n (vnode as any).cleanup = () => {\r\n // Notify plugins that component is being unmounted\r\n notifyComponentUnmounted(currentAppContext, componentInstance);\r\n cleanupHooks.forEach(hook => hook(mountCtx));\r\n };\r\n }\r\n\r\n /**\r\n * Create slots object from children and slots prop.\r\n * Uses a version signal to trigger re-renders when children change.\r\n * Supports named slots via:\r\n * - `slots` prop object (e.g., slots={{ header: () => <div>...</div> }})\r\n * - `slot` prop on children (e.g., <div slot=\"header\">...</div>)\r\n */\r\n function createSlots(children: any, slotsFromProps?: Record<string, any>): SlotsObject<any> & { _children: any; _version: { v: number }; _slotsFromProps: Record<string, any> } {\r\n // Use a simple version signal - bump version to trigger reactivity\r\n const versionSignal = signal({ v: 0 });\r\n\r\n // Extract named slots from children with slot prop\r\n function extractNamedSlotsFromChildren(c: any): { defaultChildren: any[]; namedSlots: Record<string, any[]> } {\r\n const defaultChildren: any[] = [];\r\n const namedSlots: Record<string, any[]> = {};\r\n\r\n if (c == null) return { defaultChildren, namedSlots };\r\n\r\n const items = Array.isArray(c) ? c : [c];\r\n\r\n for (const child of items) {\r\n if (child && typeof child === 'object' && child.props && child.props.slot) {\r\n const slotName = child.props.slot;\r\n if (!namedSlots[slotName]) {\r\n namedSlots[slotName] = [];\r\n }\r\n namedSlots[slotName].push(child);\r\n } else {\r\n defaultChildren.push(child);\r\n }\r\n }\r\n\r\n return { defaultChildren, namedSlots };\r\n }\r\n\r\n const slotsObj = {\r\n _children: children,\r\n _slotsFromProps: slotsFromProps || {},\r\n _version: versionSignal,\r\n default: function () {\r\n // Reading version creates a reactive dependency\r\n const _ = this._version.v;\r\n const c = this._children;\r\n const { defaultChildren } = extractNamedSlotsFromChildren(c);\r\n return defaultChildren;\r\n }\r\n };\r\n\r\n // Create a proxy to handle named slot access dynamically\r\n return new Proxy(slotsObj, {\r\n get(target, prop) {\r\n if (prop in target) {\r\n return (target as any)[prop];\r\n }\r\n\r\n // Handle named slot access\r\n if (typeof prop === 'string') {\r\n return function (scopedProps?: any) {\r\n // Reading version creates a reactive dependency\r\n const _ = target._version.v;\r\n\r\n // First check for slots from the `slots` prop\r\n if (target._slotsFromProps && typeof target._slotsFromProps[prop] === 'function') {\r\n const result = target._slotsFromProps[prop](scopedProps);\r\n if (result == null) return [];\r\n return Array.isArray(result) ? result : [result];\r\n }\r\n\r\n // Then check for element-based slots (children with slot prop)\r\n const { namedSlots } = extractNamedSlotsFromChildren(target._children);\r\n return namedSlots[prop] || [];\r\n };\r\n }\r\n\r\n return undefined;\r\n }\r\n }) as SlotsObject<any> & { _children: any; _version: { v: number }; _slotsFromProps: Record<string, any> };\r\n }\r\n\r\n /**\r\n * Normalize render result to a VNode (wrapping arrays in Fragment)\r\n */\r\n function normalizeSubTree(result: JSXElement | JSXElement[]): VNode {\r\n if (Array.isArray(result)) {\r\n return {\r\n type: Fragment,\r\n props: {},\r\n key: null,\r\n children: result as VNode[],\r\n dom: null\r\n };\r\n }\r\n if (typeof result === 'string' || typeof result === 'number') {\r\n return {\r\n type: Text,\r\n props: {},\r\n key: null,\r\n children: [],\r\n dom: null,\r\n text: result\r\n };\r\n }\r\n return result as VNode;\r\n }\r\n\r\n return {\r\n render,\r\n createApp: (rootComponent: any) => {\r\n // Simple createApp implementation\r\n return {\r\n mount(selectorOrContainer: string | HostElement) {\r\n let container: HostElement | null = null;\r\n if (typeof selectorOrContainer === 'string') {\r\n if (options.querySelector) {\r\n container = options.querySelector(selectorOrContainer);\r\n }\r\n } else {\r\n container = selectorOrContainer;\r\n }\r\n\r\n if (!container) {\r\n console.warn(`Container not found: ${selectorOrContainer}`);\r\n return;\r\n }\r\n\r\n render(rootComponent, container);\r\n }\r\n };\r\n }\r\n };\r\n}\r\n","import { signal } from '@sigx/reactivity';\r\n\r\nconst focusableIds = new Set<string>();\r\nexport const focusState = signal({ activeId: null as string | null });\r\n\r\nexport function registerFocusable(id: string) {\r\n focusableIds.add(id);\r\n if (focusState.activeId === null) {\r\n focusState.activeId = id;\r\n }\r\n}\r\n\r\nexport function unregisterFocusable(id: string) {\r\n focusableIds.delete(id);\r\n if (focusState.activeId === id) {\r\n focusState.activeId = null;\r\n // Try to focus another one\r\n if (focusableIds.size > 0) {\r\n focusState.activeId = focusableIds.values().next().value || null;\r\n }\r\n }\r\n}\r\n\r\nexport function focus(id: string) {\r\n if (focusableIds.has(id)) {\r\n focusState.activeId = id;\r\n }\r\n}\r\n\r\nexport function focusNext() {\r\n if (focusableIds.size === 0) return;\r\n const ids = Array.from(focusableIds);\r\n const currentIndex = focusState.activeId ? ids.indexOf(focusState.activeId) : -1;\r\n const nextIndex = (currentIndex + 1) % ids.length;\r\n focusState.activeId = ids[nextIndex];\r\n}\r\n\r\nexport function focusPrev() {\r\n if (focusableIds.size === 0) return;\r\n const ids = Array.from(focusableIds);\r\n const currentIndex = focusState.activeId ? ids.indexOf(focusState.activeId) : -1;\r\n const prevIndex = (currentIndex - 1 + ids.length) % ids.length;\r\n focusState.activeId = ids[prevIndex];\r\n}\r\n","\r\nexport function getColorCode(color: string): string {\r\n switch (color) {\r\n case 'red': return '\\x1b[31m';\r\n case 'green': return '\\x1b[32m';\r\n case 'blue': return '\\x1b[34m';\r\n case 'yellow': return '\\x1b[33m';\r\n case 'cyan': return '\\x1b[36m';\r\n case 'white': return '\\x1b[37m';\r\n case 'black': return '\\x1b[30m';\r\n default: return '';\r\n }\r\n}\r\n\r\nexport function getBackgroundColorCode(color: string): string {\r\n switch (color) {\r\n case 'red': return '\\x1b[41m';\r\n case 'green': return '\\x1b[42m';\r\n case 'blue': return '\\x1b[44m';\r\n case 'yellow': return '\\x1b[43m';\r\n case 'cyan': return '\\x1b[46m';\r\n case 'white': return '\\x1b[47m';\r\n case 'black': return '\\x1b[40m';\r\n default: return '';\r\n }\r\n}\r\n\r\nexport function stripAnsi(str: string): string {\r\n return str.replace(/\\x1B\\[[0-9;]*[a-zA-Z]/g, '');\r\n}\r\n","import { detectAccess, effect, effectScope, signal, signal as signal$1, untrack, watch } from \"@sigx/reactivity\";\n\n//#region src/platform.ts\nlet platformSyncProcessor = null;\n/**\n* Set the platform-specific sync processor for intrinsic elements.\n* Called by runtime-dom to handle checkbox/radio/select sync bindings.\n*/\nfunction setPlatformSyncProcessor(fn) {\n\tplatformSyncProcessor = fn;\n}\n/**\n* Get the current platform sync processor (for internal use).\n*/\nfunction getPlatformSyncProcessor() {\n\treturn platformSyncProcessor;\n}\n\n//#endregion\n//#region src/plugins.ts\nconst plugins = [];\nfunction registerComponentPlugin(plugin) {\n\tplugins.push(plugin);\n}\n/**\n* Get all registered plugins (internal use)\n*/\nfunction getComponentPlugins() {\n\treturn plugins;\n}\n\n//#endregion\n//#region src/app.ts\nconst isDev = typeof process !== \"undefined\" && true || true;\n/**\n* Unique symbol for app context injection\n*/\nconst AppContextKey = Symbol(\"sigx:app\");\nlet defaultMountFn = null;\n/**\n* Set the default mount function for the platform.\n* Called by platform packages (runtime-dom, runtime-terminal) on import.\n* \n* @example\n* ```typescript\n* // In @sigx/runtime-dom\n* import { setDefaultMount } from '@sigx/runtime-core';\n* setDefaultMount(domMount);\n* ```\n*/\nfunction setDefaultMount(mountFn) {\n\tdefaultMountFn = mountFn;\n}\n/**\n* Get the current default mount function.\n* @internal\n*/\nfunction getDefaultMount() {\n\treturn defaultMountFn;\n}\n/**\n* Create an application instance.\n* \n* @example\n* ```tsx\n* import { defineApp, defineInjectable } from '@sigx/runtime-core';\n* import { render } from '@sigx/runtime-dom';\n* \n* // Define an injectable service\n* const useApiConfig = defineInjectable(() => ({ baseUrl: 'https://api.example.com' }));\n* \n* const app = defineApp(<App />);\n* \n* app.use(myPlugin, { option: 'value' });\n* \n* // Provide using the injectable token (works with inject())\n* app.provide(useApiConfig, { baseUrl: 'https://custom.api.com' });\n* \n* app.mount(document.getElementById('app')!, render);\n* ```\n*/\nfunction defineApp(rootComponent) {\n\tconst installedPlugins = /* @__PURE__ */ new Set();\n\tconst context = {\n\t\tapp: null,\n\t\tprovides: /* @__PURE__ */ new Map(),\n\t\tconfig: {},\n\t\thooks: []\n\t};\n\tlet isMounted = false;\n\tlet container = null;\n\tlet unmountFn = null;\n\tconst app = {\n\t\tconfig: context.config,\n\t\tuse(plugin, options) {\n\t\t\tif (installedPlugins.has(plugin)) {\n\t\t\t\tif (isDev) console.warn(`Plugin ${plugin.name || \"anonymous\"} is already installed.`);\n\t\t\t\treturn app;\n\t\t\t}\n\t\t\tinstalledPlugins.add(plugin);\n\t\t\tif (typeof plugin === \"function\") plugin(app, options);\n\t\t\telse if (plugin && typeof plugin.install === \"function\") plugin.install(app, options);\n\t\t\telse if (isDev) console.warn(\"Invalid plugin: must be a function or have an install() method.\");\n\t\t\treturn app;\n\t\t},\n\t\tprovide(token, value) {\n\t\t\tconst actualToken = token?._token ?? token;\n\t\t\tif (isDev && context.provides.has(actualToken)) console.warn(`App-level provide: token is being overwritten.`);\n\t\t\tcontext.provides.set(actualToken, value);\n\t\t\treturn app;\n\t\t},\n\t\thook(hooks) {\n\t\t\tcontext.hooks.push(hooks);\n\t\t\treturn app;\n\t\t},\n\t\tmount(target, renderFn) {\n\t\t\tif (isMounted) {\n\t\t\t\tif (isDev) console.warn(\"App is already mounted. Call app.unmount() first.\");\n\t\t\t\treturn app;\n\t\t\t}\n\t\t\tconst mountFn = renderFn ?? defaultMountFn;\n\t\t\tif (!mountFn) throw new Error(\"No mount function provided and no default mount function set. Either pass a mount function to app.mount(), or import a platform package (e.g., @sigx/runtime-dom or @sigx/runtime-terminal) that sets the default.\");\n\t\t\tcontainer = target;\n\t\t\tisMounted = true;\n\t\t\tconst result = mountFn(rootComponent, target, context);\n\t\t\tif (typeof result === \"function\") unmountFn = result;\n\t\t\treturn app;\n\t\t},\n\t\tunmount() {\n\t\t\tif (!isMounted) {\n\t\t\t\tif (isDev) console.warn(\"App is not mounted.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (unmountFn) unmountFn();\n\t\t\tcontext.provides.clear();\n\t\t\tisMounted = false;\n\t\t\tcontainer = null;\n\t\t},\n\t\tget _context() {\n\t\t\treturn context;\n\t\t},\n\t\tget _isMounted() {\n\t\t\treturn isMounted;\n\t\t},\n\t\tget _container() {\n\t\t\treturn container;\n\t\t}\n\t};\n\tcontext.app = app;\n\treturn app;\n}\n/**\n* Notify all app hooks that a component was created.\n* Called by the renderer after setup() returns.\n*/\nfunction notifyComponentCreated(context, instance) {\n\tif (!context) return;\n\tfor (const hooks of context.hooks) try {\n\t\thooks.onComponentCreated?.(instance);\n\t} catch (err) {\n\t\thandleHookError(context, err, instance, \"onComponentCreated\");\n\t}\n}\n/**\n* Notify all app hooks that a component was mounted.\n* Called by the renderer after mount hooks run.\n*/\nfunction notifyComponentMounted(context, instance) {\n\tif (!context) return;\n\tfor (const hooks of context.hooks) try {\n\t\thooks.onComponentMounted?.(instance);\n\t} catch (err) {\n\t\thandleHookError(context, err, instance, \"onComponentMounted\");\n\t}\n}\n/**\n* Notify all app hooks that a component was unmounted.\n* Called by the renderer before cleanup.\n*/\nfunction notifyComponentUnmounted(context, instance) {\n\tif (!context) return;\n\tfor (const hooks of context.hooks) try {\n\t\thooks.onComponentUnmounted?.(instance);\n\t} catch (err) {\n\t\thandleHookError(context, err, instance, \"onComponentUnmounted\");\n\t}\n}\n/**\n* Notify all app hooks that a component updated.\n* Called by the renderer after re-render.\n*/\nfunction notifyComponentUpdated(context, instance) {\n\tif (!context) return;\n\tfor (const hooks of context.hooks) try {\n\t\thooks.onComponentUpdated?.(instance);\n\t} catch (err) {\n\t\thandleHookError(context, err, instance, \"onComponentUpdated\");\n\t}\n}\n/**\n* Handle an error in a component. Returns true if the error was handled.\n* Called by the renderer when an error occurs in setup or render.\n*/\nfunction handleComponentError(context, err, instance, info) {\n\tif (!context) return false;\n\tfor (const hooks of context.hooks) try {\n\t\tif (hooks.onComponentError?.(err, instance, info) === true) return true;\n\t} catch (hookErr) {\n\t\tconsole.error(\"Error in onComponentError hook:\", hookErr);\n\t}\n\tif (context.config.errorHandler) try {\n\t\tif (context.config.errorHandler(err, instance, info) === true) return true;\n\t} catch (handlerErr) {\n\t\tconsole.error(\"Error in app.config.errorHandler:\", handlerErr);\n\t}\n\treturn false;\n}\n/**\n* Handle errors that occur in hooks themselves\n*/\nfunction handleHookError(context, err, instance, hookName) {\n\tconsole.error(`Error in ${hookName} hook:`, err);\n\tif (context.config.errorHandler) try {\n\t\tcontext.config.errorHandler(err, instance, `plugin hook: ${hookName}`);\n\t} catch {}\n}\n\n//#endregion\n//#region src/component.ts\nlet currentComponentContext = null;\nfunction getCurrentInstance() {\n\treturn currentComponentContext;\n}\nfunction setCurrentInstance(ctx) {\n\tconst prev = currentComponentContext;\n\tcurrentComponentContext = ctx;\n\treturn prev;\n}\nfunction onMount(fn) {\n\tif (currentComponentContext) currentComponentContext.onMount(fn);\n\telse console.warn(\"onMount called outside of component setup\");\n}\nfunction onCleanup(fn) {\n\tif (currentComponentContext) currentComponentContext.onCleanup(fn);\n\telse console.warn(\"onCleanup called outside of component setup\");\n}\nconst componentRegistry = /* @__PURE__ */ new Map();\n/**\n* Get component metadata (for DevTools)\n*/\nfunction getComponentMeta(factory) {\n\treturn componentRegistry.get(factory);\n}\n/**\n* Helper to create a proxy that tracks property access\n*/\nfunction createPropsProxy(target, onAccess) {\n\treturn new Proxy(target, { get(obj, prop) {\n\t\tif (typeof prop === \"string\" && onAccess) onAccess(prop);\n\t\treturn obj[prop];\n\t} });\n}\n/**\n* Define a component. Returns a JSX factory function.\n* \n* @param setup - Setup function that receives context and returns a render function\n* @param options - Optional configuration (e.g., name for DevTools)\n* \n* @example\n* ```tsx\n* type CardProps = DefineProp<\"title\", string> & DefineSlot<\"header\">;\n* \n* export const Card = defineComponent<CardProps>((ctx) => {\n* const { title } = ctx.props;\n* const { slots } = ctx;\n* \n* return () => (\n* <div class=\"card\">\n* {slots.header?.() ?? <h2>{title}</h2>}\n* {slots.default()}\n* </div>\n* );\n* });\n* ```\n*/\nfunction defineComponent(setup, options) {\n\tconst factory = function(props) {\n\t\treturn {\n\t\t\ttype: factory,\n\t\t\tprops: props || {},\n\t\t\tkey: props?.key || null,\n\t\t\tchildren: [],\n\t\t\tdom: null\n\t\t};\n\t};\n\tfactory.__setup = setup;\n\tfactory.__name = options?.name;\n\tfactory.__props = null;\n\tfactory.__events = null;\n\tfactory.__ref = null;\n\tfactory.__slots = null;\n\tcomponentRegistry.set(factory, {\n\t\tname: options?.name,\n\t\tsetup\n\t});\n\tgetComponentPlugins().forEach((p) => p.onDefine?.(options?.name, factory, setup));\n\treturn factory;\n}\n\n//#endregion\n//#region src/jsx-runtime.ts\nconst Fragment = Symbol.for(\"sigx.Fragment\");\nconst Text = Symbol.for(\"sigx.Text\");\nfunction normalizeChildren(children) {\n\tif (children == null || children === false || children === true) return [];\n\tif (Array.isArray(children)) return children.flatMap((c) => normalizeChildren(c));\n\tif (typeof children === \"string\" || typeof children === \"number\") return [{\n\t\ttype: Text,\n\t\tprops: {},\n\t\tkey: null,\n\t\tchildren: [],\n\t\tdom: null,\n\t\ttext: children\n\t}];\n\tif (children.type) return [children];\n\treturn [];\n}\n/**\n* Check if a type is a sigx component (has __setup)\n*/\nfunction isComponent$1(type) {\n\treturn typeof type === \"function\" && \"__setup\" in type;\n}\n/**\n* Create a JSX element - this is the core function called by TSX transpilation\n*/\nfunction jsx(type, props, key) {\n\tconst processedProps = { ...props || {} };\n\tif (props) {\n\t\tfor (const propKey in props) if (propKey === \"sync\") {\n\t\t\tlet syncBinding = props[propKey];\n\t\t\tif (typeof syncBinding === \"function\") {\n\t\t\t\tconst detected = detectAccess(syncBinding);\n\t\t\t\tif (detected) syncBinding = detected;\n\t\t\t}\n\t\t\tif (Array.isArray(syncBinding) && syncBinding.length === 2) {\n\t\t\t\tconst [stateObj, key$1] = syncBinding;\n\t\t\t\tlet handled = false;\n\t\t\t\tconst platformProcessor = getPlatformSyncProcessor();\n\t\t\t\tif (typeof type === \"string\" && platformProcessor) handled = platformProcessor(type, processedProps, [stateObj, key$1], props);\n\t\t\t\tif (!handled) {\n\t\t\t\t\tprocessedProps.value = stateObj[key$1];\n\t\t\t\t\tconst existingHandler = processedProps[\"onUpdate:value\"];\n\t\t\t\t\tprocessedProps[\"onUpdate:value\"] = (v) => {\n\t\t\t\t\t\tstateObj[key$1] = v;\n\t\t\t\t\t\tif (existingHandler) existingHandler(v);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdelete processedProps.sync;\n\t\t\t}\n\t\t} else if (propKey.startsWith(\"sync:\")) {\n\t\t\tconst syncBinding = props[propKey];\n\t\t\tif (Array.isArray(syncBinding) && syncBinding.length === 2) {\n\t\t\t\tconst [stateObj, key$1] = syncBinding;\n\t\t\t\tconst name = propKey.slice(5);\n\t\t\t\tprocessedProps[name] = stateObj[key$1];\n\t\t\t\tconst eventName = `onUpdate:${name}`;\n\t\t\t\tconst existingHandler = processedProps[eventName];\n\t\t\t\tprocessedProps[eventName] = (v) => {\n\t\t\t\t\tstateObj[key$1] = v;\n\t\t\t\t\tif (existingHandler) existingHandler(v);\n\t\t\t\t};\n\t\t\t\tdelete processedProps[propKey];\n\t\t\t}\n\t\t}\n\t}\n\tif (isComponent$1(type)) {\n\t\tconst { children: children$1, ...rest$1 } = processedProps;\n\t\treturn {\n\t\t\ttype,\n\t\t\tprops: {\n\t\t\t\t...rest$1,\n\t\t\t\tchildren: children$1\n\t\t\t},\n\t\t\tkey: key || rest$1.key || null,\n\t\t\tchildren: [],\n\t\t\tdom: null\n\t\t};\n\t}\n\tif (typeof type === \"function\" && type !== Fragment) return type(processedProps);\n\tconst { children, ...rest } = processedProps;\n\treturn {\n\t\ttype,\n\t\tprops: rest,\n\t\tkey: key || rest.key || null,\n\t\tchildren: normalizeChildren(children),\n\t\tdom: null\n\t};\n}\n/**\n* JSX Factory for fragments\n*/\nfunction jsxs(type, props, key) {\n\treturn jsx(type, props, key);\n}\nconst jsxDEV = jsx;\n\n//#endregion\n//#region src/utils/index.ts\nvar Utils = class {\n\tstatic isPromise(value) {\n\t\treturn !!value && (typeof value === \"object\" || typeof value === \"function\") && typeof value.then === \"function\";\n\t}\n};\nfunction guid$1() {\n\treturn \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, function(c) {\n\t\tvar r = Math.random() * 16 | 0;\n\t\treturn (c == \"x\" ? r : r & 3 | 8).toString(16);\n\t});\n}\n\n//#endregion\n//#region src/models/index.ts\nconst guid = guid$1;\nlet InstanceLifetimes = /* @__PURE__ */ function(InstanceLifetimes$1) {\n\tInstanceLifetimes$1[InstanceLifetimes$1[\"Transient\"] = 0] = \"Transient\";\n\tInstanceLifetimes$1[InstanceLifetimes$1[\"Scoped\"] = 1] = \"Scoped\";\n\tInstanceLifetimes$1[InstanceLifetimes$1[\"Singleton\"] = 2] = \"Singleton\";\n\treturn InstanceLifetimes$1;\n}({});\nfunction valueOf(obj) {\n\treturn obj;\n}\n\n//#endregion\n//#region src/messaging/index.ts\nfunction createTopic(options) {\n\tlet subscribers = [];\n\tconst publish = (data) => {\n\t\tsubscribers.forEach((s) => s(data));\n\t};\n\tconst subscribe = (handler) => {\n\t\tsubscribers.push(handler);\n\t\tconst unsubscribe = () => {\n\t\t\tconst idx = subscribers.indexOf(handler);\n\t\t\tif (idx > -1) subscribers.splice(idx, 1);\n\t\t};\n\t\ttry {\n\t\t\tonCleanup(unsubscribe);\n\t\t} catch (e) {}\n\t\treturn { unsubscribe };\n\t};\n\tconst destroy = () => {\n\t\tsubscribers = [];\n\t};\n\treturn {\n\t\tpublish,\n\t\tsubscribe,\n\t\tdestroy\n\t};\n}\nfunction toSubscriber(topic) {\n\treturn { subscribe: (handler) => topic.subscribe(handler) };\n}\n\n//#endregion\n//#region src/di/injectable.ts\nfunction inject(token) {\n\tconst ctx = getCurrentInstance();\n\tif (!ctx) return void 0;\n\tlet current = ctx;\n\twhile (current) {\n\t\tif (current.provides && current.provides.has(token)) return current.provides.get(token);\n\t\tcurrent = current.parent;\n\t}\n\tconst appContext = getAppContext(ctx);\n\tif (appContext && appContext.provides.has(token)) return appContext.provides.get(token);\n}\n/**\n* Get the app context from the current component context\n*/\nfunction getAppContext(ctx) {\n\tlet current = ctx;\n\twhile (current) {\n\t\tif (current._appContext) return current._appContext;\n\t\tcurrent = current.parent;\n\t}\n\treturn null;\n}\n/**\n* Inject the App instance (useful for plugins)\n*/\nfunction injectApp() {\n\treturn inject(AppContextKey);\n}\nfunction provide(token, value) {\n\tconst ctx = getCurrentInstance();\n\tif (!ctx) {\n\t\tconsole.warn(\"provide called outside of component setup\");\n\t\treturn;\n\t}\n\tif (!ctx.provides) ctx.provides = /* @__PURE__ */ new Map();\n\tctx.provides.set(token, value);\n}\nconst globalInstances = /* @__PURE__ */ new Map();\nfunction defineInjectable(factory) {\n\tconst token = factory;\n\tconst useFn = () => {\n\t\tconst injected = inject(token);\n\t\tif (injected) return injected;\n\t\tif (!globalInstances.has(token)) globalInstances.set(token, factory());\n\t\treturn globalInstances.get(token);\n\t};\n\tuseFn._factory = factory;\n\tuseFn._token = token;\n\treturn useFn;\n}\nfunction defineProvide(useFn) {\n\tconst factory = useFn._factory;\n\tconst token = useFn._token;\n\tif (!factory || !token) throw new Error(\"defineProvide must be called with a function created by defineInjectable\");\n\tconst instance = factory();\n\tprovide(token, instance);\n\treturn instance;\n}\n\n//#endregion\n//#region src/di/factory.ts\nvar SubscriptionHandler = class {\n\tunsubs = [];\n\tadd(unsub) {\n\t\tthis.unsubs.push(unsub);\n\t}\n\tunsubscribe() {\n\t\tthis.unsubs.forEach((u) => u());\n\t\tthis.unsubs = [];\n\t}\n};\nfunction defineFactory(setup, lifetime, typeIdentifier) {\n\tconst factoryCreator = (...args) => {\n\t\tconst subscriptions = new SubscriptionHandler();\n\t\tconst deactivations = /* @__PURE__ */ new Set();\n\t\tlet customDispose = null;\n\t\tconst result = setup({\n\t\t\tonDeactivated: (fn) => deactivations.add(fn),\n\t\t\tsubscriptions,\n\t\t\toverrideDispose: (fn) => customDispose = fn\n\t\t}, ...args);\n\t\tconst dispose = () => {\n\t\t\tdeactivations.forEach((d) => d());\n\t\t\tsubscriptions.unsubscribe();\n\t\t\tresult.dispose?.();\n\t\t};\n\t\tif (customDispose) customDispose(dispose);\n\t\telse try {\n\t\t\tonCleanup(() => dispose());\n\t\t} catch (e) {}\n\t\treturn {\n\t\t\t...result,\n\t\t\tdispose\n\t\t};\n\t};\n\tif (setup.length <= 1) return defineInjectable(() => factoryCreator());\n\treturn factoryCreator;\n}\n\n//#endregion\n//#region src/stores/store.ts\nfunction defineStore(name, setup, lifetime = InstanceLifetimes.Scoped) {\n\treturn defineFactory((ctxFactory, ...args) => {\n\t\tconst scope = effectScope(true);\n\t\tlet messages = [];\n\t\tconst id = `${name}_${guid()}`;\n\t\tconst result = setup({\n\t\t\t...ctxFactory,\n\t\t\tdefineState: (state) => {\n\t\t\t\treturn defineState(state, id, scope, messages);\n\t\t\t},\n\t\t\tdefineActions: (actions) => {\n\t\t\t\treturn defineActions(actions, id, messages);\n\t\t\t}\n\t\t}, ...args);\n\t\tctxFactory.onDeactivated(() => {\n\t\t\tscope.stop();\n\t\t\tmessages?.forEach((m) => m.destroy());\n\t\t\tmessages = null;\n\t\t});\n\t\tif (!result.name) result.name = id;\n\t\treturn result;\n\t}, lifetime);\n}\nfunction defineActions(actions, storeInstanceName, messages) {\n\tconst events = {};\n\tconst namespace = `${storeInstanceName}.actions.${guid()}`;\n\tconst onDispatching = {};\n\tconst onDispatched = {};\n\tconst onFailure = {};\n\tconst result = {\n\t\tonDispatching,\n\t\tonDispatched,\n\t\tonFailure\n\t};\n\tfunction getEvent(actionName, type) {\n\t\tconst name = `${actionName}.${type}`;\n\t\tif (!events[name]) {\n\t\t\tevents[name] = createTopic({\n\t\t\t\tnamespace,\n\t\t\t\tname\n\t\t\t});\n\t\t\tmessages.push(events[name]);\n\t\t}\n\t\treturn events[name];\n\t}\n\tObject.keys(actions).forEach((actionName) => {\n\t\tonDispatching[actionName] = { subscribe: (fn) => {\n\t\t\treturn getEvent(actionName, \"onDispatching\").subscribe(function() {\n\t\t\t\tfn.apply(this, arguments[0]);\n\t\t\t});\n\t\t} };\n\t\tonDispatched[actionName] = { subscribe: (fn) => {\n\t\t\treturn getEvent(actionName, \"onDispatched\").subscribe(function() {\n\t\t\t\tconst msg = arguments[0];\n\t\t\t\tconst allArguments = [msg.result].concat(Array.from(msg.args));\n\t\t\t\tfn.apply(this, allArguments);\n\t\t\t});\n\t\t} };\n\t\tonFailure[actionName] = { subscribe: (fn) => {\n\t\t\treturn getEvent(actionName, \"onFailure\").subscribe(function() {\n\t\t\t\tconst msg = arguments[0];\n\t\t\t\tconst allArguments = [msg.reason].concat(Array.from(msg.args));\n\t\t\t\tfn.apply(this, allArguments);\n\t\t\t});\n\t\t} };\n\t\tresult[actionName] = function() {\n\t\t\ttry {\n\t\t\t\tconst currentArguments = arguments;\n\t\t\t\tgetEvent(actionName, \"onDispatching\").publish(currentArguments);\n\t\t\t\tconst returnedResult = actions[actionName].apply(this, currentArguments);\n\t\t\t\tif (Utils.isPromise(returnedResult)) returnedResult.then((result$1) => {\n\t\t\t\t\tgetEvent(actionName, \"onDispatched\").publish({\n\t\t\t\t\t\tresult: returnedResult,\n\t\t\t\t\t\targs: currentArguments\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\telse getEvent(actionName, \"onDispatched\").publish({\n\t\t\t\t\tresult: returnedResult,\n\t\t\t\t\targs: currentArguments\n\t\t\t\t});\n\t\t\t\treturn returnedResult;\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(err);\n\t\t\t\tgetEvent(actionName, \"onFailure\").publish({\n\t\t\t\t\treason: err,\n\t\t\t\t\targs: arguments\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t});\n\treturn result;\n}\nfunction defineState(value, storeInstanceName, scope, messages) {\n\tconst state = signal$1(value);\n\tconst events = {};\n\tconst mutate = {};\n\tfunction initProperty(key) {\n\t\tscope.run(() => {\n\t\t\twatch(() => state[key], (newValue) => {\n\t\t\t\ttriggerEvent(key, newValue);\n\t\t\t}, {\n\t\t\t\tdeep: true,\n\t\t\t\timmediate: true\n\t\t\t});\n\t\t});\n\t\tmutate[key] = (val) => {\n\t\t\ttry {\n\t\t\t\tlet newValue;\n\t\t\t\tif (typeof val === \"function\") newValue = val(state[key]);\n\t\t\t\telse newValue = val;\n\t\t\t\tstate[key] = newValue;\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(err);\n\t\t\t}\n\t\t};\n\t\tconst eventKey = `onMutated${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n\t\tif (!events[eventKey]) {\n\t\t\tconst topic = createTopic({\n\t\t\t\tnamespace: `${storeInstanceName}.events`,\n\t\t\t\tname: eventKey\n\t\t\t});\n\t\t\tevents[eventKey] = topic;\n\t\t\tmessages.push(topic);\n\t\t}\n\t}\n\tfunction triggerEvent(name, value$1) {\n\t\tconst keyString = name;\n\t\tevents[`onMutated${keyString.charAt(0).toUpperCase()}${keyString.slice(1)}`]?.publish(value$1);\n\t}\n\tif (value) Object.keys(value).forEach((key) => {\n\t\tinitProperty(key);\n\t});\n\treturn {\n\t\tstate,\n\t\tevents,\n\t\tmutate\n\t};\n}\n\n//#endregion\n//#region src/renderer.ts\n/**\n* Check if a vnode type is a component (has __setup)\n*/\nfunction isComponent(type) {\n\treturn typeof type === \"function\" && \"__setup\" in type;\n}\nfunction createRenderer(options) {\n\tconst { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;\n\tlet isPatching = false;\n\tlet currentAppContext = null;\n\tfunction render(element, container, appContext) {\n\t\tif (appContext) currentAppContext = appContext;\n\t\tconst oldVNode = container._vnode;\n\t\tlet vnode = null;\n\t\tif (element != null && element !== false && element !== true) if (typeof element === \"string\" || typeof element === \"number\") vnode = {\n\t\t\ttype: Text,\n\t\t\tprops: {},\n\t\t\tkey: null,\n\t\t\tchildren: [],\n\t\t\tdom: null,\n\t\t\ttext: element\n\t\t};\n\t\telse vnode = element;\n\t\tif (vnode) {\n\t\t\tif (oldVNode) patch(oldVNode, vnode, container);\n\t\t\telse mount(vnode, container);\n\t\t\tcontainer._vnode = vnode;\n\t\t} else if (oldVNode) {\n\t\t\tunmount(oldVNode, container);\n\t\t\tcontainer._vnode = null;\n\t\t}\n\t}\n\tfunction mount(vnode, container, before = null) {\n\t\tif (vnode.type === Text) {\n\t\t\tconst node = hostCreateText(String(vnode.text));\n\t\t\tvnode.dom = node;\n\t\t\tnode.__vnode = vnode;\n\t\t\thostInsert(node, container, before);\n\t\t\treturn;\n\t\t}\n\t\tif (vnode.type === Fragment) {\n\t\t\tconst anchor = hostCreateComment(\"\");\n\t\t\tvnode.dom = anchor;\n\t\t\thostInsert(anchor, container, before);\n\t\t\tvnode.children.forEach((child) => mount(child, container, anchor));\n\t\t\treturn;\n\t\t}\n\t\tif (isComponent(vnode.type)) {\n\t\t\tmountComponent(vnode, container, before, vnode.type.__setup);\n\t\t\treturn;\n\t\t}\n\t\tconst element = hostCreateElement(vnode.type);\n\t\tvnode.dom = element;\n\t\telement.__vnode = vnode;\n\t\tif (vnode.props) {\n\t\t\tfor (const key in vnode.props) if (key !== \"children\" && key !== \"key\" && key !== \"ref\") hostPatchProp(element, key, null, vnode.props[key]);\n\t\t}\n\t\tif (vnode.props.ref) {\n\t\t\tif (typeof vnode.props.ref === \"function\") vnode.props.ref(element);\n\t\t\telse if (vnode.props.ref && typeof vnode.props.ref === \"object\") vnode.props.ref.current = element;\n\t\t}\n\t\tvnode.children.forEach((child) => {\n\t\t\tchild.parent = vnode;\n\t\t\tmount(child, element);\n\t\t});\n\t\thostInsert(element, container, before);\n\t}\n\tfunction unmount(vnode, container) {\n\t\tif (vnode._effect) vnode._effect();\n\t\tif (vnode.cleanup) vnode.cleanup();\n\t\tif (isComponent(vnode.type)) {\n\t\t\tconst subTree = vnode._subTree;\n\t\t\tif (subTree) unmount(subTree, container);\n\t\t\tif (vnode.dom) hostRemove(vnode.dom);\n\t\t\tif (vnode.props?.ref) {\n\t\t\t\tif (typeof vnode.props.ref === \"function\") vnode.props.ref(null);\n\t\t\t\telse if (typeof vnode.props.ref === \"object\") vnode.props.ref.current = null;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (vnode.type === Fragment) {\n\t\t\tvnode.children.forEach((child) => unmount(child, container));\n\t\t\tif (vnode.dom) hostRemove(vnode.dom);\n\t\t\treturn;\n\t\t}\n\t\tif (vnode.props?.ref) {\n\t\t\tif (typeof vnode.props.ref === \"function\") vnode.props.ref(null);\n\t\t\telse if (vnode.props.ref && typeof vnode.props.ref === \"object\") vnode.props.ref.current = null;\n\t\t}\n\t\tif (vnode.children && vnode.children.length > 0) vnode.children.forEach((child) => unmount(child, vnode.dom));\n\t\tif (vnode.dom) hostRemove(vnode.dom);\n\t}\n\tfunction patch(oldVNode, newVNode, container) {\n\t\tif (oldVNode === newVNode) return;\n\t\tif (!isSameVNode(oldVNode, newVNode)) {\n\t\t\tconst parent = hostParentNode(oldVNode.dom) || container;\n\t\t\tconst nextSibling = hostNextSibling(oldVNode.dom);\n\t\t\tunmount(oldVNode, parent);\n\t\t\tmount(newVNode, parent, nextSibling);\n\t\t\treturn;\n\t\t}\n\t\tif (oldVNode._effect) {\n\t\t\tnewVNode.dom = oldVNode.dom;\n\t\t\tnewVNode._effect = oldVNode._effect;\n\t\t\tnewVNode._subTree = oldVNode._subTree;\n\t\t\tnewVNode._slots = oldVNode._slots;\n\t\t\tconst props = oldVNode._componentProps;\n\t\t\tnewVNode._componentProps = props;\n\t\t\tif (props) {\n\t\t\t\tconst newProps$1 = newVNode.props || {};\n\t\t\t\tuntrack(() => {\n\t\t\t\t\tfor (const key in newProps$1) if (key !== \"children\" && key !== \"key\" && key !== \"ref\") {\n\t\t\t\t\t\tif (props[key] !== newProps$1[key]) props[key] = newProps$1[key];\n\t\t\t\t\t}\n\t\t\t\t\tfor (const key in props) if (!(key in newProps$1) && key !== \"children\" && key !== \"key\" && key !== \"ref\") delete props[key];\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst slotsRef = oldVNode._slots;\n\t\t\tconst newChildren = newVNode.props?.children;\n\t\t\tconst newSlotsFromProps = newVNode.props?.slots;\n\t\t\tif (slotsRef) {\n\t\t\t\tif (newChildren !== void 0) slotsRef._children = newChildren;\n\t\t\t\tif (newSlotsFromProps !== void 0) slotsRef._slotsFromProps = newSlotsFromProps;\n\t\t\t\tif (!isPatching) {\n\t\t\t\t\tisPatching = true;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tuntrack(() => {\n\t\t\t\t\t\t\tslotsRef._version.v++;\n\t\t\t\t\t\t});\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tisPatching = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (newVNode.type === Text) {\n\t\t\tnewVNode.dom = oldVNode.dom;\n\t\t\tif (oldVNode.text !== newVNode.text) hostSetText(newVNode.dom, String(newVNode.text));\n\t\t\treturn;\n\t\t}\n\t\tif (newVNode.type === Fragment) {\n\t\t\tpatchChildren(oldVNode, newVNode, container);\n\t\t\treturn;\n\t\t}\n\t\tconst element = newVNode.dom = oldVNode.dom;\n\t\tconst oldProps = oldVNode.props || {};\n\t\tconst newProps = newVNode.props || {};\n\t\tfor (const key in oldProps) if (!(key in newProps) && key !== \"children\" && key !== \"key\" && key !== \"ref\") hostPatchProp(element, key, oldProps[key], null);\n\t\tfor (const key in newProps) {\n\t\t\tconst oldValue = oldProps[key];\n\t\t\tconst newValue = newProps[key];\n\t\t\tif (key !== \"children\" && key !== \"key\" && key !== \"ref\" && oldValue !== newValue) hostPatchProp(element, key, oldValue, newValue);\n\t\t}\n\t\tpatchChildren(oldVNode, newVNode, element);\n\t}\n\tfunction patchChildren(oldVNode, newVNode, container) {\n\t\tconst oldChildren = oldVNode.children;\n\t\tconst newChildren = newVNode.children;\n\t\tnewChildren.forEach((c) => c.parent = newVNode);\n\t\treconcileChildrenArray(container, oldChildren, newChildren);\n\t}\n\tfunction reconcileChildrenArray(parent, oldChildren, newChildren) {\n\t\tlet oldStartIdx = 0;\n\t\tlet oldEndIdx = oldChildren.length - 1;\n\t\tlet oldStartVNode = oldChildren[0];\n\t\tlet oldEndVNode = oldChildren[oldEndIdx];\n\t\tlet newStartIdx = 0;\n\t\tlet newEndIdx = newChildren.length - 1;\n\t\tlet newStartVNode = newChildren[0];\n\t\tlet newEndVNode = newChildren[newEndIdx];\n\t\tlet oldKeyToIdx;\n\t\twhile (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) if (oldStartVNode == null) oldStartVNode = oldChildren[++oldStartIdx];\n\t\telse if (oldEndVNode == null) oldEndVNode = oldChildren[--oldEndIdx];\n\t\telse if (isSameVNode(oldStartVNode, newStartVNode)) {\n\t\t\tpatch(oldStartVNode, newStartVNode, parent);\n\t\t\toldStartVNode = oldChildren[++oldStartIdx];\n\t\t\tnewStartVNode = newChildren[++newStartIdx];\n\t\t} else if (isSameVNode(oldEndVNode, newEndVNode)) {\n\t\t\tpatch(oldEndVNode, newEndVNode, parent);\n\t\t\toldEndVNode = oldChildren[--oldEndIdx];\n\t\t\tnewEndVNode = newChildren[--newEndIdx];\n\t\t} else if (isSameVNode(oldStartVNode, newEndVNode)) {\n\t\t\tpatch(oldStartVNode, newEndVNode, parent);\n\t\t\tconst nodeToMove = oldStartVNode.dom;\n\t\t\tconst anchor = hostNextSibling(oldEndVNode.dom);\n\t\t\tif (nodeToMove) hostInsert(nodeToMove, parent, anchor);\n\t\t\toldStartVNode = oldChildren[++oldStartIdx];\n\t\t\tnewEndVNode = newChildren[--newEndIdx];\n\t\t} else if (isSameVNode(oldEndVNode, newStartVNode)) {\n\t\t\tpatch(oldEndVNode, newStartVNode, parent);\n\t\t\tconst nodeToMove = oldEndVNode.dom;\n\t\t\tconst anchor = oldStartVNode.dom;\n\t\t\tif (nodeToMove) hostInsert(nodeToMove, parent, anchor);\n\t\t\toldEndVNode = oldChildren[--oldEndIdx];\n\t\t\tnewStartVNode = newChildren[++newStartIdx];\n\t\t} else {\n\t\t\tif (!oldKeyToIdx) oldKeyToIdx = createKeyToKeyIndexMap(oldChildren, oldStartIdx, oldEndIdx);\n\t\t\tconst idxInOld = newStartVNode.key != null ? oldKeyToIdx.get(String(newStartVNode.key)) : findIndexInOld(oldChildren, newStartVNode, oldStartIdx, oldEndIdx);\n\t\t\tif (idxInOld != null) {\n\t\t\t\tconst vnodeToMove = oldChildren[idxInOld];\n\t\t\t\tpatch(vnodeToMove, newStartVNode, parent);\n\t\t\t\toldChildren[idxInOld] = void 0;\n\t\t\t\tif (vnodeToMove.dom && oldStartVNode.dom) hostInsert(vnodeToMove.dom, parent, oldStartVNode.dom);\n\t\t\t} else mount(newStartVNode, parent, oldStartVNode.dom);\n\t\t\tnewStartVNode = newChildren[++newStartIdx];\n\t\t}\n\t\tif (oldStartIdx > oldEndIdx) {\n\t\t\tif (newStartIdx <= newEndIdx) {\n\t\t\t\tconst anchor = newChildren[newEndIdx + 1] == null ? null : newChildren[newEndIdx + 1].dom;\n\t\t\t\tfor (let i = newStartIdx; i <= newEndIdx; i++) mount(newChildren[i], parent, anchor);\n\t\t\t}\n\t\t} else if (newStartIdx > newEndIdx) {\n\t\t\tfor (let i = oldStartIdx; i <= oldEndIdx; i++) if (oldChildren[i]) unmount(oldChildren[i], parent);\n\t\t}\n\t}\n\tfunction isSameVNode(n1, n2) {\n\t\tconst k1 = n1.key == null ? null : n1.key;\n\t\tconst k2 = n2.key == null ? null : n2.key;\n\t\tif (n1.type !== n2.type) return false;\n\t\tif (k1 === k2) return true;\n\t\treturn String(k1) === String(k2);\n\t}\n\tfunction createKeyToKeyIndexMap(children, beginIdx, endIdx) {\n\t\tconst map = /* @__PURE__ */ new Map();\n\t\tfor (let i = beginIdx; i <= endIdx; i++) {\n\t\t\tconst key = children[i]?.key;\n\t\t\tif (key != null) map.set(String(key), i);\n\t\t}\n\t\treturn map;\n\t}\n\tfunction findIndexInOld(children, newChild, beginIdx, endIdx) {\n\t\tfor (let i = beginIdx; i <= endIdx; i++) if (children[i] && isSameVNode(children[i], newChild)) return i;\n\t\treturn null;\n\t}\n\tfunction mountComponent(vnode, container, before, setup) {\n\t\tconst anchor = hostCreateComment(\"\");\n\t\tvnode.dom = anchor;\n\t\tanchor.__vnode = vnode;\n\t\thostInsert(anchor, container, before);\n\t\tlet exposed = null;\n\t\tlet exposeCalled = false;\n\t\tconst { children, slots: slotsFromProps, ...propsData } = vnode.props || {};\n\t\tconst reactiveProps = signal$1(propsData);\n\t\tvnode._componentProps = reactiveProps;\n\t\tconst slots = createSlots(children, slotsFromProps);\n\t\tvnode._slots = slots;\n\t\tconst mountHooks = [];\n\t\tconst cleanupHooks = [];\n\t\tconst parentInstance = getCurrentInstance();\n\t\tconst componentName = vnode.type.__name;\n\t\tconst ctx = {\n\t\t\tel: container,\n\t\t\tsignal: signal$1,\n\t\t\tprops: reactiveProps,\n\t\t\tslots,\n\t\t\temit: (event, ...args) => {\n\t\t\t\tconst handler = reactiveProps[`on${event[0].toUpperCase() + event.slice(1)}`];\n\t\t\t\tif (handler && typeof handler === \"function\") handler(...args);\n\t\t\t},\n\t\t\tparent: parentInstance,\n\t\t\tonMount: (fn) => {\n\t\t\t\tmountHooks.push(fn);\n\t\t\t},\n\t\t\tonCleanup: (fn) => {\n\t\t\t\tcleanupHooks.push(fn);\n\t\t\t},\n\t\t\texpose: (exposedValue) => {\n\t\t\t\texposed = exposedValue;\n\t\t\t\texposeCalled = true;\n\t\t\t}\n\t\t};\n\t\tctx.__name = componentName;\n\t\tif (currentAppContext) ctx._appContext = currentAppContext;\n\t\tconst componentInstance = {\n\t\t\tname: componentName,\n\t\t\tctx,\n\t\t\tvnode\n\t\t};\n\t\tconst prev = setCurrentInstance(ctx);\n\t\tlet renderFn;\n\t\ttry {\n\t\t\trenderFn = setup(ctx);\n\t\t\tnotifyComponentCreated(currentAppContext, componentInstance);\n\t\t} catch (err) {\n\t\t\tif (!handleComponentError(currentAppContext, err, componentInstance, \"setup\")) throw err;\n\t\t} finally {\n\t\t\tsetCurrentInstance(prev);\n\t\t}\n\t\tif (vnode.props.ref) {\n\t\t\tconst refValue = exposeCalled ? exposed : null;\n\t\t\tif (typeof vnode.props.ref === \"function\") vnode.props.ref(refValue);\n\t\t\telse if (vnode.props.ref && typeof vnode.props.ref === \"object\") vnode.props.ref.current = refValue;\n\t\t}\n\t\tif (renderFn) vnode._effect = effect(() => {\n\t\t\tconst prevInstance = setCurrentInstance(ctx);\n\t\t\ttry {\n\t\t\t\tconst subTreeResult = renderFn();\n\t\t\t\tif (subTreeResult == null) return;\n\t\t\t\tconst subTree = normalizeSubTree(subTreeResult);\n\t\t\t\tconst prevSubTree = vnode._subTree;\n\t\t\t\tif (prevSubTree) {\n\t\t\t\t\tpatch(prevSubTree, subTree, container);\n\t\t\t\t\tnotifyComponentUpdated(currentAppContext, componentInstance);\n\t\t\t\t} else mount(subTree, container, anchor);\n\t\t\t\tvnode._subTree = subTree;\n\t\t\t} catch (err) {\n\t\t\t\tif (!handleComponentError(currentAppContext, err, componentInstance, \"render\")) throw err;\n\t\t\t} finally {\n\t\t\t\tsetCurrentInstance(prevInstance);\n\t\t\t}\n\t\t});\n\t\tconst mountCtx = { el: container };\n\t\tmountHooks.forEach((hook) => hook(mountCtx));\n\t\tnotifyComponentMounted(currentAppContext, componentInstance);\n\t\tvnode.cleanup = () => {\n\t\t\tnotifyComponentUnmounted(currentAppContext, componentInstance);\n\t\t\tcleanupHooks.forEach((hook) => hook(mountCtx));\n\t\t};\n\t}\n\t/**\n\t* Create slots object from children and slots prop.\n\t* Uses a version signal to trigger re-renders when children change.\n\t* Supports named slots via:\n\t* - `slots` prop object (e.g., slots={{ header: () => <div>...</div> }})\n\t* - `slot` prop on children (e.g., <div slot=\"header\">...</div>)\n\t*/\n\tfunction createSlots(children, slotsFromProps) {\n\t\tconst versionSignal = signal$1({ v: 0 });\n\t\tfunction extractNamedSlotsFromChildren(c) {\n\t\t\tconst defaultChildren = [];\n\t\t\tconst namedSlots = {};\n\t\t\tif (c == null) return {\n\t\t\t\tdefaultChildren,\n\t\t\t\tnamedSlots\n\t\t\t};\n\t\t\tconst items = Array.isArray(c) ? c : [c];\n\t\t\tfor (const child of items) if (child && typeof child === \"object\" && child.props && child.props.slot) {\n\t\t\t\tconst slotName = child.props.slot;\n\t\t\t\tif (!namedSlots[slotName]) namedSlots[slotName] = [];\n\t\t\t\tnamedSlots[slotName].push(child);\n\t\t\t} else defaultChildren.push(child);\n\t\t\treturn {\n\t\t\t\tdefaultChildren,\n\t\t\t\tnamedSlots\n\t\t\t};\n\t\t}\n\t\tconst slotsObj = {\n\t\t\t_children: children,\n\t\t\t_slotsFromProps: slotsFromProps || {},\n\t\t\t_version: versionSignal,\n\t\t\tdefault: function() {\n\t\t\t\tthis._version.v;\n\t\t\t\tconst c = this._children;\n\t\t\t\tconst { defaultChildren } = extractNamedSlotsFromChildren(c);\n\t\t\t\treturn defaultChildren;\n\t\t\t}\n\t\t};\n\t\treturn new Proxy(slotsObj, { get(target, prop) {\n\t\t\tif (prop in target) return target[prop];\n\t\t\tif (typeof prop === \"string\") return function(scopedProps) {\n\t\t\t\ttarget._version.v;\n\t\t\t\tif (target._slotsFromProps && typeof target._slotsFromProps[prop] === \"function\") {\n\t\t\t\t\tconst result = target._slotsFromProps[prop](scopedProps);\n\t\t\t\t\tif (result == null) return [];\n\t\t\t\t\treturn Array.isArray(result) ? result : [result];\n\t\t\t\t}\n\t\t\t\tconst { namedSlots } = extractNamedSlotsFromChildren(target._children);\n\t\t\t\treturn namedSlots[prop] || [];\n\t\t\t};\n\t\t} });\n\t}\n\t/**\n\t* Normalize render result to a VNode (wrapping arrays in Fragment)\n\t*/\n\tfunction normalizeSubTree(result) {\n\t\tif (Array.isArray(result)) return {\n\t\t\ttype: Fragment,\n\t\t\tprops: {},\n\t\t\tkey: null,\n\t\t\tchildren: result,\n\t\t\tdom: null\n\t\t};\n\t\tif (typeof result === \"string\" || typeof result === \"number\") return {\n\t\t\ttype: Text,\n\t\t\tprops: {},\n\t\t\tkey: null,\n\t\t\tchildren: [],\n\t\t\tdom: null,\n\t\t\ttext: result\n\t\t};\n\t\treturn result;\n\t}\n\treturn {\n\t\trender,\n\t\tcreateApp: (rootComponent) => {\n\t\t\treturn { mount(selectorOrContainer) {\n\t\t\t\tlet container = null;\n\t\t\t\tif (typeof selectorOrContainer === \"string\") {\n\t\t\t\t\tif (options.querySelector) container = options.querySelector(selectorOrContainer);\n\t\t\t\t} else container = selectorOrContainer;\n\t\t\t\tif (!container) {\n\t\t\t\t\tconsole.warn(`Container not found: ${selectorOrContainer}`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\trender(rootComponent, container);\n\t\t\t} };\n\t\t}\n\t};\n}\n\n//#endregion\nexport { AppContextKey, Fragment, InstanceLifetimes, SubscriptionHandler, Text, Utils, createPropsProxy, createRenderer, createTopic, defineApp, defineComponent, defineFactory, defineInjectable, defineProvide, defineStore, getComponentMeta, getComponentPlugins, getCurrentInstance, getDefaultMount, getPlatformSyncProcessor, guid, handleComponentError, inject, injectApp, jsx, jsxDEV, jsxs, notifyComponentCreated, notifyComponentMounted, notifyComponentUnmounted, notifyComponentUpdated, onCleanup, onMount, provide, registerComponentPlugin, setCurrentInstance, setDefaultMount, setPlatformSyncProcessor, signal, toSubscriber, valueOf };\n//# sourceMappingURL=index.js.map","/** @jsxImportSource @sigx/runtime-core */\r\nimport { defineComponent, onMount, onCleanup, type DefineProp, type DefineEvent, type DefineSync } from '@sigx/runtime-core';\r\nimport { onKey } from '../index';\r\nimport { registerFocusable, unregisterFocusable, focusState, focus } from '../focus';\r\n\r\nexport const Input = defineComponent<\r\n DefineSync<string> &\r\n DefineProp<\"placeholder\", string, false> &\r\n DefineProp<\"autofocus\", boolean, false> &\r\n DefineProp<\"label\", string, false> &\r\n DefineEvent<\"input\", string> &\r\n DefineEvent<\"submit\", string>\r\n>(({ props, emit }) => {\r\n const id = Math.random().toString(36).slice(2);\r\n\r\n const isFocused = () => focusState.activeId === id;\r\n\r\n const handleKey = (key: string) => {\r\n if (!isFocused()) return;\r\n\r\n if (key === '\\r') { // Enter\r\n emit('submit', props.value || '');\r\n return;\r\n }\r\n\r\n if (key === '\\n') return;\r\n\r\n if (key === '\\u007F' || key === '\\b') { // Backspace\r\n const val = props.value || '';\r\n if (val.length > 0) {\r\n const newValue = val.slice(0, -1);\r\n emit('update:value', newValue);\r\n emit('input', newValue);\r\n }\r\n return;\r\n }\r\n\r\n // Ignore control characters\r\n if (key.length > 1) return;\r\n\r\n const newValue = (props.value || '') + key;\r\n emit('update:value', newValue);\r\n emit('input', newValue);\r\n };\r\n\r\n let keyCleanup: (() => void) | null = null;\r\n\r\n onMount(() => {\r\n registerFocusable(id);\r\n if (props.autofocus) {\r\n focus(id);\r\n }\r\n keyCleanup = onKey(handleKey);\r\n });\r\n\r\n onCleanup(() => {\r\n if (keyCleanup) keyCleanup();\r\n unregisterFocusable(id);\r\n });\r\n\r\n return () => {\r\n const val = (props.value || '').replace(/[\\r\\n]+/g, ' ');\r\n const placeholder = (props.placeholder || '').replace(/[\\r\\n]+/g, ' ');\r\n const showCursor = isFocused();\r\n // console.log('Input render', { val, placeholder, showCursor });\r\n\r\n return (\r\n <box border=\"single\" borderColor={showCursor ? 'green' : 'white'} label={props.label}>\r\n <text>{val || placeholder}</text>\r\n {showCursor && <text color=\"cyan\">_</text>}\r\n </box>\r\n );\r\n };\r\n}, { name: 'Input' });\r\n","/** @jsxImportSource @sigx/runtime-core */\r\nimport { defineComponent, type DefineProp } from '@sigx/runtime-core';\r\nimport { getColorCode } from '../utils';\r\n\r\nexport const ProgressBar = defineComponent<\r\n DefineProp<\"value\", number, false> &\r\n DefineProp<\"max\", number, false> &\r\n DefineProp<\"width\", number, false> &\r\n DefineProp<\"char\", string, false> &\r\n DefineProp<\"emptyChar\", string, false> &\r\n DefineProp<\"color\", string, false>\r\n>(({ props }) => {\r\n return () => {\r\n const value = props.value || 0;\r\n const max = props.max || 100;\r\n const width = props.width || 20;\r\n const barChar = props.char || '█';\r\n const emptyChar = props.emptyChar || '░';\r\n const color = props.color;\r\n const colorCode = color ? getColorCode(color) : '';\r\n const reset = color ? '\\x1b[0m' : '';\r\n\r\n const percentage = Math.min(Math.max(value / max, 0), 1);\r\n const filledLen = Math.round(width * percentage);\r\n const emptyLen = width - filledLen;\r\n\r\n const bar = colorCode + barChar.repeat(filledLen) + emptyChar.repeat(emptyLen) + reset;\r\n const label = ` ${Math.round(percentage * 100)}%`;\r\n\r\n return (\r\n <box>\r\n <text>{bar + label}</text>\r\n </box>\r\n );\r\n };\r\n}, { name: 'ProgressBar' });\r\n","/** @jsxImportSource @sigx/runtime-core */\r\nimport { defineComponent, onMount, onCleanup, signal, type DefineProp, type DefineEvent } from '@sigx/runtime-core';\r\nimport { onKey } from '../index';\r\nimport { registerFocusable, unregisterFocusable, focusState } from '../focus';\r\n\r\nexport const Button = defineComponent<\r\n DefineProp<\"label\", string, false> &\r\n DefineProp<\"dropShadow\", boolean, false> &\r\n DefineEvent<\"click\">\r\n>(({ props, emit }) => {\r\n const id = Math.random().toString(36).slice(2);\r\n\r\n const isFocused = () => focusState.activeId === id;\r\n const pressed = signal({ value: false });\r\n\r\n const handleKey = (key: string) => {\r\n if (!isFocused()) return;\r\n\r\n if (key === '\\r' || key === ' ') { // Enter or Space\r\n // Visual press effect + emit click\r\n pressed.value = true as any;\r\n if (pressTimer) clearTimeout(pressTimer);\r\n pressTimer = setTimeout(() => {\r\n pressed.value = false as any;\r\n pressTimer = null;\r\n }, 120);\r\n emit('click');\r\n }\r\n };\r\n\r\n let keyCleanup: (() => void) | null = null;\r\n let pressTimer: ReturnType<typeof setTimeout> | null = null;\r\n\r\n onMount(() => {\r\n registerFocusable(id);\r\n keyCleanup = onKey(handleKey);\r\n });\r\n\r\n onCleanup(() => {\r\n if (keyCleanup) keyCleanup();\r\n unregisterFocusable(id);\r\n if (pressTimer) clearTimeout(pressTimer);\r\n });\r\n\r\n return () => {\r\n const focused = isFocused();\r\n const label = props.label || 'Button';\r\n const isPressed = pressed.value as boolean;\r\n\r\n return (\r\n <box\r\n border=\"single\"\r\n borderColor={isPressed ? 'yellow' : (focused ? 'green' : 'white')}\r\n backgroundColor={isPressed ? 'red' : (focused ? 'blue' : undefined)}\r\n dropShadow={props.dropShadow}\r\n >\r\n <text color={focused ? 'white' : undefined}>{label}</text>\r\n </box>\r\n );\r\n };\r\n}, { name: 'Button' });","/** @jsxImportSource @sigx/runtime-core */\r\nimport { defineComponent, onMount, onCleanup, signal, type DefineProp, type DefineEvent, type DefineSync } from '@sigx/runtime-core';\r\nimport { onKey } from '../index';\r\nimport { registerFocusable, unregisterFocusable, focusState, focus } from '../focus';\r\n\r\nexport const Checkbox = defineComponent<\r\n DefineSync<boolean> &\r\n DefineProp<\"label\", string, false> &\r\n DefineProp<\"autofocus\", boolean, false> &\r\n DefineProp<\"disabled\", boolean, false> &\r\n DefineEvent<\"change\", boolean>\r\n>(({ props, emit }) => {\r\n const id = Math.random().toString(36).slice(2);\r\n\r\n const isFocused = () => focusState.activeId === id;\r\n const checked = () => !!props.value;\r\n\r\n const handleKey = (key: string) => {\r\n if (!isFocused()) return;\r\n if (props.disabled) return;\r\n\r\n if (key === '\\r' || key === ' ') { // Enter or Space toggles\r\n const next = !checked();\r\n // Use `value` as the two-way sync default to match the rest of the components.\r\n emit('update:value', next);\r\n emit('change', next);\r\n }\r\n };\r\n\r\n let keyCleanup: (() => void) | null = null;\r\n\r\n onMount(() => {\r\n registerFocusable(id);\r\n if (props.autofocus) focus(id);\r\n keyCleanup = onKey(handleKey);\r\n });\r\n\r\n onCleanup(() => {\r\n if (keyCleanup) keyCleanup();\r\n unregisterFocusable(id);\r\n });\r\n\r\n return () => {\r\n const label = props.label || '';\r\n const focused = isFocused();\r\n const isChecked = checked();\r\n const disabled = !!props.disabled;\r\n\r\n // Visual: [x] Label or [ ] Label\r\n // When focused, show a cursor indicator and highlight the label\r\n const boxColor = disabled ? 'white' : (isChecked ? 'green' : (focused ? 'cyan' : 'white'));\r\n const labelColor = disabled ? 'white' : (focused ? 'cyan' : undefined);\r\n const checkMark = isChecked ? 'x' : ' ';\r\n const focusIndicator = focused ? '>' : ' ';\r\n\r\n return (\r\n <box>\r\n <text color={focused ? 'cyan' : 'white'}>{focusIndicator}</text>\r\n <text color={boxColor}>[{checkMark}]</text>\r\n {label && <text color={labelColor}> {label}</text>}\r\n </box>\r\n );\r\n };\r\n}, { name: 'Checkbox' });\r\n\r\nexport default Checkbox;\r\n","import { createRenderer, RendererOptions, VNode, setDefaultMount } from '@sigx/runtime-core';\r\nimport { focusNext, focusPrev } from './focus';\r\nimport { getColorCode, getBackgroundColorCode, stripAnsi } from './utils';\r\n\r\n// Import type augmentation\r\nimport './types.js';\r\n\r\nexport * from './focus';\r\nexport * from './components/Input';\r\nexport * from './components/ProgressBar';\r\nexport * from './components/Button';\r\nexport * from './components/Checkbox';\r\n\r\n// --- Terminal Node Types ---\r\n\r\nexport interface TerminalNode {\r\n type: 'root' | 'element' | 'text' | 'comment';\r\n tag?: string;\r\n text?: string;\r\n props: Record<string, any>;\r\n children: TerminalNode[];\r\n parentNode?: TerminalNode | null;\r\n}\r\n\r\n// --- Node Operations ---\r\n\r\nconst nodeOps: RendererOptions<TerminalNode, TerminalNode> = {\r\n patchProp: (el, key, prev, next) => {\r\n el.props[key] = next;\r\n scheduleRender();\r\n },\r\n insert: (child, parent, anchor) => {\r\n child.parentNode = parent;\r\n const index = anchor ? parent.children.indexOf(anchor) : -1;\r\n if (index > -1) {\r\n parent.children.splice(index, 0, child);\r\n } else {\r\n parent.children.push(child);\r\n }\r\n scheduleRender();\r\n },\r\n remove: (child) => {\r\n if (child.parentNode) {\r\n const index = child.parentNode.children.indexOf(child);\r\n if (index > -1) {\r\n child.parentNode.children.splice(index, 1);\r\n }\r\n child.parentNode = null;\r\n }\r\n scheduleRender();\r\n },\r\n createElement: (tag) => {\r\n return { type: 'element', tag, props: {}, children: [] };\r\n },\r\n createText: (text) => {\r\n return { type: 'text', text, props: {}, children: [] };\r\n },\r\n createComment: (text) => {\r\n return { type: 'comment', text, props: {}, children: [] };\r\n },\r\n setText: (node, text) => {\r\n node.text = text;\r\n scheduleRender();\r\n },\r\n setElementText: (node, text) => {\r\n node.children = [{ type: 'text', text, props: {}, children: [], parentNode: node }];\r\n scheduleRender();\r\n },\r\n parentNode: (node) => node.parentNode || null,\r\n nextSibling: (node) => {\r\n if (!node.parentNode) return null;\r\n const idx = node.parentNode.children.indexOf(node);\r\n return node.parentNode.children[idx + 1] || null;\r\n },\r\n cloneNode: (node) => {\r\n // Shallow clone for simplicity in this demo\r\n return { ...node, children: [] };\r\n }\r\n};\r\n\r\n// --- Renderer Creation ---\r\n\r\nconst renderer = createRenderer(nodeOps);\r\nexport const { render, createApp } = renderer;\r\n\r\n// --- Terminal Rendering Logic ---\r\n\r\nlet rootNode: TerminalNode | null = null;\r\nlet isRendering = false;\r\n\r\nfunction scheduleRender() {\r\n if (isRendering) return;\r\n isRendering = true;\r\n // Use setImmediate or setTimeout to batch updates\r\n setTimeout(() => {\r\n flushRender();\r\n isRendering = false;\r\n }, 10);\r\n}\r\n\r\nfunction flushRender() {\r\n if (!rootNode) return;\r\n\r\n // Move cursor to top-left\r\n process.stdout.write('\\x1B[H');\r\n\r\n // Render tree\r\n const lines = renderNodeToLines(rootNode);\r\n process.stdout.write(lines.join('\\x1B[K\\n') + '\\x1B[K');\r\n\r\n // Clear rest of screen\r\n process.stdout.write('\\x1B[J');\r\n}\r\n\r\n\r\n/**\r\n * Check if a node has a box element as an immediate child.\r\n * This is used to determine if a component wrapper should be treated as a block element.\r\n */\r\nfunction hasBoxChild(node: TerminalNode): boolean {\r\n for (const child of node.children) {\r\n if (child.tag === 'box') {\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\n\r\nexport function renderNodeToLines(node: TerminalNode): string[] {\r\n // if (node.tag === 'box') console.log('Rendering box', node.props);\r\n if (node.type === 'text') {\r\n return [node.text || ''];\r\n }\r\n if (node.type === 'comment') {\r\n return [];\r\n }\r\n\r\n let lines: string[] = [''];\r\n\r\n // Simple styling based on props (e.g., color)\r\n const color = node.props.color;\r\n const reset = color ? '\\x1b[0m' : '';\r\n const colorCode = getColorCode(color);\r\n\r\n // Render children\r\n for (const child of node.children) {\r\n if (child.type === 'text') {\r\n // Append text to the last line\r\n lines[lines.length - 1] += colorCode + (child.text || '') + reset;\r\n } else if (child.tag === 'br') {\r\n // Start a new line\r\n lines.push('');\r\n } else {\r\n // Recursively render child\r\n const childLines = renderNodeToLines(child);\r\n\r\n // Check if this child contains a box element (making it a block)\r\n // A box is always a block element, and component wrappers that contain\r\n // a box should also be treated as blocks\r\n const isBlockElement = child.tag === 'box' || hasBoxChild(child);\r\n\r\n if (isBlockElement) {\r\n // Block element - start on a new line\r\n if (lines.length === 1 && lines[0] === '') {\r\n lines = childLines;\r\n } else {\r\n lines.push(...childLines);\r\n }\r\n } else {\r\n // Inline element (like text wrapper)\r\n // This is tricky. If child returns multiple lines, it breaks the flow.\r\n // For now, assume non-box elements are inline-ish or just append.\r\n if (childLines.length > 0) {\r\n // If the child has multiple lines, treat it as a block to avoid\r\n // appending a box top border to the end of a text line.\r\n if (childLines.length > 1) {\r\n if (lines.length === 1 && lines[0] === '') {\r\n lines = childLines;\r\n } else {\r\n lines.push(...childLines);\r\n }\r\n } else {\r\n lines[lines.length - 1] += childLines[0];\r\n for (let i = 1; i < childLines.length; i++) {\r\n lines.push(childLines[i]);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Apply box borders if needed\r\n if (node.tag === 'box' && node.props.border) {\r\n return drawBox(lines, node.props.border, node.props.borderColor, node.props.backgroundColor, node.props.dropShadow, node.props.label);\r\n }\r\n\r\n return lines;\r\n}\r\n\r\nfunction drawBox(contentLines: string[], style: string, color?: string, backgroundColor?: string, dropShadow?: boolean, label?: string): string[] {\r\n const borderChars = getBorderChars(style);\r\n const colorCode = color ? getColorCode(color) : '';\r\n const bgCode = backgroundColor ? getBackgroundColorCode(backgroundColor) : '';\r\n const reset = (color || backgroundColor) ? '\\x1b[0m' : '';\r\n\r\n // Calculate width\r\n const width = contentLines.reduce((max, line) => Math.max(max, stripAnsi(line).length), 0);\r\n\r\n // If there's a label, ensure box is wide enough to accommodate it\r\n const labelText = label || '';\r\n const labelLength = stripAnsi(labelText).length;\r\n const boxInnerWidth = Math.max(width, labelLength + 2);\r\n\r\n // Build top border. If label exists, center it in the top border like a fieldset legend\r\n let topInner = '';\r\n if (labelText) {\r\n const spaceForLabel = boxInnerWidth - labelLength - 2; // remaining space for horiz lines\r\n const leftH = Math.floor(spaceForLabel / 2);\r\n const rightH = spaceForLabel - leftH;\r\n topInner = borderChars.h.repeat(leftH) + ' ' + labelText + ' ' + borderChars.h.repeat(rightH);\r\n } else {\r\n topInner = borderChars.h.repeat(boxInnerWidth);\r\n }\r\n\r\n const top = bgCode + colorCode + borderChars.tl + topInner + borderChars.tr + reset;\r\n const bottom = bgCode + colorCode + borderChars.bl + borderChars.h.repeat(boxInnerWidth) + borderChars.br + reset;\r\n\r\n const result: string[] = [];\r\n result.push(top);\r\n\r\n for (const line of contentLines) {\r\n const visibleLength = stripAnsi(line).length;\r\n const padding = ' '.repeat(boxInnerWidth - visibleLength);\r\n // We need to apply background to the content line as well, but be careful not to double apply if it already has it?\r\n // Actually, the content might have its own colors.\r\n // But the padding needs the background color.\r\n // And the border needs the background color.\r\n\r\n // If we wrap the whole line in bgCode, it should work, provided we reset at the end.\r\n // But `line` might have resets in it.\r\n // A simple approach: apply bgCode to the border chars and the padding.\r\n // For the content, if it doesn't have bg, we might want to apply it.\r\n // But `line` is already a string with ANSI codes.\r\n\r\n // Let's try wrapping the whole thing.\r\n // Note: `line` comes from `renderNodeToLines`, which might have resets.\r\n // If `line` has `\\x1b[0m`, it will reset the background too.\r\n // So we might need to replace `\\x1b[0m` with `\\x1b[0m` + bgCode + colorCode?\r\n // That's getting complicated.\r\n\r\n // For now, let's just apply bg to borders and padding.\r\n // And maybe prepend bgCode to the line?\r\n\r\n // If we just prepend bgCode to `line`, and `line` has a reset, the rest of the line will lose the bg.\r\n // So we should replace resets in `line` with `reset + bgCode + colorCode` (if we want to maintain the box style).\r\n // But `colorCode` is for the border. The content might have its own text color.\r\n\r\n // Let's assume content handles its own text color, but we want to enforce background.\r\n // We can replace `\\x1b[0m` with `\\x1b[0m${bgCode}`.\r\n\r\n const lineWithBg = bgCode + line.replace(/\\x1b\\[0m/g, `\\x1b[0m${bgCode}`);\r\n\r\n result.push(bgCode + colorCode + borderChars.v + reset + lineWithBg + bgCode + padding + colorCode + borderChars.v + reset);\r\n }\r\n\r\n result.push(bottom);\r\n\r\n if (dropShadow) {\r\n const shadowColor = '\\x1b[90m'; // Bright black (gray)\r\n const resetShadow = '\\x1b[0m';\r\n const shadowChar = '▒';\r\n const shadowBlock = shadowColor + shadowChar + resetShadow;\r\n\r\n // Apply to lines 1 to end (skipping top line 0)\r\n for (let i = 1; i < result.length; i++) {\r\n result[i] += shadowBlock;\r\n }\r\n\r\n // Add bottom shadow line\r\n // Width is boxWidth (width + 2)\r\n const bottomShadow = ' ' + shadowBlock.repeat(width + 2);\r\n result.push(bottomShadow);\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction getBorderChars(style: string) {\r\n if (style === 'double') {\r\n return { tl: '╔', tr: '╗', bl: '╚', br: '╝', h: '═', v: '║' };\r\n }\r\n if (style === 'rounded') {\r\n return { tl: '╭', tr: '╮', bl: '╰', br: '╯', h: '─', v: '│' };\r\n }\r\n // Default single\r\n return { tl: '┌', tr: '┐', bl: '└', br: '┘', h: '─', v: '│' };\r\n}\r\n\r\nfunction renderNodeToString(node: TerminalNode, depth = 0): string {\r\n // Deprecated, but kept for compatibility if needed, or just redirect\r\n return renderNodeToLines(node).join('\\n');\r\n}\r\n\r\n\r\n// --- Public API for mounting ---\r\n\r\ntype KeyHandler = (key: string) => void;\r\nconst keyHandlers = new Set<KeyHandler>();\r\n\r\nexport function onKey(handler: KeyHandler) {\r\n keyHandlers.add(handler);\r\n return () => keyHandlers.delete(handler);\r\n}\r\n\r\nfunction handleInput(key: string) {\r\n // Ctrl+C to exit\r\n if (key === '\\u0003') {\r\n process.stdout.write('\\x1B[?25h'); // Show cursor\r\n process.exit();\r\n }\r\n\r\n // Tab navigation\r\n if (key === '\\t') {\r\n focusNext();\r\n return;\r\n }\r\n // Shift+Tab (often \\x1b[Z)\r\n if (key === '\\x1b[Z') {\r\n focusPrev();\r\n return;\r\n }\r\n\r\n for (const handler of keyHandlers) {\r\n handler(key);\r\n }\r\n}\r\n\r\nexport interface RenderTerminalOptions {\r\n clearConsole?: boolean;\r\n}\r\n\r\nexport function renderTerminal(app: any, options: RenderTerminalOptions = {}) {\r\n rootNode = { type: 'root', props: {}, children: [] };\r\n\r\n // Create a proxy container that looks like a HostElement\r\n const container = rootNode;\r\n\r\n // Setup input\r\n if (process.stdin.isTTY) {\r\n process.stdin.setRawMode(true);\r\n process.stdin.resume();\r\n process.stdin.setEncoding('utf8');\r\n process.stdin.on('data', handleInput);\r\n }\r\n\r\n // Clear console if requested\r\n if (options.clearConsole) {\r\n process.stdout.write('\\x1B[2J\\x1B[3J\\x1B[H');\r\n }\r\n\r\n // Hide cursor\r\n process.stdout.write('\\x1B[?25l');\r\n\r\n render(app, container);\r\n\r\n // Initial render\r\n flushRender();\r\n\r\n return {\r\n unmount: () => {\r\n render(null, container);\r\n // Show cursor\r\n process.stdout.write('\\x1B[?25h');\r\n\r\n if (process.stdin.isTTY) {\r\n process.stdin.setRawMode(false);\r\n process.stdin.pause();\r\n process.stdin.off('data', handleInput);\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Mount function for Terminal environments.\r\n * Use this with defineApp().mount() to render to the terminal.\r\n * \r\n * @example\r\n * ```tsx\r\n * import { defineApp } from '@sigx/runtime-core';\r\n * import { terminalMount } from '@sigx/runtime-terminal';\r\n * \r\n * const app = defineApp(<Counter />);\r\n * app.use(loggingPlugin)\r\n * .mount({ clearConsole: true }, terminalMount);\r\n * ```\r\n */\r\nexport const terminalMount = (component: any, options: RenderTerminalOptions, appContext?: any): (() => void) => {\r\n rootNode = { type: 'root', props: {}, children: [] };\r\n\r\n const container = rootNode;\r\n\r\n // Setup input\r\n if (process.stdin.isTTY) {\r\n process.stdin.setRawMode(true);\r\n process.stdin.resume();\r\n process.stdin.setEncoding('utf8');\r\n process.stdin.on('data', handleInput);\r\n }\r\n\r\n // Clear console if requested\r\n if (options?.clearConsole) {\r\n process.stdout.write('\\x1B[2J\\x1B[3J\\x1B[H');\r\n }\r\n\r\n // Hide cursor\r\n process.stdout.write('\\x1B[?25l');\r\n\r\n // Render with app context support\r\n render(component, container, appContext);\r\n\r\n // Initial render\r\n flushRender();\r\n\r\n // Return unmount function\r\n return () => {\r\n render(null, container);\r\n // Show cursor\r\n process.stdout.write('\\x1B[?25h');\r\n\r\n if (process.stdin.isTTY) {\r\n process.stdin.setRawMode(false);\r\n process.stdin.pause();\r\n process.stdin.off('data', handleInput);\r\n }\r\n };\r\n};\r\n\r\n// Set terminalMount as the default mount function for this platform\r\nsetDefaultMount(terminalMount);\r\n\r\ndeclare global {\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n box: TerminalAttributes;\r\n text: TerminalAttributes;\r\n br: TerminalAttributes;\r\n }\r\n\r\n interface TerminalAttributes {\r\n color?: 'red' | 'green' | 'blue' | 'yellow' | 'cyan' | 'white' | 'black' | string;\r\n backgroundColor?: 'red' | 'green' | 'blue' | 'yellow' | 'cyan' | 'white' | 'black' | string;\r\n border?: 'single' | 'double' | 'rounded' | 'none';\r\n borderColor?: 'red' | 'green' | 'blue' | 'yellow' | 'cyan' | 'white' | 'black' | string;\r\n dropShadow?: boolean;\r\n label?: string;\r\n children?: any;\r\n }\r\n\r\n }\r\n}\r\n\r\n"],"mappings":";AAgBA,MAAMA,UAA6B,EAAE;;;;AASrC,SAAgB,sBAAkD;AAC9D,QAAO;;;;;ACwBX,IAA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KAAK;AAC9B,UAAQ,MAAM,QAAQ;AACtB,UAAQ,MAAM,YAAY,OAAO;AACjC,UAAQ,MAAM,GAAG,QAAQ,YAAY;;AAIzC,KAAI,SAAS,aACT,SAAQ,OAAO,MAAM,uBAAuB;AAIhD,SAAQ,OAAO,MAAM,YAAY;AAGjC,QAAO,WAAW,WAAW,WAAW;AAGxC,cAAa;AAGb,cAAa;AACT,SAAO,MAAM,UAAU;AAEvB,UAAQ,OAAO,MAAM,YAAY;AAEjC,MAAI,QAAQ,MAAM,OAAO;AACrB,WAAQ,MAAM,WAAW,MAAM;AAC/B,WAAQ,MAAM,OAAO;AACrB,WAAQ,MAAM,IAAI,QAAQ,YAAY;;;;AAMlD,gBAAgB,cAAc"}
@@ -0,0 +1,4 @@
1
+ type KeyHandler = (key: string) => void;
2
+ export declare function onKey(handler: KeyHandler): () => boolean;
3
+ export declare function handleInput(key: string): void;
4
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { TerminalNode } from './index.js';
2
+ /**
3
+ * Module augmentation for Terminal platform.
4
+ * When @sigx/runtime-terminal is imported, these types automatically extend the core types.
5
+ */
6
+ declare module '@sigx/runtime-core' {
7
+ /** Terminal platform sets TerminalNode as the default element type */
8
+ interface PlatformTypes {
9
+ element: TerminalNode;
10
+ }
11
+ }
12
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare function getColorCode(color: string): string;
2
+ export declare function getBackgroundColorCode(color: string): string;
3
+ export declare function stripAnsi(str: string): string;
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@sigx/runtime-terminal",
3
+ "version": "0.1.0",
4
+ "description": "Terminal renderer for SignalX",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "rolldown -c && tsc --emitDeclarationOnly",
19
+ "dev": "rolldown -c -w"
20
+ },
21
+ "keywords": [
22
+ "sigx",
23
+ "terminal",
24
+ "tui",
25
+ "cli",
26
+ "console"
27
+ ],
28
+ "author": "Andreas Ekdahl",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/signalxjs/core.git",
33
+ "directory": "packages/runtime-terminal"
34
+ },
35
+ "homepage": "https://github.com/signalxjs",
36
+ "bugs": {
37
+ "url": "https://github.com/signalxjs/core/issues"
38
+ },
39
+ "dependencies": {
40
+ "@sigx/runtime-core": "^0.1.0",
41
+ "@sigx/reactivity": "^0.1.0"
42
+ },
43
+ "devDependencies": {
44
+ "rolldown": "^1.0.0-beta.52",
45
+ "typescript": "^5.9.3",
46
+ "@types/node": "^20.0.0"
47
+ }
48
+ }