Filesystem API
Filesystem constructors, bridge utilities, and RuntimeFileSystem types for kernel I/O.
Filesystem API
Use the filesystem API when configuring how kernels read and write project files. The package provides constructors for Node.js, in-memory, and any fs-compatible backends, plus bridge utilities for cross-worker filesystem access.
Filesystem Types
Prop
Type
Prop
Type
Prop
Type
Constructors
| Function | Import Path | Description |
|---|---|---|
fromNodeFS(basePath) | @taucad/runtime/filesystem | Node.js filesystem rooted at basePath |
fromMemoryFS(files?) | @taucad/runtime | In-memory Map-backed filesystem, optionally seeded |
fromFsLike(fs, rootPath?) | @taucad/runtime | Any fs-compatible object (BrowserFS, memfs, polyfills) |
createRuntimeFileSystem(base) | @taucad/runtime/filesystem | Wrap RuntimeFileSystemBase with enhanced helper methods |
Bridge Types
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Bridge Utilities
For cross-worker filesystem access, these utilities create MessagePort-based bridges:
| Function | Description |
|---|---|
createBridgePort(handlers) | Create a MessagePort bridge to a filesystem. Returns BridgeHandle. |
createBridgeServer(handlers, port, options?) | Serve an object's methods over a MessagePort. |
createBridgeProxy<T>(port) | Create a Proxy-based client that dispatches calls over MessagePort. |
createBridgeCall(port, method, args) | Send a single RPC call over a MessagePort and await the response. |
exposeFileSystem(handlers, options?) | Expose a filesystem to incoming bridge connections. |
createFileSystemBridge(handlers, options?) | Create a MessageChannel and transfer a port to a worker. |
catchMessages(port, handler) | Attach an error-handling message listener to a MessagePort. |
extractTransferables(value) | Walk a value and collect ArrayBuffers for transfer. |
Usage
Node.js Filesystem
import { createRuntimeClient } from '@taucad/runtime';
import { fromNodeFS } from '@taucad/runtime/filesystem/node';
import { replicad } from '@taucad/runtime/kernels';
import { esbuild } from '@taucad/runtime/bundler';
const client = createRuntimeClient({
kernels: [replicad()],
bundlers: [esbuild()],
fileSystem: fromNodeFS('/path/to/project'),
});In-Memory Filesystem
import { createRuntimeClient, fromMemoryFS } from '@taucad/runtime';
import { replicad } from '@taucad/runtime/kernels';
import { esbuild } from '@taucad/runtime/bundler';
const client = createRuntimeClient({
kernels: [replicad()],
bundlers: [esbuild()],
fileSystem: fromMemoryFS({
'main.ts': 'export default function main() { return null; }',
}),
});Filesystem Bridge
import { createBridgePort } from '@taucad/runtime/filesystem';
import { fromNodeFS } from '@taucad/runtime/filesystem/node';
const fileSystem = fromNodeFS('/path/to/project');
const { port, dispose } = createBridgePort(fileSystem);
// Transfer port to a worker for remote filesystem access
worker.postMessage({ fsPort: port }, [port]);
// When done, release resources
dispose();Related
- Set Up the Filesystem -- Practical guide to filesystem configuration
- Worker Model -- How the filesystem is bridged to the worker
- API: Client --
createRuntimeClientfilesystem option - API: Types --
RuntimeFileSystemBase,RuntimeFileSystem