@almadar/ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../renderer/pattern-resolver.ts","../../renderer/client-effect-executor.ts","../../renderer/useClientEffects.ts","../../renderer/data-resolver.ts","../../renderer/slot-definitions.ts","../../renderer/offline-executor.ts","../../renderer/init.ts"],"names":["useRef","useEffect","useCallback","componentMapping","patternRegistry"],"mappings":";;;;;;;;;AA4CA,IAAI,mBAA0D,EAAC;AAC/D,IAAI,kBAAqD,EAAC;AAMnD,SAAS,0BAA0B,MAAA,EAGjC;AACP,EAAA,gBAAA,GAAmB,MAAA,CAAO,gBAAA;AAC1B,EAAA,eAAA,GAAkB,MAAA,CAAO,eAAA;AAC3B;AAKO,SAAS,oBACd,OAAA,EACM;AACN,EAAA,gBAAA,GAAmB,OAAA;AACrB;AAKO,SAAS,mBACd,QAAA,EACM;AACN,EAAA,eAAA,GAAkB,QAAA;AACpB;AAwBO,SAAS,eAAe,MAAA,EAAwC;AACrE,EAAA,MAAM,EAAE,IAAA,EAAM,GAAG,KAAA,EAAM,GAAI,MAAA;AAG3B,EAAA,MAAM,OAAA,GAAU,iBAAiB,IAAI,CAAA;AACrC,EAAA,IAAI,CAAC,OAAA,EAAS;AAEZ,IAAA,IAAI,MAAA,CAAO,IAAA,CAAK,gBAAgB,CAAA,CAAE,WAAW,CAAA,EAAG;AAC9C,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OAEF;AAAA,IACF;AACA,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,sBAAA,EAAyB,IAAI,CAAA,CAAE,CAAA;AAAA,EACjD;AAGA,EAAA,IAAI,QAAQ,UAAA,EAAY;AACtB,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN,CAAA,2BAAA,EAA8B,IAAI,CAAA,gBAAA,CAAA,IACjC,OAAA,CAAQ,aAAa,CAAA,MAAA,EAAS,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A,OAAA,CAAQ,GAAA,CAAI,2CAA2C,oBAAoB,CAAA;AAC3E,EAAA,OAAA,CAAQ,GAAA,CAAI,sCAAA,EAAwC,MAAA,CAAO,IAAA,CAAK,YAAY,CAAC,CAAA;AAG7E,EAAA,MAAM,oBAAA,GAAuB,oBAAA;AAC7B,EAAA,MAAMC,iBAAAA,GAAmB,oBAAA,CAAqB,QAAA,IAAY,EAAC;AAE3D,EAAA,OAAA,CAAQ,IAAI,6CAAA,EAA+C,MAAA,CAAO,IAAA,CAAKA,iBAAgB,EAAE,MAAM,CAAA;AAC/F,EAAA,OAAA,CAAQ,GAAA,CAAI,sCAAsC,MAAA,CAAO,IAAA,CAAKA,iBAAgB,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA;AAG3F,EAAA,MAAM,YAAA,GAAe,YAAA;AACrB,EAAA,MAAMC,gBAAAA,GAAkB,YAAA,CAAa,QAAA,IAAY,EAAC;AAElD,EAAA,OAAA,CAAQ,IAAI,6CAAA,EAA+C,MAAA,CAAO,IAAA,CAAKA,gBAAe,EAAE,MAAM,CAAA;AAI9F,EAAA,yBAAA,CAA0B;AAAA,IACxB,gBAAA,EAAAD,iBAAAA;AAAA;AAAA,IAEA,eAAA,EAAiBC;AAAA,GAClB,CAAA;AAED,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,mCAAA,EAAsC,MAAA,CAAO,IAAA,CAAKD,iBAAgB,CAAA,CAAE,MAAM,CAAA,wBAAA,EAA2B,MAAA,CAAO,IAAA,CAAKC,gBAAe,CAAA,CAAE,MAAM,CAAA,oBAAA,CAAsB,CAAA;AAE1K,EAAA,OAAO,MAAA,CAAO,IAAA,CAAKD,iBAAgB,CAAA,CAAE,MAAA;AACvC","file":"index.js","sourcesContent":["/**\n * Pattern Resolver\n *\n * Resolves pattern configurations to component information.\n * Uses the central pattern registry and component mapping from orbital-shared/patterns/.\n *\n * This is the shared logic used by both Builder's PatternRenderer and\n * the compiled shell's UISlotRenderer.\n *\n * @packageDocumentation\n */\n\nimport type { PatternConfig, ResolvedPattern } from './types';\n\n// ============================================================================\n// Component Mapping (imported from orbital-shared/patterns/)\n// ============================================================================\n\n/**\n * Component mapping entry from component-mapping.json\n */\ninterface ComponentMappingEntry {\n component: string;\n importPath: string;\n category: string;\n deprecated?: boolean;\n replacedBy?: string;\n}\n\n/**\n * Pattern definition from registry.json\n */\ninterface PatternDefinition {\n type: string;\n category: string;\n description: string;\n propsSchema?: Record<string, {\n required?: boolean;\n types?: string[];\n description?: string;\n }>;\n}\n\n// These will be populated by the sync process or at runtime\nlet componentMapping: Record<string, ComponentMappingEntry> = {};\nlet patternRegistry: Record<string, PatternDefinition> = {};\n\n/**\n * Initialize the pattern resolver with mappings.\n * Called at app startup with data from JSON files.\n */\nexport function initializePatternResolver(config: {\n componentMapping: Record<string, ComponentMappingEntry>;\n patternRegistry: Record<string, PatternDefinition>;\n}): void {\n componentMapping = config.componentMapping;\n patternRegistry = config.patternRegistry;\n}\n\n/**\n * Set component mapping (alternative to full initialization).\n */\nexport function setComponentMapping(\n mapping: Record<string, ComponentMappingEntry>\n): void {\n componentMapping = mapping;\n}\n\n/**\n * Set pattern registry (alternative to full initialization).\n */\nexport function setPatternRegistry(\n registry: Record<string, PatternDefinition>\n): void {\n patternRegistry = registry;\n}\n\n// ============================================================================\n// Pattern Resolution\n// ============================================================================\n\n/**\n * Resolve a pattern configuration to component information.\n *\n * @param config - Pattern configuration from render-ui effect\n * @returns Resolved pattern with component name, import path, and validated props\n * @throws Error if pattern type is unknown\n *\n * @example\n * ```typescript\n * const resolved = resolvePattern({\n * type: 'entity-table',\n * entity: 'Task',\n * columns: ['title', 'status']\n * });\n * // resolved.component === 'DataTable'\n * // resolved.importPath === '@/components/organisms/DataTable'\n * ```\n */\nexport function resolvePattern(config: PatternConfig): ResolvedPattern {\n const { type, ...props } = config;\n\n // Look up component mapping\n const mapping = componentMapping[type];\n if (!mapping) {\n // Check if we have any mappings loaded\n if (Object.keys(componentMapping).length === 0) {\n console.warn(\n '[PatternResolver] Component mapping not initialized. ' +\n 'Call initializePatternResolver() at app startup.'\n );\n }\n throw new Error(`Unknown pattern type: ${type}`);\n }\n\n // Check for deprecated patterns\n if (mapping.deprecated) {\n console.warn(\n `[PatternResolver] Pattern \"${type}\" is deprecated.` +\n (mapping.replacedBy ? ` Use \"${mapping.replacedBy}\" instead.` : '')\n );\n }\n\n // Validate props against registry schema\n const validatedProps = validatePatternProps(type, props);\n\n return {\n component: mapping.component,\n importPath: mapping.importPath,\n category: mapping.category,\n validatedProps,\n };\n}\n\n/**\n * Validate pattern props against the registry schema.\n * Returns normalized props with defaults applied.\n */\nfunction validatePatternProps(\n patternType: string,\n props: Record<string, unknown>\n): Record<string, unknown> {\n const definition = patternRegistry[patternType];\n\n // If no definition, return props as-is (allow unknown patterns)\n if (!definition || !definition.propsSchema) {\n return props;\n }\n\n const validated: Record<string, unknown> = { ...props };\n const schema = definition.propsSchema;\n\n // Check required props\n for (const [propName, propDef] of Object.entries(schema)) {\n if (propDef.required && !(propName in validated)) {\n // Don't throw, just warn - allows for flexibility\n console.warn(\n `[PatternResolver] Missing required prop \"${propName}\" for pattern \"${patternType}\"`\n );\n }\n }\n\n return validated;\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Check if a pattern type is known.\n */\nexport function isKnownPattern(type: string): boolean {\n return type in componentMapping;\n}\n\n/**\n * Get all known pattern types.\n */\nexport function getKnownPatterns(): string[] {\n return Object.keys(componentMapping);\n}\n\n/**\n * Get patterns by category.\n */\nexport function getPatternsByCategory(category: string): string[] {\n return Object.entries(componentMapping)\n .filter(([, mapping]) => mapping.category === category)\n .map(([type]) => type);\n}\n\n/**\n * Get the component mapping for a pattern type.\n */\nexport function getPatternMapping(\n type: string\n): ComponentMappingEntry | undefined {\n return componentMapping[type];\n}\n\n/**\n * Get the pattern definition from the registry.\n */\nexport function getPatternDefinition(\n type: string\n): PatternDefinition | undefined {\n return patternRegistry[type];\n}\n","/**\n * Client Effect Executor\n *\n * Executes client effects returned from the server.\n * This is the core of the dual execution model - the server processes\n * events and returns client effects, which this module executes.\n *\n * Used by both Builder preview and compiled shells.\n *\n * @packageDocumentation\n */\n\nimport type {\n ClientEffect,\n ClientEffectExecutorConfig,\n PatternConfig,\n NotifyOptions,\n} from './types';\n\n// ============================================================================\n// Effect Execution\n// ============================================================================\n\n/**\n * Execute an array of client effects.\n *\n * Effects are executed sequentially in order.\n * Errors in one effect don't prevent subsequent effects from executing.\n *\n * @param effects - Array of client effects to execute\n * @param config - Configuration providing implementations for each effect type\n *\n * @example\n * ```typescript\n * executeClientEffects(\n * [\n * ['render-ui', 'main', { type: 'entity-table', entity: 'Task' }],\n * ['notify', 'Tasks loaded!', { type: 'success' }]\n * ],\n * {\n * renderToSlot: (slot, pattern) => slotManager.render(slot, pattern),\n * navigate: (path) => router.push(path),\n * notify: (message, opts) => toast.show(message, opts),\n * eventBus: { emit: (event, payload) => bus.emit(event, payload) }\n * }\n * );\n * ```\n */\nexport function executeClientEffects(\n effects: ClientEffect[],\n config: ClientEffectExecutorConfig\n): void {\n if (!effects || effects.length === 0) {\n return;\n }\n\n for (const effect of effects) {\n try {\n executeEffect(effect, config);\n } catch (error) {\n console.error(\n `[ClientEffectExecutor] Error executing effect:`,\n effect,\n error\n );\n }\n }\n\n // Call onComplete callback if provided\n config.onComplete?.();\n}\n\n/**\n * Execute a single client effect.\n */\nfunction executeEffect(\n effect: ClientEffect,\n config: ClientEffectExecutorConfig\n): void {\n const [effectType, ...args] = effect;\n\n switch (effectType) {\n case 'render-ui': {\n const [slot, patternConfig] = args as [string, PatternConfig | null];\n executeRenderUI(slot, patternConfig, config);\n break;\n }\n\n case 'navigate': {\n const [path, params] = args as [string, Record<string, unknown>?];\n executeNavigate(path, params, config);\n break;\n }\n\n case 'notify': {\n const [message, options] = args as [string, NotifyOptions?];\n executeNotify(message, options, config);\n break;\n }\n\n case 'emit': {\n const [event, payload] = args as [string, unknown?];\n executeEmit(event, payload, config);\n break;\n }\n\n default:\n console.warn(`[ClientEffectExecutor] Unknown effect type: ${effectType}`);\n }\n}\n\n// ============================================================================\n// Individual Effect Handlers\n// ============================================================================\n\n/**\n * Execute a render-ui effect.\n *\n * If patternConfig is null, the slot is cleared.\n */\nfunction executeRenderUI(\n slot: string,\n patternConfig: PatternConfig | null,\n config: ClientEffectExecutorConfig\n): void {\n config.renderToSlot(slot, patternConfig);\n}\n\n/**\n * Execute a navigate effect.\n */\nfunction executeNavigate(\n path: string,\n params: Record<string, unknown> | undefined,\n config: ClientEffectExecutorConfig\n): void {\n config.navigate(path, params);\n}\n\n/**\n * Execute a notify effect.\n */\nfunction executeNotify(\n message: string,\n options: NotifyOptions | undefined,\n config: ClientEffectExecutorConfig\n): void {\n config.notify(message, options);\n}\n\n/**\n * Execute an emit effect.\n */\nfunction executeEmit(\n event: string,\n payload: unknown | undefined,\n config: ClientEffectExecutorConfig\n): void {\n config.eventBus.emit(event, payload);\n}\n\n// ============================================================================\n// Effect Parsing Utilities\n// ============================================================================\n\n/**\n * Parse a raw effect array into a typed ClientEffect.\n * Handles unknown effect formats gracefully.\n */\nexport function parseClientEffect(\n raw: unknown[]\n): ClientEffect | null {\n if (!Array.isArray(raw) || raw.length < 1) {\n console.warn('[ClientEffectExecutor] Invalid effect format:', raw);\n return null;\n }\n\n const [type, ...args] = raw;\n\n if (typeof type !== 'string') {\n console.warn('[ClientEffectExecutor] Effect type must be string:', raw);\n return null;\n }\n\n switch (type) {\n case 'render-ui':\n return ['render-ui', args[0] as string, args[1] as PatternConfig | null];\n case 'navigate':\n return ['navigate', args[0] as string, args[1] as Record<string, unknown>];\n case 'notify':\n return ['notify', args[0] as string, args[1] as NotifyOptions];\n case 'emit':\n return ['emit', args[0] as string, args[1]];\n default:\n console.warn(`[ClientEffectExecutor] Unknown effect type: ${type}`);\n return null;\n }\n}\n\n/**\n * Parse an array of raw effects into typed ClientEffects.\n * Filters out invalid effects.\n */\nexport function parseClientEffects(\n raw: unknown[] | undefined\n): ClientEffect[] {\n if (!raw || !Array.isArray(raw)) {\n return [];\n }\n\n return raw\n .map((effect) => parseClientEffect(effect as unknown[]))\n .filter((effect): effect is ClientEffect => effect !== null);\n}\n\n// ============================================================================\n// Effect Filtering\n// ============================================================================\n\n/**\n * Filter effects by type.\n */\nexport function filterEffectsByType<T extends ClientEffect[0]>(\n effects: ClientEffect[],\n type: T\n): Extract<ClientEffect, [T, ...unknown[]]>[] {\n return effects.filter(\n (effect): effect is Extract<ClientEffect, [T, ...unknown[]]> =>\n effect[0] === type\n );\n}\n\n/**\n * Get all render-ui effects.\n */\nexport function getRenderUIEffects(\n effects: ClientEffect[]\n): Array<['render-ui', string, PatternConfig | null]> {\n return filterEffectsByType(effects, 'render-ui');\n}\n\n/**\n * Get all navigate effects.\n */\nexport function getNavigateEffects(\n effects: ClientEffect[]\n): Array<['navigate', string, Record<string, unknown>?]> {\n return filterEffectsByType(effects, 'navigate');\n}\n\n/**\n * Get all notify effects.\n */\nexport function getNotifyEffects(\n effects: ClientEffect[]\n): Array<['notify', string, NotifyOptions?]> {\n return filterEffectsByType(effects, 'notify');\n}\n\n/**\n * Get all emit effects.\n */\nexport function getEmitEffects(\n effects: ClientEffect[]\n): Array<['emit', string, unknown?]> {\n return filterEffectsByType(effects, 'emit');\n}\n","/**\n * useClientEffects Hook\n *\n * React hook for executing client effects from server responses.\n * Handles effect tracking to prevent duplicate executions and\n * integrates with the client effect executor.\n *\n * Used by both Builder preview and compiled shell trait hooks.\n *\n * @packageDocumentation\n */\n\nimport { useEffect, useRef, useCallback } from 'react';\nimport { executeClientEffects } from './client-effect-executor';\nimport type { ClientEffect, ClientEffectExecutorConfig } from './types';\n\n// ============================================================================\n// Hook Types\n// ============================================================================\n\n/**\n * Options for the useClientEffects hook\n */\nexport interface UseClientEffectsOptions extends ClientEffectExecutorConfig {\n /**\n * Whether to execute effects. Defaults to true.\n * Set to false to temporarily disable effect execution.\n */\n enabled?: boolean;\n\n /**\n * Debug mode - logs effect execution details.\n */\n debug?: boolean;\n}\n\n/**\n * Result of useClientEffects hook\n */\nexport interface UseClientEffectsResult {\n /**\n * Number of effects executed in the last batch.\n */\n executedCount: number;\n\n /**\n * Whether effects are currently being executed.\n */\n executing: boolean;\n\n /**\n * Manually trigger effect execution.\n * Useful for imperative control.\n */\n execute: (effects: ClientEffect[]) => void;\n}\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Execute client effects from server response.\n *\n * This hook automatically executes effects when they change,\n * tracking which effects have been executed to prevent duplicates.\n *\n * @param effects - Array of client effects to execute (from server response)\n * @param options - Configuration including effect implementations\n * @returns Hook result with execution state and manual trigger\n *\n * @example\n * ```typescript\n * function useMyTrait() {\n * const [state, setState] = useState({ pendingEffects: [] });\n * const effectConfig = useClientEffectConfig();\n *\n * useClientEffects(state.pendingEffects, {\n * ...effectConfig,\n * onComplete: () => setState(s => ({ ...s, pendingEffects: [] }))\n * });\n *\n * // ...\n * }\n * ```\n */\nexport function useClientEffects(\n effects: ClientEffect[] | undefined,\n options: UseClientEffectsOptions\n): UseClientEffectsResult {\n const {\n enabled = true,\n debug = false,\n onComplete,\n ...config\n } = options;\n\n // Track executed effects to prevent duplicate execution\n const executedRef = useRef<Set<string>>(new Set());\n const executingRef = useRef(false);\n const executedCountRef = useRef(0);\n\n // Generate a unique key for an effect (for deduplication)\n const getEffectKey = useCallback((effect: ClientEffect): string => {\n return JSON.stringify(effect);\n }, []);\n\n // Manual execute function\n const execute = useCallback((effectsToExecute: ClientEffect[]) => {\n if (executingRef.current || effectsToExecute.length === 0) {\n return;\n }\n\n executingRef.current = true;\n\n // Filter out already executed effects\n const newEffects = effectsToExecute.filter((effect) => {\n const key = getEffectKey(effect);\n if (executedRef.current.has(key)) {\n if (debug) {\n console.log('[useClientEffects] Skipping duplicate effect:', effect);\n }\n return false;\n }\n return true;\n });\n\n if (newEffects.length === 0) {\n executingRef.current = false;\n return;\n }\n\n if (debug) {\n console.log('[useClientEffects] Executing effects:', newEffects);\n }\n\n // Mark effects as executed\n newEffects.forEach((effect) => {\n executedRef.current.add(getEffectKey(effect));\n });\n\n // Execute effects\n executeClientEffects(newEffects, {\n ...config,\n onComplete: () => {\n executedCountRef.current = newEffects.length;\n executingRef.current = false;\n onComplete?.();\n },\n });\n }, [config, debug, getEffectKey, onComplete]);\n\n // Automatic execution on effects change\n useEffect(() => {\n if (!enabled || !effects || effects.length === 0) {\n return;\n }\n\n execute(effects);\n }, [effects, enabled, execute]);\n\n // Reset executed tracking when effects array reference changes\n // (indicates a new batch of effects from a new event response)\n const prevEffectsRef = useRef<ClientEffect[] | undefined>();\n useEffect(() => {\n if (effects !== prevEffectsRef.current) {\n // New effects array - this is a new batch\n // Keep the executed set but allow these new effects to execute\n prevEffectsRef.current = effects;\n }\n }, [effects]);\n\n return {\n executedCount: executedCountRef.current,\n executing: executingRef.current,\n execute,\n };\n}\n\n// ============================================================================\n// Effect Config Context Hook\n// ============================================================================\n\n/**\n * Context for client effect configuration.\n * This should be provided at the app root by OrbitalProvider.\n */\nimport { createContext, useContext } from 'react';\n\nconst ClientEffectConfigContext = createContext<ClientEffectExecutorConfig | null>(null);\n\n/**\n * Provider for client effect configuration.\n */\nexport const ClientEffectConfigProvider = ClientEffectConfigContext.Provider;\n\n/**\n * Hook to get the client effect configuration from context.\n *\n * @throws Error if used outside of ClientEffectConfigProvider\n *\n * @example\n * ```typescript\n * function MyTraitHook() {\n * const effectConfig = useClientEffectConfig();\n *\n * useClientEffects(pendingEffects, {\n * ...effectConfig,\n * onComplete: () => clearPendingEffects()\n * });\n * }\n * ```\n */\nexport function useClientEffectConfig(): ClientEffectExecutorConfig {\n const context = useContext(ClientEffectConfigContext);\n\n if (!context) {\n throw new Error(\n 'useClientEffectConfig must be used within a ClientEffectConfigProvider. ' +\n 'Make sure your component tree is wrapped with OrbitalProvider.'\n );\n }\n\n return context;\n}\n\n/**\n * Hook to get client effect configuration, returning null if not available.\n * Use this for optional integration where effects may not be configured.\n */\nexport function useClientEffectConfigOptional(): ClientEffectExecutorConfig | null {\n return useContext(ClientEffectConfigContext);\n}\n\n// Export the context for direct use\nexport { ClientEffectConfigContext };\n","/**\n * Data Resolver\n *\n * Resolves entity data for pattern rendering.\n * Supports multiple data sources with priority:\n * 1. Server-provided data (from EventResponse.data)\n * 2. Entity store (Builder in-memory mock data)\n * 3. Empty array (fallback)\n *\n * Used by both Builder's PatternRenderer and compiled shell's UISlotRenderer.\n *\n * @packageDocumentation\n */\n\nimport type { DataContext, DataResolution } from './types';\n\n// ============================================================================\n// Data Resolution\n// ============================================================================\n\n/**\n * Resolve entity data from available sources.\n *\n * Priority:\n * 1. fetchedData (from server response) - highest priority\n * 2. entityStore (Builder mock data)\n * 3. Empty array (fallback)\n *\n * @param entityName - Name of the entity to resolve data for\n * @param context - Data context with available sources\n * @returns Resolved data with loading state\n *\n * @example\n * ```typescript\n * const { data, loading } = resolveEntityData('Task', {\n * fetchedData: response.data,\n * entityStore: mockStore\n * });\n * ```\n */\nexport function resolveEntityData(\n entityName: string,\n context: DataContext\n): DataResolution {\n // 1. Server-provided data (highest priority)\n if (context.fetchedData && entityName in context.fetchedData) {\n const data = context.fetchedData[entityName];\n return {\n data: Array.isArray(data) ? data : [],\n loading: false,\n };\n }\n\n // 2. Entity store (Builder mock data)\n if (context.entityStore) {\n try {\n const data = context.entityStore.getRecords(entityName);\n return {\n data: Array.isArray(data) ? data : [],\n loading: false,\n };\n } catch (error) {\n console.warn(\n `[DataResolver] Error getting records from entity store for \"${entityName}\":`,\n error\n );\n }\n }\n\n // 3. Fallback - no data available\n // Return empty but indicate loading if we expect data to come\n const hasAnySources = context.fetchedData || context.entityStore;\n return {\n data: [],\n loading: !hasAnySources, // Only loading if no sources configured\n };\n}\n\n/**\n * Resolve entity data with query filtering.\n *\n * Applies query singleton filters if available.\n *\n * @param entityName - Name of the entity\n * @param queryRef - Optional query reference for filtering\n * @param context - Data context\n * @returns Filtered resolved data\n */\nexport function resolveEntityDataWithQuery(\n entityName: string,\n queryRef: string | undefined,\n context: DataContext\n): DataResolution {\n // First resolve the base data\n const resolution = resolveEntityData(entityName, context);\n\n // If no query ref or no query singleton, return unfiltered\n if (!queryRef || !context.querySingleton) {\n return resolution;\n }\n\n // Apply query filters\n try {\n const filters = context.querySingleton.getFilters(queryRef);\n const filteredData = applyFilters(resolution.data, filters);\n return {\n ...resolution,\n data: filteredData,\n };\n } catch (error) {\n console.warn(\n `[DataResolver] Error applying query filters for \"${queryRef}\":`,\n error\n );\n return resolution;\n }\n}\n\n// ============================================================================\n// Filtering\n// ============================================================================\n\n/**\n * Apply filters to a data array.\n * Simple equality-based filtering.\n */\nfunction applyFilters(\n data: unknown[],\n filters: Record<string, unknown>\n): unknown[] {\n if (!filters || Object.keys(filters).length === 0) {\n return data;\n }\n\n return data.filter((item) => {\n if (typeof item !== 'object' || item === null) {\n return false;\n }\n\n const record = item as Record<string, unknown>;\n return Object.entries(filters).every(([key, value]) => {\n // Handle undefined/null filter values (match all)\n if (value === undefined || value === null) {\n return true;\n }\n\n // Get the record value\n const recordValue = record[key];\n\n // Handle array values (check if recordValue is in the array)\n if (Array.isArray(value)) {\n return value.includes(recordValue);\n }\n\n // Handle string patterns (simple contains)\n if (typeof value === 'string' && typeof recordValue === 'string') {\n if (value.startsWith('*') && value.endsWith('*')) {\n const pattern = value.slice(1, -1);\n return recordValue.toLowerCase().includes(pattern.toLowerCase());\n }\n }\n\n // Equality comparison\n return recordValue === value;\n });\n });\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Get a single entity record by ID.\n */\nexport function resolveEntityById(\n entityName: string,\n id: string | number,\n context: DataContext\n): unknown | null {\n const { data } = resolveEntityData(entityName, context);\n\n return data.find((item) => {\n if (typeof item !== 'object' || item === null) {\n return false;\n }\n const record = item as Record<string, unknown>;\n return record.id === id || record._id === id;\n }) ?? null;\n}\n\n/**\n * Get the count of entities matching criteria.\n */\nexport function resolveEntityCount(\n entityName: string,\n context: DataContext,\n filters?: Record<string, unknown>\n): number {\n const { data } = resolveEntityData(entityName, context);\n\n if (filters) {\n return applyFilters(data, filters).length;\n }\n\n return data.length;\n}\n\n/**\n * Check if any entities exist for a given entity name.\n */\nexport function hasEntities(\n entityName: string,\n context: DataContext\n): boolean {\n const { data } = resolveEntityData(entityName, context);\n return data.length > 0;\n}\n\n/**\n * Create a data context from fetched data only.\n * Convenience function for compiled shells.\n */\nexport function createFetchedDataContext(\n data: Record<string, unknown[]>\n): DataContext {\n return { fetchedData: data };\n}\n\n/**\n * Merge multiple data contexts.\n * Later contexts take precedence.\n */\nexport function mergeDataContexts(...contexts: DataContext[]): DataContext {\n const merged: DataContext = {};\n\n for (const context of contexts) {\n if (context.fetchedData) {\n merged.fetchedData = {\n ...merged.fetchedData,\n ...context.fetchedData,\n };\n }\n if (context.entityStore) {\n merged.entityStore = context.entityStore;\n }\n if (context.querySingleton) {\n merged.querySingleton = context.querySingleton;\n }\n }\n\n return merged;\n}\n","/**\n * Slot Definitions\n *\n * Defines the available UI slots and their rendering behavior.\n * Slots are either inline (rendered in the component tree) or\n * portal (rendered to document.body via React Portal).\n *\n * @packageDocumentation\n */\n\nimport type { UISlot, SlotDefinition, SlotType } from './types';\n\n// ============================================================================\n// Slot Definitions\n// ============================================================================\n\n/**\n * Definitions for all available UI slots.\n *\n * Inline slots render within the component hierarchy.\n * Portal slots render to document.body, breaking out of overflow containers.\n */\nexport const SLOT_DEFINITIONS: Record<UISlot, SlotDefinition> = {\n // -------------------------------------------------------------------------\n // Inline Slots - Render in place within the component tree\n // -------------------------------------------------------------------------\n\n main: {\n name: 'main',\n type: 'inline',\n },\n\n sidebar: {\n name: 'sidebar',\n type: 'inline',\n },\n\n // -------------------------------------------------------------------------\n // Portal Slots - Render to document.body via React Portal\n // -------------------------------------------------------------------------\n\n modal: {\n name: 'modal',\n type: 'portal',\n portalTarget: 'body',\n zIndex: 1000,\n },\n\n drawer: {\n name: 'drawer',\n type: 'portal',\n portalTarget: 'body',\n zIndex: 900,\n },\n\n overlay: {\n name: 'overlay',\n type: 'portal',\n portalTarget: 'body',\n zIndex: 1100,\n },\n\n center: {\n name: 'center',\n type: 'portal',\n portalTarget: 'body',\n zIndex: 1000,\n },\n\n toast: {\n name: 'toast',\n type: 'portal',\n portalTarget: 'body',\n zIndex: 1200,\n },\n\n // -------------------------------------------------------------------------\n // Game HUD Slots - Portal for game overlay UI\n // -------------------------------------------------------------------------\n\n 'hud-top': {\n name: 'hud-top',\n type: 'portal',\n portalTarget: 'body',\n zIndex: 500,\n },\n\n 'hud-bottom': {\n name: 'hud-bottom',\n type: 'portal',\n portalTarget: 'body',\n zIndex: 500,\n },\n\n floating: {\n name: 'floating',\n type: 'portal',\n portalTarget: 'body',\n zIndex: 800,\n },\n};\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Get the slot definition for a slot name.\n */\nexport function getSlotDefinition(slot: UISlot): SlotDefinition {\n return SLOT_DEFINITIONS[slot];\n}\n\n/**\n * Check if a slot is a portal slot.\n */\nexport function isPortalSlot(slot: UISlot): boolean {\n return SLOT_DEFINITIONS[slot]?.type === 'portal';\n}\n\n/**\n * Check if a slot is an inline slot.\n */\nexport function isInlineSlot(slot: UISlot): boolean {\n return SLOT_DEFINITIONS[slot]?.type === 'inline';\n}\n\n/**\n * Get all slots of a specific type.\n */\nexport function getSlotsByType(type: SlotType): UISlot[] {\n return Object.entries(SLOT_DEFINITIONS)\n .filter(([, def]) => def.type === type)\n .map(([name]) => name as UISlot);\n}\n\n/**\n * Get all inline slots.\n */\nexport function getInlineSlots(): UISlot[] {\n return getSlotsByType('inline');\n}\n\n/**\n * Get all portal slots.\n */\nexport function getPortalSlots(): UISlot[] {\n return getSlotsByType('portal');\n}\n\n/**\n * All valid slot names.\n */\nexport const ALL_SLOTS: UISlot[] = Object.keys(SLOT_DEFINITIONS) as UISlot[];\n","/**\n * Offline Effect Executor\n *\n * Enables client-only mode for applications that need to work without\n * server connectivity. Provides:\n * - Mock data providers for simulating server responses\n * - Local effect execution without server round-trip\n * - Sync queue for effects that need server persistence when back online\n *\n * Used by both Builder preview (offline mode) and compiled shells (PWA mode).\n *\n * @packageDocumentation\n */\n\nimport type {\n ClientEffect,\n ClientEffectExecutorConfig,\n PatternConfig,\n EventResponse,\n} from './types';\nimport { executeClientEffects } from './client-effect-executor';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Effect that needs to be synced to server when online\n */\nexport interface PendingSyncEffect {\n /** Unique ID for this effect */\n id: string;\n /** Timestamp when effect was queued */\n timestamp: number;\n /** Effect type (persist, call-service, etc.) */\n type: string;\n /** Effect payload */\n payload: unknown;\n /** Number of retry attempts */\n retries: number;\n /** Maximum retries before giving up */\n maxRetries: number;\n}\n\n/**\n * Configuration for offline executor\n */\nexport interface OfflineExecutorConfig extends ClientEffectExecutorConfig {\n /**\n * Mock data provider for simulating fetch responses.\n * Returns data for a given entity name.\n */\n mockDataProvider?: (entityName: string) => unknown[];\n\n /**\n * Whether to queue server effects for sync when online.\n * Default: true\n */\n enableSyncQueue?: boolean;\n\n /**\n * Maximum number of effects to queue before dropping oldest.\n * Default: 100\n */\n maxQueueSize?: number;\n\n /**\n * Callback when an effect is added to sync queue.\n */\n onEffectQueued?: (effect: PendingSyncEffect) => void;\n\n /**\n * Callback when sync queue changes.\n */\n onQueueChange?: (queue: PendingSyncEffect[]) => void;\n}\n\n/**\n * Offline executor state\n */\nexport interface OfflineExecutorState {\n /** Whether we're in offline mode */\n isOffline: boolean;\n /** Pending effects waiting for sync */\n syncQueue: PendingSyncEffect[];\n /** Number of effects processed locally */\n localEffectsProcessed: number;\n /** Number of effects synced to server */\n effectsSynced: number;\n /** Last sync attempt timestamp */\n lastSyncAttempt?: number;\n /** Last successful sync timestamp */\n lastSuccessfulSync?: number;\n}\n\n// ============================================================================\n// ID Generator\n// ============================================================================\n\nlet effectIdCounter = 0;\nfunction generateEffectId(): string {\n return `offline-effect-${++effectIdCounter}-${Date.now()}`;\n}\n\n// ============================================================================\n// Offline Executor Class\n// ============================================================================\n\n/**\n * OfflineExecutor - Handles effects in offline/client-only mode.\n *\n * Features:\n * - Executes client effects immediately (render-ui, navigate, notify, emit)\n * - Queues server effects (persist, fetch, call-service) for later sync\n * - Provides mock data for fetch effects when offline\n * - Syncs queued effects when connection is restored\n *\n * @example\n * ```typescript\n * const executor = new OfflineExecutor({\n * renderToSlot: (slot, pattern) => slotManager.render(slot, pattern),\n * navigate: (path) => router.push(path),\n * notify: (message, opts) => toast.show(message, opts),\n * eventBus: { emit: (event, payload) => bus.emit(event, payload) },\n * mockDataProvider: (entityName) => mockStore.getAll(entityName),\n * });\n *\n * // Process effects locally\n * const response = executor.processEventOffline('LOAD', { id: '123' });\n *\n * // When back online\n * await executor.syncPendingEffects(serverUrl);\n * ```\n */\nexport class OfflineExecutor {\n private config: OfflineExecutorConfig;\n private state: OfflineExecutorState;\n private storage: Storage | null;\n\n constructor(config: OfflineExecutorConfig) {\n this.config = {\n enableSyncQueue: true,\n maxQueueSize: 100,\n ...config,\n };\n\n this.state = {\n isOffline: !this.checkOnline(),\n syncQueue: [],\n localEffectsProcessed: 0,\n effectsSynced: 0,\n };\n\n // Use localStorage if available\n this.storage = typeof localStorage !== 'undefined' ? localStorage : null;\n\n // Load persisted queue\n this.loadSyncQueue();\n\n // Listen for online/offline events\n if (typeof window !== 'undefined') {\n window.addEventListener('online', this.handleOnline);\n window.addEventListener('offline', this.handleOffline);\n }\n }\n\n /**\n * Check if we're online (browser API)\n */\n private checkOnline(): boolean {\n return typeof navigator !== 'undefined' ? navigator.onLine : true;\n }\n\n /**\n * Handle going online\n */\n private handleOnline = (): void => {\n this.state.isOffline = false;\n // Attempt to sync pending effects\n // Note: Actual sync should be triggered by the app with proper server URL\n };\n\n /**\n * Handle going offline\n */\n private handleOffline = (): void => {\n this.state.isOffline = true;\n };\n\n /**\n * Load sync queue from localStorage\n */\n private loadSyncQueue(): void {\n if (!this.storage) return;\n\n try {\n const stored = this.storage.getItem('orbital-offline-queue');\n if (stored) {\n this.state.syncQueue = JSON.parse(stored);\n }\n } catch (error) {\n console.warn('[OfflineExecutor] Failed to load sync queue:', error);\n }\n }\n\n /**\n * Save sync queue to localStorage\n */\n private saveSyncQueue(): void {\n if (!this.storage) return;\n\n try {\n this.storage.setItem('orbital-offline-queue', JSON.stringify(this.state.syncQueue));\n } catch (error) {\n console.warn('[OfflineExecutor] Failed to save sync queue:', error);\n }\n }\n\n /**\n * Add an effect to the sync queue\n */\n private queueForSync(type: string, payload: unknown): void {\n if (!this.config.enableSyncQueue) return;\n\n const effect: PendingSyncEffect = {\n id: generateEffectId(),\n timestamp: Date.now(),\n type,\n payload,\n retries: 0,\n maxRetries: 3,\n };\n\n // Add to queue, respecting max size\n this.state.syncQueue.push(effect);\n if (this.state.syncQueue.length > (this.config.maxQueueSize ?? 100)) {\n this.state.syncQueue.shift(); // Remove oldest\n }\n\n this.saveSyncQueue();\n\n // Notify listeners\n this.config.onEffectQueued?.(effect);\n this.config.onQueueChange?.(this.state.syncQueue);\n }\n\n /**\n * Execute client effects immediately.\n */\n executeClientEffects(effects: ClientEffect[]): void {\n if (effects.length === 0) return;\n\n executeClientEffects(effects, this.config);\n this.state.localEffectsProcessed += effects.length;\n }\n\n /**\n * Process an event in offline mode.\n *\n * Returns a simulated EventResponse with mock data.\n * Client effects are executed immediately.\n * Server effects are queued for sync.\n */\n processEventOffline(\n event: string,\n payload?: Record<string, unknown>,\n effects?: Array<unknown[]>\n ): EventResponse {\n const clientEffects: ClientEffect[] = [];\n const fetchedData: Record<string, unknown[]> = {};\n\n // Process effects\n if (effects) {\n for (const effect of effects) {\n if (!Array.isArray(effect) || effect.length < 1) continue;\n\n const [type, ...args] = effect as [string, ...unknown[]];\n\n switch (type) {\n // Client effects - execute immediately\n case 'render-ui':\n case 'navigate':\n case 'notify':\n case 'emit':\n clientEffects.push(effect as ClientEffect);\n break;\n\n // Fetch effect - use mock data\n case 'fetch': {\n const [entityName, _query] = args;\n if (typeof entityName === 'string' && this.config.mockDataProvider) {\n fetchedData[entityName] = this.config.mockDataProvider(entityName);\n }\n break;\n }\n\n // Server effects - queue for sync\n case 'persist':\n case 'call-service':\n case 'spawn':\n case 'despawn':\n this.queueForSync(type, { args, event, payload });\n break;\n\n default:\n console.warn(`[OfflineExecutor] Unknown effect type: ${type}`);\n }\n }\n }\n\n // Execute client effects\n if (clientEffects.length > 0) {\n this.executeClientEffects(clientEffects);\n }\n\n return {\n success: true,\n data: Object.keys(fetchedData).length > 0 ? fetchedData : undefined,\n clientEffects: clientEffects.length > 0 ? clientEffects : undefined,\n };\n }\n\n /**\n * Sync pending effects to server.\n *\n * @param serverUrl - Base URL for the orbital server\n * @param authToken - Optional auth token for requests\n * @returns Number of successfully synced effects\n */\n async syncPendingEffects(\n serverUrl: string,\n authToken?: string\n ): Promise<number> {\n if (this.state.syncQueue.length === 0) {\n return 0;\n }\n\n this.state.lastSyncAttempt = Date.now();\n let syncedCount = 0;\n const failedEffects: PendingSyncEffect[] = [];\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n };\n if (authToken) {\n headers['Authorization'] = `Bearer ${authToken}`;\n }\n\n for (const effect of this.state.syncQueue) {\n try {\n const response = await fetch(`${serverUrl}/sync-effect`, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n type: effect.type,\n payload: effect.payload,\n offlineId: effect.id,\n offlineTimestamp: effect.timestamp,\n }),\n });\n\n if (response.ok) {\n syncedCount++;\n } else {\n // Increment retry count\n effect.retries++;\n if (effect.retries < effect.maxRetries) {\n failedEffects.push(effect);\n }\n }\n } catch (error) {\n // Network error - keep in queue\n effect.retries++;\n if (effect.retries < effect.maxRetries) {\n failedEffects.push(effect);\n }\n }\n }\n\n // Update queue with failed effects\n this.state.syncQueue = failedEffects;\n this.state.effectsSynced += syncedCount;\n\n if (syncedCount > 0) {\n this.state.lastSuccessfulSync = Date.now();\n }\n\n this.saveSyncQueue();\n this.config.onQueueChange?.(this.state.syncQueue);\n\n return syncedCount;\n }\n\n /**\n * Get current executor state\n */\n getState(): OfflineExecutorState {\n return { ...this.state };\n }\n\n /**\n * Get number of pending effects\n */\n getPendingCount(): number {\n return this.state.syncQueue.length;\n }\n\n /**\n * Clear the sync queue\n */\n clearQueue(): void {\n this.state.syncQueue = [];\n this.saveSyncQueue();\n this.config.onQueueChange?.(this.state.syncQueue);\n }\n\n /**\n * Dispose the executor and clean up listeners\n */\n dispose(): void {\n if (typeof window !== 'undefined') {\n window.removeEventListener('online', this.handleOnline);\n window.removeEventListener('offline', this.handleOffline);\n }\n }\n}\n\n// ============================================================================\n// Factory Function\n// ============================================================================\n\n/**\n * Create an offline executor with sensible defaults.\n *\n * @example\n * ```typescript\n * const executor = createOfflineExecutor({\n * renderToSlot: slotManager.render,\n * navigate: router.push,\n * notify: toast.show,\n * eventBus: { emit: bus.emit },\n * mockDataProvider: (entity) => store.getAll(entity),\n * });\n * ```\n */\nexport function createOfflineExecutor(\n config: OfflineExecutorConfig\n): OfflineExecutor {\n return new OfflineExecutor(config);\n}\n\n// ============================================================================\n// React Hook (optional integration)\n// ============================================================================\n\nimport { useState, useEffect, useCallback, useRef } from 'react';\n\n/**\n * Options for useOfflineExecutor hook\n */\nexport interface UseOfflineExecutorOptions extends OfflineExecutorConfig {\n /** Server URL for syncing */\n serverUrl?: string;\n /** Auth token for server requests */\n authToken?: string;\n /** Auto-sync when coming back online */\n autoSync?: boolean;\n}\n\n/**\n * Result of useOfflineExecutor hook\n */\nexport interface UseOfflineExecutorResult {\n /** Current executor state */\n state: OfflineExecutorState;\n /** Whether we're offline */\n isOffline: boolean;\n /** Number of pending effects */\n pendingCount: number;\n /** Execute client effects */\n executeClientEffects: (effects: ClientEffect[]) => void;\n /** Process event offline */\n processEventOffline: (\n event: string,\n payload?: Record<string, unknown>,\n effects?: Array<unknown[]>\n ) => EventResponse;\n /** Manually trigger sync */\n sync: () => Promise<number>;\n /** Clear the queue */\n clearQueue: () => void;\n}\n\n/**\n * React hook for offline effect execution.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { isOffline, pendingCount, processEventOffline, sync } = useOfflineExecutor({\n * renderToSlot: slotManager.render,\n * navigate: router.push,\n * notify: toast.show,\n * eventBus: { emit: bus.emit },\n * serverUrl: '/api/orbitals',\n * autoSync: true,\n * });\n *\n * return (\n * <div>\n * {isOffline && <Banner>Offline - {pendingCount} changes pending</Banner>}\n * <button onClick={() => processEventOffline('SAVE', data)}>Save</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useOfflineExecutor(\n options: UseOfflineExecutorOptions\n): UseOfflineExecutorResult {\n const executorRef = useRef<OfflineExecutor | null>(null);\n const [state, setState] = useState<OfflineExecutorState>({\n isOffline: false,\n syncQueue: [],\n localEffectsProcessed: 0,\n effectsSynced: 0,\n });\n\n // Create executor on mount\n useEffect(() => {\n const executor = new OfflineExecutor({\n ...options,\n onQueueChange: (queue) => {\n setState(executor.getState());\n options.onQueueChange?.(queue);\n },\n });\n\n executorRef.current = executor;\n setState(executor.getState());\n\n return () => {\n executor.dispose();\n executorRef.current = null;\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n // Auto-sync when coming online\n useEffect(() => {\n if (!options.autoSync || !options.serverUrl) return;\n\n const handleOnline = async () => {\n if (executorRef.current) {\n await executorRef.current.syncPendingEffects(\n options.serverUrl!,\n options.authToken\n );\n setState(executorRef.current.getState());\n }\n };\n\n window.addEventListener('online', handleOnline);\n return () => window.removeEventListener('online', handleOnline);\n }, [options.autoSync, options.serverUrl, options.authToken]);\n\n const executeEffects = useCallback((effects: ClientEffect[]) => {\n executorRef.current?.executeClientEffects(effects);\n if (executorRef.current) {\n setState(executorRef.current.getState());\n }\n }, []);\n\n const processEventOffline = useCallback(\n (event: string, payload?: Record<string, unknown>, effects?: Array<unknown[]>) => {\n const result = executorRef.current?.processEventOffline(event, payload, effects);\n if (executorRef.current) {\n setState(executorRef.current.getState());\n }\n return result ?? { success: false, error: 'Executor not initialized' };\n },\n []\n );\n\n const sync = useCallback(async () => {\n if (!executorRef.current || !options.serverUrl) return 0;\n const count = await executorRef.current.syncPendingEffects(\n options.serverUrl,\n options.authToken\n );\n setState(executorRef.current.getState());\n return count;\n }, [options.serverUrl, options.authToken]);\n\n const clearQueue = useCallback(() => {\n executorRef.current?.clearQueue();\n if (executorRef.current) {\n setState(executorRef.current.getState());\n }\n }, []);\n\n return {\n state,\n isOffline: state.isOffline,\n pendingCount: state.syncQueue.length,\n executeClientEffects: executeEffects,\n processEventOffline,\n sync,\n clearQueue,\n };\n}\n","/**\n * Pattern Resolver Initialization\n *\n * Loads pattern registry and component mapping from orbital-shared/patterns/\n * and initializes the pattern resolver at app startup.\n *\n * @packageDocumentation\n */\n\nimport { initializePatternResolver } from './pattern-resolver';\n\n// Import patterns data from @almadar/patterns\nimport componentMappingJson from '@almadar/patterns/component-mapping.json';\nimport registryJson from '@almadar/patterns/registry.json';\n\n// Type definitions for the JSON structures\ninterface ComponentMappingJson {\n mappings: Record<string, {\n component: string;\n importPath: string;\n category: string;\n deprecated?: boolean;\n replacedBy?: string;\n }>;\n}\n\ninterface RegistryJson {\n patterns: Record<string, {\n type: string;\n category: string;\n description: string;\n propsSchema?: Record<string, unknown>;\n }>;\n}\n\n/**\n * Initialize the pattern resolver with shared pattern data.\n * Must be called once at app startup before any pattern rendering.\n * @returns The number of patterns initialized\n */\nexport function initializePatterns(): number {\n console.log('[PatternResolver] initializePatterns called');\n console.log('[PatternResolver] componentMappingJson:', componentMappingJson);\n console.log('[PatternResolver] registryJson keys:', Object.keys(registryJson));\n\n // Extract mappings from component-mapping.json (has { mappings: {...} })\n const componentMappingData = componentMappingJson as ComponentMappingJson;\n const componentMapping = componentMappingData.mappings || {};\n\n console.log('[PatternResolver] Extracted mappings count:', Object.keys(componentMapping).length);\n console.log('[PatternResolver] Sample mappings:', Object.keys(componentMapping).slice(0, 5));\n\n // Extract patterns from registry.json (has { patterns: {...} })\n const registryData = registryJson as RegistryJson;\n const patternRegistry = registryData.patterns || {};\n\n console.log('[PatternResolver] Extracted patterns count:', Object.keys(patternRegistry).length);\n\n // Initialize the pattern resolver with the data\n // Use type assertion since JSON types are compatible at runtime\n initializePatternResolver({\n componentMapping,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n patternRegistry: patternRegistry as any,\n });\n\n console.log(`[PatternResolver] Initialized with ${Object.keys(componentMapping).length} component mappings and ${Object.keys(patternRegistry).length} pattern definitions`);\n\n return Object.keys(componentMapping).length;\n}\n"]}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Entity Filtering Utilities
3
+ *
4
+ * Provides filter types and utility functions for filtering entity records.
5
+ * Used by EntityStore and can be imported by runtime preview.
6
+ */
7
+ /** Filter value for a single field (entity filtering) */
8
+ interface EntityFilterValue {
9
+ /** The field key (may include suffix like _from, _to for date ranges) */
10
+ field: string;
11
+ /** The actual record field to compare against (defaults to field if not specified) */
12
+ targetField?: string;
13
+ value: unknown;
14
+ /** Comparison operator for filtering
15
+ * - eq: exact match (default)
16
+ * - contains: substring match for strings
17
+ * - in: value is in array
18
+ * - date_eq: same date (ignoring time)
19
+ * - date_gte: on or after date
20
+ * - date_lte: on or before date
21
+ */
22
+ operator?: FilterOperator;
23
+ }
24
+ /** Operator type for filter */
25
+ type FilterOperator = 'eq' | 'contains' | 'in' | 'date_eq' | 'date_gte' | 'date_lte' | 'search';
26
+ /** Filter state for an entity - Map of field key to filter value */
27
+ type EntityFilters = Map<string, EntityFilterValue>;
28
+ /** Record type that can be filtered */
29
+ interface FilterableRecord {
30
+ id: string;
31
+ [key: string]: unknown;
32
+ }
33
+ /**
34
+ * Extract date part from ISO string or Date object.
35
+ * Returns format: "YYYY-MM-DD"
36
+ */
37
+ declare function getDateString(value: unknown): string | null;
38
+ /**
39
+ * Apply a single filter to check if a record matches.
40
+ * Returns true if the record passes the filter.
41
+ */
42
+ declare function matchesFilter(record: FilterableRecord, filter: EntityFilterValue): boolean;
43
+ /**
44
+ * Apply all filters to a list of records.
45
+ * Returns only records that match ALL filters.
46
+ */
47
+ declare function applyFilters<T extends FilterableRecord>(records: T[], entityFilters: EntityFilters): T[];
48
+ /**
49
+ * Create a filter value with proper defaults.
50
+ */
51
+ declare function createFilter(field: string, value: unknown, operator?: FilterOperator, targetField?: string): EntityFilterValue;
52
+
53
+ /**
54
+ * Entity Store
55
+ *
56
+ * Simple module-level store for runtime entities.
57
+ * No providers needed - hooks import and use directly.
58
+ *
59
+ * NOTE: Mutations create new Map instances to trigger React rerenders
60
+ * when using useSyncExternalStore.
61
+ */
62
+
63
+ interface Entity {
64
+ id: string;
65
+ type: string;
66
+ [key: string]: unknown;
67
+ }
68
+ type Listener = () => void;
69
+ /**
70
+ * Subscribe to store changes
71
+ */
72
+ declare function subscribe(listener: Listener): () => void;
73
+ /**
74
+ * Get all entities
75
+ */
76
+ declare function getEntities(): Map<string, Entity>;
77
+ /**
78
+ * Get entity by ID
79
+ */
80
+ declare function getEntity(id: string): Entity | undefined;
81
+ /**
82
+ * Get entities by type
83
+ */
84
+ declare function getByType(type: string | string[]): Entity[];
85
+ /**
86
+ * Get all entities as array
87
+ */
88
+ declare function getAllEntities(): Entity[];
89
+ /**
90
+ * Get singleton entity by type (first of that type)
91
+ */
92
+ declare function getSingleton(type: string): Entity | undefined;
93
+ /**
94
+ * Spawn a new entity
95
+ */
96
+ declare function spawnEntity(config: {
97
+ type: string;
98
+ id?: string;
99
+ [key: string]: unknown;
100
+ }): string;
101
+ /**
102
+ * Update an entity
103
+ */
104
+ declare function updateEntity(id: string, updates: Partial<Entity>): void;
105
+ /**
106
+ * Update singleton entity by type
107
+ */
108
+ declare function updateSingleton(type: string, updates: Partial<Entity>): void;
109
+ /**
110
+ * Remove an entity
111
+ */
112
+ declare function removeEntity(id: string): void;
113
+ /**
114
+ * Clear all entities
115
+ */
116
+ declare function clearEntities(): void;
117
+ /**
118
+ * Set a filter for an entity type
119
+ * @param entityType - The entity type to filter (e.g., "Player", "Enemy")
120
+ * @param field - The filter key (e.g., 'status' or 'date_from')
121
+ * @param value - The filter value
122
+ * @param operator - The comparison operator
123
+ * @param targetField - The actual record field to compare (defaults to field)
124
+ */
125
+ declare function setFilter(entityType: string, field: string, value: unknown, operator?: FilterOperator, targetField?: string): void;
126
+ /**
127
+ * Clear a specific filter
128
+ */
129
+ declare function clearFilter(entityType: string, field: string): void;
130
+ /**
131
+ * Clear all filters for an entity type
132
+ */
133
+ declare function clearAllFilters(entityType: string): void;
134
+ /**
135
+ * Get active filters for an entity type
136
+ */
137
+ declare function getFilters(entityType: string): EntityFilters;
138
+ /**
139
+ * Get entities by type with optional filtering
140
+ */
141
+ declare function getByTypeFiltered(type: string | string[]): Entity[];
142
+ /**
143
+ * Get snapshot for React useSyncExternalStore
144
+ */
145
+ declare function getSnapshot(): Map<string, Entity>;
146
+ /**
147
+ * Get filter snapshot for React useSyncExternalStore
148
+ */
149
+ declare function getFilterSnapshot(): Map<string, EntityFilters>;
150
+
151
+ export { type Entity, type EntityFilterValue, type EntityFilters, type FilterOperator, type FilterableRecord, applyFilters, clearAllFilters, clearEntities, clearFilter, createFilter, getAllEntities, getByType, getByTypeFiltered, getDateString, getEntities, getEntity, getFilterSnapshot, getFilters, getSingleton, getSnapshot, matchesFilter, removeEntity, setFilter, spawnEntity, subscribe, updateEntity, updateSingleton };
@@ -0,0 +1,196 @@
1
+ // stores/filtering.ts
2
+ function getDateString(value) {
3
+ if (!value) return null;
4
+ if (typeof value === "string") {
5
+ const match = value.match(/^(\d{4}-\d{2}-\d{2})/);
6
+ return match ? match[1] : null;
7
+ }
8
+ if (value instanceof Date) {
9
+ return value.toISOString().split("T")[0];
10
+ }
11
+ return null;
12
+ }
13
+ function matchesFilter(record, filter) {
14
+ const fieldToCompare = filter.targetField || filter.field;
15
+ const recordValue = record[fieldToCompare];
16
+ const filterValue = filter.value;
17
+ const operator = filter.operator || "eq";
18
+ if (filterValue === null || filterValue === void 0 || filterValue === "") {
19
+ return true;
20
+ }
21
+ switch (operator) {
22
+ case "eq":
23
+ if (typeof recordValue === "string" && typeof filterValue === "string") {
24
+ return recordValue.toLowerCase() === filterValue.toLowerCase();
25
+ }
26
+ return recordValue === filterValue;
27
+ case "contains":
28
+ if (typeof recordValue !== "string") return false;
29
+ return recordValue.toLowerCase().includes(String(filterValue).toLowerCase());
30
+ case "in":
31
+ if (Array.isArray(filterValue)) {
32
+ const normalizedFilterValues = filterValue.map(
33
+ (v) => typeof v === "string" ? v.toLowerCase() : v
34
+ );
35
+ const normalizedRecordValue = typeof recordValue === "string" ? recordValue.toLowerCase() : recordValue;
36
+ return normalizedFilterValues.includes(normalizedRecordValue);
37
+ }
38
+ return false;
39
+ case "date_eq": {
40
+ const recordDate = getDateString(recordValue);
41
+ const filterDate = getDateString(filterValue);
42
+ return Boolean(recordDate && filterDate && recordDate === filterDate);
43
+ }
44
+ case "date_gte": {
45
+ const recordDate = getDateString(recordValue);
46
+ const filterDate = getDateString(filterValue);
47
+ return Boolean(recordDate && filterDate && recordDate >= filterDate);
48
+ }
49
+ case "date_lte": {
50
+ const recordDate = getDateString(recordValue);
51
+ const filterDate = getDateString(filterValue);
52
+ return Boolean(recordDate && filterDate && recordDate <= filterDate);
53
+ }
54
+ case "search": {
55
+ if (typeof filterValue !== "string" || !filterValue.trim()) {
56
+ return true;
57
+ }
58
+ const searchTerm = filterValue.toLowerCase();
59
+ return Object.values(record).some((value) => {
60
+ if (value === null || value === void 0) return false;
61
+ return String(value).toLowerCase().includes(searchTerm);
62
+ });
63
+ }
64
+ default:
65
+ return true;
66
+ }
67
+ }
68
+ function applyFilters(records, entityFilters) {
69
+ if (entityFilters.size === 0) return records;
70
+ return records.filter((record) => {
71
+ for (const [, filter] of entityFilters) {
72
+ if (!matchesFilter(record, filter)) {
73
+ return false;
74
+ }
75
+ }
76
+ return true;
77
+ });
78
+ }
79
+ function createFilter(field, value, operator = "eq", targetField) {
80
+ return {
81
+ field,
82
+ value,
83
+ operator,
84
+ targetField: targetField || field
85
+ };
86
+ }
87
+
88
+ // stores/entityStore.ts
89
+ var entities = /* @__PURE__ */ new Map();
90
+ var filters = /* @__PURE__ */ new Map();
91
+ var listeners = /* @__PURE__ */ new Set();
92
+ var idCounter = 0;
93
+ function subscribe(listener) {
94
+ listeners.add(listener);
95
+ return () => listeners.delete(listener);
96
+ }
97
+ function notify() {
98
+ listeners.forEach((listener) => listener());
99
+ }
100
+ function getEntities() {
101
+ return entities;
102
+ }
103
+ function getEntity(id) {
104
+ return entities.get(id);
105
+ }
106
+ function getByType(type) {
107
+ const types = Array.isArray(type) ? type : [type];
108
+ return [...entities.values()].filter((e) => types.includes(e.type));
109
+ }
110
+ function getAllEntities() {
111
+ return [...entities.values()];
112
+ }
113
+ function getSingleton(type) {
114
+ return [...entities.values()].find((e) => e.type === type);
115
+ }
116
+ function spawnEntity(config) {
117
+ const id = config.id ?? `entity_${++idCounter}`;
118
+ const entity = { ...config, id };
119
+ entities = new Map(entities);
120
+ entities.set(id, entity);
121
+ notify();
122
+ return id;
123
+ }
124
+ function updateEntity(id, updates) {
125
+ const entity = entities.get(id);
126
+ if (entity) {
127
+ entities = new Map(entities);
128
+ entities.set(id, { ...entity, ...updates });
129
+ notify();
130
+ }
131
+ }
132
+ function updateSingleton(type, updates) {
133
+ const entity = getSingleton(type);
134
+ if (entity) {
135
+ updateEntity(entity.id, updates);
136
+ }
137
+ }
138
+ function removeEntity(id) {
139
+ if (entities.has(id)) {
140
+ entities = new Map(entities);
141
+ entities.delete(id);
142
+ notify();
143
+ }
144
+ }
145
+ function clearEntities() {
146
+ entities = /* @__PURE__ */ new Map();
147
+ notify();
148
+ }
149
+ function setFilter(entityType, field, value, operator = "eq", targetField) {
150
+ filters = new Map(filters);
151
+ const entityFilters = new Map(filters.get(entityType) || []);
152
+ entityFilters.set(field, createFilter(field, value, operator, targetField));
153
+ filters.set(entityType, entityFilters);
154
+ notify();
155
+ }
156
+ function clearFilter(entityType, field) {
157
+ const entityFilters = filters.get(entityType);
158
+ if (entityFilters && entityFilters.has(field)) {
159
+ filters = new Map(filters);
160
+ const newFilters = new Map(entityFilters);
161
+ newFilters.delete(field);
162
+ filters.set(entityType, newFilters);
163
+ notify();
164
+ }
165
+ }
166
+ function clearAllFilters(entityType) {
167
+ if (filters.has(entityType)) {
168
+ filters = new Map(filters);
169
+ filters.set(entityType, /* @__PURE__ */ new Map());
170
+ notify();
171
+ }
172
+ }
173
+ function getFilters(entityType) {
174
+ return filters.get(entityType) || /* @__PURE__ */ new Map();
175
+ }
176
+ function getByTypeFiltered(type) {
177
+ const types = Array.isArray(type) ? type : [type];
178
+ let result = [...entities.values()].filter((e) => types.includes(e.type));
179
+ for (const t of types) {
180
+ const typeFilters = filters.get(t);
181
+ if (typeFilters && typeFilters.size > 0) {
182
+ result = applyFilters(result, typeFilters);
183
+ }
184
+ }
185
+ return result;
186
+ }
187
+ function getSnapshot() {
188
+ return entities;
189
+ }
190
+ function getFilterSnapshot() {
191
+ return filters;
192
+ }
193
+
194
+ export { applyFilters, clearAllFilters, clearEntities, clearFilter, createFilter, getAllEntities, getByType, getByTypeFiltered, getDateString, getEntities, getEntity, getFilterSnapshot, getFilters, getSingleton, getSnapshot, matchesFilter, removeEntity, setFilter, spawnEntity, subscribe, updateEntity, updateSingleton };
195
+ //# sourceMappingURL=index.js.map
196
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../stores/filtering.ts","../../stores/entityStore.ts"],"names":[],"mappings":";AAiDO,SAAS,cAAc,KAAA,EAA+B;AACzD,EAAA,IAAI,CAAC,OAAO,OAAO,IAAA;AACnB,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAG3B,IAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,KAAA,CAAM,sBAAsB,CAAA;AAChD,IAAA,OAAO,KAAA,GAAQ,KAAA,CAAM,CAAC,CAAA,GAAI,IAAA;AAAA,EAC9B;AACA,EAAA,IAAI,iBAAiB,IAAA,EAAM;AACvB,IAAA,OAAO,MAAM,WAAA,EAAY,CAAE,KAAA,CAAM,GAAG,EAAE,CAA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EAA0B;AACxD,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,UAAU,CAAA,EAAG;AAC3B,IAAA,OAAA,GAAU,IAAI,IAAI,OAAO,CAAA;AACzB,IAAA,OAAA,CAAQ,GAAA,CAAI,UAAA,kBAAY,IAAI,GAAA,EAAK,CAAA;AACjC,IAAA,MAAA,EAAO;AAAA,EACT;AACF;AAKO,SAAS,WAAW,UAAA,EAAmC;AAC5D,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,UAAU,CAAA,wBAAS,GAAA,EAAI;AAC5C;AAKO,SAAS,kBAAkB,IAAA,EAAmC;AACnE,EAAA,MAAM,QAAQ,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,GAAI,IAAA,GAAO,CAAC,IAAI,CAAA;AAChD,EAAA,IAAI,MAAA,GAAS,CAAC,GAAG,QAAA,CAAS,MAAA,EAAQ,CAAA,CAAE,MAAA,CAAO,CAAA,CAAA,KAAK,KAAA,CAAM,QAAA,CAAS,CAAA,CAAE,IAAI,CAAC,CAAA;AAGtE,EAAA,KAAA,MAAW,KAAK,KAAA,EAAO;AACrB,IAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA;AACjC,IAAA,IAAI,WAAA,IAAe,WAAA,CAAY,IAAA,GAAO,CAAA,EAAG;AACvC,MAAA,MAAA,GAAS,YAAA,CAAa,QAAQ,WAAW,CAAA;AAAA,IAC3C;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;AAKO,SAAS,WAAA,GAAmC;AACjD,EAAA,OAAO,QAAA;AACT;AAKO,SAAS,iBAAA,GAAgD;AAC9D,EAAA,OAAO,OAAA;AACT","file":"index.js","sourcesContent":["/**\n * Entity Filtering Utilities\n *\n * Provides filter types and utility functions for filtering entity records.\n * Used by EntityStore and can be imported by runtime preview.\n */\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/** Filter value for a single field (entity filtering) */\nexport interface EntityFilterValue {\n /** The field key (may include suffix like _from, _to for date ranges) */\n field: string;\n /** The actual record field to compare against (defaults to field if not specified) */\n targetField?: string;\n value: unknown;\n /** Comparison operator for filtering\n * - eq: exact match (default)\n * - contains: substring match for strings\n * - in: value is in array\n * - date_eq: same date (ignoring time)\n * - date_gte: on or after date\n * - date_lte: on or before date\n */\n operator?: FilterOperator;\n}\n\n/** Operator type for filter */\nexport type FilterOperator = 'eq' | 'contains' | 'in' | 'date_eq' | 'date_gte' | 'date_lte' | 'search';\n\n/** Filter state for an entity - Map of field key to filter value */\nexport type EntityFilters = Map<string, EntityFilterValue>;\n\n/** Record type that can be filtered */\nexport interface FilterableRecord {\n id: string;\n [key: string]: unknown;\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Extract date part from ISO string or Date object.\n * Returns format: \"YYYY-MM-DD\"\n */\nexport function getDateString(value: unknown): string | null {\n if (!value) return null;\n if (typeof value === 'string') {\n // Handle ISO dates \"2024-01-15T00:00:00.000Z\" -> \"2024-01-15\"\n // Also handle plain date strings \"2024-01-15\"\n const match = value.match(/^(\\d{4}-\\d{2}-\\d{2})/);\n return match ? match[1] : null;\n }\n if (value instanceof Date) {\n return value.toISOString().split('T')[0];\n }\n return null;\n}\n\n/**\n * Apply a single filter to check if a record matches.\n * Returns true if the record passes the filter.\n */\nexport function matchesFilter(record: FilterableRecord, filter: EntityFilterValue): boolean {\n // Use targetField if specified, otherwise fall back to field\n const fieldToCompare = filter.targetField || filter.field;\n const recordValue = record[fieldToCompare];\n const filterValue = filter.value;\n const operator = filter.operator || 'eq';\n\n // Skip if filter value is null/undefined/empty (means \"all\")\n if (filterValue === null || filterValue === undefined || filterValue === '') {\n return true;\n }\n\n switch (operator) {\n case 'eq':\n // Case-insensitive comparison for strings\n if (typeof recordValue === 'string' && typeof filterValue === 'string') {\n return recordValue.toLowerCase() === filterValue.toLowerCase();\n }\n return recordValue === filterValue;\n\n case 'contains':\n if (typeof recordValue !== 'string') return false;\n return recordValue.toLowerCase().includes(String(filterValue).toLowerCase());\n\n case 'in':\n if (Array.isArray(filterValue)) {\n // Case-insensitive for string arrays\n const normalizedFilterValues = filterValue.map(v =>\n typeof v === 'string' ? v.toLowerCase() : v\n );\n const normalizedRecordValue = typeof recordValue === 'string'\n ? recordValue.toLowerCase()\n : recordValue;\n return normalizedFilterValues.includes(normalizedRecordValue);\n }\n return false;\n\n case 'date_eq': {\n // Compare dates ignoring time\n const recordDate = getDateString(recordValue);\n const filterDate = getDateString(filterValue);\n return Boolean(recordDate && filterDate && recordDate === filterDate);\n }\n\n case 'date_gte': {\n // Record date >= filter date\n const recordDate = getDateString(recordValue);\n const filterDate = getDateString(filterValue);\n return Boolean(recordDate && filterDate && recordDate >= filterDate);\n }\n\n case 'date_lte': {\n // Record date <= filter date\n const recordDate = getDateString(recordValue);\n const filterDate = getDateString(filterValue);\n return Boolean(recordDate && filterDate && recordDate <= filterDate);\n }\n\n case 'search': {\n // Search across ALL string/number fields in the record\n // The filterValue is the search term, recordValue is ignored\n // We search all fields, not just the targetField\n if (typeof filterValue !== 'string' || !filterValue.trim()) {\n return true; // Empty search matches all\n }\n const searchTerm = filterValue.toLowerCase();\n return Object.values(record).some((value) => {\n if (value === null || value === undefined) return false;\n return String(value).toLowerCase().includes(searchTerm);\n });\n }\n\n default:\n return true;\n }\n}\n\n/**\n * Apply all filters to a list of records.\n * Returns only records that match ALL filters.\n */\nexport function applyFilters<T extends FilterableRecord>(\n records: T[],\n entityFilters: EntityFilters\n): T[] {\n if (entityFilters.size === 0) return records;\n\n return records.filter(record => {\n for (const [, filter] of entityFilters) {\n if (!matchesFilter(record, filter)) {\n return false;\n }\n }\n return true;\n });\n}\n\n/**\n * Create a filter value with proper defaults.\n */\nexport function createFilter(\n field: string,\n value: unknown,\n operator: FilterOperator = 'eq',\n targetField?: string\n): EntityFilterValue {\n return {\n field,\n value,\n operator,\n targetField: targetField || field\n };\n}\n","/**\n * Entity Store\n *\n * Simple module-level store for runtime entities.\n * No providers needed - hooks import and use directly.\n *\n * NOTE: Mutations create new Map instances to trigger React rerenders\n * when using useSyncExternalStore.\n */\n\nimport {\n type EntityFilterValue,\n type FilterOperator,\n type EntityFilters,\n applyFilters,\n createFilter\n} from './filtering';\n\n// Re-export filtering types for convenience\nexport type { EntityFilterValue, FilterOperator, EntityFilters };\nexport { applyFilters, createFilter };\n\nexport interface Entity {\n id: string;\n type: string;\n [key: string]: unknown;\n}\n\ntype Listener = () => void;\n\n// Module-level state - use `let` so we can reassign to new Map on mutations\nlet entities = new Map<string, Entity>();\nlet filters = new Map<string, EntityFilters>();\nconst listeners = new Set<Listener>();\nlet idCounter = 0;\n\n/**\n * Subscribe to store changes\n */\nexport function subscribe(listener: Listener): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\n/**\n * Notify all listeners of changes\n */\nfunction notify(): void {\n listeners.forEach(listener => listener());\n}\n\n/**\n * Get all entities\n */\nexport function getEntities(): Map<string, Entity> {\n return entities;\n}\n\n/**\n * Get entity by ID\n */\nexport function getEntity(id: string): Entity | undefined {\n return entities.get(id);\n}\n\n/**\n * Get entities by type\n */\nexport function getByType(type: string | string[]): Entity[] {\n const types = Array.isArray(type) ? type : [type];\n return [...entities.values()].filter(e => types.includes(e.type));\n}\n\n/**\n * Get all entities as array\n */\nexport function getAllEntities(): Entity[] {\n return [...entities.values()];\n}\n\n/**\n * Get singleton entity by type (first of that type)\n */\nexport function getSingleton(type: string): Entity | undefined {\n return [...entities.values()].find(e => e.type === type);\n}\n\n/**\n * Spawn a new entity\n */\nexport function spawnEntity(config: { type: string; id?: string; [key: string]: unknown }): string {\n const id = config.id ?? `entity_${++idCounter}`;\n const entity: Entity = { ...config, id };\n // Create new Map to trigger React rerender\n entities = new Map(entities);\n entities.set(id, entity);\n notify();\n return id;\n}\n\n/**\n * Update an entity\n */\nexport function updateEntity(id: string, updates: Partial<Entity>): void {\n const entity = entities.get(id);\n if (entity) {\n // Create new Map to trigger React rerender\n entities = new Map(entities);\n entities.set(id, { ...entity, ...updates });\n notify();\n }\n}\n\n/**\n * Update singleton entity by type\n */\nexport function updateSingleton(type: string, updates: Partial<Entity>): void {\n const entity = getSingleton(type);\n if (entity) {\n updateEntity(entity.id, updates);\n }\n}\n\n/**\n * Remove an entity\n */\nexport function removeEntity(id: string): void {\n if (entities.has(id)) {\n // Create new Map to trigger React rerender\n entities = new Map(entities);\n entities.delete(id);\n notify();\n }\n}\n\n/**\n * Clear all entities\n */\nexport function clearEntities(): void {\n // Create new Map to trigger React rerender\n entities = new Map();\n notify();\n}\n\n// ============================================================================\n// Filter Management\n// ============================================================================\n\n/**\n * Set a filter for an entity type\n * @param entityType - The entity type to filter (e.g., \"Player\", \"Enemy\")\n * @param field - The filter key (e.g., 'status' or 'date_from')\n * @param value - The filter value\n * @param operator - The comparison operator\n * @param targetField - The actual record field to compare (defaults to field)\n */\nexport function setFilter(\n entityType: string,\n field: string,\n value: unknown,\n operator: FilterOperator = 'eq',\n targetField?: string\n): void {\n filters = new Map(filters);\n const entityFilters = new Map(filters.get(entityType) || []);\n entityFilters.set(field, createFilter(field, value, operator, targetField));\n filters.set(entityType, entityFilters);\n notify();\n}\n\n/**\n * Clear a specific filter\n */\nexport function clearFilter(entityType: string, field: string): void {\n const entityFilters = filters.get(entityType);\n if (entityFilters && entityFilters.has(field)) {\n filters = new Map(filters);\n const newFilters = new Map(entityFilters);\n newFilters.delete(field);\n filters.set(entityType, newFilters);\n notify();\n }\n}\n\n/**\n * Clear all filters for an entity type\n */\nexport function clearAllFilters(entityType: string): void {\n if (filters.has(entityType)) {\n filters = new Map(filters);\n filters.set(entityType, new Map());\n notify();\n }\n}\n\n/**\n * Get active filters for an entity type\n */\nexport function getFilters(entityType: string): EntityFilters {\n return filters.get(entityType) || new Map();\n}\n\n/**\n * Get entities by type with optional filtering\n */\nexport function getByTypeFiltered(type: string | string[]): Entity[] {\n const types = Array.isArray(type) ? type : [type];\n let result = [...entities.values()].filter(e => types.includes(e.type));\n\n // Apply filters for each type\n for (const t of types) {\n const typeFilters = filters.get(t);\n if (typeFilters && typeFilters.size > 0) {\n result = applyFilters(result, typeFilters);\n }\n }\n\n return result;\n}\n\n/**\n * Get snapshot for React useSyncExternalStore\n */\nexport function getSnapshot(): Map<string, Entity> {\n return entities;\n}\n\n/**\n * Get filter snapshot for React useSyncExternalStore\n */\nexport function getFilterSnapshot(): Map<string, EntityFilters> {\n return filters;\n}\n"]}