@sigx/runtime-core 0.1.0 → 0.1.2
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.
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -763,10 +763,10 @@ function createRenderer(options) {
|
|
|
763
763
|
element.__vnode = vnode;
|
|
764
764
|
if (vnode.props) {
|
|
765
765
|
for (const key in vnode.props) if (key !== "children" && key !== "key" && key !== "ref") hostPatchProp(element, key, null, vnode.props[key]);
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
766
|
+
if (vnode.props.ref) {
|
|
767
|
+
if (typeof vnode.props.ref === "function") vnode.props.ref(element);
|
|
768
|
+
else if (typeof vnode.props.ref === "object") vnode.props.ref.current = element;
|
|
769
|
+
}
|
|
770
770
|
}
|
|
771
771
|
vnode.children.forEach((child) => {
|
|
772
772
|
child.parent = vnode;
|
|
@@ -996,7 +996,7 @@ function createRenderer(options) {
|
|
|
996
996
|
} finally {
|
|
997
997
|
setCurrentInstance(prev);
|
|
998
998
|
}
|
|
999
|
-
if (vnode.props
|
|
999
|
+
if (vnode.props?.ref) {
|
|
1000
1000
|
const refValue = exposeCalled ? exposed : null;
|
|
1001
1001
|
if (typeof vnode.props.ref === "function") vnode.props.ref(refValue);
|
|
1002
1002
|
else if (vnode.props.ref && typeof vnode.props.ref === "object") vnode.props.ref.current = refValue;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["platformSyncProcessor: SyncProcessor | null","plugins: ComponentPlugin[]","defaultMountFn: MountFn<any> | null","context: AppContext","container: TContainer | null","unmountFn: (() => void) | null","app: App<TContainer>","currentComponentContext: ComponentSetupContext<any, any, any> | null","isComponent","key","rest","guid","guidFn","subscribers: ((data: T) => void)[]","current: any","customDispose: ((fn: () => void) => void) | null","messages: Topic<any>[] | null","events: { [key: string]: Topic<any> }","onDispatching: any","onDispatched: any","onFailure: any","result: any","msg: { result: any; args: IArguments; }","msg: { reason: any; args: IArguments; }","signal","events: any","mutate: any","value","currentAppContext: AppContext | null","vnode: VNode | null","newProps","oldKeyToIdx: Map<string | number, number> | undefined","exposed: any","signal","mountHooks: ((ctx: MountContext) => void)[]","cleanupHooks: ((ctx: MountContext) => void)[]","ctx: ComponentSetupContext","componentInstance: ComponentInstance","renderFn: ViewFn | undefined","defaultChildren: any[]","namedSlots: Record<string, any[]>","container: HostElement | null"],"sources":["../src/platform.ts","../src/plugins.ts","../src/app.ts","../src/component.ts","../src/jsx-runtime.ts","../src/utils/index.ts","../src/models/index.ts","../src/messaging/index.ts","../src/di/injectable.ts","../src/di/factory.ts","../src/stores/store.ts","../src/renderer.ts"],"sourcesContent":["/**\r\n * Platform-specific hooks 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 * Platform-specific sync processor for intrinsic elements.\r\n * Platforms (DOM, Terminal) can register their own sync handling logic.\r\n * \r\n * @param type - The intrinsic element type (e.g., 'input', 'select')\r\n * @param props - The props object being built (mutable)\r\n * @param syncBinding - The [stateObj, key] tuple for the sync binding\r\n * @param originalProps - The original props from JSX (read-only)\r\n * @returns true if handled (skip generic fallback), false to use generic fallback\r\n */\r\nexport type SyncProcessor = (\r\n type: string,\r\n props: Record<string, any>,\r\n syncBinding: [Record<string, any>, string],\r\n originalProps: Record<string, any>\r\n) => boolean;\r\n\r\n// Private holder - no TDZ issues since this module has no circular deps\r\nlet platformSyncProcessor: SyncProcessor | null = null;\r\n\r\n/**\r\n * Set the platform-specific sync processor for intrinsic elements.\r\n * Called by runtime-dom to handle checkbox/radio/select sync bindings.\r\n */\r\nexport function setPlatformSyncProcessor(fn: SyncProcessor): void {\r\n platformSyncProcessor = fn;\r\n}\r\n\r\n/**\r\n * Get the current platform sync processor (for internal use).\r\n */\r\nexport function getPlatformSyncProcessor(): SyncProcessor | null {\r\n return platformSyncProcessor;\r\n}\r\n","/**\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","// 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","export class Utils {\r\n static isPromise(value: any): boolean {\r\n return !!value && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function';\r\n }\r\n}\r\n\r\nexport function guid(): string {\r\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\r\n var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);\r\n return v.toString(16);\r\n });\r\n}\r\n","import { guid as guidFn } from \"../utils/index.js\";\r\n\r\nexport type guid = string;\r\nexport const guid = guidFn;\r\n\r\nexport enum InstanceLifetimes {\r\n Transient = 0,\r\n Scoped = 1,\r\n Singleton = 2\r\n}\r\n\r\nexport interface Subscription {\r\n unsubscribe(): void;\r\n}\r\n\r\nexport interface Topic<T> {\r\n publish(data: T): void;\r\n subscribe(handler: (data: T) => void): Subscription;\r\n destroy(): void;\r\n}\r\n\r\nexport function valueOf<T>(obj: any): T {\r\n return obj as T;\r\n}\r\n","import { Subscription, Topic } from \"../models/index.js\";\r\nimport { onCleanup } from \"../component.js\";\r\n\r\nexport function createTopic<T>(options?: { namespace?: string; name?: string }): Topic<T> {\r\n let subscribers: ((data: T) => void)[] = [];\r\n\r\n const publish = (data: T) => {\r\n subscribers.forEach(s => s(data));\r\n };\r\n\r\n const subscribe = (handler: (data: T) => void): Subscription => {\r\n subscribers.push(handler);\r\n const unsubscribe = () => {\r\n const idx = subscribers.indexOf(handler);\r\n if (idx > -1) subscribers.splice(idx, 1);\r\n };\r\n\r\n // Auto-unsubscribe if inside a component or effect scope that supports cleanup\r\n try {\r\n onCleanup(unsubscribe);\r\n } catch (e) {\r\n // Not in a context that supports auto-cleanup, ignore\r\n }\r\n\r\n return { unsubscribe };\r\n };\r\n\r\n const destroy = () => {\r\n subscribers = [];\r\n };\r\n\r\n return {\r\n publish,\r\n subscribe,\r\n destroy\r\n };\r\n}\r\n\r\nexport function toSubscriber<T>(topic: Topic<T>) {\r\n return {\r\n subscribe: (handler: (data: T) => void) => topic.subscribe(handler)\r\n };\r\n}\r\n","import { getCurrentInstance } from \"../component.js\";\r\nimport { AppContextKey, type AppContext } from \"../app.js\";\r\n\r\n// We need to define what a Component looks like for DI purposes\r\n// Since we removed HTMLElement dependency, we need to rely on the context structure\r\n// The context has a 'parent' property which points to the parent context or component instance.\r\n\r\nexport function inject<T>(token: any): T | undefined {\r\n const ctx = getCurrentInstance();\r\n // If called outside component, return undefined (or handle as needed)\r\n if (!ctx) return undefined;\r\n\r\n // Traverse up the tree\r\n // In our new architecture, ctx.parent is the parent VNode or Component Context\r\n // We need to standardize where 'provides' are stored.\r\n // Let's assume they are stored on the component instance (ctx) or VNode.\r\n\r\n let current: any = ctx;\r\n while (current) {\r\n if (current.provides && current.provides.has(token)) {\r\n return current.provides.get(token);\r\n }\r\n current = current.parent;\r\n }\r\n\r\n // Fallback: check app-level provides if we have an app context\r\n const appContext = getAppContext(ctx);\r\n if (appContext && appContext.provides.has(token)) {\r\n return appContext.provides.get(token);\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Get the app context from the current component context\r\n */\r\nfunction getAppContext(ctx: any): AppContext | null {\r\n // Walk up to find app context attached to root\r\n let current = ctx;\r\n while (current) {\r\n if (current._appContext) {\r\n return current._appContext;\r\n }\r\n current = current.parent;\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * Inject the App instance (useful for plugins)\r\n */\r\nexport function injectApp() {\r\n return inject(AppContextKey);\r\n}\r\n\r\nexport function provide<T>(token: any, value: T) {\r\n const ctx = getCurrentInstance();\r\n if (!ctx) {\r\n console.warn(\"provide called outside of component setup\");\r\n return;\r\n }\r\n\r\n if (!(ctx as any).provides) {\r\n (ctx as any).provides = new Map();\r\n }\r\n (ctx as any).provides.set(token, value);\r\n}\r\n\r\nconst globalInstances = new Map<any, any>();\r\n\r\nexport function defineInjectable<T>(factory: () => T) {\r\n const token = factory;\r\n\r\n const useFn = () => {\r\n const injected = inject<T>(token);\r\n if (injected) return injected;\r\n\r\n // Fallback to global singleton\r\n if (!globalInstances.has(token)) {\r\n globalInstances.set(token, factory());\r\n }\r\n return globalInstances.get(token);\r\n };\r\n\r\n // Attach metadata for defineProvide\r\n (useFn as any)._factory = factory;\r\n (useFn as any)._token = token;\r\n\r\n return useFn;\r\n}\r\n\r\nexport function defineProvide<T>(useFn: () => T): T {\r\n const factory = (useFn as any)._factory;\r\n const token = (useFn as any)._token;\r\n\r\n if (!factory || !token) {\r\n throw new Error(\"defineProvide must be called with a function created by defineInjectable\");\r\n }\r\n\r\n const instance = factory();\r\n provide(token, instance);\r\n return instance;\r\n}\r\n","import { defineInjectable } from \"./injectable.js\";\r\nimport { InstanceLifetimes, guid } from \"../models/index.js\";\r\nimport { onCleanup } from \"../component.js\";\r\n\r\nexport class SubscriptionHandler {\r\n private unsubs: (() => void)[] = [];\r\n add(unsub: () => void) {\r\n this.unsubs.push(unsub);\r\n }\r\n unsubscribe() {\r\n this.unsubs.forEach(u => u());\r\n this.unsubs = [];\r\n }\r\n}\r\n\r\nexport interface SetupFactoryContext {\r\n onDeactivated(fn: () => void): void;\r\n subscriptions: SubscriptionHandler;\r\n overrideDispose(onDispose: (fn: () => void) => void): void;\r\n}\r\n\r\nexport function defineFactory<InferReturnSetup>(\r\n setup: (ctx: SetupFactoryContext, ...args: any) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n): () => InferReturnSetup & { dispose?: () => void }\r\nexport function defineFactory<InferReturnSetup, T1>(\r\n setup: (ctx: SetupFactoryContext, param1: T1) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n): (param1: T1) => InferReturnSetup\r\nexport function defineFactory<InferReturnSetup, T1, T2>(\r\n setup: (ctx: SetupFactoryContext, param1: T1, param2: T2) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: string\r\n): (param1: T1, param2: T2) => InferReturnSetup\r\nexport function defineFactory<InferReturnSetup, T1, T2, T3>(\r\n setup: (ctx: SetupFactoryContext, param1: T1, param2: T2, param3: T3) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n): (param1: T1, param2: T2, param3: T3) => InferReturnSetup\r\nexport function defineFactory<InferReturnSetup, T1, T2, T3, T4>(\r\n setup: (ctx: SetupFactoryContext, param1: T1, param2: T2, param3: T3, param4: T4) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n): (param1: T1, param2: T2, param3: T3, param4: T4) => InferReturnSetup\r\nexport function defineFactory<InferReturnSetup, T1, T2, T3, T4, T5>(\r\n setup: (ctx: SetupFactoryContext, param1: T1, param2: T2, param3: T3, param4: T4, param5: T5) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n): (param1: T1, param2: T2, param3: T3, param4: T4, param5: T5) => InferReturnSetup\r\nexport function defineFactory<InferReturnSetup>(\r\n setup: (ctx: SetupFactoryContext, ...args: any) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n) {\r\n // The actual factory that creates the instance\r\n const factoryCreator = (...args: any[]) => {\r\n const subscriptions = new SubscriptionHandler();\r\n const deactivations = new Set<() => void>();\r\n let customDispose: ((fn: () => void) => void) | null = null;\r\n\r\n const ctx: SetupFactoryContext = {\r\n onDeactivated: (fn) => deactivations.add(fn),\r\n subscriptions,\r\n overrideDispose: (fn) => customDispose = fn\r\n };\r\n\r\n const result = setup(ctx, ...args);\r\n\r\n const dispose = () => {\r\n deactivations.forEach(d => d());\r\n subscriptions.unsubscribe();\r\n (result as any).dispose?.();\r\n };\r\n\r\n if (customDispose) {\r\n (customDispose as (fn: () => void) => void)(dispose);\r\n } else {\r\n // Auto-dispose if in component context\r\n try {\r\n onCleanup(() => dispose());\r\n } catch (e) { }\r\n }\r\n\r\n return { ...result, dispose };\r\n };\r\n\r\n // If it's a parameterless factory, we can make it injectable\r\n if (setup.length <= 1) {\r\n return defineInjectable(() => factoryCreator());\r\n }\r\n\r\n return factoryCreator;\r\n}\r\n","import { guid, Subscription, Topic, InstanceLifetimes, valueOf } from \"../models/index.js\";\r\nimport { createTopic, toSubscriber } from \"../messaging/index.js\";\r\nimport { defineFactory, SetupFactoryContext } from \"../di/factory.js\";\r\nimport { Utils } from \"../utils/index.js\";\r\nimport { signal, watch, effectScope, EffectScope } from \"@sigx/reactivity\";\r\n\r\ntype MaybeUndefined<T, I> = I extends true ? T | undefined : T;\r\n\r\ntype MutateFn<T> = (value: T | ((prev: T) => T)) => void;\r\n\r\ntype StoreStateContext<TState extends object, TInternalState extends object> = {\r\n state: TState;\r\n internalState: TInternalState;\r\n};\r\n\r\ntype StoreActionContext<TState extends object, TInternalState extends object, TGetters, TEvents extends Record<string, Topic<any>>, TSetup extends object> = StoreStateContext<TState, TInternalState> & {\r\n get: TGetters;\r\n mutate: {\r\n [K in keyof TState]: MutateFn<TState[K]>;\r\n };\r\n events: TEvents;\r\n setup: TSetup;\r\n};\r\n\r\nexport type StoreEvents<TState extends object, TEvents extends Record<string, Topic<any>> = {}> = {\r\n [K in keyof TState as `onMutated${Capitalize<string & K>}`]: ReturnType<typeof toSubscriber<TState[K]>>;\r\n\r\n} & TEvents;\r\n\r\ntype MapActionOnDispatching<T extends Function> = T extends (...args: infer U) => any ? (...args: U) => void : never;\r\ntype MapActionOnDispatched<T extends Function> = T extends (...args: infer U) => Promise<infer Y> | infer Y ? (result: Y, ...args: U) => void : never;\r\ntype MapActionOnFailure<T extends Function> = T extends (...args: infer U) => any ? (failureReason: any, ...args: U) => void : never;\r\n\r\nexport type StoreReturnDefineAction<TAction extends { [key: string]: any }> = {\r\n onDispatching: {\r\n [k in keyof TAction]: {\r\n subscribe(fn: MapActionOnDispatching<TAction[k]>): Subscription\r\n }\r\n }\r\n onDispatched: {\r\n [k in keyof TAction]: {\r\n subscribe(fn: MapActionOnDispatched<TAction[k]>): Subscription\r\n }\r\n }\r\n onFailure: {\r\n [k in keyof TAction]: {\r\n subscribe(fn: MapActionOnFailure<TAction[k]>): Subscription\r\n }\r\n }\r\n} & TAction\r\n\r\nexport interface SetupStoreContext extends SetupFactoryContext {\r\n defineState<\r\n TState extends object,\r\n TEvents extends Record<string, Topic<any>> = Record<string, Topic<any>>\r\n >(state: TState): {\r\n state: TState\r\n events: StoreEvents<TState, TEvents>\r\n mutate: {\r\n [K in keyof TState]: MutateFn<TState[K]>;\r\n };\r\n }\r\n defineActions<TActions extends { [key: string]: any }>(actions: TActions): StoreReturnDefineAction<TActions>\r\n}\r\n\r\nexport interface IReturnSetupStore<TState, TGetters, TActions extends { [key: string]: Function }, TEvents> {\r\n state?: TState\r\n get?: TGetters\r\n actions?: StoreReturnDefineAction<TActions>\r\n events?: TEvents\r\n name?: string\r\n}\r\n\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>>(name: string, setup: (ctx: SetupStoreContext) => InferReturnSetup, lifetime?: InstanceLifetimes): ReturnType<typeof defineFactory<InferReturnSetup>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>, T1>(name: string, setup: (ctx: SetupStoreContext, param1: T1) => InferReturnSetup, lifetime?: InstanceLifetimes): ReturnType<typeof defineFactory<InferReturnSetup, T1>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>, T1, T2>(name: string, setup: (ctx: SetupStoreContext, param1: T1, param2: T2) => InferReturnSetup, lifetime?: InstanceLifetimes): ReturnType<typeof defineFactory<InferReturnSetup, T1, T2>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>, T1, T2, T3>(name: string, setup: (ctx: SetupStoreContext, param1: T1, param2: T2, param3: T3, lifetime?: InstanceLifetimes) => InferReturnSetup): ReturnType<typeof defineFactory<InferReturnSetup, T1, T2, T3>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>, T1, T2, T3, T4>(name: string, setup: (ctx: SetupStoreContext, param1: T1, param2: T2, param3: T3, param4: T4, lifetime?: InstanceLifetimes) => InferReturnSetup): ReturnType<typeof defineFactory<InferReturnSetup, T1, T2, T3, T4>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>, T1, T2, T3, T4, T5>(name: string, setup: (ctx: SetupStoreContext, param1: T1, param2: T2, param3: T3, param4: T4, param5: T5) => InferReturnSetup, lifetime?: InstanceLifetimes): ReturnType<typeof defineFactory<InferReturnSetup, T1, T2, T3, T4, T5>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>\r\n>(name: string, setup: (ctx: SetupStoreContext, ...args: any) => InferReturnSetup, lifetime = InstanceLifetimes.Scoped) {\r\n\r\n return defineFactory<InferReturnSetup>((ctxFactory, ...args: any) => {\r\n const scope = effectScope(true);\r\n let messages: Topic<any>[] | null = [] satisfies Topic<any>[];\r\n const instanceId = guid();\r\n const id = `${name}_${instanceId}`;\r\n\r\n const result = setup({\r\n ...ctxFactory,\r\n defineState: (state) => {\r\n return defineState(state, id, scope, messages!);\r\n },\r\n defineActions: (actions) => {\r\n return defineActions(actions, id, messages!);\r\n }\r\n }, ...args);\r\n\r\n ctxFactory.onDeactivated(() => {\r\n scope.stop();\r\n messages?.forEach(m => m.destroy());\r\n messages = null;\r\n });\r\n\r\n // add store name for easy debugging\r\n if (!result.name) {\r\n result.name = id;\r\n }\r\n return result;\r\n }, lifetime);\r\n}\r\n\r\nfunction defineActions<\r\n TAction extends { [key: string]: any }\r\n>(\r\n actions: TAction,\r\n storeInstanceName: string,\r\n messages: Topic<any>[]\r\n): StoreReturnDefineAction<TAction> {\r\n const events: { [key: string]: Topic<any> } = {};\r\n const namespace = `${storeInstanceName}.actions.${guid()}`;\r\n\r\n const onDispatching: any = {};\r\n const onDispatched: any = {};\r\n const onFailure: any = {};\r\n const result: any = {\r\n onDispatching,\r\n onDispatched,\r\n onFailure\r\n };\r\n\r\n function getEvent(actionName: string, type: \"onDispatching\" | \"onDispatched\" | \"onFailure\") {\r\n const name = `${actionName}.${type}`;\r\n if (!events[name]) {\r\n events[name] = createTopic({\r\n namespace: namespace,\r\n name: name\r\n });\r\n messages.push(events[name]);\r\n }\r\n return events[name];\r\n }\r\n\r\n Object.keys(actions).forEach(actionName => {\r\n // Setup event subscribers\r\n onDispatching[actionName] = {\r\n subscribe: (fn: Function) => {\r\n return getEvent(actionName, \"onDispatching\").subscribe(function (this: any) {\r\n fn.apply(this, arguments[0]);\r\n });\r\n }\r\n };\r\n onDispatched[actionName] = {\r\n subscribe: (fn: Function) => {\r\n return getEvent(actionName, \"onDispatched\").subscribe(function (this: any) {\r\n const msg: { result: any; args: IArguments; } = arguments[0];\r\n const allArguments = [msg.result].concat(Array.from(msg.args));\r\n fn.apply(this, allArguments);\r\n });\r\n }\r\n };\r\n onFailure[actionName] = {\r\n subscribe: (fn: Function) => {\r\n return getEvent(actionName, \"onFailure\").subscribe(function (this: any) {\r\n const msg: { reason: any; args: IArguments; } = arguments[0];\r\n const allArguments = [msg.reason].concat(Array.from(msg.args));\r\n fn.apply(this, allArguments);\r\n });\r\n }\r\n };\r\n\r\n // Wrap action\r\n result[actionName] = function (this: any) {\r\n try {\r\n const currentArguments = arguments;\r\n getEvent(actionName, \"onDispatching\").publish(currentArguments);\r\n\r\n const returnedResult = actions[actionName].apply(this, currentArguments);\r\n if (Utils.isPromise(returnedResult)) {\r\n (returnedResult as Promise<any>).then(result => {\r\n getEvent(actionName, \"onDispatched\").publish({ result: returnedResult, args: currentArguments });\r\n });\r\n }\r\n else {\r\n getEvent(actionName, \"onDispatched\").publish({ result: returnedResult, args: currentArguments });\r\n }\r\n\r\n return returnedResult;\r\n }\r\n catch (err) {\r\n console.error(err);\r\n getEvent(actionName, \"onFailure\").publish({ reason: err, args: arguments });\r\n }\r\n };\r\n });\r\n\r\n return result;\r\n}\r\n\r\nfunction defineState<\r\n TState extends object,\r\n TEvents extends Record<string, Topic<any>>\r\n>(\r\n value: TState,\r\n storeInstanceName: string,\r\n scope: EffectScope,\r\n messages: Topic<any>[]\r\n) {\r\n\r\n // Use signal directly for the state\r\n const state = signal(value);\r\n const events: any = {};\r\n const mutate: any = {};\r\n\r\n function initProperty(key: string) {\r\n // Setup watcher\r\n scope.run(() => {\r\n watch(() => (state as any)[key], (newValue: any) => {\r\n triggerEvent(key, newValue);\r\n }, { deep: true, immediate: true });\r\n });\r\n\r\n // Setup mutate\r\n mutate[key] = (val: any) => {\r\n try {\r\n let newValue;\r\n if (typeof val === \"function\") {\r\n newValue = val((state as any)[key]);\r\n } else {\r\n newValue = val;\r\n }\r\n (state as any)[key] = newValue;\r\n } catch (err) {\r\n console.error(err);\r\n }\r\n };\r\n\r\n // Setup event\r\n const eventKey = `onMutated${key.charAt(0).toUpperCase()}${key.slice(1)}`;\r\n if (!events[eventKey]) {\r\n const topic = createTopic({\r\n namespace: `${storeInstanceName}.events`,\r\n name: eventKey\r\n });\r\n events[eventKey] = topic;\r\n messages.push(topic);\r\n }\r\n }\r\n\r\n function triggerEvent(name: string, value: any) {\r\n const keyString = name;\r\n const afterEventKey = `onMutated${keyString.charAt(0).toUpperCase()}${keyString.slice(1)}`;\r\n events[afterEventKey]?.publish(value);\r\n }\r\n\r\n if (value) {\r\n Object.keys(value).forEach(key => {\r\n initProperty(key);\r\n });\r\n }\r\n\r\n return {\r\n state: state as TState,\r\n events: events as StoreEvents<TState, TEvents>,\r\n mutate: mutate as StoreActionContext<TState, {}, {}, TEvents, {}>[\"mutate\"]\r\n };\r\n}\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"],"mappings":";;;AA0BA,IAAIA,wBAA8C;;;;;AAMlD,SAAgB,yBAAyB,IAAyB;AAC9D,yBAAwB;;;;;AAM5B,SAAgB,2BAAiD;AAC7D,QAAO;;;;;ACxBX,MAAMC,UAA6B,EAAE;AAErC,SAAgB,wBAAwB,QAA+B;AACnE,SAAQ,KAAK,OAAO;;;;;AAMxB,SAAgB,sBAAkD;AAC9D,QAAO;;;;;ACSX,MAAM,QAAQ,OAAO,YAAY,eAA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QAAI,OAAO,mBAAmB,OAAO,OAAO,gBAAgB,UAAU,YAAY;KAC9E,MAAM,SAAS,OAAO,gBAAgB,MAAM,YAAY;AACxD,SAAI,UAAU,KAAM,QAAO,EAAE;AAC7B,YAAO,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;;IAIpD,MAAM,EAAE,eAAe,8BAA8B,OAAO,UAAU;AACtE,WAAO,WAAW,SAAS,EAAE;;KAM5C,CAAC;;;;;CAMN,SAAS,iBAAiB,QAA0C;AAChE,MAAI,MAAM,QAAQ,OAAO,CACrB,QAAO;GACH,MAAM;GACN,OAAO,EAAE;GACT,KAAK;GACL,UAAU;GACV,KAAK;GACR;AAEL,MAAI,OAAO,WAAW,YAAY,OAAO,WAAW,SAChD,QAAO;GACH,MAAM;GACN,OAAO,EAAE;GACT,KAAK;GACL,UAAU,EAAE;GACZ,KAAK;GACL,MAAM;GACT;AAEL,SAAO;;AAGX,QAAO;EACH;EACA,YAAY,kBAAuB;AAE/B,UAAO,EACH,MAAM,qBAA2C;IAC7C,IAAIC,YAAgC;AACpC,QAAI,OAAO,wBAAwB,UAC/B;SAAI,QAAQ,cACR,aAAY,QAAQ,cAAc,oBAAoB;UAG1D,aAAY;AAGhB,QAAI,CAAC,WAAW;AACZ,aAAQ,KAAK,wBAAwB,sBAAsB;AAC3D;;AAGJ,WAAO,eAAe,UAAU;MAEvC;;EAER"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["platformSyncProcessor: SyncProcessor | null","plugins: ComponentPlugin[]","defaultMountFn: MountFn<any> | null","context: AppContext","container: TContainer | null","unmountFn: (() => void) | null","app: App<TContainer>","currentComponentContext: ComponentSetupContext<any, any, any> | null","isComponent","key","rest","guid","guidFn","subscribers: ((data: T) => void)[]","current: any","customDispose: ((fn: () => void) => void) | null","messages: Topic<any>[] | null","events: { [key: string]: Topic<any> }","onDispatching: any","onDispatched: any","onFailure: any","result: any","msg: { result: any; args: IArguments; }","msg: { reason: any; args: IArguments; }","signal","events: any","mutate: any","value","currentAppContext: AppContext | null","vnode: VNode | null","newProps","oldKeyToIdx: Map<string | number, number> | undefined","exposed: any","signal","mountHooks: ((ctx: MountContext) => void)[]","cleanupHooks: ((ctx: MountContext) => void)[]","ctx: ComponentSetupContext","componentInstance: ComponentInstance","renderFn: ViewFn | undefined","defaultChildren: any[]","namedSlots: Record<string, any[]>","container: HostElement | null"],"sources":["../src/platform.ts","../src/plugins.ts","../src/app.ts","../src/component.ts","../src/jsx-runtime.ts","../src/utils/index.ts","../src/models/index.ts","../src/messaging/index.ts","../src/di/injectable.ts","../src/di/factory.ts","../src/stores/store.ts","../src/renderer.ts"],"sourcesContent":["/**\r\n * Platform-specific hooks 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 * Platform-specific sync processor for intrinsic elements.\r\n * Platforms (DOM, Terminal) can register their own sync handling logic.\r\n * \r\n * @param type - The intrinsic element type (e.g., 'input', 'select')\r\n * @param props - The props object being built (mutable)\r\n * @param syncBinding - The [stateObj, key] tuple for the sync binding\r\n * @param originalProps - The original props from JSX (read-only)\r\n * @returns true if handled (skip generic fallback), false to use generic fallback\r\n */\r\nexport type SyncProcessor = (\r\n type: string,\r\n props: Record<string, any>,\r\n syncBinding: [Record<string, any>, string],\r\n originalProps: Record<string, any>\r\n) => boolean;\r\n\r\n// Private holder - no TDZ issues since this module has no circular deps\r\nlet platformSyncProcessor: SyncProcessor | null = null;\r\n\r\n/**\r\n * Set the platform-specific sync processor for intrinsic elements.\r\n * Called by runtime-dom to handle checkbox/radio/select sync bindings.\r\n */\r\nexport function setPlatformSyncProcessor(fn: SyncProcessor): void {\r\n platformSyncProcessor = fn;\r\n}\r\n\r\n/**\r\n * Get the current platform sync processor (for internal use).\r\n */\r\nexport function getPlatformSyncProcessor(): SyncProcessor | null {\r\n return platformSyncProcessor;\r\n}\r\n","/**\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","// 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","export class Utils {\r\n static isPromise(value: any): boolean {\r\n return !!value && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function';\r\n }\r\n}\r\n\r\nexport function guid(): string {\r\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\r\n var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);\r\n return v.toString(16);\r\n });\r\n}\r\n","import { guid as guidFn } from \"../utils/index.js\";\r\n\r\nexport type guid = string;\r\nexport const guid = guidFn;\r\n\r\nexport enum InstanceLifetimes {\r\n Transient = 0,\r\n Scoped = 1,\r\n Singleton = 2\r\n}\r\n\r\nexport interface Subscription {\r\n unsubscribe(): void;\r\n}\r\n\r\nexport interface Topic<T> {\r\n publish(data: T): void;\r\n subscribe(handler: (data: T) => void): Subscription;\r\n destroy(): void;\r\n}\r\n\r\nexport function valueOf<T>(obj: any): T {\r\n return obj as T;\r\n}\r\n","import { Subscription, Topic } from \"../models/index.js\";\r\nimport { onCleanup } from \"../component.js\";\r\n\r\nexport function createTopic<T>(options?: { namespace?: string; name?: string }): Topic<T> {\r\n let subscribers: ((data: T) => void)[] = [];\r\n\r\n const publish = (data: T) => {\r\n subscribers.forEach(s => s(data));\r\n };\r\n\r\n const subscribe = (handler: (data: T) => void): Subscription => {\r\n subscribers.push(handler);\r\n const unsubscribe = () => {\r\n const idx = subscribers.indexOf(handler);\r\n if (idx > -1) subscribers.splice(idx, 1);\r\n };\r\n\r\n // Auto-unsubscribe if inside a component or effect scope that supports cleanup\r\n try {\r\n onCleanup(unsubscribe);\r\n } catch (e) {\r\n // Not in a context that supports auto-cleanup, ignore\r\n }\r\n\r\n return { unsubscribe };\r\n };\r\n\r\n const destroy = () => {\r\n subscribers = [];\r\n };\r\n\r\n return {\r\n publish,\r\n subscribe,\r\n destroy\r\n };\r\n}\r\n\r\nexport function toSubscriber<T>(topic: Topic<T>) {\r\n return {\r\n subscribe: (handler: (data: T) => void) => topic.subscribe(handler)\r\n };\r\n}\r\n","import { getCurrentInstance } from \"../component.js\";\r\nimport { AppContextKey, type AppContext } from \"../app.js\";\r\n\r\n// We need to define what a Component looks like for DI purposes\r\n// Since we removed HTMLElement dependency, we need to rely on the context structure\r\n// The context has a 'parent' property which points to the parent context or component instance.\r\n\r\nexport function inject<T>(token: any): T | undefined {\r\n const ctx = getCurrentInstance();\r\n // If called outside component, return undefined (or handle as needed)\r\n if (!ctx) return undefined;\r\n\r\n // Traverse up the tree\r\n // In our new architecture, ctx.parent is the parent VNode or Component Context\r\n // We need to standardize where 'provides' are stored.\r\n // Let's assume they are stored on the component instance (ctx) or VNode.\r\n\r\n let current: any = ctx;\r\n while (current) {\r\n if (current.provides && current.provides.has(token)) {\r\n return current.provides.get(token);\r\n }\r\n current = current.parent;\r\n }\r\n\r\n // Fallback: check app-level provides if we have an app context\r\n const appContext = getAppContext(ctx);\r\n if (appContext && appContext.provides.has(token)) {\r\n return appContext.provides.get(token);\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Get the app context from the current component context\r\n */\r\nfunction getAppContext(ctx: any): AppContext | null {\r\n // Walk up to find app context attached to root\r\n let current = ctx;\r\n while (current) {\r\n if (current._appContext) {\r\n return current._appContext;\r\n }\r\n current = current.parent;\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * Inject the App instance (useful for plugins)\r\n */\r\nexport function injectApp() {\r\n return inject(AppContextKey);\r\n}\r\n\r\nexport function provide<T>(token: any, value: T) {\r\n const ctx = getCurrentInstance();\r\n if (!ctx) {\r\n console.warn(\"provide called outside of component setup\");\r\n return;\r\n }\r\n\r\n if (!(ctx as any).provides) {\r\n (ctx as any).provides = new Map();\r\n }\r\n (ctx as any).provides.set(token, value);\r\n}\r\n\r\nconst globalInstances = new Map<any, any>();\r\n\r\nexport function defineInjectable<T>(factory: () => T) {\r\n const token = factory;\r\n\r\n const useFn = () => {\r\n const injected = inject<T>(token);\r\n if (injected) return injected;\r\n\r\n // Fallback to global singleton\r\n if (!globalInstances.has(token)) {\r\n globalInstances.set(token, factory());\r\n }\r\n return globalInstances.get(token);\r\n };\r\n\r\n // Attach metadata for defineProvide\r\n (useFn as any)._factory = factory;\r\n (useFn as any)._token = token;\r\n\r\n return useFn;\r\n}\r\n\r\nexport function defineProvide<T>(useFn: () => T): T {\r\n const factory = (useFn as any)._factory;\r\n const token = (useFn as any)._token;\r\n\r\n if (!factory || !token) {\r\n throw new Error(\"defineProvide must be called with a function created by defineInjectable\");\r\n }\r\n\r\n const instance = factory();\r\n provide(token, instance);\r\n return instance;\r\n}\r\n","import { defineInjectable } from \"./injectable.js\";\r\nimport { InstanceLifetimes, guid } from \"../models/index.js\";\r\nimport { onCleanup } from \"../component.js\";\r\n\r\nexport class SubscriptionHandler {\r\n private unsubs: (() => void)[] = [];\r\n add(unsub: () => void) {\r\n this.unsubs.push(unsub);\r\n }\r\n unsubscribe() {\r\n this.unsubs.forEach(u => u());\r\n this.unsubs = [];\r\n }\r\n}\r\n\r\nexport interface SetupFactoryContext {\r\n onDeactivated(fn: () => void): void;\r\n subscriptions: SubscriptionHandler;\r\n overrideDispose(onDispose: (fn: () => void) => void): void;\r\n}\r\n\r\nexport function defineFactory<InferReturnSetup>(\r\n setup: (ctx: SetupFactoryContext, ...args: any) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n): () => InferReturnSetup & { dispose?: () => void }\r\nexport function defineFactory<InferReturnSetup, T1>(\r\n setup: (ctx: SetupFactoryContext, param1: T1) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n): (param1: T1) => InferReturnSetup\r\nexport function defineFactory<InferReturnSetup, T1, T2>(\r\n setup: (ctx: SetupFactoryContext, param1: T1, param2: T2) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: string\r\n): (param1: T1, param2: T2) => InferReturnSetup\r\nexport function defineFactory<InferReturnSetup, T1, T2, T3>(\r\n setup: (ctx: SetupFactoryContext, param1: T1, param2: T2, param3: T3) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n): (param1: T1, param2: T2, param3: T3) => InferReturnSetup\r\nexport function defineFactory<InferReturnSetup, T1, T2, T3, T4>(\r\n setup: (ctx: SetupFactoryContext, param1: T1, param2: T2, param3: T3, param4: T4) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n): (param1: T1, param2: T2, param3: T3, param4: T4) => InferReturnSetup\r\nexport function defineFactory<InferReturnSetup, T1, T2, T3, T4, T5>(\r\n setup: (ctx: SetupFactoryContext, param1: T1, param2: T2, param3: T3, param4: T4, param5: T5) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n): (param1: T1, param2: T2, param3: T3, param4: T4, param5: T5) => InferReturnSetup\r\nexport function defineFactory<InferReturnSetup>(\r\n setup: (ctx: SetupFactoryContext, ...args: any) => InferReturnSetup,\r\n lifetime: InstanceLifetimes,\r\n typeIdentifier?: guid\r\n) {\r\n // The actual factory that creates the instance\r\n const factoryCreator = (...args: any[]) => {\r\n const subscriptions = new SubscriptionHandler();\r\n const deactivations = new Set<() => void>();\r\n let customDispose: ((fn: () => void) => void) | null = null;\r\n\r\n const ctx: SetupFactoryContext = {\r\n onDeactivated: (fn) => deactivations.add(fn),\r\n subscriptions,\r\n overrideDispose: (fn) => customDispose = fn\r\n };\r\n\r\n const result = setup(ctx, ...args);\r\n\r\n const dispose = () => {\r\n deactivations.forEach(d => d());\r\n subscriptions.unsubscribe();\r\n (result as any).dispose?.();\r\n };\r\n\r\n if (customDispose) {\r\n (customDispose as (fn: () => void) => void)(dispose);\r\n } else {\r\n // Auto-dispose if in component context\r\n try {\r\n onCleanup(() => dispose());\r\n } catch (e) { }\r\n }\r\n\r\n return { ...result, dispose };\r\n };\r\n\r\n // If it's a parameterless factory, we can make it injectable\r\n if (setup.length <= 1) {\r\n return defineInjectable(() => factoryCreator());\r\n }\r\n\r\n return factoryCreator;\r\n}\r\n","import { guid, Subscription, Topic, InstanceLifetimes, valueOf } from \"../models/index.js\";\r\nimport { createTopic, toSubscriber } from \"../messaging/index.js\";\r\nimport { defineFactory, SetupFactoryContext } from \"../di/factory.js\";\r\nimport { Utils } from \"../utils/index.js\";\r\nimport { signal, watch, effectScope, EffectScope } from \"@sigx/reactivity\";\r\n\r\ntype MaybeUndefined<T, I> = I extends true ? T | undefined : T;\r\n\r\ntype MutateFn<T> = (value: T | ((prev: T) => T)) => void;\r\n\r\ntype StoreStateContext<TState extends object, TInternalState extends object> = {\r\n state: TState;\r\n internalState: TInternalState;\r\n};\r\n\r\ntype StoreActionContext<TState extends object, TInternalState extends object, TGetters, TEvents extends Record<string, Topic<any>>, TSetup extends object> = StoreStateContext<TState, TInternalState> & {\r\n get: TGetters;\r\n mutate: {\r\n [K in keyof TState]: MutateFn<TState[K]>;\r\n };\r\n events: TEvents;\r\n setup: TSetup;\r\n};\r\n\r\nexport type StoreEvents<TState extends object, TEvents extends Record<string, Topic<any>> = {}> = {\r\n [K in keyof TState as `onMutated${Capitalize<string & K>}`]: ReturnType<typeof toSubscriber<TState[K]>>;\r\n\r\n} & TEvents;\r\n\r\ntype MapActionOnDispatching<T extends Function> = T extends (...args: infer U) => any ? (...args: U) => void : never;\r\ntype MapActionOnDispatched<T extends Function> = T extends (...args: infer U) => Promise<infer Y> | infer Y ? (result: Y, ...args: U) => void : never;\r\ntype MapActionOnFailure<T extends Function> = T extends (...args: infer U) => any ? (failureReason: any, ...args: U) => void : never;\r\n\r\nexport type StoreReturnDefineAction<TAction extends { [key: string]: any }> = {\r\n onDispatching: {\r\n [k in keyof TAction]: {\r\n subscribe(fn: MapActionOnDispatching<TAction[k]>): Subscription\r\n }\r\n }\r\n onDispatched: {\r\n [k in keyof TAction]: {\r\n subscribe(fn: MapActionOnDispatched<TAction[k]>): Subscription\r\n }\r\n }\r\n onFailure: {\r\n [k in keyof TAction]: {\r\n subscribe(fn: MapActionOnFailure<TAction[k]>): Subscription\r\n }\r\n }\r\n} & TAction\r\n\r\nexport interface SetupStoreContext extends SetupFactoryContext {\r\n defineState<\r\n TState extends object,\r\n TEvents extends Record<string, Topic<any>> = Record<string, Topic<any>>\r\n >(state: TState): {\r\n state: TState\r\n events: StoreEvents<TState, TEvents>\r\n mutate: {\r\n [K in keyof TState]: MutateFn<TState[K]>;\r\n };\r\n }\r\n defineActions<TActions extends { [key: string]: any }>(actions: TActions): StoreReturnDefineAction<TActions>\r\n}\r\n\r\nexport interface IReturnSetupStore<TState, TGetters, TActions extends { [key: string]: Function }, TEvents> {\r\n state?: TState\r\n get?: TGetters\r\n actions?: StoreReturnDefineAction<TActions>\r\n events?: TEvents\r\n name?: string\r\n}\r\n\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>>(name: string, setup: (ctx: SetupStoreContext) => InferReturnSetup, lifetime?: InstanceLifetimes): ReturnType<typeof defineFactory<InferReturnSetup>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>, T1>(name: string, setup: (ctx: SetupStoreContext, param1: T1) => InferReturnSetup, lifetime?: InstanceLifetimes): ReturnType<typeof defineFactory<InferReturnSetup, T1>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>, T1, T2>(name: string, setup: (ctx: SetupStoreContext, param1: T1, param2: T2) => InferReturnSetup, lifetime?: InstanceLifetimes): ReturnType<typeof defineFactory<InferReturnSetup, T1, T2>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>, T1, T2, T3>(name: string, setup: (ctx: SetupStoreContext, param1: T1, param2: T2, param3: T3, lifetime?: InstanceLifetimes) => InferReturnSetup): ReturnType<typeof defineFactory<InferReturnSetup, T1, T2, T3>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>, T1, T2, T3, T4>(name: string, setup: (ctx: SetupStoreContext, param1: T1, param2: T2, param3: T3, param4: T4, lifetime?: InstanceLifetimes) => InferReturnSetup): ReturnType<typeof defineFactory<InferReturnSetup, T1, T2, T3, T4>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>, T1, T2, T3, T4, T5>(name: string, setup: (ctx: SetupStoreContext, param1: T1, param2: T2, param3: T3, param4: T4, param5: T5) => InferReturnSetup, lifetime?: InstanceLifetimes): ReturnType<typeof defineFactory<InferReturnSetup, T1, T2, T3, T4, T5>>\r\nexport function defineStore<\r\n TState extends object,\r\n TGetters extends object,\r\n TActions extends { [key: string]: any },\r\n TEvents extends Record<string, ReturnType<typeof toSubscriber<any>>>,\r\n InferReturnSetup extends IReturnSetupStore<TState, TGetters, TActions, TEvents>\r\n>(name: string, setup: (ctx: SetupStoreContext, ...args: any) => InferReturnSetup, lifetime = InstanceLifetimes.Scoped) {\r\n\r\n return defineFactory<InferReturnSetup>((ctxFactory, ...args: any) => {\r\n const scope = effectScope(true);\r\n let messages: Topic<any>[] | null = [] satisfies Topic<any>[];\r\n const instanceId = guid();\r\n const id = `${name}_${instanceId}`;\r\n\r\n const result = setup({\r\n ...ctxFactory,\r\n defineState: (state) => {\r\n return defineState(state, id, scope, messages!);\r\n },\r\n defineActions: (actions) => {\r\n return defineActions(actions, id, messages!);\r\n }\r\n }, ...args);\r\n\r\n ctxFactory.onDeactivated(() => {\r\n scope.stop();\r\n messages?.forEach(m => m.destroy());\r\n messages = null;\r\n });\r\n\r\n // add store name for easy debugging\r\n if (!result.name) {\r\n result.name = id;\r\n }\r\n return result;\r\n }, lifetime);\r\n}\r\n\r\nfunction defineActions<\r\n TAction extends { [key: string]: any }\r\n>(\r\n actions: TAction,\r\n storeInstanceName: string,\r\n messages: Topic<any>[]\r\n): StoreReturnDefineAction<TAction> {\r\n const events: { [key: string]: Topic<any> } = {};\r\n const namespace = `${storeInstanceName}.actions.${guid()}`;\r\n\r\n const onDispatching: any = {};\r\n const onDispatched: any = {};\r\n const onFailure: any = {};\r\n const result: any = {\r\n onDispatching,\r\n onDispatched,\r\n onFailure\r\n };\r\n\r\n function getEvent(actionName: string, type: \"onDispatching\" | \"onDispatched\" | \"onFailure\") {\r\n const name = `${actionName}.${type}`;\r\n if (!events[name]) {\r\n events[name] = createTopic({\r\n namespace: namespace,\r\n name: name\r\n });\r\n messages.push(events[name]);\r\n }\r\n return events[name];\r\n }\r\n\r\n Object.keys(actions).forEach(actionName => {\r\n // Setup event subscribers\r\n onDispatching[actionName] = {\r\n subscribe: (fn: Function) => {\r\n return getEvent(actionName, \"onDispatching\").subscribe(function (this: any) {\r\n fn.apply(this, arguments[0]);\r\n });\r\n }\r\n };\r\n onDispatched[actionName] = {\r\n subscribe: (fn: Function) => {\r\n return getEvent(actionName, \"onDispatched\").subscribe(function (this: any) {\r\n const msg: { result: any; args: IArguments; } = arguments[0];\r\n const allArguments = [msg.result].concat(Array.from(msg.args));\r\n fn.apply(this, allArguments);\r\n });\r\n }\r\n };\r\n onFailure[actionName] = {\r\n subscribe: (fn: Function) => {\r\n return getEvent(actionName, \"onFailure\").subscribe(function (this: any) {\r\n const msg: { reason: any; args: IArguments; } = arguments[0];\r\n const allArguments = [msg.reason].concat(Array.from(msg.args));\r\n fn.apply(this, allArguments);\r\n });\r\n }\r\n };\r\n\r\n // Wrap action\r\n result[actionName] = function (this: any) {\r\n try {\r\n const currentArguments = arguments;\r\n getEvent(actionName, \"onDispatching\").publish(currentArguments);\r\n\r\n const returnedResult = actions[actionName].apply(this, currentArguments);\r\n if (Utils.isPromise(returnedResult)) {\r\n (returnedResult as Promise<any>).then(result => {\r\n getEvent(actionName, \"onDispatched\").publish({ result: returnedResult, args: currentArguments });\r\n });\r\n }\r\n else {\r\n getEvent(actionName, \"onDispatched\").publish({ result: returnedResult, args: currentArguments });\r\n }\r\n\r\n return returnedResult;\r\n }\r\n catch (err) {\r\n console.error(err);\r\n getEvent(actionName, \"onFailure\").publish({ reason: err, args: arguments });\r\n }\r\n };\r\n });\r\n\r\n return result;\r\n}\r\n\r\nfunction defineState<\r\n TState extends object,\r\n TEvents extends Record<string, Topic<any>>\r\n>(\r\n value: TState,\r\n storeInstanceName: string,\r\n scope: EffectScope,\r\n messages: Topic<any>[]\r\n) {\r\n\r\n // Use signal directly for the state\r\n const state = signal(value);\r\n const events: any = {};\r\n const mutate: any = {};\r\n\r\n function initProperty(key: string) {\r\n // Setup watcher\r\n scope.run(() => {\r\n watch(() => (state as any)[key], (newValue: any) => {\r\n triggerEvent(key, newValue);\r\n }, { deep: true, immediate: true });\r\n });\r\n\r\n // Setup mutate\r\n mutate[key] = (val: any) => {\r\n try {\r\n let newValue;\r\n if (typeof val === \"function\") {\r\n newValue = val((state as any)[key]);\r\n } else {\r\n newValue = val;\r\n }\r\n (state as any)[key] = newValue;\r\n } catch (err) {\r\n console.error(err);\r\n }\r\n };\r\n\r\n // Setup event\r\n const eventKey = `onMutated${key.charAt(0).toUpperCase()}${key.slice(1)}`;\r\n if (!events[eventKey]) {\r\n const topic = createTopic({\r\n namespace: `${storeInstanceName}.events`,\r\n name: eventKey\r\n });\r\n events[eventKey] = topic;\r\n messages.push(topic);\r\n }\r\n }\r\n\r\n function triggerEvent(name: string, value: any) {\r\n const keyString = name;\r\n const afterEventKey = `onMutated${keyString.charAt(0).toUpperCase()}${keyString.slice(1)}`;\r\n events[afterEventKey]?.publish(value);\r\n }\r\n\r\n if (value) {\r\n Object.keys(value).forEach(key => {\r\n initProperty(key);\r\n });\r\n }\r\n\r\n return {\r\n state: state as TState,\r\n events: events as StoreEvents<TState, TEvents>,\r\n mutate: mutate as StoreActionContext<TState, {}, {}, TEvents, {}>[\"mutate\"]\r\n };\r\n}\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 // 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 (typeof vnode.props.ref === 'object') {\r\n vnode.props.ref.current = element;\r\n }\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"],"mappings":";;;AA0BA,IAAIA,wBAA8C;;;;;AAMlD,SAAgB,yBAAyB,IAAyB;AAC9D,yBAAwB;;;;;AAM5B,SAAgB,2BAAiD;AAC7D,QAAO;;;;;ACxBX,MAAMC,UAA6B,EAAE;AAErC,SAAgB,wBAAwB,QAA+B;AACnE,SAAQ,KAAK,OAAO;;;;;AAMxB,SAAgB,sBAAkD;AAC9D,QAAO;;;;;ACSX,MAAM,QAAQ,OAAO,YAAY,eAAe,QAA0C;;;;AAS1F,MAAa,gBAAgB,OAAO,WAAW;AAM/C,IAAIC,iBAAsC;;;;;;;;;;;;AAa1C,SAAgB,gBA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AU,KAAM,QAAO,EAAE;AAC7B,YAAO,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;;IAIpD,MAAM,EAAE,eAAe,8BAA8B,OAAO,UAAU;AACtE,WAAO,WAAW,SAAS,EAAE;;KAM5C,CAAC;;;;;CAMN,SAAS,iBAAiB,QAA0C;AAChE,MAAI,MAAM,QAAQ,OAAO,CACrB,QAAO;GACH,MAAM;GACN,OAAO,EAAE;GACT,KAAK;GACL,UAAU;GACV,KAAK;GACR;AAEL,MAAI,OAAO,WAAW,YAAY,OAAO,WAAW,SAChD,QAAO;GACH,MAAM;GACN,OAAO,EAAE;GACT,KAAK;GACL,UAAU,EAAE;GACZ,KAAK;GACL,MAAM;GACT;AAEL,SAAO;;AAGX,QAAO;EACH;EACA,YAAY,kBAAuB;AAE/B,UAAO,EACH,MAAM,qBAA2C;IAC7C,IAAIC,YAAgC;AACpC,QAAI,OAAO,wBAAwB,UAC/B;SAAI,QAAQ,cACR,aAAY,QAAQ,cAAc,oBAAoB;UAG1D,aAAY;AAGhB,QAAI,CAAC,WAAW;AACZ,aAAQ,KAAK,wBAAwB,sBAAsB;AAC3D;;AAGJ,WAAO,eAAe,UAAU;MAEvC;;EAER"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sigx/runtime-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Runtime core for SignalX",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,10 +41,12 @@
|
|
|
41
41
|
"url": "https://github.com/signalxjs/core/issues"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@sigx/reactivity": "
|
|
44
|
+
"@sigx/reactivity": "workspace:^"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.0.0",
|
|
47
48
|
"rolldown": "^1.0.0-beta.52",
|
|
48
49
|
"typescript": "^5.9.3"
|
|
49
50
|
}
|
|
50
|
-
}
|
|
51
|
+
}
|
|
52
|
+
|