ebitenutil: Use gopherwasm

This commit is contained in:
Hajime Hoshi 2018-05-25 01:23:09 +09:00
parent 2ec075004a
commit 9b7f5f7273

View File

@ -21,7 +21,7 @@ import (
"errors"
"fmt"
"github.com/gopherjs/gopherjs/js"
"github.com/hajimehoshi/gopherwasm/js"
)
type file struct {
@ -34,7 +34,7 @@ func (f *file) Close() error {
func OpenFile(path string) (ReadSeekCloser, error) {
var err error
var content *js.Object
var content js.Value
ch := make(chan struct{})
req := js.Global.Get("XMLHttpRequest").New()
req.Call("open", "GET", path, true)
@ -58,7 +58,8 @@ func OpenFile(path string) (ReadSeekCloser, error) {
return nil, err
}
data := js.Global.Get("Uint8Array").New(content).Interface().([]uint8)
var data []byte
js.ValueOf(data).Call("set", content)
f := &file{bytes.NewReader(data)}
return f, nil
}