import './styles/pyscript_base.css'; import { loadConfigFromElement } from './pyconfig'; import type { AppConfig } from './pyconfig'; import type { Runtime } from './runtime'; import { PyScript, initHandlers, mountElements } from './components/pyscript'; import { PyLoader } from './components/pyloader'; import { PyodideRuntime } from './pyodide'; import { getLogger } from './logger'; import { runtimeLoaded, scriptsQueue, } from './stores'; import { handleFetchError, showError, globalExport } from './utils' import { createCustomElements } from './components/elements'; const logger = getLogger('pyscript/main'); let scriptsQueue_: PyScript[]; scriptsQueue.subscribe((value: PyScript[]) => { scriptsQueue_ = value; }); /* High-level overview of the lifecycle of a PyScript App: 1. pyscript.js is loaded by the browser. PyScriptApp().main() is called 2. loadConfig(): search for py-config and compute the config for the app 3. show the loader/splashscreen 4. loadRuntime(): start downloading the actual runtime (e.g. pyodide.js) --- wait until (4) has finished --- 5. now the pyodide src is available. Initialize the engine 6. setup the environment, install packages 7. run user scripts 8. initialize the rest of web components such as py-button, py-repl, etc. More concretely: - Points 1-4 are implemented sequentially in PyScriptApp.main(). - PyScriptApp.loadRuntime adds a