stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.94k stars 174 forks source link

Alternative mechanism to get generated server URL than events #1525

Closed jswhisperer closed 1 month ago

jswhisperer commented 1 month ago

Working in embedded webviews it's difficult to get events as they are overwritten (in my case) I would be nice to have an alternative to server-ready event

    webcontainerInstance.on("server-ready", (port: any, url: string) => {
            webc.value = url;
        });

If it was on the instance somewhere rather just await npm start should be sufficent to know the server is running.

await webcontainerInstance
            .spawn("npm", ["run", "start"])
            .then((deets) => {
                webc.value = "http://localhost:3111"; // or deets.url ?
            })
            .catch((e: any) => console.log(e));

or webcontainerInstance.url