How paulmillr/chokidar works
Main Components
a) Core Components:
• File System Interface Layer
• Event Normalization Engine
• Watcher Manager
• Event Emitter System
b) Supporting Components:
• Configuration Handler
• Path Filter System
• Stats Collection System
[Application Layer (Consumer)]
• ↕
[Chokidar Public API]
• ↕
[Watcher Manager]
• ↙ ↓ ↘
[FS Watch] [FS WatchFile] [Stats Collector]
• ↓
[Event Normalizer]
• ↓
[Native FS API]
Component Details
a) Public API Layer:
• Main watch() method
• FSWatcher instance methods (add, unwatch, close, getWatched)
• Event emission capabilities (add, change, unlink, etc.)
b) Watcher Manager:
• Decision logic between fs.watch and fs.watchFile
• Configuration options handling
• Path management system
c) Event Processing:
• Event normalization flow
• Atomic write detection
• Chunked write handling
Specific Implementation Details
• Rectangles: Core components
• Rounded rectangles: APIs and interfaces
• Hexagons: Decision points
• Blue: Core functionality
• Green: File system operations
• Yellow: Event handling
• Gray: Configuration and utilities
Important Relationships to Highlight
• How the watching strategies (polling vs. native) are selected
• Event normalization process
• Path filtering system
• How atomic and chunked writes are handled
Configuration Flow
How options affect the system:
• usePolling
• awaitWriteFinish
• ignored paths
• atomic writes
• depth limitations
This design should reflect Chokidar's v4 architecture, which has been simplified to have only one dependency and focuses on core file watching functionality without glob support.