import './styles/pyscript_base.css'; import { loadConfigFromElement } from './pyconfig'; import type { AppConfig } from './pyconfig'; import type { Runtime } from './runtime'; import { make_PyScript, initHandlers, mountElements } from './components/pyscript'; import { PyLoader } from './components/pyloader'; import { PyodideRuntime } from './pyodide'; import { getLogger } from './logger'; import { handleFetchError, showError, globalExport } from './utils'; import { createCustomElements } from './components/elements'; type ImportType = { [key: string]: unknown }; type ImportMapType = { imports: ImportType | null; }; const logger = getLogger('pyscript/main'); /* 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. connect the py-script web component. This causes the execution of all the 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