2022-10-10 12:50:21 +00:00
|
|
|
import { Plug } from "../../plugos/plug.ts";
|
|
|
|
import { FileMeta } from "../types.ts";
|
2022-04-07 13:21:30 +00:00
|
|
|
|
2022-09-12 12:50:37 +00:00
|
|
|
export type FileEncoding = "string" | "arraybuffer" | "dataurl";
|
|
|
|
export type FileData = ArrayBuffer | string;
|
2022-04-07 13:21:30 +00:00
|
|
|
export interface SpacePrimitives {
|
|
|
|
// Pages
|
2022-09-12 12:50:37 +00:00
|
|
|
fetchFileList(): Promise<FileMeta[]>;
|
|
|
|
readFile(
|
2022-04-07 13:21:30 +00:00
|
|
|
name: string,
|
2022-10-12 09:47:13 +00:00
|
|
|
encoding: FileEncoding,
|
2022-09-12 12:50:37 +00:00
|
|
|
): Promise<{ data: FileData; meta: FileMeta }>;
|
|
|
|
getFileMeta(name: string): Promise<FileMeta>;
|
|
|
|
writeFile(
|
2022-09-05 09:47:30 +00:00
|
|
|
name: string,
|
2022-09-12 12:50:37 +00:00
|
|
|
encoding: FileEncoding,
|
|
|
|
data: FileData,
|
2022-10-12 09:47:13 +00:00
|
|
|
selfUpdate?: boolean,
|
2022-09-12 12:50:37 +00:00
|
|
|
): Promise<FileMeta>;
|
|
|
|
deleteFile(name: string): Promise<void>;
|
2022-09-05 09:47:30 +00:00
|
|
|
|
2022-04-07 13:21:30 +00:00
|
|
|
// Plugs
|
|
|
|
proxySyscall(plug: Plug<any>, name: string, args: any[]): Promise<any>;
|
|
|
|
invokeFunction(
|
|
|
|
plug: Plug<any>,
|
|
|
|
env: string,
|
|
|
|
name: string,
|
2022-10-12 09:47:13 +00:00
|
|
|
args: any[],
|
2022-04-07 13:21:30 +00:00
|
|
|
): Promise<any>;
|
|
|
|
}
|