Skip to content

Commit 537fac5

Browse files
committed
polyscript 0.16.0
1 parent 57490ad commit 537fac5

File tree

12 files changed

+2677
-4488
lines changed

12 files changed

+2677
-4488
lines changed

.yarn/releases/yarn-4.2.2.cjs

-894
This file was deleted.

.yarn/releases/yarn-4.5.3.cjs

+934
Large diffs are not rendered by default.

.yarnrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
nodeLinker: node-modules
22

3-
yarnPath: .yarn/releases/yarn-4.2.2.cjs
3+
yarnPath: .yarn/releases/yarn-4.5.3.cjs

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
"packages/*"
1010
]
1111
},
12-
"packageManager": "yarn@4.2.2",
12+
"packageManager": "yarn@4.5.3",
1313
"devDependencies": {
14-
"lint-staged": "^15.2.4",
15-
"prettier": "^3.2.5"
14+
"lint-staged": "^15.2.11",
15+
"prettier": "^3.4.2"
1616
},
1717
"dependencies": {
18-
"husky": "^9.0.11",
19-
"release-it": "^17.3.0"
18+
"husky": "^9.1.7",
19+
"release-it": "^17.11.0"
2020
},
2121
"engines": {
2222
"node": "^18"

packages/docs/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
"format": "prettier -w src src/**/*.astro *.mjs *.js *.json"
1313
},
1414
"dependencies": {
15-
"@astrojs/starlight": "^0.23.1",
15+
"@astrojs/starlight": "^0.30.3",
1616
"@codemirror/lang-python": "^6.1.6",
17-
"astro": "^4.8.6",
17+
"astro": "^5.1.1",
1818
"codemirror": "^6.0.1",
1919
"pysandbox": "workspace:^",
2020
"xterm": "^5.3.0",
2121
"xterm-addon-fit": "^0.8.0",
22-
"xterm-readline": "^1.1.1"
22+
"xterm-readline": "^1.1.2"
2323
},
2424
"devDependencies": {
25-
"prettier": "^3.2.5",
26-
"prettier-plugin-astro": "^0.13.0"
25+
"prettier": "^3.4.2",
26+
"prettier-plugin-astro": "^0.14.1"
2727
}
2828
}

packages/pysandbox/package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@
4747
"test": "playwright test"
4848
},
4949
"devDependencies": {
50-
"@playwright/test": "^1.44.0",
51-
"auto-changelog": "^2.4.0",
52-
"jsr": "^0.12.4",
53-
"playwright": "^1.44.0",
54-
"prettier": "^3.2.5",
55-
"release-it": "^17.3.0",
56-
"tsup": "^8.0.2",
57-
"typescript": "^5.4.5"
50+
"@playwright/test": "^1.49.1",
51+
"auto-changelog": "^2.5.0",
52+
"jsr": "^0.13.2",
53+
"playwright": "^1.49.1",
54+
"prettier": "^3.4.2",
55+
"release-it": "^17.11.0",
56+
"tsup": "^8.3.5",
57+
"typescript": "^5.7.2"
5858
},
5959
"dependencies": {
60-
"polyscript": "^0.12.10"
60+
"polyscript": "^0.16.10"
6161
},
6262
"publishConfig": {
6363
"registry": "https://registry.npmjs.org"

packages/pysandbox/src/sandbox/py/PyMainThreadSandbox.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { PySandboxOptions } from "./types";
55
import { ISandbox } from "../../sanbox";
66
import bootstrapProgramCode from "./python/main/bootstrap_program.py";
77
import bootstrapCode from "./python/main/bootstrap_common.py";
8-
import bootstrapRestrictedCode from "./python/main/bootstrap_restricted.py";
98

109
export class PyMainThreadSandbox implements ISandbox {
1110
#wrap: any;
@@ -28,9 +27,7 @@ export class PyMainThreadSandbox implements ISandbox {
2827
...runtimeModule,
2928
...this.#options?.modules,
3029
});
31-
const bootstrapMainCode = `${bootstrapCode}${
32-
this.#options?.restricted ? bootstrapRestrictedCode : ""
33-
}`;
30+
const bootstrapMainCode = `${bootstrapCode}`;
3431

3532
await wrap.interpreter.runPythonAsync(
3633
`${bootstrapModulesCode}${bootstrapMainCode}`,

packages/pysandbox/src/sandbox/py/PyWorkerSandbox.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ export class PyWorkerSandbox implements ISandbox {
6262
}
6363
pyworker.sync.jsExports = () => Object.keys(jsApi);
6464
pyworker.onmessage = (event) => {
65-
switch (event.data.get("name")) {
66-
case "ready": {
67-
this.#sync = pyworker.sync;
68-
resolve(pyworker);
69-
}
65+
if (event.data === "__ready__") {
66+
this.#sync = pyworker.sync;
67+
resolve(pyworker);
68+
return;
7069
}
7170
};
7271
});

packages/pysandbox/src/sandbox/py/python/main/bootstrap_restricted.py

-3
This file was deleted.

packages/pysandbox/src/sandbox/py/python/runtime/api.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import sys
22
import js
3-
import micropip
43
import pyodide
54
import pyodide_js
65
import os
@@ -9,6 +8,9 @@
98

109
async def micropip_install(packages, id, keep_going=False):
1110
try:
11+
await pyodide_js.loadPackage("micropip")
12+
import micropip
13+
1214
await micropip.install(packages, keep_going=keep_going)
1315
except Exception as e:
1416
if id:
@@ -46,7 +48,7 @@ async def format_code(code, id):
4648
await micropip_install(["black"], id)
4749
import black
4850

49-
BLACK_MODE = black.Mode(target_versions={black.TargetVersion.PY311})
51+
BLACK_MODE = black.Mode(target_versions={black.TargetVersion.PY312})
5052

5153
try:
5254
code = black.format_file_contents(code, fast=False, mode=BLACK_MODE)
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import js
22
import polyscript
33
import pysandbox
4-
import pyodide
54

65
for name in pysandbox.api.__all__:
76
setattr(polyscript.xworker.sync, name, getattr(pysandbox.api, name))
87

98
for name in polyscript.xworker.sync.jsExports().to_py():
109
setattr(js, name, getattr(polyscript.xworker.sync, name))
1110

12-
js.postMessage(pyodide.ffi.to_js({"name": "ready"}))
11+
js.postMessage("__ready__")

0 commit comments

Comments
 (0)