Skip to content

Commit d9fd81a

Browse files
committed
Added proper transform to MicroPython
1 parent 6b16980 commit d9fd81a

File tree

6 files changed

+28
-23
lines changed

6 files changed

+28
-23
lines changed

docs/core.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/core.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esm/interpreter/micropython.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export default {
2222
run,
2323
runAsync,
2424
runEvent,
25-
transform: (_, value) => value,
25+
transform: (interpreter, value) => (
26+
value instanceof interpreter.PyProxy ?
27+
interpreter.PyProxy.toJs(value) :
28+
value
29+
),
2630
writeFile: ({ FS, _module: { PATH, PATH_FS } }, path, buffer) =>
2731
writeFile({ FS, PATH, PATH_FS }, path, buffer),
2832
};

index.html

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
<li><a href="/test/index.html">pyodide</a></li>
1616
<li><a href="/test/micropython.html">micropython</a></li>
1717
<li><a href="/test/remote.html">remote micropython</a></li>
18-
<li>
19-
<a href="/test/matplot.worker.html">matplot worker (toml)</a>
20-
</li>
18+
<li><a href="/test/matplot.worker.html">matplot worker (toml)</a></li>
2119
<li><a href="/test/matplot.json.html">matplot json</a></li>
2220
<li><a href="/test/matplot.html">matplot toml</a></li>
2321
<li><a href="/test/many.html">all together</a></li>
@@ -34,21 +32,9 @@
3432
<li><a href="/test/worker/input.html">worker w/ input</a></li>
3533
<li><a href="/test/order.html">execution order</a></li>
3634
<li><a href="/test/plugins/">plugins</a></li>
37-
<li>
38-
<a href="/test/plugins/py-script.html">
39-
custom tags: PyScript
40-
</a>
41-
</li>
42-
<li>
43-
<a href="/test/async-events/">
44-
async events
45-
</a>
46-
</li>
47-
<li>
48-
<a href="/test/multi-turtle/">
49-
multi turtle
50-
</a>
51-
</li>
35+
<li><a href="/test/plugins/index.html">custom tags</a></li>
36+
<li><a href="/test/async-events/">async events</a></li>
37+
<li><a href="/test/multi-turtle/">multi turtle</a></li>
5238
</ul>
5339
</body>
5440
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@
8383
"sticky-module": "^0.1.1"
8484
},
8585
"worker": {
86-
"blob": "sha256-HzMxq6cZquh//odEM+NnPqiEbGGFtAHGoJ6ldDNmJmE="
86+
"blob": "sha256-qCANJhVOyA+B1ms4kuhKj6mC9rErzLpD95XDILaiP+0="
8787
}
8888
}

test/micropython/random.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<script type="module" src="../../core.js"></script>
7+
<script type="micropython">
8+
import random, js
9+
10+
print(random.randint(0,255))
11+
print(js.performance.now())
12+
print(js.Date.now())
13+
</script>
14+
</head>
15+
</html>

0 commit comments

Comments
 (0)