Skip to content
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

Communication from webcontainer to host #1693

Open
paoloricciuti opened this issue Jan 6, 2025 · 4 comments
Open

Communication from webcontainer to host #1693

paoloricciuti opened this issue Jan 6, 2025 · 4 comments

Comments

@paoloricciuti
Copy link

I was trying to make the svelte inspector work in svelte lab...I kinda did it but it's a bit ugly because I have to read from the terminal. I saw that in the web container there's a custom code binary that stack blitz uses to open the tab. How does it work? Is there some even I can listen on? In general, there's a way to communicate from the web container to the page mounting it without using the terminal?

@Nemikolh
Copy link
Member

Nemikolh commented Jan 6, 2025

Hey @paoloricciuti! 👋 Thanks for asking!

There's an event that is not yet exposed but that the code binary uses under the hood to communicate that a file should be "opened" (the embedder decides what to do with that information) at a specific line.

It's basically another event type that we should expose via webcontainerInstance.on(<event>, listener).

I'll mention this to the team because I've come across this in TutorialKit too and I think this is really easy to add.

@paoloricciuti
Copy link
Author

Great...it would be cool to have a generic way to communicate to and from the web container.

@Nemikolh
Copy link
Member

Nemikolh commented Jan 6, 2025

I agree, we've talked about adding a MessagePort that could be obtained like nodejs' parentPort but it's not as easy short term. And there's a lot of debate on how it would work with regards to child processes and the event loop.

Would having that extra 'code' event be enough for you for now?

@paoloricciuti
Copy link
Author

Would having that extra 'code' event be enough for you for now?

Oh yeah absolutely...I just think that in general communication in and out the web container should be addressed (just making a proposal obviously, not pretending 😁)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants