{"version":3,"file":"fs.mjs","names":[],"sources":["../../../../../../../@warlock.js/fs/src/facade/fs.ts"],"sourcesContent":["import { pathExistsAsync } from \"../exists\";\nimport { hashBuffer, hashFileAsync, hashString, type HashAlgorithm } from \"../hash\";\nimport { Directory } from \"./directory\";\nimport { dirs } from \"./dirs\";\nimport { File } from \"./file\";\nimport { files } from \"./files\";\n\n/**\n * The `fs` shorthand facade — an async, ergonomic surface over\n * `@warlock.js/fs`'s primitives:\n *\n * - `fs.files.*` — file operations\n * - `fs.dirs.*` — directory operations\n * - `fs.file(path)` / `fs.dir(path)` — lazy `File` / `Directory` handles\n * - `fs.exists(path)` — type-agnostic existence (file OR directory)\n *\n * Async-only by design: synchronous callers use the bare primitives\n * (`getFile` / `putFile` / …), which keep the package's `bare = sync`,\n * `*Async = async` charter. `fs.*` never sandboxes paths — path containment is\n * the storage layer's job.\n *\n * @example\n * import { fs } from \"@warlock.js/fs\";\n *\n * await fs.files.put(\"cache/data.json\", \"{}\", { atomic: true });\n * const cfg = await fs.files.getJson(\"config.json\", { schema, default: {} });\n * const dir = fs.dir(\"uploads\");\n * if (await dir.isEmpty()) { ... }\n */\nexport const fs = {\n  files,\n  dirs,\n\n  /**\n   * Hashing — `file`/`dir` are async (they read from disk); `string`/`buffer`\n   * are sync (pure, in-memory — no IO to await). Defaults to SHA-256.\n   */\n  hash: {\n    file: (path: string, algorithm?: HashAlgorithm): Promise<string> =>\n      hashFileAsync(path, algorithm),\n    dir: (path: string, algorithm?: HashAlgorithm): Promise<string> => dirs.hash(path, algorithm),\n    string: (content: string, algorithm?: HashAlgorithm): string => hashString(content, algorithm),\n    buffer: (content: Buffer | Uint8Array, algorithm?: HashAlgorithm): string =>\n      hashBuffer(content, algorithm),\n  },\n\n  /** Does anything exist at this path (file OR directory)? */\n  exists(path: string): Promise<boolean> {\n    return pathExistsAsync(path);\n  },\n\n  /** A lazy handle to a file path (no IO until a method is called). */\n  file(path: string): File {\n    return new File(path);\n  },\n\n  /** A lazy handle to a directory path (no IO until a method is called). */\n  dir(path: string): Directory {\n    return new Directory(path);\n  },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,KAAK;CAChB;CACA;;;;;CAMA,MAAM;EACJ,OAAO,MAAc,cACnB,cAAc,MAAM,SAAS;EAC/B,MAAM,MAAc,cAA+C,KAAK,KAAK,MAAM,SAAS;EAC5F,SAAS,SAAiB,cAAsC,WAAW,SAAS,SAAS;EAC7F,SAAS,SAA8B,cACrC,WAAW,SAAS,SAAS;CACjC;;CAGA,OAAO,MAAgC;EACrC,OAAO,gBAAgB,IAAI;CAC7B;;CAGA,KAAK,MAAoB;EACvB,OAAO,IAAI,KAAK,IAAI;CACtB;;CAGA,IAAI,MAAyB;EAC3B,OAAO,IAAI,UAAU,IAAI;CAC3B;AACF"}