union Any { Chdir, Chmod, Chown, CopyFile, Cwd, CwdRes, Link, MakeTempDir, MakeTempDirRes, Mkdir, Read, ReadDir, ReadDirRes, ReadRes, Readlink, ReadlinkRes, Remove, Rename, Seek, Stat, StatRes, Symlink, Truncate, Write, WriteRes, } enum ErrorKind: byte { NoError = 0, // io errors NotFound, PermissionDenied, ConnectionRefused, ConnectionReset, ConnectionAborted, NotConnected, AddrInUse, AddrNotAvailable, BrokenPipe, AlreadyExists, WouldBlock, InvalidInput, InvalidData, TimedOut, Interrupted, WriteZero, Other, UnexpectedEof, BadResource, CommandFailed, // url errors EmptyHost, IdnaError, InvalidPort, InvalidIpv4Address, InvalidIpv6Address, InvalidDomainCharacter, RelativeUrlWithoutBase, RelativeUrlWithCannotBeABaseBase, SetHostOnCannotBeABaseUrl, Overflow, // hyper errors HttpUser, HttpClosed, HttpCanceled, HttpParse, HttpOther, TooLarge, // custom errors InvalidUri, InvalidSeekMode, OpNotAvailable, WorkerInitFailed, UnixError, NoAsyncSupport, NoSyncSupport, ImportMapError, InvalidPath, ImportPrefixMissing, UnsupportedFetchScheme, TooManyRedirects, // other kinds Diagnostic, JSError, } table Cwd {} table CwdRes { cwd: string; } enum MediaType: byte { JavaScript = 0, TypeScript, Json, Unknown } table Base { cmd_id: uint32; sync: bool = false; error_kind: ErrorKind = NoError; error: string; inner: Any; } table FormatError { error: string; } table FormatErrorRes { error: string; } table Chdir { directory: string; } table KeyValue { key: string; value: string; } table MakeTempDir { dir: string; prefix: string; suffix: string; } table MakeTempDirRes { path: string; } table Mkdir { path: string; recursive: bool; mode: uint; // Specified by https://godoc.org/os#FileMode } table Chmod { path: string; mode: uint; // Specified by https://godoc.org/os#FileMode } table Chown { path: string; uid: uint; gid: uint; // Specified by https://godoc.org/os#Chown } table Remove { path: string; recursive: bool; } table ReadDir { path: string; } table ReadDirRes { entries: [StatRes]; } table CopyFile { from: string; to: string; } table Rename { oldpath: string; newpath: string; } table Readlink { name: string; } table ReadlinkRes { path: string; } table Symlink { oldname: string; newname: string; } table Link { oldname: string; newname: string; } table Stat { filename: string; lstat: bool; } table StatRes { is_file: bool; is_symlink: bool; len: ulong; modified:ulong; accessed:ulong; created:ulong; mode: uint; has_mode: bool; // false on windows name: string; } table Truncate { name: string; len: uint; } table Read { rid: uint32; // (ptr, len) is passed as second parameter to Deno.core.send(). } table ReadRes { nread: uint; eof: bool; } table Write { rid: uint32; } table WriteRes { nbyte: uint; } table Seek { rid: uint32; offset: int; whence: uint; } root_type Base;