mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Exposing config type once resolved and running (#2175)
This commit is contained in:
committed by
GitHub
parent
84c7d69db9
commit
dd86169f2a
@@ -10,6 +10,11 @@ RUNNING_IN_WORKER = not hasattr(globalThis, "document")
|
||||
|
||||
config = json.loads(globalThis.JSON.stringify(_config))
|
||||
|
||||
if "MicroPython" in sys.version:
|
||||
config["type"] = "mpy"
|
||||
else:
|
||||
config["type"] = "py"
|
||||
|
||||
|
||||
# allow `from pyscript.js_modules.xxx import yyy`
|
||||
class JSModule:
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -114,3 +114,8 @@ test('Pyodide loader', async ({ page }) => {
|
||||
const body = await page.evaluate(() => document.body.textContent);
|
||||
await expect(body.includes('Loaded Pyodide')).toBe(true);
|
||||
});
|
||||
|
||||
test('Py and Mpy config["type"]', async ({ page }) => {
|
||||
await page.goto('http://localhost:8080/tests/js-integration/config_type.html');
|
||||
await page.waitForSelector('html.mpy.py');
|
||||
});
|
||||
|
||||
23
pyscript.core/tests/js-integration/config_type.html
Normal file
23
pyscript.core/tests/js-integration/config_type.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../../dist/core.css">
|
||||
<script type="module" src="../../dist/core.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="mpy">
|
||||
from pyscript import config, document
|
||||
|
||||
if config["type"] is "mpy":
|
||||
document.documentElement.classList.add("mpy")
|
||||
</script>
|
||||
<script type="py">
|
||||
from pyscript import config, document
|
||||
|
||||
if config["type"] is "py":
|
||||
document.documentElement.classList.add("py")
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user