This changes the calling convention for calling a Javascript function from Python so that any proxied arguments are automatically destroyed at the end of the function call. This is a breaking change. It should make it much more convenient to use the foreign function interface. 

The docs need to be updated to explain the new calling convention before this can be merged. We should put a link to the appropriate section in the docs into the error message emitted when a borrowed proxy is used after it is free so that people have an easy time learning the model by trial and error.
ENH Destroy proxies created in JsProxy.__call__ when done with call. This changes the calling convention for calling a Javascript function from Python so that any proxied arguments are automatically destroyed at the end of the function call. This is a breaking change. It should make it much more convenient to use the foreign function interface. 

The docs need to be updated to explain the new calling convention before this can be merged. We should put a link to the appropriate section in the docs into the error message emitted when a borrowed proxy is used after it is free so that people have an easy time learning the model by trial and error.
# When the pyodide package is imported, both the js and the pyodide_js modules
# will be available to import from. Not all functions in pyodide_js will work
# until after pyodide is first imported, imported functions from pyodide_js
# should not be used at import time. It is fine to use js functions at import
# time.
#
# All pure Python code that does not require js or pyodide_js should go in
# the _pyodide package.
#
# This package is imported by the test suite as well, and currently we don't use
# pytest mocks for js or pyodide_js, so make sure to test "if IN_BROWSER" before
# importing from these.

from ._core import JsProxy, JsException, create_once_callable, create_proxy, to_js, IN_BROWSER, ConversionError, destroy_proxies  # type: ignore
from _pyodide._base import (
    eval_code,
    eval_code_async,
    find_imports,
    CodeRunner,
    should_quiet,
)
from ._util import open_url
from . import _state  # noqa

from _pyodide._importhook import jsfinder

register_js_module = jsfinder.register_js_module
unregister_js_module = jsfinder.unregister_js_module

if IN_BROWSER:
    import asyncio
    from .webloop import WebLoopPolicy

    asyncio.set_event_loop_policy(WebLoopPolicy())


__version__ = "0.19.0dev0"

__all__ = [
    "open_url",
    "eval_code",
    "eval_code_async",
    "CodeRunner",
    "find_imports",
    "JsProxy",
    "JsException",
    "to_js",
    "register_js_module",
    "unregister_js_module",
    "create_once_callable",
    "create_proxy",
    "console",
    "should_quiet",
    "ConversionError",
    "destroy_proxies",
]

# When the pyodide package is imported, both the js and the pyodide_js modules
# will be available to import from. Not all functions in pyodide_js will work
# until after pyodide is first imported, imported functions from pyodide_js
# should not be used at import time. It is fine to use js functions at import
# time.
#
# All pure Python code that does not require js or pyodide_js should go in
# the _pyodide package.
#
# This package is imported by the test suite as well, and currently we don't use
# pytest mocks for js or pyodide_js, so make sure to test "if IN_BROWSER" before
# importing from these.

from ._core import JsProxy, JsException, create_once_callable, create_proxy, to_js, IN_BROWSER, ConversionError, destroy_proxies  # type: ignore
from _pyodide._base import (
    eval_code,
    eval_code_async,
    find_imports,
    CodeRunner,
    should_quiet,
)
from ._util import open_url
from . import _state  # noqa

from _pyodide._importhook import jsfinder

register_js_module = jsfinder.register_js_module
unregister_js_module = jsfinder.unregister_js_module

if IN_BROWSER:
    import asyncio
    from .webloop import WebLoopPolicy

    asyncio.set_event_loop_policy(WebLoopPolicy())


__version__ = "0.19.0dev0"

__all__ = [
    "open_url",
    "eval_code",
    "eval_code_async",
    "CodeRunner",
    "find_imports",
    "JsProxy",
    "JsException",
    "to_js",
    "register_js_module",
    "unregister_js_module",
    "create_once_callable",
    "create_proxy",
    "console",
    "should_quiet",
    "ConversionError",
    "destroy_proxies",
]
