pyodide/worker/worker.js - Worker Entry Point
Location: src/pyodide/worker/worker.js
This file is the main entry point for the Pyodide web worker. It is responsible for initializing the worker's state and handling incoming messages from the main thread.
Core Logic
workerState
- Description: An object that holds the state of the worker, including:
pyodide: The Pyodide instance (once loaded).isInitialized: A boolean flag indicating if Pyodide is ready.packagesLoaded: ASetto track which standard packages have been loaded.micropipPackagesLoaded: ASetto track whichmicropippackages have been loaded.
self.onmessage
- Description: The main message handler for the worker. It receives all messages from the main thread and delegates them to the
handleMessagefunction fromworker-handlers.js. - Error Handling: It includes a
try...catchblock to handle any errors that occur during message processing and sends an error message back to the main thread.