{"version":3,"file":"options.mjs","names":[],"sources":["../../../../../../../@warlock.js/fs/src/facade/options.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { Stats } from \"node:fs\";\nimport type { StandardSchemaV1 } from \"./standard-schema\";\n\n/** Read options. `encoding: null` returns a `Buffer`; otherwise a decoded string. */\nexport type ReadOptions = { encoding?: BufferEncoding | null };\n\n/**\n * JSON read options. `schema` validates the parsed value against any Standard\n * Schema (seal / zod / valibot); `default` is returned when the file is missing\n * (instead of throwing).\n */\nexport type ReadJsonOptions<T = unknown> = {\n  schema?: StandardSchemaV1<T>;\n  default?: T;\n};\n\n/** Write options shared by the string/Buffer writers. */\nexport type WriteOptions = {\n  /** Text encoding for string writes (default `utf-8`). Ignored for `Buffer`. */\n  encoding?: BufferEncoding;\n  /** Write via a temp file + rename so readers never see a half-written file. */\n  atomic?: boolean;\n  /** Create missing parent directories (default `true`). */\n  ensureDir?: boolean;\n  /** When `false`, throw if the target already exists (drives `create`). Default `true`. */\n  overwrite?: boolean;\n};\n\n/** JSON write options — adds the pretty-print `indent` (default `2`). */\nexport type WriteJsonOptions = WriteOptions & { indent?: number };\n\n/** JSON merge options — shallow spread by default; `deep` for a recursive merge. */\nexport type MergeJsonOptions = WriteJsonOptions & { deep?: boolean };\n\n/** Copy options (files + directories). */\nexport type CopyOptions = {\n  /** Overwrite an existing destination (default `true`). */\n  overwrite?: boolean;\n  /** Throw if the destination already exists (default `false`). */\n  errorOnExist?: boolean;\n  /** Follow symlinks instead of copying the link (default `false`). */\n  dereference?: boolean;\n};\n\n/** Move options. `ensureDir` (default `true`) creates the destination's parent. */\nexport type MoveOptions = {\n  overwrite?: boolean;\n  ensureDir?: boolean;\n};\n\n/** Directory-listing options. `recursive` walks the whole tree. */\nexport type ListOptions = { recursive?: boolean };\n\n/** Directory-walk options. */\nexport type WalkOptions = {\n  recursive?: boolean;\n  followSymlinks?: boolean;\n};\n\n/** One entry yielded by `walk()`. Discriminated by `type` (never `kind`). */\nexport type WalkEntry = {\n  path: string;\n  name: string;\n  type: \"file\" | \"directory\";\n};\n\n/**\n * Normalized stats — a small, stable shape (with the raw `node:fs.Stats` kept\n * on `raw` as an escape hatch). Discriminated by `type`, not `kind`.\n */\nexport type FileStats = {\n  path: string;\n  name: string;\n  size: number;\n  type: \"file\" | \"directory\";\n  lastModified: Date;\n  raw: Stats;\n};\n\n/**\n * Normalize a raw `node:fs.Stats` into a {@link FileStats}.\n *\n * @param filePath - The path the stats were read for.\n * @param raw - The raw `node:fs.Stats`.\n * @returns The normalized stats.\n */\nexport function normalizeStats(filePath: string, raw: Stats): FileStats {\n  return {\n    path: filePath,\n    name: path.basename(filePath),\n    size: raw.size,\n    type: raw.isDirectory() ? \"directory\" : \"file\",\n    lastModified: raw.mtime,\n    raw,\n  };\n}\n"],"mappings":";;;;;;;;;;AAuFA,SAAgB,eAAe,UAAkB,KAAuB;CACtE,OAAO;EACL,MAAM;EACN,MAAM,KAAK,SAAS,QAAQ;EAC5B,MAAM,IAAI;EACV,MAAM,IAAI,YAAY,IAAI,cAAc;EACxC,cAAc,IAAI;EAClB;CACF;AACF"}