diff --git a/README.md b/README.md new file mode 100644 index 0000000..f5c39eb --- /dev/null +++ b/README.md @@ -0,0 +1,80 @@ +
+ +---- + +`Muon` is a lightweight alternative to Electron written in Golang in about ~300 LoC, using Ultralight instead of Chromium. [Ultralight](https://ultralig.ht/) is a corss-platform WebKit rewrite using the GPU to target embeded desktop applications that resulted in a fast, lightweight, and low-memory HTML UI solution that blends the power of Chromium with the small footprint of Native UI. + + +# Features + +- Full JS to Go interop +- GPU based rendering +- Cross-platform +- Hot-reloading +- Superior disk size + memory & cpu usage + + +| | Muon | Electron | +|:----:|---------|----------| +| CPU | 0.0% | 1.2% | +| MEM | 26.0 MB | 201.7 MB | +| SIZE | 42 MB | 136 MB | + +# Example + +From `examples/create-react-app/main.go`: +```go +package main + +import ( + "github.com/ImVexed/muon" + + "cra-go/webfiles" + "net/http" +) + +func main() { + // Any static asset packer of your liking (ex. fileb0x) + fileHandler := http.FileServer(webfiles.HTTP) + + cfg := &muon.Config{ + Title: "Hello, World!", + Height: 500, + Width: 500, + Hint: 2 | 4, + } + + m := muon.New(cfg, fileHandler) + + // Expose our `add` function to the JS runtime + m.Bind("add", add) + + // Show the Window and start the Runtime + if err := m.Start(); err != nil { + panic(err) + } +} + +// Muon automatically handles interop to and from the JS runtime +func add(a float64, b float64) float64 { + return a + b +} +``` + +# FAQ + +## Q: *How are JS types translated to Go types?* +- JS: `Boolean` Go: `bool` +- JS: `Number` Go: `float64` +- JS: `String` Go: `string` +- JS: `Object` Go: `struct` via JSON + +## Q: *I get `exit status 3221225781` when I try to run my program* +- Your program likely can't find the [Ultralight](https://ultralig.ht/) libraries. Ensure they're either installed on the system, or, in the same folder as your program. \ No newline at end of file diff --git a/examples/create-react-app/README.md b/examples/create-react-app/README.md index af827be..5eefd9b 100644 --- a/examples/create-react-app/README.md +++ b/examples/create-react-app/README.md @@ -2,7 +2,4 @@ - Run `yarn && yarn build` inside of `public/` - Run `go generate && go build` inside this directory. -- Ensure Ultralight libraries are installed - -## Help! I get `exit status 3221225781` when I try to run the executable! -Due to Ultralight's licensing it can only be dynamically linked to. Meaning you'll need to either add the respective `.dll`'s or `.so`'s to either a system path, or the same directory as the the executable. You can find these libraries on https://ultralig.ht/ (The version that Muon uses can be found in `ultralight/libs/`) \ No newline at end of file +- Ensure Ultralight libraries are installed \ No newline at end of file diff --git a/examples/create-react-app/cra-go.exe b/examples/create-react-app/cra-go.exe deleted file mode 100644 index baed95e..0000000 Binary files a/examples/create-react-app/cra-go.exe and /dev/null differ diff --git a/logo.svg b/logo.svg new file mode 100644 index 0000000..a98e156 --- /dev/null +++ b/logo.svg @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/muon.go b/muon.go index 90c5f32..489affc 100644 --- a/muon.go +++ b/muon.go @@ -11,6 +11,7 @@ import ( . "github.com/ImVexed/muon/ultralight" ) +// Window represents a single Ultralight instance type Window struct { wnd ULWindow view ULView @@ -25,6 +26,7 @@ type ipf struct { ReturnTypes []reflect.Type } +// Config contains configurable controls for the Ultralight engine type Config struct { Title string Height uint32 @@ -34,6 +36,7 @@ type Config struct { Y int32 } +// New creates a Ultralight Window func New(cfg *Config, handler http.Handler) *Window { w := &Window{ cfg: cfg, @@ -57,6 +60,7 @@ func New(cfg *Config, handler http.Handler) *Window { return w } +// Start sets up the Ultralight runtime and begins showing the Window func (w *Window) Start() error { addr, err := serveHandler(w.handler)