///
import { ClientServerProxy, Module, ServerProxy } from "./proxy";
declare enum Type {
Array = "array",
Buffer = "buffer",
Date = "date",
Error = "error",
Function = "function",
Object = "object",
Proxy = "proxy",
Undefined = "undefined"
}
interface EncodedArray {
type: Type.Array;
values: Argument[];
}
interface EncodedBuffer {
type: Type.Buffer;
data: Uint8Array;
}
interface EncodedDate {
type: Type.Date;
date: string;
}
interface EncodedError {
type: Type.Error;
code: string | undefined;
message: string;
stack: string | undefined;
}
interface EncodedFunction {
type: Type.Function;
id: number;
}
interface EncodedObject {
type: Type.Object;
values: {
[key: string]: Argument;
};
}
interface EncodedProxy {
type: Type.Proxy;
id: number;
}
interface EncodedUndefined {
type: Type.Undefined;
}
export declare type Argument = EncodedArray | EncodedBuffer | EncodedDate | EncodedError | EncodedFunction | EncodedObject | EncodedProxy | EncodedUndefined | string | number | boolean | null;
/**
* Convert an argument for serialization.
* If sending a function is possible, provide `storeFunction`.
* If sending a proxy is possible, provide `storeProxy`.
*/
export declare const encode:
| ServerProxy>(value: any, storeFunction?: ((fn: () => void) => number) | undefined, storeProxy?: ((proxy: P) => number | Module) | undefined) => Argument;
/**
* Decode arguments into their original values.
* If running a remote callback is supported, provide `runCallback`.
* If using a remote proxy is supported, provide `createProxy`.
*/
export declare const decode: (argument?: string | number | boolean | EncodedArray | EncodedBuffer | EncodedDate | EncodedError | EncodedFunction | EncodedObject | EncodedProxy | EncodedUndefined | null | undefined, runCallback?: ((id: number, args: any[]) => void) | undefined, createProxy?: ((id: number) => ServerProxy) | undefined) => any;
export {};