Without actually reading the documentation or source code -- I guess "js" package is just an API that somehow maps to the real "window" object and calls those DOM methods via some sort of Proxy object.
https://pyodide.org/en/stable/usage/quickstart.html#accessin...