UNPKG

@georgestagg/webr

Version:

The statistical programming langauge R compiled into WASM for use in a web browser and node.

52 lines (51 loc) 1.62 kB
import { ChannelType } from './chan/channel'; import { Message } from './chan/message'; import { RObject, RawType, RObjectTree, NamedObject, REnvironment } from './robj'; export declare type EvalRCodeOptions = { captureStreams?: boolean; captureConditions?: boolean; withAutoprint?: boolean; withHandlers?: boolean; }; export { Console, ConsoleCallbacks } from '../console/console'; export declare type FSNode = { id: number; name: string; mode: number; isFolder: boolean; contents: { [key: string]: FSNode; }; }; export interface WebROptions { RArgs?: string[]; REnv?: { [key: string]: string; }; WEBR_URL?: string; PKG_URL?: string; SW_URL?: string; homedir?: string; interactive?: boolean; channelType?: typeof ChannelType[keyof typeof ChannelType]; } export declare class WebR { #private; constructor(options?: WebROptions); init(): Promise<unknown>; close(): void; read(): Promise<Message>; flush(): Promise<Message[]>; write(msg: Message): void; writeConsole(input: string): void; interrupt(): void; installPackages(packages: string[]): Promise<void>; putFileData(name: string, data: Uint8Array): Promise<any>; getFileData(name: string): Promise<Uint8Array>; getFSNode(path: string): Promise<FSNode>; evalRCode(code: string, env?: REnvironment, options?: EvalRCodeOptions): Promise<{ result: RObject; output: unknown[]; }>; newRObject(jsObj: RawType | RawType[] | RObjectTree<RObject> | NamedObject<RawType | RObject>): Promise<RObject>; }