import './styles/pyscript_base.css'; import { loadConfigFromElement } from './pyconfig'; import type { AppConfig } from './pyconfig'; import type { Runtime } from './runtime'; import { version } from './runtime'; import { PluginManager, define_custom_element } from './plugin'; import { make_PyScript, initHandlers, mountElements } from './components/pyscript'; import { PyodideRuntime } from './pyodide'; import { getLogger } from './logger'; import { handleFetchError, showWarning, globalExport } from './utils'; import { calculatePaths } from './plugins/fetch'; import { createCustomElements } from './components/elements'; import { UserError, ErrorCode, _createAlertBanner } from "./exceptions" import { type Stdio, StdioMultiplexer, DEFAULT_STDIO } from './stdio'; import { PyTerminalPlugin } from './plugins/pyterminal'; import { SplashscreenPlugin } from './plugins/splashscreen'; import { ImportmapPlugin } from './plugins/importmap'; // eslint-disable-next-line // @ts-ignore import pyscript from './python/pyscript.py'; 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. (it used to be "show the splashscreen", but now it's a plugin) 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 6.5: call the Plugin.afterSetup() hook 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