import { default as React, ReactNode } from 'react'; /** * Service contract definition * Defines a typed interface for a service that can be resolved at runtime */ export interface ServiceContract { readonly id: symbol; readonly name: string; readonly defaultValue?: T; } /** * Service registration options */ export interface ServiceRegistrationOptions { /** Scope of the service instance */ scope?: 'singleton' | 'transient'; /** Tags for service discovery */ tags?: string[]; } /** * Internal service registration */ interface ServiceRegistration { contract: ServiceContract; implementation: T; scope: 'singleton' | 'transient'; tags: string[]; } /** * Feature dependency injection container * Manages service registrations and resolution */ export declare class FeatureDIContainer { private services; private singletons; private factoryFunctions; /** * Register a service implementation */ register(contract: ServiceContract, implementation: T, options?: ServiceRegistrationOptions): this; /** * Register a factory function for lazy instantiation */ registerFactory(contract: ServiceContract, factory: () => T, options?: ServiceRegistrationOptions): this; /** * Resolve a service */ resolve(contract: ServiceContract): T; /** * Try to resolve a service, returning undefined if not found */ tryResolve(contract: ServiceContract): T | undefined; /** * Check if a service is registered */ has(contract: ServiceContract): boolean; /** * Unregister a service */ unregister(contract: ServiceContract): boolean; /** * Clear all registrations */ clear(): void; /** * Get all services with a specific tag */ getByTag(tag: string): ServiceRegistration[]; /** * Get all registered service contracts */ getRegisteredContracts(): ServiceContract[]; /** * Create a child container that inherits from this container */ createChild(): FeatureDIContainer; } /** * Get the global DI container */ export declare function getContainer(): FeatureDIContainer; /** * Register a service in the global container */ export declare function registerService(contract: ServiceContract, implementation: T, options?: ServiceRegistrationOptions): void; /** * Create a typed service contract */ export declare function createServiceContract(name: string, defaultValue?: T): ServiceContract; /** * DI Provider component */ export declare function FeatureDIProvider({ container, children, }: { container?: FeatureDIContainer; children: ReactNode; }): React.ReactElement; /** * Hook to get the DI container */ export declare function useDIContainer(): FeatureDIContainer; /** * Hook to resolve a service */ export declare function useService(contract: ServiceContract): T; /** * Hook to try to resolve a service (returns undefined if not found) */ export declare function useTryService(contract: ServiceContract): T | undefined; /** * Hook to check if a service exists */ export declare function useHasService(contract: ServiceContract): boolean; /** * Hook to get all services with a specific tag */ export declare function useServicesByTag(tag: string): T[]; /** * Analytics service contract */ export interface AnalyticsService { track(event: string, properties?: Record): void; identify(userId: string, traits?: Record): void; page(name: string, properties?: Record): void; reset(): void; } export declare const AnalyticsContract: ServiceContract; /** * Notification service contract */ export interface NotificationService { success(message: string, options?: NotificationOptions): void; error(message: string, options?: NotificationOptions): void; warning(message: string, options?: NotificationOptions): void; info(message: string, options?: NotificationOptions): void; dismiss(id?: string): void; } interface NotificationOptions { duration?: number; title?: string; action?: { label: string; onClick: () => void; }; } export declare const NotificationContract: ServiceContract; /** * Navigation service contract */ export interface NavigationService { navigate(path: string, options?: { replace?: boolean; }): void; goBack(): void; goForward(): void; replace(path: string): void; getCurrentPath(): string; } export declare const NavigationContract: ServiceContract; /** * Storage service contract */ export interface StorageService { get(key: string): T | null; set(key: string, value: T): void; remove(key: string): void; clear(): void; } export declare const StorageContract: ServiceContract; /** * Event handler type */ type EventHandler = (payload: T) => void; /** * Cross-feature event bus contract */ export interface FeatureEventBus { emit(event: string, payload?: T): void; on(event: string, handler: EventHandler): () => void; once(event: string, handler: EventHandler): () => void; off(event: string, handler: EventHandler): void; offAll(event?: string): void; } export declare const FeatureEventBusContract: ServiceContract; /** * Simple event bus implementation */ export declare class SimpleFeatureEventBus implements FeatureEventBus { private listeners; private onceListeners; emit(event: string, payload?: T): void; on(event: string, handler: EventHandler): () => void; once(event: string, handler: EventHandler): () => void; off(event: string, handler: EventHandler): void; offAll(event?: string): void; } /** * Hook to use the feature event bus */ export declare function useFeatureEventBus(): FeatureEventBus; /** * Hook to subscribe to feature events * Automatically unsubscribes on unmount */ export declare function useFeatureEvent(event: string, handler: EventHandler): void; export {};