muon/README.md

110 lines
4.3 KiB
Markdown
Raw Permalink 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>
2019-10-09 16:53:46 -05:00
<img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/ImVexed/muon?style=flat-square">
2019-10-04 18:54:37 -05:00
<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-09 09:40:14 -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 embedded 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,
2019-10-08 22:23:57 -05:00
Titled: true,
2019-10-07 15:19:53 -05:00
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
2019-10-08 09:30:12 -05:00
## Q: *How do I setup Ultralight?*
- See our [getting started guide](https://github.com/ImVexed/muon/blob/master/getting-started.md)
2019-10-08 11:00:42 -05:00
## Q: *Is there perfect Chrome or Firefox feature parity?*
- No, see [Missing Ultralight Features](https://github.com/ultralight-ux/Ultralight/issues/178)
2019-10-11 10:58:23 -05:00
## Q: *How do I get rid of the Console on Windows?*
- Add `-ldflags -H=windowsgui` to either your `go build` or `go run` to get rid of the window.
## Q: *I get `exit status 3221225781`*
- 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 propagated 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-11 10:52:12 -05:00
## Q: *I get ` libWebCore.so: cannot open shared object file`*
- If you're attempting to load the libraries out of the same directory as your program add `-ldflags "-r ."` to your `go build` to set `rpath` to the local directory for library resolution.
2019-10-10 18:11:42 -05:00
2019-10-11 10:52:12 -05:00
## Q: *I get `symbol not found: ulCreateSettings`*
- This likely means you're not using the 1.1 Ultralight pre-release which can be downloaded only from their [GitHub Repo](https://github.com/ultralight-ux/Ultralight#getting-the-latest-sdk) for now
2019-10-16 23:40:35 -05:00
## Q: *How do I compile for x86?*
- Currently, Ultralight only supports Windows for x86. Ensure you have a 32-bit `gcc` in your path, and ensure you have `CGO_ENABLED=1` and `GOARCH=386` environment variables set.
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).