import fs from 'node:fs'; export declare const DIR: unique symbol; /** * A file's identity, as `:`. An inode number is only unique * within one filesystem, so the device it came from is part of the identity: * without it two unrelated files on different devices can collide and be * taken for the same file, leaving the injected copy stale. */ export type File = string; export type Dir = typeof DIR; /** * A link to something inside the tree, by the `/`-separated path it points at * relative to the tree's root. The source and a copy hold the same link * exactly when their links point at the same relative path, whatever the link * text, so a Windows junction's absolute target matches the relative one it was * made from. */ export type Link = `link:${string}`; export type Value = File | Dir | Link; export type InodeMap = Record; export interface DiffItemBase { path: string; oldValue?: Value; newValue?: Value; } export interface AddedItem extends DiffItemBase { path: string; oldValue?: undefined; newValue: Value; } export interface RemovedItem extends DiffItemBase { path: string; oldValue: Value; newValue?: undefined; } export interface ModifiedItem extends DiffItemBase { path: string; oldValue: Value; newValue: Value; } export interface DirDiff { added: AddedItem[]; removed: RemovedItem[]; modified: ModifiedItem[]; } /** * Get the difference between 2 files tree. * * The arrays in the resulting object are sorted in such a way that every directory paths are placed before * the files it contains. * When performing removal of removed files according to this diff, the `removed` array should be reversed first. */ export declare function diffDir(oldIndex: InodeMap, newIndex: InodeMap): DirDiff; /** * Apply a patch on a directory. * * The {@link optimizedDirPatch} is assumed to be already optimized (i.e. `removed` is already reversed). */ export declare function applyPatch(optimizedDirPatch: DirDiff, sourceDir: string, targetDir: string): Promise; export type ExtendFilesMapStats = Pick; export interface ExtendFilesMapOptions { /** Map relative path of each file to their real path */ filesMap: Map; /** Map relative path of each file to their stats */ filesStats?: Record; /** * The root of the tree `filesMap` lists. When it is set, a listed link is * read as the install imports it (see `linkValue`), and `filesStats` is * not used, since it does not tell a link from what it points at. */ linkRoot?: string; } /** * Convert a pair of a files index map, which is a map from relative path of each file to their real paths, * and an optional file stats map, which is a map from relative path of each file to their stats, * into an inodes map, which is a map from relative path of every file and directory to their inode type. */ export declare function extendFilesMap({ filesMap, filesStats, linkRoot }: ExtendFilesMapOptions): Promise; /** A source directory's files, read once per poll and published to each of its injected copies. */ export interface PublishSource { dir: string; map: InodeMap; } export declare function readPublishSource(dir: string, includeOnlyPackageFiles?: boolean): Promise; /** * Copy changed files into `targetDir` as independent files, so a watcher on * the injected directory sees the write. A hardlink edited in place is * republished when its mtime is at least `editedSinceMs`. A copy whose size * and mtime already match the source is left alone. */ export declare function publishEditsForWatchers(source: PublishSource, targetDir: string, editedSinceMs: number): Promise; export declare class DirPatcher { private readonly sourceDir; private readonly targetDir; private readonly patch; private constructor(); static fromMultipleTargets(sourceDir: string, targetDirs: string[], includeOnlyPackageFiles?: boolean): Promise; apply(): Promise; }