muon/README.md

96 lines
3.3 KiB
Markdown
Raw Normal View History

2019-10-04 18:54:37 -05:00
<p align="center">
<img width="200" height="200" src="./logo.svg" alt="gnet">
<br /> <br />
<a title="Go Report Card" target="_blank" href="https://goreportcard.com/report/github.com/ImVexed/muon"><img src="https://goreportcard.com/badge/github.com/ImVexed/muon?style=flat-square"></a>
<img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/ImVexed/muon">
<br/>
2019-10-07 14:46:23 -05:00
<a target="_blank" href="https://gowalker.org/github.com/ImVexed/muon"><img src="https://img.shields.io/badge/api-reference-blue.svg?style=flat-square"></a>
2019-10-04 18:54:37 -05:00
</p>
----
2019-10-04 22:15:20 -05:00
`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 cross-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.
2019-10-04 18:54:37 -05:00
# Features
- Full JS to Go interop
- GPU based rendering
- Cross-platform
- Hot-reloading
- Superior disk size + memory & cpu usage
2019-10-04 22:27:50 -05:00
Comparison with a "Hello, World!" React App
2019-10-04 18:54:37 -05:00
| | Muon | Electron |
|:----:|---------|----------|
| CPU | 0.0% | 1.2% |
| MEM | 26.0 MB | 201.7 MB |
2019-10-04 22:27:50 -05:00
| DISK | 42 MB | 136 MB |
2019-10-04 18:54:37 -05:00
# Example
From `examples/create-react-app/main.go`:
```go
package main
import (
2019-10-04 19:01:11 -05:00
"github.com/ImVexed/muon"
2019-10-04 18:54:37 -05:00
2019-10-04 19:01:11 -05:00
"cra-go/webfiles"
"net/http"
2019-10-04 18:54:37 -05:00
)
func main() {
2019-10-04 18:59:47 -05:00
// Any static asset packer of your liking (ex. fileb0x)
2019-10-04 19:01:11 -05:00
fileHandler := http.FileServer(webfiles.HTTP)
2019-10-04 18:54:37 -05:00
2019-10-07 15:19:53 -05:00
cfg := &muon.Config{
Title: "Hello, World!",
Height: 500,
Width: 500,
Tilted: true,
Resizeable: true,
}
2019-10-04 18:54:37 -05:00
2019-10-04 19:01:11 -05:00
m := muon.New(cfg, fileHandler)
2019-10-04 18:54:37 -05:00
2019-10-04 18:59:47 -05:00
// Expose our `add` function to the JS runtime
2019-10-04 19:01:11 -05:00
m.Bind("add", add)
2019-10-04 18:54:37 -05:00
2019-10-04 18:59:47 -05:00
// Show the Window and start the Runtime
2019-10-04 19:01:11 -05:00
if err := m.Start(); err != nil {
panic(err)
}
2019-10-04 18:54:37 -05:00
}
// Muon automatically handles interop to and from the JS runtime
func add(a float64, b float64) float64 {
2019-10-04 19:01:11 -05:00
return a + b
2019-10-04 18:54:37 -05:00
}
```
# 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*
2019-10-07 15:03:58 -05:00
- Your program likely can't find the Ultralight libraries. Ensure they're either installed on the system, or, in the same folder as your program. Currently, Muon uses the 1.1 Ultralight pre-release that hasn't yet propogated to their main site and can only be downloaded from the [Ultralight](https://github.com/ultralight-ux/Ultralight#getting-the-latest-sdk) github repo.
2019-10-04 19:01:47 -05:00
## Q: *How do I get rid of the Console window on Windows?*
- Add `-ldflags -H=windowsgui` to either your `go build` or `go run` to get rid of the window.
2019-10-08 09:02:21 -05:00
# Licensing
While muon itself is MIT licensed, [Ultralight](https://ultralig.ht/) is not.
```
Ultralight is free for non-commercial use, educational use,
and also free for commercial use by small indie developers making
less than US$100,000 a year. You can find full terms in the SDK.
Pricing plans for larger commercial projects will be announced later.
```
Their specific license terms can be found [here](https://github.com/ultralight-ux/Ultralight/tree/master/license).