This repo contains the editor component of Atelier. It is comprised of three crates:
- The front-end WASM application
- A server component that the front-end talks to via websockets
- A package that uses
web_viewto serve the WASM application up in a platform-native browser window so that it looks like a native application
Webview Window───────────────────────┐
│ │
│ ┌─────────────────────────┐ │
│ │ │ │
│ │ WASM Front-end │ │◀─┐
│ │ │ │ │
│ └─────────────────────────┘ │ │
│ ▲ │ │
└──────────────────╋─────────────────┘ │
┃ │
┃ │
┃ Websockets │ HTTP File Serving
┃ │
┃ │
▼ │
┌────────────────────────────────────┐ │
│ │ │
│ │ │
│ Server │──┘
│ │
│ │
└────────────────────────────────────┘
▲
│
│ OS commands
│
▼
┌────────────────────────────────────┐
│ Host Filesystem │
└────────────────────────────────────┘
The startup sequence looks like this:
- User launches the web_view executable
- The web_view executable starts and launches the server process
- The web_view exeutable waits until it can reach the server via its embedded HTTP server
- The web_view executable loads
index.html index.htmlloads the UIKit CSS and JSindex.htmlthen loadsmain.jsmain.jsmakes an HTTP request to the server formain.wasm- The WASM front-end is loaded into the
web_viewwindow - The WASM front-end establishes a websocket connection to the server
- This is so that the front-end can interact with the host system, similar to how Electron functions
web_view is significantly lighter weight than a CEF window. It uses platform-specific browser windows: Cocoa/WebKit on macOS, gtk-webkit2 on Linux and MSHTML (IE10/11) on Windows. As of the date of this writing, it consumes around 30MB of RAM.
This crate contains the WASM front-end application. It uses the Yew framework, and functions much like Angular, Elm, and React. This crate uses the cargo-web cargo extension to compile for WASM.
The UI is just plain UIKit, utilized by the WASM application.
This crate contains the server component. It listens for commands from the front-end on 127.0.0.1 via websockets, and executes them on behalf of the front-end. This is because WASM/JS apps cannot interact much with the host for security reasons.
This contains the web_view component, and is the one the user will launch. This crate is rather simple and is just to provide the window.
The application can be run without the server and web_view component by using nginx or similar to serve the WASM application. When used in this fashion, the WASM application is limited in what it can do. For example, the browser places limits on how much storage can be used by an application.
We attempt to keep feature parity between the local and non-local versions, but this isn't always possible. The areas where they differ are called out in the book.