/** The mtime/size pair a write compares against to notice a concurrent edit. */ export interface FileStat { readonly mtimeMs: number; readonly size: number; } /** A missing file is a real state (zeros), not an error. */ export declare function statOf(path: string): FileStat; export declare function isNotFound(error: unknown): boolean; /** * What one read of the profile found. * * `missing` is separate from `error` because the two mean opposite things to * the owner: a file that is not there yet is an honest empty profile, "you * have not told me anything", while a file that cannot be read is a failure * they need to be told about, with the reason. */ export type ProfileReadResult = { readonly kind: 'text'; readonly text: string; readonly seen: FileStat; } | { readonly kind: 'missing'; readonly seen: FileStat; } | { readonly kind: 'error'; readonly cause: string; }; /** * Decode bytes as UTF-8, fatally. * * Fatal rather than replacement characters: a UTF-16 mis-save decodes to * plausible-looking mojibake under a lenient decoder, and the profile would * then load "successfully" full of garbage instead of saying it cannot be read. * Round-tripping the bytes is the only honest check. * * The cause is stated here rather than passed through from the runtime: Node * says "The encoded data was not valid for encoding utf-8" and Bun says * "invalid byte sequence", and the owner should read the same sentence either way, * one that names the encoding, since "saved as UTF-16" is the accident behind * almost every occurrence. */ export declare function decodeProfileBytes(bytes: Buffer, seen: FileStat): ProfileReadResult; /** * Stat BEFORE the read, on both paths: if the file changes while it is being * read, this baseline is the older one, so the next write notices and reloads * rather than believing its projection is current. */ export declare function readProfile(path: string): Promise; /** {@link readProfile}, synchronously, for the one call that cannot await. */ export declare function readProfileSync(path: string): ProfileReadResult; //# sourceMappingURL=store-load.d.ts.map