mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
PyGame - TOML + JSON absolute URL + input patch (#2313)
* Make config URL canonical * Better baseURL + input patch
This commit is contained in:
committed by
GitHub
parent
caeab77a8e
commit
b22f384d73
4
core/package-lock.json
generated
4
core/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@pyscript/core",
|
||||
"version": "0.6.36",
|
||||
"version": "0.6.39",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@pyscript/core",
|
||||
"version": "0.6.36",
|
||||
"version": "0.6.39",
|
||||
"license": "APACHE-2.0",
|
||||
"dependencies": {
|
||||
"@ungap/with-resolvers": "^0.1.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pyscript/core",
|
||||
"version": "0.6.36",
|
||||
"version": "0.6.39",
|
||||
"type": "module",
|
||||
"description": "PyScript",
|
||||
"module": "./index.js",
|
||||
|
||||
@@ -11,6 +11,17 @@ import { getText } from "../fetch.js";
|
||||
|
||||
const progress = createProgress("py-game");
|
||||
|
||||
const inputPatch = `
|
||||
import builtins
|
||||
def input(prompt=""):
|
||||
import js
|
||||
return js.prompt(prompt)
|
||||
|
||||
builtins.input = input
|
||||
del builtins
|
||||
del input
|
||||
`;
|
||||
|
||||
let toBeWarned = true;
|
||||
|
||||
const hooks = {
|
||||
@@ -45,7 +56,7 @@ const hooks = {
|
||||
progress,
|
||||
wrap.interpreter,
|
||||
config,
|
||||
url || location.href,
|
||||
url ? new URL(url, location.href).href : location.href,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,6 +74,7 @@ const hooks = {
|
||||
});
|
||||
|
||||
await wrap.interpreter.runPythonAsync(stdlib);
|
||||
wrap.interpreter.runPython(inputPatch);
|
||||
|
||||
let code = dedent(script.textContent);
|
||||
if (script.src) code = await fetch(script.src).then(getText);
|
||||
|
||||
0
core/tests/manual/game/config.toml
Normal file
0
core/tests/manual/game/config.toml
Normal file
@@ -8,7 +8,7 @@
|
||||
<script type="module" src="../../../dist/core.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="py-game" src="aliens.py" config="{}"></script>
|
||||
<script type="py-game" src="aliens.py" config="./config.toml"></script>
|
||||
<div class="demo">
|
||||
<div class="demo-header">pygame.examples.aliens</div>
|
||||
<div class="demo-content">
|
||||
|
||||
Reference in New Issue
Block a user