//#region src/protocol.d.ts /** Runtime-agnostic filesystem interface for the write plan. */ interface FileSystem { cwd(): string; exists(path: string): Promise; mkdir(path: string, options: { recursive: boolean; }): Promise; writeFile(path: string, content: string | Uint8Array): Promise; } /** Internal brand symbol used to identify PlateNodes at runtime. */ declare const PLATE_SYMBOL: unique symbol; /** A resolved file ready for disk serialization. */ interface VirtualFile { /** Relative path from the target directory. */ path: string; /** String or binary content. */ content: string | Uint8Array; } /** * Union of accepted content types for {@link file}. * * - `string` / `Uint8Array` – literal content. * - `Record` – serialised to pretty-printed JSON. * - `() => FileContentValue | Promise` – lazy factory evaluated once per generation. * `null` / `undefined` results are coerced to an empty string. */ type FileContentValue = string | Uint8Array | Record | null | undefined; type FileContent = FileContentValue | (() => FileContentValue | Promise); /** A node in a virtual file-tree that can produce one or more {@link VirtualFile} entries. */ interface PlateNode { [PLATE_SYMBOL]: true; /** * Returns all {@link VirtualFile} entries reachable from this node given * the accumulated path prefix so far. * @param currentPath – Normalised path inherited from ancestor directories. */ generate(currentPath: string): Promise; } //#endregion //#region src/primitives.d.ts /** * Create a virtual file node. * * The `content` parameter is optional — when omitted the resolved file will * have an empty string as its content. Plain objects are automatically * serialised to pretty-printed JSON. Pass a factory function for lazy * evaluation (it is called once per generation run). * * @param name – Relative file path (e.g. `"src/index.ts"`). * @param content – Optional content (see {@link FileContent}). */ declare function file(name: string, content?: FileContent): PlateNode; declare function dir(name: string, ...children: unknown[]): PlateNode; //#endregion //#region src/engine.d.ts /** * Compile a list of nodes into a flat array of {@link VirtualFile} objects. * * All paths are validated and normalised before any result is yielded. * Throws on directory-traversal or absolute-path escape attempts. * * @param nodes – One or more {@link PlateNode}s (e.g. from {@link file} / {@link dir}). * @returns Flat array of resolved virtual files. */ declare function emit(...nodes: PlateNode[]): Promise; //#endregion //#region src/plan.d.ts /** A resolved file in the plan, with its absolute path and status. */ interface PlanFile { path: string; absolutePath: string; content: string | Uint8Array; status: "write" | "skip"; } /** A deferred write plan returned by {@link plan}. */ interface Plan { files: PlanFile[]; /** * Execute the plan. Requires a {@link FileSystem} if one was not * provided to {@link plan} via `PlanOptions.fs`. */ run(fs?: FileSystem): Promise; } /** Options for {@link plan}. */ interface PlanOptions { /** Base output directory. Required unless `fs.cwd()` is provided. */ targetDir?: string; /** * When `false` and a `FileSystem` is available at plan-time, * existing files are silently skipped. * @default true */ overwrite?: boolean; /** A {@link FileSystem} implementation for I/O operations. */ fs?: FileSystem; } /** * Create a deferred write plan. * * Provide a {@link FileSystem} via `options.fs` or pass one to * {@link Plan.run} when you're ready to write. At least a * `targetDir` or a filesystem with `cwd()` is required. * * @param files – Array of virtual files to write (typically from {@link emit}). * @param options – Plan options. */ declare function plan(files: VirtualFile[], options?: PlanOptions): Promise; //#endregion export { emit as a, FileContent as c, PlateNode as d, VirtualFile as f, plan as i, FileSystem as l, PlanFile as n, dir as o, PlanOptions as r, file as s, Plan as t, PLATE_SYMBOL as u };