Repository: pyscript/pyscript

Issue:
ImportError when importing PyWorker from pyscript 
### Checklist

- [X] I added a descriptive title
- [X] I searched for other issues and couldn't find a solution or duplication
- [X] I already searched in Google and didn't find any good information or help

### What happened?

Importing `PyWorker` from the `pyscript` module ends up in an `ImportError` exception:
```python
from pyscript import PyWorker
```
produces the following traceback (in the browser) - more accurate error info in the console info:
```
Traceback (most recent call last):
  File "/lib/python311.zip/_pyodide/_base.py", line 499, in eval_code
    .run(globals, locals)
     ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 340, in run
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<exec>", line 3, in <module>
ImportError: cannot import name 'PyWorker' from 'pyscript' (/home/pyodide/pyscript/__init__.py)
```

Just FYI: the following

```python
from polyscript import XWorker
```

worked perfectly, instead.



### What browsers are you seeing the problem on? (if applicable)

Chrome

### Console info

```shell
PythonError: Traceback (most recent call last):
  File "/lib/python311.zip/_pyodide/_base.py", line 468, in eval_code
    .run(globals, locals)
     ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 310, in run
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<exec>", line 3, in <module>
ImportError: cannot import name 'PyWorker' from 'pyscript' (/home/pyodide/pyscript/__init__.py)

    at new_error (pyodide.asm.js:9:14992)
    at pyodide.asm.wasm:0x152d67
    at pyodide.asm.wasm:0x152e6c
    at Module._pythonexc2js (pyodide.asm.js:9:656029)
    at Module.callPyObjectKwargs (pyodide.asm.js:9:75733)
    at Module.callPyObject (pyodide.asm.js:9:75942)
    at Function.apply (pyodide.asm.js:9:89846)
    at Object.apply (pyodide.asm.js:9:88624)
    at Object.runPython (pyodide.asm.js:9:123292)
    at Object.Ge [as run] (_python.js:12:28)
    at a.<computed> [as run] (custom.js:110:51)
    at onInterpreterReady (core.js:224:52)
```


### Additional Context

PyScript Release: `2023.09.1`
Tested on both `RC1` and `RC2`
ImportError when importing PyWorker from pyscript 
### Checklist

- [X] I added a descriptive title
- [X] I searched for other issues and couldn't find a solution or duplication
- [X] I already searched in Google and didn't find any good information or help

### What happened?

Importing `PyWorker` from the `pyscript` module ends up in an `ImportError` exception:
```python
from pyscript import PyWorker
```
produces the following traceback (in the browser) - more accurate error info in the console info:
```
Traceback (most recent call last):
  File "/lib/python311.zip/_pyodide/_base.py", line 499, in eval_code
    .run(globals, locals)
     ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 340, in run
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<exec>", line 3, in <module>
ImportError: cannot import name 'PyWorker' from 'pyscript' (/home/pyodide/pyscript/__init__.py)
```

Just FYI: the following

```python
from polyscript import XWorker
```

worked perfectly, instead.



### What browsers are you seeing the problem on? (if applicable)

Chrome

### Console info

```shell
PythonError: Traceback (most recent call last):
  File "/lib/python311.zip/_pyodide/_base.py", line 468, in eval_code
    .run(globals, locals)
     ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 310, in run
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<exec>", line 3, in <module>
ImportError: cannot import name 'PyWorker' from 'pyscript' (/home/pyodide/pyscript/__init__.py)

    at new_error (pyodide.asm.js:9:14992)
    at pyodide.asm.wasm:0x152d67
    at pyodide.asm.wasm:0x152e6c
    at Module._pythonexc2js (pyodide.asm.js:9:656029)
    at Module.callPyObjectKwargs (pyodide.asm.js:9:75733)
    at Module.callPyObject (pyodide.asm.js:9:75942)
    at Function.apply (pyodide.asm.js:9:89846)
    at Object.apply (pyodide.asm.js:9:88624)
    at Object.runPython (pyodide.asm.js:9:123292)
    at Object.Ge [as run] (_python.js:12:28)
    at a.<computed> [as run] (custom.js:110:51)
    at onInterpreterReady (core.js:224:52)
```


### Additional Context

PyScript Release: `2023.09.1`
Tested on both `RC1` and `RC2`


Discussion:
@antocuni as you refactored out this part is there any reason [we don't export anymore](https://github.com/pyscript/pyscript/blob/main/pyscript.core/src/stdlib/pyscript/__init__.py) both `PyWorker` and `current_target()` from [magic_js.py](https://github.com/pyscript/pyscript/blob/main/pyscript.core/src/stdlib/pyscript/magic_js.py) ???

If it's just an overlook this looks like easy to "fix" (it's not a bug, we just don't export those names).

If there were other rasons, please share, thanks!
@antocuni as you refactored out this part is there any reason [we don't export anymore](https://github.com/pyscript/pyscript/blob/main/pyscript.core/src/stdlib/pyscript/__init__.py) both `PyWorker` and `current_target()` from [magic_js.py](https://github.com/pyscript/pyscript/blob/main/pyscript.core/src/stdlib/pyscript/magic_js.py) ???

If it's just an overlook this looks like easy to "fix" (it's not a bug, we just don't export those names).

If there were other rasons, please share, thanks!

Resolving patch:
diff --git a/pyscript.core/src/stdlib/pyscript/__init__.py b/pyscript.core/src/stdlib/pyscript/__init__.py
--- a/pyscript.core/src/stdlib/pyscript/__init__.py
+++ b/pyscript.core/src/stdlib/pyscript/__init__.py
@@ -29,7 +29,7 @@
 #     pyscript.magic_js. This is the blessed way to access them from pyscript,
 #     as it works transparently in both the main thread and worker cases.
 
-from pyscript.magic_js import RUNNING_IN_WORKER, window, document, sync
+from pyscript.magic_js import RUNNING_IN_WORKER, PyWorker, window, document, sync, current_target
 from pyscript.display import HTML, display
 
 try:


Test patch:
diff --git a/pyscript.core/tests/integration/test_01_basic.py b/pyscript.core/tests/integration/test_01_basic.py
--- a/pyscript.core/tests/integration/test_01_basic.py
+++ b/pyscript.core/tests/integration/test_01_basic.py
@@ -6,6 +6,16 @@
 
 
 class TestBasic(PyScriptTest):
+    def test_pyscript_exports(self):
+        self.pyscript_run(
+            """
+            <script type="py">
+                from pyscript import RUNNING_IN_WORKER, PyWorker, window, document, sync, current_target
+            </script>
+            """
+        )
+        assert self.console.error.lines == []
+
     def test_script_py_hello(self):
         self.pyscript_run(
             """