# smartchok - Technical Hints ## Chokidar 4.x Migration (2024) The module has been migrated from `@tempfix/watcher` to `chokidar` 4.x. Key changes: ### Dependencies - **Removed**: `@tempfix/watcher` (a fork of fabiospampinato/watcher) - **Added**: `chokidar` 4.x and `picomatch` ### Why picomatch? Chokidar 4.x removed built-in glob pattern support. We use `picomatch` to maintain backward compatibility and provide glob pattern matching functionality. ### Implementation Details 1. **Glob pattern extraction**: The `getGlobBase()` method extracts base directories from glob patterns 2. **Pattern matching**: Each glob pattern is compiled to a picomatch matcher function 3. **Event filtering**: File system events are filtered based on glob patterns before being emitted 4. **Path normalization**: Paths are normalized to handle different formats (with/without leading ./) ### Event Handling Chokidar 4.x events are mapped 1:1 with smartchok events: - `add`, `change`, `unlink`: File events - `addDir`, `unlinkDir`: Directory events - `error`: Error events - `raw`: Raw events from underlying watchers - `ready`: Emitted when initial scan is complete ### Testing All existing tests pass without modification, confirming backward compatibility is maintained.