|
18 | 18 | define("mpy", { |
19 | 19 | interpreter: "micropython", |
20 | 20 | config: "../fetch.toml", |
21 | | - async onInterpreterReady(micropython, element) { |
22 | | - console.log(micropython); |
23 | | - // Somehow this doesn't work in MicroPython |
24 | | - micropython.io.stdout = (message) => { |
25 | | - console.log("🐍", micropython.type, message); |
26 | | - }; |
27 | | - micropython.io.stderr = (message) => { |
28 | | - console.error("⚠️🐍", message); |
29 | | - }; |
| 21 | + hooks: { |
| 22 | + main: { |
| 23 | + async onReady(micropython, element) { |
| 24 | + console.log(micropython); |
| 25 | + // Somehow this doesn't work in MicroPython |
| 26 | + micropython.io.stdout = (message) => { |
| 27 | + console.log("🐍", micropython.type, message); |
| 28 | + }; |
| 29 | + micropython.io.stderr = (message) => { |
| 30 | + console.error("⚠️🐍", message); |
| 31 | + }; |
30 | 32 |
|
31 | | - micropython.run(element.textContent); |
32 | | - element.replaceChildren("See console ->"); |
33 | | - element.style.display = "block"; |
| 33 | + micropython.run(element.textContent); |
| 34 | + element.replaceChildren("See console ->"); |
| 35 | + element.style.display = "block"; |
34 | 36 |
|
35 | | - const button = document.createElement("button"); |
36 | | - button.textContent = "click"; |
37 | | - button.setAttribute("mpy-click", "test_click"); |
38 | | - document.body.append(button); |
| 37 | + const button = document.createElement("button"); |
| 38 | + button.textContent = "click"; |
| 39 | + button.setAttribute("mpy-click", "test_click"); |
| 40 | + document.body.append(button); |
39 | 41 |
|
40 | | - const error = document.createElement("button"); |
41 | | - error.textContent = "error"; |
42 | | - error.setAttribute("mpy-click", "test_error"); |
43 | | - document.body.append(error); |
44 | | - }, |
| 42 | + const error = document.createElement("button"); |
| 43 | + error.textContent = "error"; |
| 44 | + error.setAttribute("mpy-click", "test_error"); |
| 45 | + document.body.append(error); |
| 46 | + } |
| 47 | + } |
| 48 | + } |
45 | 49 | }); |
46 | 50 | </script> |
47 | 51 | </head> |
|
0 commit comments