mirror of
https://github.com/pyscript/pyscript.git
synced 2026-04-04 20:00:24 -04:00
split interpreter class (#1218)
* split interpreter class * add new files * add newlines * disable eslint for run * remove usage of interpreter from unit test * delete fakeinterpreter class * fix unit tests * add comments * remove interpreter.ts and pyodide.ts files * suggested changes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { Interpreter } from '../interpreter';
|
||||
import { showWarning } from '../utils';
|
||||
import { Plugin } from '../plugin';
|
||||
import { getLogger } from '../logger';
|
||||
import { InterpreterClient } from '../interpreter_client';
|
||||
|
||||
const logger = getLogger('plugins/importmap');
|
||||
|
||||
@@ -11,7 +11,7 @@ type ImportMapType = {
|
||||
};
|
||||
|
||||
export class ImportmapPlugin extends Plugin {
|
||||
async afterSetup(interpreter: Interpreter) {
|
||||
async afterSetup(interpreter: InterpreterClient) {
|
||||
// make importmap ES modules available from python using 'import'.
|
||||
//
|
||||
// XXX: this code can probably be improved because errors are silently
|
||||
@@ -46,7 +46,7 @@ export class ImportmapPlugin extends Plugin {
|
||||
}
|
||||
|
||||
logger.info('Registering JS module', name);
|
||||
interpreter.registerJsModule(name, exports);
|
||||
interpreter._remote.registerJsModule(name, exports);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { PyScriptApp } from '../main';
|
||||
import type { AppConfig } from '../pyconfig';
|
||||
import type { Interpreter } from '../interpreter';
|
||||
import { Plugin } from '../plugin';
|
||||
import { UserError, ErrorCode } from '../exceptions';
|
||||
import { getLogger } from '../logger';
|
||||
import { type Stdio } from '../stdio';
|
||||
import { InterpreterClient } from '../interpreter_client';
|
||||
|
||||
const logger = getLogger('py-terminal');
|
||||
|
||||
@@ -46,7 +46,7 @@ export class PyTerminalPlugin extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
afterSetup(interpreter: Interpreter) {
|
||||
afterSetup(interpreter: InterpreterClient) {
|
||||
// the Python interpreter has been initialized and we are ready to
|
||||
// execute user code:
|
||||
//
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { AppConfig } from '../pyconfig';
|
||||
import type { UserError } from '../exceptions';
|
||||
import type { Interpreter } from '../interpreter';
|
||||
import { showWarning } from '../utils';
|
||||
import { Plugin } from '../plugin';
|
||||
import { getLogger } from '../logger';
|
||||
import { InterpreterClient } from '../interpreter_client';
|
||||
|
||||
const logger = getLogger('py-splashscreen');
|
||||
|
||||
@@ -55,7 +55,7 @@ export class SplashscreenPlugin extends Plugin {
|
||||
});
|
||||
}
|
||||
|
||||
afterStartup(interpreter: Interpreter) {
|
||||
afterStartup(interpreter: InterpreterClient) {
|
||||
if (this.autoclose && this.enabled) {
|
||||
this.elem.close();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Plugin } from "../plugin";
|
||||
import { TargetedStdio, StdioMultiplexer } from "../stdio";
|
||||
import type { Interpreter } from "../interpreter";
|
||||
import { make_PyScript } from "../components/pyscript";
|
||||
import { InterpreterClient } from "../interpreter_client";
|
||||
|
||||
type PyScriptTag = InstanceType<ReturnType<typeof make_PyScript>>;
|
||||
|
||||
@@ -27,7 +27,7 @@ export class StdioDirector extends Plugin {
|
||||
* with that ID for the duration of the evaluation.
|
||||
*
|
||||
*/
|
||||
beforePyScriptExec(options: {interpreter: Interpreter, src: string, pyScriptTag: PyScriptTag}): void {
|
||||
beforePyScriptExec(options: {interpreter: InterpreterClient, src: string, pyScriptTag: PyScriptTag}): void {
|
||||
if (options.pyScriptTag.hasAttribute("output")){
|
||||
const targeted_io = new TargetedStdio(options.pyScriptTag, "output", true, true)
|
||||
options.pyScriptTag.stdout_manager = targeted_io
|
||||
@@ -43,7 +43,7 @@ export class StdioDirector extends Plugin {
|
||||
/** After a <py-script> tag is evaluated, if that tag has a 'stdout_manager'
|
||||
* (presumably TargetedStdio, or some other future IO handler), it is removed.
|
||||
*/
|
||||
afterPyScriptExec(options: {interpreter: Interpreter, src: string, pyScriptTag: PyScriptTag, result: any}): void {
|
||||
afterPyScriptExec(options: {interpreter: InterpreterClient, src: string, pyScriptTag: PyScriptTag, result: any}): void {
|
||||
if (options.pyScriptTag.stdout_manager != null){
|
||||
this._stdioMultiplexer.removeListener(options.pyScriptTag.stdout_manager)
|
||||
options.pyScriptTag.stdout_manager = null
|
||||
|
||||
Reference in New Issue
Block a user