UNPKG

@re-shell/cli

Version:

Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja

143 lines (142 loc) 5.18 kB
import * as fs from 'fs-extra'; import { EventEmitter } from 'events'; import { WorkspaceEntry } from './workspace-schema'; import { PlatformCapabilities, WatcherFallbackOptions, WatcherHealthStatus } from './platform-watcher'; export interface FileWatchEvent { type: FileChangeType; path: string; workspace?: string; timestamp: number; size?: number; stats?: fs.Stats; } export type FileChangeType = 'add' | 'change' | 'unlink' | 'addDir' | 'unlinkDir'; export interface WatchOptions { ignored?: string | RegExp | (string | RegExp)[]; persistent?: boolean; ignoreInitial?: boolean; followSymlinks?: boolean; cwd?: string; disableGlobbing?: boolean; usePolling?: boolean; interval?: number; binaryInterval?: number; alwaysStat?: boolean; depth?: number; awaitWriteFinish?: boolean | { stabilityThreshold?: number; pollInterval?: number; }; ignorePermissionErrors?: boolean; atomic?: boolean; enableFallbacks?: boolean; platformOptimizations?: boolean; fallbackOptions?: Partial<WatcherFallbackOptions>; platformSpecific?: { darwin?: any; linux?: any; win32?: any; [key: string]: any; }; } export interface ChangePropagationRule { id: string; name: string; description: string; sourcePattern: RegExp | string; targetWorkspaces: string[] | 'all' | ((workspace: string) => boolean); actionType: PropagationActionType; condition?: (event: FileWatchEvent, workspaces: Record<string, WorkspaceEntry>) => boolean; transform?: (event: FileWatchEvent) => FileWatchEvent; debounceMs?: number; } export type PropagationActionType = 'rebuild' | 'restart-dev' | 'run-tests' | 'invalidate-cache' | 'notify' | 'custom'; export interface PropagationEvent { rule: ChangePropagationRule; sourceEvent: FileWatchEvent; targetWorkspaces: string[]; timestamp: number; actionType: PropagationActionType; } export interface WatcherStats { totalEvents: number; eventsByType: Record<FileChangeType, number>; eventsByWorkspace: Record<string, number>; propagatedEvents: number; startTime: number; uptime: number; watchedPaths: string[]; activeRules: number; platformCapabilities: PlatformCapabilities; activeWatchers: number; fallbackWatchers: number; healthyWatchers: number; watcherFailures: number; } export declare class FileWatcher extends EventEmitter { private watchers; private watchedPaths; private propagationRules; private debounceTimers; private eventDebouncer; private platformWatcher; private stats; private workspaces; private rootPath; private isActive; private watcherFailures; constructor(rootPath?: string, fallbackOptions?: Partial<WatcherFallbackOptions>); private setupPlatformWatcherListeners; startWatching(workspaces: Record<string, WorkspaceEntry>, options?: WatchOptions): Promise<void>; stopWatching(): Promise<void>; addPropagationRule(rule: ChangePropagationRule): void; removePropagationRule(ruleId: string): boolean; getStats(): WatcherStats; isWatching(): boolean; getPlatformCapabilities(): PlatformCapabilities; getPlatformWatcherHealth(watcherId?: string): WatcherHealthStatus | Map<string, WatcherHealthStatus>; testPlatformCapabilities(): Promise<import("./platform-watcher").PlatformTestResult>; private setupDebouncerListeners; private getWorkspaceForPath; private handleFileEvent; private processPropagationRules; private matchesRule; private propagateChange; private debouncePropagate; private emitPropagation; private resolveTargetWorkspaces; private watchRootFiles; private handleWatchError; private handleWatchReady; configureDebouncer(options: Partial<{ delay: number; maxDelay: number; maxBatchSize: number; enableDeduplication: boolean; enableBatching: boolean; groupByType: boolean; includeStats: boolean; }>): void; addDebouncerFilter(filter: { patterns: RegExp[]; types: string[]; minFileSize?: number; maxFileSize?: number; extensions?: string[]; excludePatterns?: RegExp[]; }): void; getDebouncerStats(): { pendingEvents: number; activeTimers: number; activeBatches: number; totalFilters: number; options: any; }; flushDebouncedEvents(): void; private initializeDefaultRules; } export declare function createFileWatcher(rootPath?: string, fallbackOptions?: Partial<WatcherFallbackOptions>): Promise<FileWatcher>; export declare function startWorkspaceWatcher(workspaceFile: string, options?: WatchOptions, fallbackOptions?: Partial<WatcherFallbackOptions>): Promise<FileWatcher>; export declare function createCrossPlatformWatcher(rootPath?: string, enableFallbacks?: boolean): Promise<FileWatcher>; export declare function getPlatformCapabilities(): PlatformCapabilities; export declare function testPlatformWatching(): Promise<import("./platform-watcher").PlatformTestResult>;