/** * @file Library Defaults Configuration * @description Centralized default values for the Harbor React Library. * * This module provides a single source of truth for all default configuration * values used throughout the library. Instead of hardcoding values in individual * modules, import defaults from here to ensure consistency and easy modification. * * ## Design Principles * * 1. **Centralized**: All defaults in one place for easy discovery and modification * 2. **Typed**: Full TypeScript support with branded types for safety * 3. **Documented**: Each value includes purpose, range, and reasoning * 4. **Overridable**: All defaults can be overridden at runtime via config * 5. **Feature-Flag Ready**: Integration points for conditional behavior * * @module core/config/library-defaults * @version 1.0.0 * * @example * ```typescript * import { TIMING_DEFAULTS, CACHE_DEFAULTS } from '@/lib/core/config/library-defaults'; * * // Use centralized defaults instead of magic numbers * const cache = new RequestCache({ * defaultTtl: CACHE_DEFAULTS.DEFAULT_TTL_MS, * maxEntries: CACHE_DEFAULTS.MAX_ENTRIES, * }); * ``` */ /** * Branded type for milliseconds to prevent unit confusion. */ export type Milliseconds = number & { readonly __brand: 'Milliseconds'; }; /** * Branded type for seconds. */ export type Seconds = number & { readonly __brand: 'Seconds'; }; /** * Branded type for pixels. */ export type Pixels = number & { readonly __brand: 'Pixels'; }; /** * Branded type for percentage (0-1 range). */ export type Percentage = number & { readonly __brand: 'Percentage'; }; export declare const ms: (value: number) => Milliseconds; export declare const sec: (value: number) => Seconds; export declare const px: (value: number) => Pixels; export declare const pct: (value: number) => Percentage; /** One second in milliseconds */ export declare const SECOND: Milliseconds; /** One minute in milliseconds */ export declare const MINUTE: Milliseconds; /** One hour in milliseconds */ export declare const HOUR: Milliseconds; /** One day in milliseconds */ export declare const DAY: Milliseconds; /** * Default timing values used throughout the library. */ export declare const TIMING_DEFAULTS: { /** * Default timeout for API requests. * @default 30000 (30 seconds) */ readonly API_TIMEOUT_MS: Milliseconds; /** * Default timeout for module loading. * @default 5000 (5 seconds) */ readonly MODULE_LOAD_TIMEOUT_MS: Milliseconds; /** * Default timeout for hydration tasks. * @default 10000 (10 seconds) */ readonly HYDRATION_TASK_TIMEOUT_MS: Milliseconds; /** * Default timeout for streaming operations. * @default 60000 (60 seconds) */ readonly STREAM_TIMEOUT_MS: Milliseconds; /** * Base delay for retry operations. * @default 1000 (1 second) */ readonly RETRY_BASE_DELAY_MS: Milliseconds; /** * Maximum delay for retry backoff. * @default 30000 (30 seconds) */ readonly RETRY_MAX_DELAY_MS: Milliseconds; /** * Maximum jitter range for retry delays (as percentage). * @default 0.25 (25%) */ readonly RETRY_JITTER_RANGE: Percentage; /** * Maximum number of retry attempts. * @default 3 */ readonly MAX_RETRY_ATTEMPTS: 3; /** * Default debounce delay for user input. * @default 300 (300ms) */ readonly DEBOUNCE_DELAY_MS: Milliseconds; /** * Default throttle delay for scroll/resize handlers. * @default 100 (100ms) */ readonly THROTTLE_DELAY_MS: Milliseconds; /** * Default session timeout. * @default 1800000 (30 minutes) */ readonly SESSION_TIMEOUT_MS: Milliseconds; /** * Activity check interval for session monitoring. * @default 60000 (1 minute) */ readonly ACTIVITY_CHECK_INTERVAL_MS: Milliseconds; /** * Default animation duration. * @default 200 (200ms) */ readonly ANIMATION_DURATION_MS: Milliseconds; /** * Default toast display duration. * @default 5000 (5 seconds) */ readonly TOAST_DURATION_MS: Milliseconds; /** * Default polling interval for status checks. * @default 1000 (1 second) */ readonly POLL_INTERVAL_MS: Milliseconds; /** * Interval for garbage collection in caches. * @default 60000 (1 minute) */ readonly GC_INTERVAL_MS: Milliseconds; }; /** * Default cache configuration values. */ export declare const CACHE_DEFAULTS: { /** * Default cache TTL (time-to-live). * @default 300000 (5 minutes) */ readonly DEFAULT_TTL_MS: Milliseconds; /** * Maximum cache entries. * @default 100 */ readonly MAX_ENTRIES: 100; /** * Request deduplication window. * @default 100 (100ms) */ readonly DEDUPLICATION_WINDOW_MS: Milliseconds; /** * Stale-while-revalidate TTL. * @default 60000 (1 minute) */ readonly STALE_TTL_MS: Milliseconds; }; /** * Default queue and buffer sizes. */ export declare const QUEUE_DEFAULTS: { /** * Maximum queue size for hydration tasks. * @default 1000 */ readonly MAX_HYDRATION_QUEUE_SIZE: 1000; /** * Maximum queue size for request batching. * @default 50 */ readonly MAX_BATCH_SIZE: 50; /** * Maximum buffer size for streaming. * @default 1000 */ readonly MAX_STREAM_BUFFER_SIZE: 1000; /** * Maximum offline queue size. * @default 100 */ readonly MAX_OFFLINE_QUEUE_SIZE: 100; /** * Maximum event history size. * @default 1000 */ readonly MAX_EVENT_HISTORY_SIZE: 1000; /** * Maximum navigation history length. * @default 50 */ readonly MAX_NAVIGATION_HISTORY: 50; }; /** * Default performance configuration values. */ export declare const PERFORMANCE_DEFAULTS: { /** * Target frame time for smooth 60fps. * @default 16 (16ms) */ readonly FRAME_TIME_MS: Milliseconds; /** * Maximum tasks per frame to prevent jank. * @default 10 */ readonly MAX_TASKS_PER_FRAME: 10; /** * Minimum idle time before scheduling low-priority work. * @default 100 (100ms) */ readonly MIN_IDLE_TIME_MS: Milliseconds; /** * Moderate memory pressure threshold. * @default 0.7 (70%) */ readonly MEMORY_MODERATE_THRESHOLD: Percentage; /** * Critical memory pressure threshold. * @default 0.9 (90%) */ readonly MEMORY_CRITICAL_THRESHOLD: Percentage; /** * Default sample rate for performance metrics. * @default 1.0 (100%) */ readonly METRICS_SAMPLE_RATE: Percentage; /** * Report interval for performance metrics. * @default 60000 (1 minute) */ readonly METRICS_REPORT_INTERVAL_MS: Milliseconds; }; /** * Default UI configuration values. */ export declare const UI_DEFAULTS: { /** * Default sidebar width. * @default 280 */ readonly SIDEBAR_WIDTH_PX: Pixels; /** * Collapsed sidebar width. * @default 64 */ readonly SIDEBAR_COLLAPSED_WIDTH_PX: Pixels; /** * Default modal max width. * @default 500 */ readonly MODAL_MAX_WIDTH_PX: Pixels; /** * Base spacing unit. * @default 4 */ readonly SPACING_UNIT_PX: Pixels; /** * Default border radius. * @default 8 */ readonly BORDER_RADIUS_PX: Pixels; /** * Z-index for dropdowns. * @default 100 */ readonly Z_INDEX_DROPDOWN: 100; /** * Z-index for modals. * @default 200 */ readonly Z_INDEX_MODAL: 200; /** * Z-index for toasts. * @default 300 */ readonly Z_INDEX_TOAST: 300; /** * Z-index for tooltips. * @default 400 */ readonly Z_INDEX_TOOLTIP: 400; }; /** * Default network configuration values. */ export declare const NETWORK_DEFAULTS: { /** * Maximum concurrent requests. * @default 6 */ readonly MAX_CONCURRENT_REQUESTS: 6; /** * Rate limit: requests per window. * @default 100 */ readonly RATE_LIMIT_MAX_REQUESTS: 100; /** * Rate limit: window duration. * @default 60000 (1 minute) */ readonly RATE_LIMIT_WINDOW_MS: Milliseconds; /** * Connection ping interval. * @default 30000 (30 seconds) */ readonly PING_INTERVAL_MS: Milliseconds; /** * WebSocket reconnect delay. * @default 3000 (3 seconds) */ readonly WS_RECONNECT_DELAY_MS: Milliseconds; /** * Maximum WebSocket reconnect attempts. * @default 10 */ readonly MAX_WS_RECONNECT_ATTEMPTS: 10; }; /** * Standard feature flag keys for library features. * These should be used consistently across all modules. */ export declare const LIBRARY_FEATURE_FLAGS: { /** Enable streaming data support */ readonly STREAMING_ENABLED: "lib.streaming.enabled"; /** Enable progressive hydration */ readonly HYDRATION_ENABLED: "lib.hydration.enabled"; /** Enable priority-based hydration */ readonly HYDRATION_PRIORITY_ENABLED: "lib.hydration.priority"; /** Enable offline queue support */ readonly OFFLINE_QUEUE_ENABLED: "lib.offline.enabled"; /** Enable data sync features */ readonly DATA_SYNC_ENABLED: "lib.data.sync.enabled"; /** Enable predictive prefetching */ readonly PREDICTIVE_PREFETCH_ENABLED: "lib.perf.predictive.enabled"; /** Enable memory pressure monitoring */ readonly MEMORY_MONITORING_ENABLED: "lib.perf.memory.enabled"; /** Enable render tracking */ readonly RENDER_TRACKING_ENABLED: "lib.perf.render.enabled"; /** Enable debug mode */ readonly DEBUG_MODE: "lib.debug.enabled"; /** Enable verbose logging */ readonly VERBOSE_LOGGING: "lib.debug.verbose"; /** Enable DevTools integration */ readonly DEVTOOLS_ENABLED: "lib.debug.devtools"; }; /** * Complete library configuration interface. * Use this type for providing runtime overrides. */ export interface LibraryConfig { readonly timing: Partial; readonly cache: Partial; readonly queue: Partial; readonly performance: Partial; readonly ui: Partial; readonly network: Partial; readonly features: Partial>; } /** * Get a timing default with optional override. */ export declare function getTimingDefault(key: K, override?: number): (typeof TIMING_DEFAULTS)[K]; /** * Get a cache default with optional override. */ export declare function getCacheDefault(key: K, override?: number): (typeof CACHE_DEFAULTS)[K]; /** * Get a queue default with optional override. */ export declare function getQueueDefault(key: K, override?: number): (typeof QUEUE_DEFAULTS)[K]; export declare const LIBRARY_DEFAULTS: { readonly timing: { /** * Default timeout for API requests. * @default 30000 (30 seconds) */ readonly API_TIMEOUT_MS: Milliseconds; /** * Default timeout for module loading. * @default 5000 (5 seconds) */ readonly MODULE_LOAD_TIMEOUT_MS: Milliseconds; /** * Default timeout for hydration tasks. * @default 10000 (10 seconds) */ readonly HYDRATION_TASK_TIMEOUT_MS: Milliseconds; /** * Default timeout for streaming operations. * @default 60000 (60 seconds) */ readonly STREAM_TIMEOUT_MS: Milliseconds; /** * Base delay for retry operations. * @default 1000 (1 second) */ readonly RETRY_BASE_DELAY_MS: Milliseconds; /** * Maximum delay for retry backoff. * @default 30000 (30 seconds) */ readonly RETRY_MAX_DELAY_MS: Milliseconds; /** * Maximum jitter range for retry delays (as percentage). * @default 0.25 (25%) */ readonly RETRY_JITTER_RANGE: Percentage; /** * Maximum number of retry attempts. * @default 3 */ readonly MAX_RETRY_ATTEMPTS: 3; /** * Default debounce delay for user input. * @default 300 (300ms) */ readonly DEBOUNCE_DELAY_MS: Milliseconds; /** * Default throttle delay for scroll/resize handlers. * @default 100 (100ms) */ readonly THROTTLE_DELAY_MS: Milliseconds; /** * Default session timeout. * @default 1800000 (30 minutes) */ readonly SESSION_TIMEOUT_MS: Milliseconds; /** * Activity check interval for session monitoring. * @default 60000 (1 minute) */ readonly ACTIVITY_CHECK_INTERVAL_MS: Milliseconds; /** * Default animation duration. * @default 200 (200ms) */ readonly ANIMATION_DURATION_MS: Milliseconds; /** * Default toast display duration. * @default 5000 (5 seconds) */ readonly TOAST_DURATION_MS: Milliseconds; /** * Default polling interval for status checks. * @default 1000 (1 second) */ readonly POLL_INTERVAL_MS: Milliseconds; /** * Interval for garbage collection in caches. * @default 60000 (1 minute) */ readonly GC_INTERVAL_MS: Milliseconds; }; readonly cache: { /** * Default cache TTL (time-to-live). * @default 300000 (5 minutes) */ readonly DEFAULT_TTL_MS: Milliseconds; /** * Maximum cache entries. * @default 100 */ readonly MAX_ENTRIES: 100; /** * Request deduplication window. * @default 100 (100ms) */ readonly DEDUPLICATION_WINDOW_MS: Milliseconds; /** * Stale-while-revalidate TTL. * @default 60000 (1 minute) */ readonly STALE_TTL_MS: Milliseconds; }; readonly queue: { /** * Maximum queue size for hydration tasks. * @default 1000 */ readonly MAX_HYDRATION_QUEUE_SIZE: 1000; /** * Maximum queue size for request batching. * @default 50 */ readonly MAX_BATCH_SIZE: 50; /** * Maximum buffer size for streaming. * @default 1000 */ readonly MAX_STREAM_BUFFER_SIZE: 1000; /** * Maximum offline queue size. * @default 100 */ readonly MAX_OFFLINE_QUEUE_SIZE: 100; /** * Maximum event history size. * @default 1000 */ readonly MAX_EVENT_HISTORY_SIZE: 1000; /** * Maximum navigation history length. * @default 50 */ readonly MAX_NAVIGATION_HISTORY: 50; }; readonly performance: { /** * Target frame time for smooth 60fps. * @default 16 (16ms) */ readonly FRAME_TIME_MS: Milliseconds; /** * Maximum tasks per frame to prevent jank. * @default 10 */ readonly MAX_TASKS_PER_FRAME: 10; /** * Minimum idle time before scheduling low-priority work. * @default 100 (100ms) */ readonly MIN_IDLE_TIME_MS: Milliseconds; /** * Moderate memory pressure threshold. * @default 0.7 (70%) */ readonly MEMORY_MODERATE_THRESHOLD: Percentage; /** * Critical memory pressure threshold. * @default 0.9 (90%) */ readonly MEMORY_CRITICAL_THRESHOLD: Percentage; /** * Default sample rate for performance metrics. * @default 1.0 (100%) */ readonly METRICS_SAMPLE_RATE: Percentage; /** * Report interval for performance metrics. * @default 60000 (1 minute) */ readonly METRICS_REPORT_INTERVAL_MS: Milliseconds; }; readonly ui: { /** * Default sidebar width. * @default 280 */ readonly SIDEBAR_WIDTH_PX: Pixels; /** * Collapsed sidebar width. * @default 64 */ readonly SIDEBAR_COLLAPSED_WIDTH_PX: Pixels; /** * Default modal max width. * @default 500 */ readonly MODAL_MAX_WIDTH_PX: Pixels; /** * Base spacing unit. * @default 4 */ readonly SPACING_UNIT_PX: Pixels; /** * Default border radius. * @default 8 */ readonly BORDER_RADIUS_PX: Pixels; /** * Z-index for dropdowns. * @default 100 */ readonly Z_INDEX_DROPDOWN: 100; /** * Z-index for modals. * @default 200 */ readonly Z_INDEX_MODAL: 200; /** * Z-index for toasts. * @default 300 */ readonly Z_INDEX_TOAST: 300; /** * Z-index for tooltips. * @default 400 */ readonly Z_INDEX_TOOLTIP: 400; }; readonly network: { /** * Maximum concurrent requests. * @default 6 */ readonly MAX_CONCURRENT_REQUESTS: 6; /** * Rate limit: requests per window. * @default 100 */ readonly RATE_LIMIT_MAX_REQUESTS: 100; /** * Rate limit: window duration. * @default 60000 (1 minute) */ readonly RATE_LIMIT_WINDOW_MS: Milliseconds; /** * Connection ping interval. * @default 30000 (30 seconds) */ readonly PING_INTERVAL_MS: Milliseconds; /** * WebSocket reconnect delay. * @default 3000 (3 seconds) */ readonly WS_RECONNECT_DELAY_MS: Milliseconds; /** * Maximum WebSocket reconnect attempts. * @default 10 */ readonly MAX_WS_RECONNECT_ATTEMPTS: 10; }; readonly featureFlags: { /** Enable streaming data support */ readonly STREAMING_ENABLED: "lib.streaming.enabled"; /** Enable progressive hydration */ readonly HYDRATION_ENABLED: "lib.hydration.enabled"; /** Enable priority-based hydration */ readonly HYDRATION_PRIORITY_ENABLED: "lib.hydration.priority"; /** Enable offline queue support */ readonly OFFLINE_QUEUE_ENABLED: "lib.offline.enabled"; /** Enable data sync features */ readonly DATA_SYNC_ENABLED: "lib.data.sync.enabled"; /** Enable predictive prefetching */ readonly PREDICTIVE_PREFETCH_ENABLED: "lib.perf.predictive.enabled"; /** Enable memory pressure monitoring */ readonly MEMORY_MONITORING_ENABLED: "lib.perf.memory.enabled"; /** Enable render tracking */ readonly RENDER_TRACKING_ENABLED: "lib.perf.render.enabled"; /** Enable debug mode */ readonly DEBUG_MODE: "lib.debug.enabled"; /** Enable verbose logging */ readonly VERBOSE_LOGGING: "lib.debug.verbose"; /** Enable DevTools integration */ readonly DEVTOOLS_ENABLED: "lib.debug.devtools"; }; }; export default LIBRARY_DEFAULTS;