ordojs
Version:
A revolutionary web framework with compile-time optimizations and unified client-server development
125 lines (124 loc) • 3.19 kB
TypeScript
/**
* @fileoverview OrdoJS CLI - File Watcher
*
* Efficient file system monitoring with intelligent change detection
* and dependency tracking for hot module replacement.
*/
import { EventEmitter } from 'events';
/**
* File change event types
*/
export declare enum FileChangeType {
ADDED = "added",
CHANGED = "changed",
DELETED = "deleted"
}
/**
* File change event data
*/
export interface FileChangeEvent {
/** Type of change */
type: FileChangeType;
/** Absolute path to the changed file */
filePath: string;
/** Relative path from the watched directory */
relativePath: string;
/** Timestamp of the change */
timestamp: number;
/** File extension */
extension: string;
}
/**
* File watcher options
*/
export interface FileWatcherOptions {
/** Directory to watch */
watchDir: string;
/** File patterns to watch (glob patterns) */
patterns?: string[];
/** File patterns to ignore */
ignorePatterns?: string[];
/** Debounce delay in milliseconds */
debounceMs?: number;
/** Enable recursive watching */
recursive?: boolean;
}
/**
* Dependency tracking information
*/
export interface DependencyInfo {
/** Files that depend on this file */
dependents: Set<string>;
/** Files that this file depends on */
dependencies: Set<string>;
/** Last modification time */
lastModified: number;
}
export declare class FileWatcher extends EventEmitter {
private options;
private watchers;
private dependencyGraph;
private debounceTimers;
private isWatching;
/**
* Create a new FileWatcher instance
*/
constructor(options: FileWatcherOptions);
/**
* Start watching files
*/
start(): Promise<void>;
/**
* Stop watching files
*/
stop(): Promise<void>;
/**
* Get files that are affected by a change to the given file
*/
getAffectedFiles(filePath: string): string[];
/**
* Add a dependency relationship
*/
addDependency(dependent: string, dependency: string): void;
/**
* Remove a dependency relationship
*/
removeDependency(dependent: string, dependency: string): void;
/**
* Get dependency information for a file
*/
getDependencyInfo(filePath: string): DependencyInfo | undefined;
private shouldWatchFile;
/**
* Simple glob pattern matching
*/
private matchesPattern;
/**
* Start watching the directory
*/
private startWatching; /**
* Handle file change events with debouncing
*/
private handleFileChange;
/**
* Process a file change after debouncing
*/
private processFileChange;
/**
* Build initial dependency graph by scanning existing files
*/
private buildInitialDependencyGraph;
/**
* Update dependency information for a file
*/
private updateDependencyInfo;
/**
* Remove dependency information for a deleted file
*/
private removeDependencyInfo;
/**
* Recursively collect all dependents of a file
*/
private collectDependents;
}
//# sourceMappingURL=file-watcher.d.ts.map