web: Remove IsNodeJS

gjbt now creates a pseudo-Node environment by creating
window.process object, and this conflicted with an assumption that
Ebiten doesn't nothing on Node environment. See
https://github.com/myitcv/gjbt/pull/13 for the detail.

This change allows Ebiten work on pseudo-Node environment. Even
after this change, Ebiten doesn't work on real Node environment
due to lack of DOM.
This commit is contained in:
Hajime Hoshi 2018-06-28 00:09:52 +09:00
parent e196ee59f7
commit f19e349d38
4 changed files with 1 additions and 29 deletions

View File

@ -21,8 +21,6 @@ import (
"fmt"
"github.com/gopherjs/gopherwasm/js"
"github.com/hajimehoshi/ebiten/internal/web"
)
type (
@ -118,10 +116,6 @@ type context struct {
}
func Init() error {
if web.IsNodeJS() {
return fmt.Errorf("opengl: Node.js is not supported")
}
if js.Global.Get("WebGLRenderingContext") == js.Undefined {
return fmt.Errorf("opengl: WebGL is not supported")
}

View File

@ -26,7 +26,6 @@ import (
"github.com/hajimehoshi/ebiten/internal/hooks"
"github.com/hajimehoshi/ebiten/internal/input"
"github.com/hajimehoshi/ebiten/internal/opengl"
"github.com/hajimehoshi/ebiten/internal/web"
)
var canvas js.Value
@ -227,10 +226,6 @@ func (u *userInterface) loop(g GraphicsContext) error {
}
func init() {
// Do nothing in node.js.
if web.IsNodeJS() {
return
}
if document.Get("body") == js.Null {
ch := make(chan struct{})
window.Call("addEventListener", "load", js.NewCallback(func([]js.Value) {

View File

@ -28,21 +28,11 @@ var (
isNodeJS = false
)
func IsNodeJS() bool {
isNodeJSOnce.Do(func() {
isNodeJS = js.Global.Get("process") != js.Undefined
})
return isNodeJS
}
func IsBrowser() bool {
return !IsNodeJS()
return true
}
func IsIOSSafari() bool {
if IsNodeJS() {
return false
}
ua := js.Global.Get("navigator").Get("userAgent").String()
if !strings.Contains(ua, "iPhone") {
return false
@ -51,9 +41,6 @@ func IsIOSSafari() bool {
}
func IsAndroidChrome() bool {
if IsNodeJS() {
return false
}
ua := js.Global.Get("navigator").Get("userAgent").String()
if !strings.Contains(ua, "Android") {
return false

View File

@ -16,10 +16,6 @@
package web
func IsNodeJS() bool {
return false
}
func IsBrowser() bool {
return false
}