-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Enhance MicroPython Terminal on both Main and Worker #2083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
OK ... after yesterday demo I think I could rewrite this whole thing in a better way and provide just two different terminals, one for Pyodide and one for MicroPython. The branching logic is a bit overwhelming and this plugin is now too "spaghetti" to me so I might just put this on hold (as draft) and provide a definitive one that makes MicroPython terminal story the best we can have. @ntoll does this sound reasonable to you? I really don't like the current state of the file and the fact terminal in worker is actually inferior somehow to what we could have instead ... |
@ntoll this is final now and tested with both MicroPython (new features) and Pyodide (no regressions). You can test this live as it's already on npm https://webreflection.github.io/coincident/test/pyterminal/ This also updates polyscript in a way that satisfies the I think we should release this 😇 |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
@WebReflection ok... I've just looked through this. I agree with your "spaghetti" thoughts. This isn't the spaghetti mama used to make... 😋 😉 I notice you've already split out the terminal into a mpy and py version. How much more work would be needed for you to be happy with the state of the code..? I also agree that having the terminal on main (as well as the worker) for MicroPython is a good thing, with further (later) refinement for Pyodide to come. I think it's important simply because stuff like tab completion, history and all the other good stuff is rather fun to have available for those who simply want a quick REPL for MicroPython. I'm forever going to pyscript.net just to type stuff in to check MicroPython things. ;-) |
This is already published on npm, I am OK with the current state of the code. There's some inevitable repetition but the split makes it less bloated anyway and unfortunately the stream dance is never too elegant but super effective. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Let's get this out to the world, and we can refine our spaghetti recipe moving forwards. 👍 🇮🇹 🍝 👨🍳 |
Description
This MR allows MicroPython
terminal
on the main thread viaimport code; code.interact()
same mechanism used to enable it on workers.It is based on the following assumptions / constraints:
input
is delegated to the JSprompt
... so it's blocking on main ... everything looks fine on workercode.interact()
might be invokedinput
, which is default in PyScript, is explicitly removed when MicroPython terminal is meant to be usedtime
orutime
and there is a sleep, the whole thing is just blocked until the sum of sleeps is completed and the output is shown only after ... on workers, everything works as expectedOn both main and worker, these are the enhancements:
/cc @ntoll
Changes
invalidInput
string to be able to remove it from hooks when ampy
terminal is found on the pageChecklist
CHANGELOG.md