import type { DirEntry, FileInfo, FileSystemAdapter, FileWatcher, WatchOptions } from "../../base.js"; import { setupNodeFsWatcher } from "./shared-watcher.js"; import { type NativeSnapshotPlatform } from "./native-snapshot-identity.js"; export interface NodeFileSystemLogger { error(message: string, context?: Record): void; debug(message: string, context?: Record): void; } interface NodeFileSnapshotStat { readonly dev: bigint; readonly ino: bigint; readonly size: bigint; readonly mtimeNs: bigint; readonly ctimeNs: bigint; isFile(): boolean; isSymbolicLink(): boolean; } interface NodeFileHandle { stat(): Promise; read(buffer: Uint8Array, offset: number, length: number, position: number): Promise<{ bytesRead: number; }>; writeFile(content: Uint8Array): Promise; close(): Promise; } export interface NodeFileSystemOperations { realpath(path: string): Promise; lstat(path: string): Promise; open(path: string, flags: number | string): Promise; } export interface NodeFileSystemCapabilityOptions { /** Test seam for runtime constants. An own undefined value means unavailable. */ readonly noFollow?: number; /** Test seam for native open and path semantics. */ readonly platform?: NativeSnapshotPlatform; /** Test seam for create-new primitive availability. */ readonly exclusiveCreate?: boolean; /** Test seam for deterministic filesystem races and write failures. */ readonly operations?: Partial; } /** Runtime whose Node-compatible filesystem implementation backs the adapter. */ export type NodeCompatibleRuntimeProvenance = "node" | "bun" | "deno" | "unknown"; export declare function hasUsableWindowsSnapshotIdentity(runtime: NodeCompatibleRuntimeProvenance): boolean; export declare function readNodeFileSnapshotWithinLimit(operations: NodeFileSystemOperations, platform: NativeSnapshotPlatform, noFollow: number | undefined, path: string, containmentRoot: string, byteLimit: number): Promise; /** * Resolve the `O_NOFOLLOW` open flag that binds an exact-inode snapshot read. * * `constants` is `undefined` in a runtime without `node:fs` — e.g. a browser * bundle that transitively imports this adapter. Dereferencing `.O_NOFOLLOW` on * it unconditionally threw `Cannot read properties of undefined (reading * 'O_NOFOLLOW')` during construction and aborted client hydration (#3661). * Treat the missing constants as "unavailable" (`undefined`) — the same meaning * {@link NodeFileSystemCapabilityOptions.noFollow} already documents for an own * `undefined` — so `canOpenExactSnapshot` degrades to `false` instead of the * constructor exploding. An own `noFollow` on `options` still wins (the test seam). */ export declare function resolveNoFollowFlag(options: NodeFileSystemCapabilityOptions, constants: { readonly O_NOFOLLOW?: number; } | undefined): number | undefined; /** * Filesystem implementation shared by runtimes that provide Node-compatible * `node:fs` APIs (currently Node.js and Bun). */ export declare class NodeCompatibleFileSystemAdapter implements FileSystemAdapter { private readonly logger; constructor(logger?: NodeFileSystemLogger, options?: NodeFileSystemCapabilityOptions); readFile(path: string): Promise; readFileBytes(path: string): Promise; readFileBytesBounded(path: string, byteLimit: number): Promise; readFileBytesWithinLimit(path: string, byteLimit: number): Promise; writeFile(path: string, content: string): Promise; writeFileBytes(path: string, content: Uint8Array): Promise; rename(from: string, to: string): Promise; exists(path: string): Promise; readDir(path: string): AsyncIterable; stat(path: string): Promise; lstat(path: string): Promise; realPath(path: string): Promise; mkdir(path: string, options?: { recursive?: boolean; }): Promise; remove(path: string, options?: { recursive?: boolean; }): Promise; makeTempDir(prefix: string): Promise; protected setupWatcher(path: string, options: Parameters[1]): Promise; watch(paths: string | string[], options?: WatchOptions): FileWatcher; } export interface NodeCompatibleFileSystemAdapter { readFileSnapshotWithinLimit?(path: string, containmentRoot: string, byteLimit: number): Promise; createFileBytesExclusive?(path: string, content: Uint8Array): Promise; } export {}; //# sourceMappingURL=node-filesystem-adapter.d.ts.map