PyGame - TOML + JSON absolute URL + input patch (#2313)

* Make config URL canonical

* Better baseURL + input patch
This commit is contained in:
Andrea Giammarchi
2025-03-11 11:32:30 +01:00
committed by GitHub
parent caeab77a8e
commit b22f384d73
5 changed files with 17 additions and 5 deletions

View File

@@ -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",

View File

@@ -1,6 +1,6 @@
{
"name": "@pyscript/core",
"version": "0.6.36",
"version": "0.6.39",
"type": "module",
"description": "PyScript",
"module": "./index.js",

View File

@@ -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);

View File

View 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">