mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-18 22:00:37 -05:00
Rename runtimes with interpreter (#1082)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Runtime } from '../runtime';
|
||||
import type { Interpreter } from '../interpreter';
|
||||
import { showWarning } from '../utils';
|
||||
import { Plugin } from '../plugin';
|
||||
import { getLogger } from '../logger';
|
||||
@@ -11,7 +11,7 @@ type ImportMapType = {
|
||||
};
|
||||
|
||||
export class ImportmapPlugin extends Plugin {
|
||||
async afterSetup(runtime: Runtime) {
|
||||
async afterSetup(interpreter: Interpreter) {
|
||||
// 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);
|
||||
runtime.registerJsModule(name, exports);
|
||||
interpreter.registerJsModule(name, exports);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { PyScriptApp } from '../main';
|
||||
import type { AppConfig } from '../pyconfig';
|
||||
import type { Runtime } from '../runtime';
|
||||
import type { Interpreter } from '../interpreter';
|
||||
import { Plugin } from '../plugin';
|
||||
import { UserError, ErrorCode } from "../exceptions"
|
||||
import { UserError, ErrorCode } from '../exceptions';
|
||||
import { getLogger } from '../logger';
|
||||
import { type Stdio } from '../stdio';
|
||||
|
||||
@@ -23,8 +23,8 @@ export class PyTerminalPlugin extends Plugin {
|
||||
const got = JSON.stringify(t);
|
||||
throw new UserError(
|
||||
ErrorCode.BAD_CONFIG,
|
||||
'Invalid value for config.terminal: the only accepted' +
|
||||
`values are true, false and "auto", got "${got}".`
|
||||
'Invalid value for config.terminal: the only accepted' +
|
||||
`values are true, false and "auto", got "${got}".`,
|
||||
);
|
||||
}
|
||||
if (t === undefined) {
|
||||
@@ -46,7 +46,7 @@ export class PyTerminalPlugin extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
afterSetup(runtime: Runtime) {
|
||||
afterSetup(interpreter: Interpreter) {
|
||||
// the Python interpreter has been initialized and we are ready to
|
||||
// execute user code:
|
||||
//
|
||||
|
||||
@@ -15,8 +15,8 @@ class MyPlugin(Plugin):
|
||||
def configure(self, config):
|
||||
console.log(f"configuration received: {config}")
|
||||
|
||||
def afterStartup(self, runtime):
|
||||
console.log(f"runtime received: {runtime}")
|
||||
def afterStartup(self, interpreter):
|
||||
console.log(f"interpreter received: {interpreter}")
|
||||
|
||||
|
||||
plugin = MyPlugin("py-markdown")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { AppConfig } from '../pyconfig';
|
||||
import type { UserError } from '../exceptions';
|
||||
import type { Runtime } from '../runtime';
|
||||
import type { Interpreter } from '../interpreter';
|
||||
import { showWarning } from '../utils';
|
||||
import { Plugin } from '../plugin';
|
||||
import { getLogger } from '../logger';
|
||||
@@ -29,7 +29,7 @@ export class SplashscreenPlugin extends Plugin {
|
||||
|
||||
if ('autoclose_loader' in config) {
|
||||
this.autoclose = config.autoclose_loader;
|
||||
showWarning(AUTOCLOSE_LOADER_DEPRECATED, "html");
|
||||
showWarning(AUTOCLOSE_LOADER_DEPRECATED, 'html');
|
||||
}
|
||||
|
||||
if (config.splashscreen) {
|
||||
@@ -43,13 +43,13 @@ export class SplashscreenPlugin extends Plugin {
|
||||
customElements.define('py-splashscreen', PySplashscreen);
|
||||
this.elem = <PySplashscreen>document.createElement('py-splashscreen');
|
||||
document.body.append(this.elem);
|
||||
document.addEventListener("py-status-message", (e: CustomEvent) => {
|
||||
document.addEventListener('py-status-message', (e: CustomEvent) => {
|
||||
const msg = e.detail;
|
||||
this.elem.log(msg);
|
||||
});
|
||||
}
|
||||
|
||||
afterStartup(runtime: Runtime) {
|
||||
afterStartup(interpreter: Interpreter) {
|
||||
if (this.autoclose) {
|
||||
this.elem.close();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Plugin } from "../plugin";
|
||||
import { TargetedStdio, StdioMultiplexer } from "../stdio";
|
||||
import type { Interpreter } from "../interpreter";
|
||||
|
||||
|
||||
/**
|
||||
@@ -24,7 +25,7 @@ export class StdioDirector extends Plugin {
|
||||
* with that ID for the duration of the evaluation.
|
||||
*
|
||||
*/
|
||||
beforePyScriptExec(runtime: any, src: any, PyScriptTag): void {
|
||||
beforePyScriptExec(interpreter: Interpreter, src: string, PyScriptTag: any): void {
|
||||
if (PyScriptTag.hasAttribute("output")){
|
||||
const targeted_io = new TargetedStdio(PyScriptTag, "output", true, true)
|
||||
PyScriptTag.stdout_manager = targeted_io
|
||||
@@ -40,7 +41,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(runtime: any, src: any, PyScriptTag: any, result: any): void {
|
||||
afterPyScriptExec(interpreter: Interpreter, src: string, PyScriptTag: any, result: any): void {
|
||||
if (PyScriptTag.stdout_manager != null){
|
||||
this._stdioMultiplexer.removeListener(PyScriptTag.stdout_manager)
|
||||
PyScriptTag.stdout_manager = null
|
||||
|
||||
Reference in New Issue
Block a user