mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-23 04:03:00 -05:00
Add type annotations (#562)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { loadedEnvironments, mode, pyodideLoaded } from '../stores';
|
||||
import { loadedEnvironments, mode, pyodideLoaded, type Environment } from '../stores';
|
||||
import { guidGenerator, addClasses, removeClasses } from '../utils';
|
||||
import type { PyodideInterface } from '../pyodide';
|
||||
// Premise used to connect to the first available pyodide interpreter
|
||||
let runtime;
|
||||
let environments;
|
||||
let environments: Record<Environment['id'], Environment> = {};
|
||||
let currentMode;
|
||||
let Element;
|
||||
|
||||
|
||||
@@ -101,9 +101,10 @@ export class PyodideRuntime extends Object {
|
||||
pyodide.globals.set('pyscript_loader', loader);
|
||||
|
||||
loader?.log('Runtime created...');
|
||||
loadedEnvironments.update((value: any): any => {
|
||||
value[newEnv['id']] = newEnv;
|
||||
});
|
||||
loadedEnvironments.update(environments => ({
|
||||
...environments,
|
||||
[newEnv['id']]: newEnv,
|
||||
}));
|
||||
|
||||
// now we call all initializers before we actually executed all page scripts
|
||||
loader?.log('Initializing components...');
|
||||
|
||||
@@ -5,14 +5,14 @@ import { keymap } from '@codemirror/view';
|
||||
import { defaultKeymap } from '@codemirror/commands';
|
||||
import { oneDarkTheme } from '@codemirror/theme-one-dark';
|
||||
|
||||
import { componentDetailsNavOpen, loadedEnvironments, mode, pyodideLoaded } from '../stores';
|
||||
import { componentDetailsNavOpen, loadedEnvironments, mode, pyodideLoaded, type Environment } from '../stores';
|
||||
import { addClasses, htmlDecode } from '../utils';
|
||||
import { BaseEvalElement } from './base';
|
||||
|
||||
// Premise used to connect to the first available pyodide interpreter
|
||||
|
||||
let pyodideReadyPromise;
|
||||
let environments;
|
||||
let environments: Record<Environment['id'], Environment> = {};
|
||||
let currentMode;
|
||||
|
||||
pyodideLoaded.subscribe(value => {
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
loadedEnvironments,
|
||||
mode,
|
||||
pyodideLoaded,
|
||||
type Environment,
|
||||
} from '../stores';
|
||||
import { addClasses, htmlDecode } from '../utils';
|
||||
import { BaseEvalElement } from './base';
|
||||
@@ -12,7 +13,7 @@ import type { PyodideInterface } from '../pyodide';
|
||||
|
||||
// Premise used to connect to the first available pyodide interpreter
|
||||
let pyodideReadyPromise;
|
||||
let environments;
|
||||
let environments: Record<Environment['id'], Environment> = {};
|
||||
let currentMode;
|
||||
|
||||
pyodideLoaded.subscribe(value => {
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import type { PyLoader } from './components/pyloader';
|
||||
import type { PyScript } from './components/pyscript';
|
||||
import type { PyodideInterface } from './pyodide';
|
||||
|
||||
export type Initializer = () => Promise<void>;
|
||||
|
||||
export type Environment = {
|
||||
id: string;
|
||||
promise: Promise<PyodideInterface>;
|
||||
runtime: PyodideInterface;
|
||||
state: string;
|
||||
};
|
||||
|
||||
export const pyodideLoaded = writable({
|
||||
loaded: false,
|
||||
premise: null,
|
||||
});
|
||||
|
||||
export const loadedEnvironments = writable([{}]);
|
||||
export const loadedEnvironments = writable<Record<Environment['id'], Environment>>({});
|
||||
export const DEFAULT_MODE = 'play';
|
||||
|
||||
export const navBarOpen = writable(false);
|
||||
|
||||
Reference in New Issue
Block a user