@kobakazu0429/wasmer-wasi
Version:
Isomorphic Javascript library for interacting with WASI Modules in Node.js and the Browser. 📚
86 lines (85 loc) • 2.45 kB
TypeScript
import { BigIntPolyfillType } from "./polyfills/bigint";
import { DataViewPolyfillType } from "./polyfills/dataview";
import { WASI_FILETYPE } from "./constants";
interface Rights {
base: BigIntPolyfillType;
inheriting: BigIntPolyfillType;
}
interface File {
real: number;
offset?: bigint;
filetype?: WASI_FILETYPE;
rights: Rights;
path?: any;
fakePath?: any;
}
declare type Exports = {
[key: string]: any;
};
export declare type WASIBindings = {
hrtime: () => bigint;
exit: (rval: number) => void;
kill: (signal: string) => void;
randomFillSync: <T>(buffer: T, offset: number, size: number) => T;
isTTY: (fd: number) => boolean;
fs: any;
path: any;
};
export declare type WASIArgs = string[];
export declare type WASIEnv = {
[key: string]: string | undefined;
};
export declare type WASIPreopenedDirs = {
[key: string]: string;
};
export declare type WASIConfigOld = {
preopenDirectories?: WASIPreopenedDirs;
env?: WASIEnv;
args?: WASIArgs;
bindings?: WASIBindings;
stdin?: {
read: () => Promise<Uint8Array>;
};
};
export declare type WASIConfig = {
preopens?: WASIPreopenedDirs;
env?: WASIEnv;
args?: WASIArgs;
bindings?: WASIBindings;
traceSyscalls?: boolean;
stdin?: {
read: () => Promise<Uint8Array>;
};
};
export declare class WASIError extends Error {
errno: number;
constructor(errno: number);
}
export declare class WASIExitError extends Error {
code: number | null;
constructor(code: number | null);
}
export declare class WASIKillError extends Error {
signal: string;
constructor(signal: string);
}
export default class WASIDefault {
memory: WebAssembly.Memory;
view: DataViewPolyfillType;
FD_MAP: Map<number, File>;
wasiImport: Exports;
bindings: WASIBindings;
stdin?: {
read: () => Promise<Uint8Array>;
};
static defaultBindings: WASIBindings;
constructor(wasiConfig?: WASIConfigOld | WASIConfig);
refreshMemory(): void;
setMemory(memory: WebAssembly.Memory): void;
start(instance: WebAssembly.Instance): void;
private getImportNamespace;
getImports(module: WebAssembly.Module): Record<string, Record<string, Function>>;
}
export declare const WASI: typeof WASIDefault;
export declare type WASI = WASIDefault;
export {};