import type { IMemFSHost } from "./structures/IMemFSHost"; /** * Create an in-memory filesystem suitable for use as `globalThis.fs` inside a * Go/wasm runtime. * * The returned host exposes the low-level `fs` object (install it on * `globalThis.fs` before loading `wasm_exec.js`) and convenience helpers * (`writeFile`, `readFile`, `mkdirp`, …) for seeding source files and reading * compiler output without touching the real filesystem. * * Every successful mutation leaves a valid tree: `/` stays a directory, each * proper ancestor of a node exists and is a directory, and a file has no * descendants. An operation that cannot satisfy that throws (`writeFile`, * `mkdirp`) or reports a POSIX error through its callback, having changed no * node, byte, or descriptor. * * @evidence contracts/common.md#principled-implementation * The owned Node-shaped fs bridge uses maps for virtual node/descriptor * identity and preserves opened nodes independently from paths. The Go js/wasm * callback interface is the authority; unsupported link and metadata mutation * capabilities are explicit in IWasmExecFS. * @evidence contracts/common.md#clear-and-simple-design * One closure owns the tree, indexes and descriptor identities. Shared helpers * centralize path validation, insertion/removal and byte mutation; separate * stream captures and pipe queues reflect non-seekable lifetimes rather than * adding filesystem nodes that would blur their operation contracts. * @evidence contracts/common.md#prohibited-implementation-shortcuts * Virtual flag/errno values are bridge constants, not native-host guesses. * The implementation owns its maps rather than patching foreign filesystem * methods. Directory indexes, geometric file growth and linked pipe queues * correct repeated global scans, full-buffer copies and queue shifts at their * owners, without size exceptions or benchmark-specific paths. * @evidence contracts/common.md#meaningful-documentation * Native paragraphs explain installation, copying and tree ownership; helper * and interface comments state cost and unsupported capabilities. This follows * the documentation skill's paragraph, units and rationale guidance. * @evidence contracts/performance.md#efficient-algorithms * Directory lookup visits D direct entries and sorts them in O(D log D), * emptiness uses the indexed child count, and rename visits only S subtree * nodes plus F open descriptors. Growing file writes amortize copying through * geometric capacity; pipe enqueue/dequeue change linked endpoints in O(1). * Path normalization costs O(P) path characters; ancestor validation builds * d prefixes with total length K, costing O(K + d) time and temporary space * under expected constant-time map access after hashing each prefix. Output fragments * append without flattening prior text; reading a dirty B-byte capture costs * O(B), while an unchanged capture read reuses its materialized string. * @evidence contracts/performance.md#reuse-equivalent-work * Child membership is maintained once by node insertion/deletion rather than * reconstructed for every listing. Text decoding is cached on node identity * and invalidated by every content mutation. Open descriptors share their * actual inode; public byte reads still copy to preserve caller isolation. * Each output stream keeps its own incremental UTF-8 decoder, so a split * character is decoded once and capture reads reuse the materialized string * until another fragment arrives. * @evidence contracts/performance.md#bound-retention-and-release-resources * Each host owns its tree, indexes, captures and descriptors. Unlink/rmdir * remove tree entries, close releases descriptors, and consumed pipe entries * are detached. File write capacity stays at most twice logical length; truncate * and replacement release spare storage. Total input and captured output have * no fixed bound, so the caller owns deletion, resetStdio and host lifetime. */ export declare function createMemFS(): IMemFSHost;