Skip to content

Instantly share code, notes, and snippets.

@creationix
Created January 6, 2016 02:41
Show Gist options
  • Save creationix/7b1196e604cfe255fef6 to your computer and use it in GitHub Desktop.
Save creationix/7b1196e604cfe255fef6 to your computer and use it in GitHub Desktop.

I just learned that service workers are finally getting to the state where JavaScript in the browser can handle HTTP requests browser-side!

A couple years ago, I was working on making a web ide that used git in the browser to sync and edit code entirely offline in any browser. Using appcache manifest I was able to even make the page reload offline. Data was stored in local storage and indexed db.

There was one major flaw though. I had no reasonable way to run the code. Sure I could eval some JavaScript snippets or even run them in a web worker (dynamically creating worker urls from blobs from user text). But what I really wanted and couldn't do was service HTTP requests and develop a web app in the browser.

So here's the basic idea for the next generation of tedit:

  • Command line for primary interface, will have smart auto-completion, suggestions, inline help links and syntax highlighting. But it will be a command line!
  • Apps can be launched from the command line. There will be a text editor widget that can edit source files on the virtual filesystem.
  • Apps/programs can also run in the background and will be shown as simple icons or lines in a table (think top) showing status.
  • Basic tiling window manager for apps.
  • Everything can be an app, the window manager, the editor, the background process viewer.

Essentially, we're creating a mini operating system in the browser as a full development environment. The APIs exposed by the platform can be mirrored in node.js so that a server developed in the browser can also be deployed to a real server without modifications.

@creationix
Copy link
Author

Now what really excites me, is since we're virtualizing the entire stack, we can prototype any API. We can implement any programming language in JS and it will act like a native language in this virtual OS. We can use websocket bridges and webrtc to act as gateways to TCP clients/servers in the OS. It would be possible to re-implement node.js to run in the browser. And thanks to service workers, our simulated node server can serve real web pages to a real browser window. This is the step I was missing before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment