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",
|
"name": "@pyscript/core",
|
||||||
"version": "0.6.36",
|
"version": "0.6.39",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pyscript/core",
|
"name": "@pyscript/core",
|
||||||
"version": "0.6.36",
|
"version": "0.6.39",
|
||||||
"license": "APACHE-2.0",
|
"license": "APACHE-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ungap/with-resolvers": "^0.1.0",
|
"@ungap/with-resolvers": "^0.1.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pyscript/core",
|
"name": "@pyscript/core",
|
||||||
"version": "0.6.36",
|
"version": "0.6.39",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "PyScript",
|
"description": "PyScript",
|
||||||
"module": "./index.js",
|
"module": "./index.js",
|
||||||
|
|||||||
@@ -11,6 +11,17 @@ import { getText } from "../fetch.js";
|
|||||||
|
|
||||||
const progress = createProgress("py-game");
|
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;
|
let toBeWarned = true;
|
||||||
|
|
||||||
const hooks = {
|
const hooks = {
|
||||||
@@ -45,7 +56,7 @@ const hooks = {
|
|||||||
progress,
|
progress,
|
||||||
wrap.interpreter,
|
wrap.interpreter,
|
||||||
config,
|
config,
|
||||||
url || location.href,
|
url ? new URL(url, location.href).href : location.href,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +74,7 @@ const hooks = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await wrap.interpreter.runPythonAsync(stdlib);
|
await wrap.interpreter.runPythonAsync(stdlib);
|
||||||
|
wrap.interpreter.runPython(inputPatch);
|
||||||
|
|
||||||
let code = dedent(script.textContent);
|
let code = dedent(script.textContent);
|
||||||
if (script.src) code = await fetch(script.src).then(getText);
|
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>
|
<script type="module" src="../../../dist/core.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<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">
|
||||||
<div class="demo-header">pygame.examples.aliens</div>
|
<div class="demo-header">pygame.examples.aliens</div>
|
||||||
<div class="demo-content">
|
<div class="demo-content">
|
||||||
|
|||||||
Reference in New Issue
Block a user