@georgestagg/webr
Version:
The statistical programming langauge R compiled into WASM for use in a web browser and node.
40 lines (39 loc) • 1.54 kB
TypeScript
import { Message } from './message';
import { SharedBufferChannelMain, SharedBufferChannelWorker } from './channel-shared';
import { ServiceWorkerChannelMain, ServiceWorkerChannelWorker } from './channel-service';
import { WebROptions } from '../webr-main';
export interface ChannelMain {
initialised: Promise<unknown>;
close(): void;
read(): Promise<Message>;
flush(): Promise<Message[]>;
write(msg: Message): void;
request(msg: Message, transferables?: [Transferable]): Promise<any>;
interrupt(): void;
}
export interface ChannelWorker {
resolve(): void;
write(msg: Message, transfer?: [Transferable]): void;
read(): Message;
handleInterrupt(): void;
setInterrupt(interrupt: () => void): void;
run(args: string[]): void;
inputOrDispatch: () => number;
setDispatchHandler: (dispatch: (msg: Message) => void) => void;
}
export declare const ChannelType: {
readonly Automatic: 0;
readonly SharedArrayBuffer: 1;
readonly ServiceWorker: 2;
};
export declare type ChannelInitMessage = {
type: string;
data: {
config: Required<WebROptions>;
channelType: Exclude<typeof ChannelType[keyof typeof ChannelType], typeof ChannelType.Automatic>;
clientId?: string;
location?: string;
};
};
export declare function newChannelMain(data: Required<WebROptions>): SharedBufferChannelMain | ServiceWorkerChannelMain;
export declare function newChannelWorker(msg: ChannelInitMessage): SharedBufferChannelWorker | ServiceWorkerChannelWorker;