mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
cleanup leftovers such as mode and pyodideReadyPromise (#649)
* remove usage of mode * clean up pyodideReadyPromise
This commit is contained in:
@@ -3,7 +3,6 @@ import { BaseEvalElement } from './base';
|
||||
import {
|
||||
initializers,
|
||||
loadedEnvironments,
|
||||
mode,
|
||||
postInitializers,
|
||||
pyodideLoaded,
|
||||
scriptsQueue,
|
||||
@@ -64,12 +63,6 @@ scriptsQueue.subscribe((value: PyScript[]) => {
|
||||
console.log('post initializers set');
|
||||
});
|
||||
|
||||
let mode_: string;
|
||||
mode.subscribe((value: string) => {
|
||||
mode_ = value;
|
||||
console.log('post initializers set');
|
||||
});
|
||||
|
||||
let loader: PyLoader | undefined;
|
||||
globalLoader.subscribe(value => {
|
||||
loader = value;
|
||||
@@ -109,14 +102,11 @@ export class PyodideRuntime extends Object {
|
||||
await initializer();
|
||||
}
|
||||
|
||||
// now we can actually execute the page scripts if we are in play mode
|
||||
loader?.log('Initializing scripts...');
|
||||
if (mode_ == 'play') {
|
||||
for (const script of scriptsQueue_) {
|
||||
await script.evaluate();
|
||||
}
|
||||
scriptsQueue.set([]);
|
||||
for (const script of scriptsQueue_) {
|
||||
await script.evaluate();
|
||||
}
|
||||
scriptsQueue.set([]);
|
||||
|
||||
// now we call all post initializers AFTER we actually executed all page scripts
|
||||
loader?.log('Running post initializers...');
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
addPostInitializer,
|
||||
addToScriptsQueue,
|
||||
loadedEnvironments,
|
||||
mode,
|
||||
pyodideLoaded,
|
||||
type Environment,
|
||||
} from '../stores';
|
||||
@@ -12,9 +11,8 @@ import { BaseEvalElement } from './base';
|
||||
import type { PyodideInterface } from '../pyodide';
|
||||
|
||||
// Premise used to connect to the first available pyodide interpreter
|
||||
let pyodideReadyPromise;
|
||||
let pyodideReadyPromise: PyodideInterface;
|
||||
let environments: Record<Environment['id'], Environment> = {};
|
||||
let currentMode;
|
||||
|
||||
pyodideLoaded.subscribe(value => {
|
||||
pyodideReadyPromise = value;
|
||||
@@ -23,10 +21,6 @@ loadedEnvironments.subscribe(value => {
|
||||
environments = value;
|
||||
});
|
||||
|
||||
mode.subscribe(value => {
|
||||
currentMode = value;
|
||||
});
|
||||
|
||||
export class PyScript extends BaseEvalElement {
|
||||
constructor() {
|
||||
super();
|
||||
@@ -74,13 +68,8 @@ export class PyScript extends BaseEvalElement {
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMode == 'edit') {
|
||||
// TODO: We need to build a plan for this
|
||||
this.appendChild(mainDiv);
|
||||
} else {
|
||||
this.appendChild(mainDiv);
|
||||
addToScriptsQueue(this);
|
||||
}
|
||||
this.appendChild(mainDiv);
|
||||
addToScriptsQueue(this);
|
||||
|
||||
console.log('connected');
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import type { PyodideInterface } from './pyodide';
|
||||
// @ts-ignore
|
||||
import pyscript from './pyscript.py';
|
||||
|
||||
let pyodideReadyPromise;
|
||||
let pyodide: PyodideInterface;
|
||||
|
||||
const loadInterpreter = async function (indexUrl: string): Promise<PyodideInterface> {
|
||||
@@ -61,4 +60,4 @@ const loadFromFile = async function (s: string, runtime: PyodideInterface): Prom
|
||||
);
|
||||
};
|
||||
|
||||
export { loadInterpreter, pyodideReadyPromise, loadPackage, loadFromFile };
|
||||
export { loadInterpreter, loadPackage, loadFromFile };
|
||||
|
||||
@@ -14,14 +14,12 @@ export type Environment = {
|
||||
export const pyodideLoaded = writable<PyodideInterface>();
|
||||
|
||||
export const loadedEnvironments = writable<Record<Environment['id'], Environment>>({});
|
||||
export const DEFAULT_MODE = 'play';
|
||||
|
||||
export const navBarOpen = writable(false);
|
||||
export const componentsNavOpen = writable(false);
|
||||
export const componentDetailsNavOpen = writable(false);
|
||||
export const mainDiv = writable(null);
|
||||
export const currentComponentDetails = writable([]);
|
||||
export const mode = writable(DEFAULT_MODE);
|
||||
export const scriptsQueue = writable<PyScript[]>([]);
|
||||
export const initializers = writable<Initializer[]>([]);
|
||||
export const postInitializers = writable<Initializer[]>([]);
|
||||
|
||||
Reference in New Issue
Block a user