Skip to content
Snippets Groups Projects
Commit b4153daa authored by Jono Wenger's avatar Jono Wenger
Browse files

Fix wasm_exec.js and update README

parent 5c32adf2
No related branches found
No related tags found
1 merge request!60Revert "Fail a test to be sure it works"
...@@ -38,9 +38,12 @@ directory. Then run the server ...@@ -38,9 +38,12 @@ directory. Then run the server
```shell ```shell
$ GOOS=js GOARCH=wasm go build -o test/assets/xxdk.wasm $ GOOS=js GOARCH=wasm go build -o test/assets/xxdk.wasm
$ go run test/server/main.go $ cd test/server/
$ go run main.go
``` ```
Navigate to http://localhost:9090 to see the web page.
## `wasm_exec.js` ## `wasm_exec.js`
`wasm_exec.js` is provided by Go and is used to import the WebAssembly module in `wasm_exec.js` is provided by Go and is used to import the WebAssembly module in
...@@ -62,7 +65,7 @@ global.Go = class { ...@@ -62,7 +65,7 @@ global.Go = class {
go: { go: {
// ... // ...
// func Throw(exception string, message string) // func Throw(exception string, message string)
'gitlab.com/elixxir/client/wasm.Throw': (sp) => { 'gitlab.com/elixxir/xxdk-wasm/wasm.Throw': (sp) => {
const exception = loadString(sp + 8) const exception = loadString(sp + 8)
const message = loadString(sp + 24) const message = loadString(sp + 24)
throw globalThis[exception](message) throw globalThis[exception](message)
......
...@@ -11,13 +11,15 @@ package main ...@@ -11,13 +11,15 @@ package main
import ( import (
"fmt" "fmt"
"gitlab.com/elixxir/client/bindings"
"gitlab.com/elixxir/xxdk-wasm/wasm" "gitlab.com/elixxir/xxdk-wasm/wasm"
"os" "os"
"syscall/js" "syscall/js"
) )
func main() { func main() {
fmt.Println("Go Web Assembly") fmt.Println("Starting xxDK WebAssembly bindings.")
fmt.Printf("Client version %s\n", bindings.GetVersion())
// wasm/backup.go // wasm/backup.go
js.Global().Set("NewCmixFromBackup", js.FuncOf(wasm.NewCmixFromBackup)) js.Global().Set("NewCmixFromBackup", js.FuncOf(wasm.NewCmixFromBackup))
......
...@@ -503,7 +503,7 @@ ...@@ -503,7 +503,7 @@
}, },
// func Throw(exception string, message string) // func Throw(exception string, message string)
'gitlab.com/elixxir/client/wasm.Throw': (sp) => { 'gitlab.com/elixxir/xxdk-wasm/wasm.Throw': (sp) => {
const exception = loadString(sp + 8) const exception = loadString(sp + 8)
const message = loadString(sp + 24) const message = loadString(sp + 24)
throw globalThis[exception](message) throw globalThis[exception](message)
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
func main() { func main() {
port := "9090" port := "9090"
root := "test/assets" root := "../assets"
fmt.Printf("Starting server on port %s from %s\n", port, root) fmt.Printf("Starting server on port %s from %s\n", port, root)
err := http.ListenAndServe(":"+port, http.FileServer(http.Dir(root))) err := http.ListenAndServe(":"+port, http.FileServer(http.Dir(root)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment