mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Force FS types into a shared RuntimeFS type
This commit is contained in:
9 files changed
+226
-95
No files matched your search
+29
-2
@@ -11,13 +11,40 @@ export interface DirectoryEntry {
|
||||
|
||||
/**
|
||||
* Filesystem interface compatible with both WebContainer and LightningFS
|
||||
* This interface unifies the APIs of both filesystem implementations
|
||||
*/
|
||||
export interface JSRuntimeFS {
|
||||
// Core file operations with proper overloads for type safety
|
||||
readFile(path: string): Promise<Uint8Array>;
|
||||
readFile(path: string, encoding: 'utf8'): Promise<string>;
|
||||
readFile(path: string, encoding: string): Promise<string>;
|
||||
readFile(path: string, encoding?: string): Promise<string | Uint8Array>;
|
||||
writeFile(path: string, data: string | Uint8Array): Promise<void>;
|
||||
|
||||
writeFile(path: string, data: string | Uint8Array, encoding?: string): Promise<void>;
|
||||
|
||||
// readdir overloads for different return types
|
||||
readdir(path: string): Promise<string[]>;
|
||||
readdir(path: string, options: { withFileTypes: true }): Promise<DirectoryEntry[]>;
|
||||
readdir(path: string, options?: { withFileTypes?: boolean }): Promise<string[] | DirectoryEntry[]>;
|
||||
|
||||
mkdir(path: string, options?: { recursive?: boolean }): Promise<void>;
|
||||
stat(path: string): Promise<{ isDirectory(): boolean; isFile(): boolean }>;
|
||||
stat(path: string): Promise<{
|
||||
isDirectory(): boolean;
|
||||
isFile(): boolean;
|
||||
size?: number;
|
||||
mtimeMs?: number;
|
||||
}>;
|
||||
lstat(path: string): Promise<{
|
||||
isDirectory(): boolean;
|
||||
isFile(): boolean;
|
||||
size?: number;
|
||||
mtimeMs?: number;
|
||||
}>;
|
||||
|
||||
// Additional operations that LightningFS supports
|
||||
unlink(path: string): Promise<void>;
|
||||
rmdir(path: string): Promise<void>;
|
||||
rename(oldPath: string, newPath: string): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user