/** Files: handles the files in the project. Currently traverses the directory structure twice: once to populate the files list used by the router and once to create the list used by the file system watcher. Has the following limits so we can catch when Kitten is run in a multi-project folder and exit early without potentially hitting V8 heap memory limits: KITTEN_MAXIMUM_NUMBER_OF_PATHS=10000 KITTEN_MAXIMUM_DIRECTORY_DEPTH=16 The paths limit is enforced strictly and throws if hit, whereas the depth limit simply limits the development-time file system watcher to not watch depths beyond it (but no error is raised). Neither of those limits should be hit for regular Small Web development with Kitten but if you need to, you can override those constants using environment variables with the same name to raise the limits when running Kitten. Copyright ⓒ 2021-present, Aral Balkan (mail@ar.al) Small Technology Foundation (https://small-tech.org) License: AGPL version 3.0. */ import Watcher from 'watcher'; export declare const MAXIMUM_NUMBER_OF_PATHS: number; export declare const MAXIMUM_DIRECTORY_DEPTH: number; /** Thrown when folder being served hits Kitten’s project file count limit. */ export declare class ProjectTooLargeError extends Error { constructor(); } /** Thrown when person tries to serve the root folder (/). */ export declare class CannotServeRootError extends Error { constructor(); } /** Thrown when person tries to serve their home folder (~). */ export declare class CannotServeHomeFolderError extends Error { constructor(); } export declare class FileEventDetails { itemType: string; eventType: string; itemPath: string; constructor(itemType?: string, eventType?: string, itemPath?: string); } type FilesByExtension = Record; export declare class FilesByExtensionCategoryType { [categoryType: string]: FilesByExtension; constructor(); } /** Async filter function. Thanks to: https://stackoverflow.com/a/62820464 */ export declare function asyncFilter(array: any[], predicate: (value: any, index: number, array?: any[]) => any): Promise; /** Checks if passed symlink is within the root directory of the project we’re serving and thus whether it is safe. */ export declare function isSafeSymlink(symlink: string): Promise; export default class Files extends EventTarget { static isBeingInstantiatedByFactoryMethod: boolean; /** Static factory method: constructs a Files instance, asynchronously initialises it, and returns the list of files found organised by their extension category type. */ static new(basePath?: string): Promise; watcher: Watcher; pathToWatch: string; byExtensionCategoryType: FilesByExtensionCategoryType; /** Find files at given base path and start watching for changes. */ constructor(basePath: string); initialise(): Promise; /** Adds file to the list of files. */ addFile(filePath: string): void; /** Notifies file listeners that an action has happened on a file. */ notifyListeners(fileEventDetails: FileEventDetails): Promise; /** Closes the watcher. */ close(): void; } export {};