stlite icon indicating copy to clipboard operation
stlite copied to clipboard

Stlite Sharing: auto-save/run-as-you-type feature

Open whitphx opened this issue 1 year ago • 2 comments

whitphx avatar Jun 05 '24 08:06 whitphx

This is a great library - thank you! Is there an API to update the code for a running stlite app? I'm able to mount code, and I have a monaco editor, but when I change the code and .mount again, I see the toasts, but the code doesn't change.

I noticed you have a save button here: https://edit.share.stlite.net/ and are able to detect code changes to reload the code. How can I do that?

Screenshot 2024-07-13 at 12 01 49 PM

stevewillard avatar Jul 13 '24 16:07 stevewillard

stlite.mount() returns a controller object that has some methods to install packages and manipulate files on the virtual file system after mounting the app.

const controller = stlite.mount(
  // ... options ...
);

await controller.install(["package1", "package2"]);

await controller.writeFile("path/to/file", "file content");

await controller.renameFile("old/path", "new/path");

await controller.unlink("path/to/file");

See the actual implementation for more details and available options.

whitphx avatar Jul 16 '24 13:07 whitphx