{"version":3,"file":"useModuleSystem.mjs","sources":["../../../../src/lib/vdom/hooks/useModuleSystem.ts"],"sourcesContent":["/**\n * @file Module System Hooks\n * @description Hooks for accessing module system context and utilities\n */\n\nimport { useContext } from 'react';\nimport type { ModuleId } from '../types';\nimport type { ModuleSystemContextValue } from '../ModuleProviderContext';\nimport { ModuleSystemContext, ModuleHierarchyContext } from '../ModuleProviderContext';\nimport type { VDOMPool } from '../vdom-pool';\nimport type { ModuleRegistry } from '../module-registry';\nimport type { ModuleLoader } from '../module-loader';\nimport type { ModuleEventBus } from '../event-bus';\n\n// ============================================================================\n// Context Hooks\n// ============================================================================\n\n/**\n * Hook to access the module system context.\n * @throws Error if used outside of ModuleProvider\n * @returns Module system context value\n */\nexport function useModuleSystem(): ModuleSystemContextValue {\n  const context = useContext<ModuleSystemContextValue | null>(ModuleSystemContext);\n  if (context === null || context === undefined) {\n    throw new Error('useModuleSystem must be used within a ModuleProvider');\n  }\n  return context;\n}\n\n/**\n * Hook to access the module hierarchy context.\n * @returns Module hierarchy context value\n */\nexport function useModuleHierarchy(): {\n  moduleId: ModuleId | null;\n  depth: number;\n  path: ModuleId[];\n} {\n  return useContext<{\n    moduleId: ModuleId | null;\n    depth: number;\n    path: ModuleId[];\n  }>(ModuleHierarchyContext);\n}\n\n// ============================================================================\n// Utility Hooks\n// ============================================================================\n\n/**\n * Hook to get the VDOM pool.\n * @returns VDOM pool instance\n */\nexport function useVDOMPool(): VDOMPool {\n  const { pool } = useModuleSystem();\n  return pool;\n}\n\n/**\n * Hook to get the module registry.\n * @returns Module registry instance\n */\nexport function useModuleRegistry(): ModuleRegistry {\n  const { registry } = useModuleSystem();\n  return registry;\n}\n\n/**\n * Hook to get the module loader.\n * @returns Module loader instance\n */\nexport function useModuleLoader(): ModuleLoader {\n  const { loader } = useModuleSystem();\n  return loader;\n}\n\n/**\n * Hook to get the event bus.\n * @returns Event bus instance\n */\nexport function useEventBus(): ModuleEventBus {\n  const { eventBus } = useModuleSystem();\n  return eventBus;\n}\n\n/**\n * Hook to check if in development mode.\n * @returns Whether in development mode\n */\nexport function useDevMode(): boolean {\n  const { config } = useModuleSystem();\n  return config.devMode ?? false;\n}\n"],"names":["useModuleSystem","context","useContext","ModuleSystemContext","useModuleHierarchy","ModuleHierarchyContext","useVDOMPool","pool","useModuleRegistry","registry","useModuleLoader","loader","useEventBus","eventBus","useDevMode","config"],"mappings":";;AAuBO,SAASA,IAA4C;AAC1D,QAAMC,IAAUC,EAA4CC,CAAmB;AAC/E,MAAIF,KAAY;AACd,UAAM,IAAI,MAAM,sDAAsD;AAExE,SAAOA;AACT;AAMO,SAASG,IAId;AACA,SAAOF,EAIJG,CAAsB;AAC3B;AAUO,SAASC,IAAwB;AACtC,QAAM,EAAE,MAAAC,EAAA,IAASP,EAAA;AACjB,SAAOO;AACT;AAMO,SAASC,IAAoC;AAClD,QAAM,EAAE,UAAAC,EAAA,IAAaT,EAAA;AACrB,SAAOS;AACT;AAMO,SAASC,IAAgC;AAC9C,QAAM,EAAE,QAAAC,EAAA,IAAWX,EAAA;AACnB,SAAOW;AACT;AAMO,SAASC,IAA8B;AAC5C,QAAM,EAAE,UAAAC,EAAA,IAAab,EAAA;AACrB,SAAOa;AACT;AAMO,SAASC,IAAsB;AACpC,QAAM,EAAE,QAAAC,EAAA,IAAWf,EAAA;AACnB,SAAOe,EAAO,WAAW;AAC3B;"}