@dodona/papyros
Version:
Scratchpad for multiple programming languages in the browser.
36 lines (35 loc) • 1.46 kB
TypeScript
import { Backend, RunMode, WorkerDiagnostic } from "../../Backend";
import { BackendEvent } from "../../../communication/BackendEvent";
import { PyodideExtras } from "pyodide-worker-runner";
/**
* Implementation of a Python backend for Papyros
* Powered by Pyodide (https://pyodide.org/)
*/
export declare class PythonWorker extends Backend<PyodideExtras> {
private pyodide;
private papyros;
/**
* Promise to asynchronously install imports needed by the code
*/
private installPromise;
constructor();
private static convert;
/**
* @return {any} Function to expose a method with Pyodide support
*/
protected syncExpose(): any;
private static getPyodide;
launch(onEvent: (e: BackendEvent) => void): Promise<void>;
/**
* Helper method to install imports and prevent race conditions with double downloading
* @param {string} code The code containing import statements
*/
private installImports;
runModes(code: string): Array<RunMode>;
runCode(extras: PyodideExtras, code: string, mode?: string): Promise<any>;
lintCode(code: string): Promise<Array<WorkerDiagnostic>>;
provideFiles(inlineFiles: Record<string, string>, hrefFiles: Record<string, string>): Promise<void>;
deleteFile(name: string): Promise<void>;
updateFile(name: string, content: string, binary: boolean): Promise<void>;
renameFile(oldName: string, newName: string): Promise<void>;
}