Go Lang Web Assembly bindings for DOM, HTML etc

Overview

WebAPI

Go Language Web Assembly bindings for DOM, HTML etc

GoDoc

WARNING: The current API is in very early state and should be consider to be expremental. There is upcommig changed like moving types into multiple packages.

This library is trying to be feature complete and up to date with current standard to let everything a browser having to offect be available in WebAssembly in a Go API accessable. To achive this most of the code is generated from WebIDL files. WebIDL files can be found in different standard making it easiser to be up to date than handwritten binding code.

Example:

func main() {
    element := webapiall.GetWindow().Document().GetElementById("foo")
    // NOTE: After Go 1.12, the extra call to JSValue() will no loger   be needed
    button := webapiall.HTMLButtonElementFromJS(element.JSValue())
    button.SetValue("Hello World")
}

Roadmap

Milestone Status Description
1 Ongoing Be abto to read and and understand all of WebIDL syntax. Notible missing thing are namespace and union
2 Planned Easy up the syntax. Promise will be refactor and other places where simplifications can be done. Classes can be renamed like clipboard.ClipboardPermission to clipboard.Permission.
3 Planned API Stability with a predefined release schedule. Documentation and added examples

More infomation of missing stuff can be found on the generator status info.

Issues
  • Example_buttonTest() in example_test.go panics when button is clicked

    Example_buttonTest() in example_test.go panics when button is clicked

    Tested in both FF 83 and Chromium 86 with the following Go environment:

    GO111MODULE=""
    GOARCH="amd64"
    GOBIN=""
    GOCACHE="/home/smoyer1/.cache/go-build"
    GOENV="/home/smoyer1/.config/go/env"
    GOEXE=""
    GOFLAGS=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOINSECURE=""
    GOMODCACHE="/home/smoyer1/go/pkg/mod"
    GONOPROXY=""
    GONOSUMDB=""
    GOOS="linux"
    GOPATH="/home/smoyer1/go:/usr/share/go-tools"
    GOPRIVATE=""
    GOPROXY="https://proxy.golang.org,direct"
    GOROOT="/opt/go/1.15.4"
    GOSUMDB="sum.golang.org"
    GOTMPDIR=""
    GOTOOLDIR="/opt/go/1.15.4/pkg/tool/linux_amd64"
    GCCGO="gccgo"
    AR="ar"
    CC="gcc"
    CXX="g++"
    CGO_ENABLED="1"
    GOMOD="/home/smoyer1/git/hnjobs/go.mod"
    CGO_CFLAGS="-g -O2"
    CGO_CPPFLAGS=""
    CGO_CXXFLAGS="-g -O2"
    CGO_FFLAGS="-g -O2"
    CGO_LDFLAGS="-g -O2"
    PKG_CONFIG="pkg-config"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build286617590=/tmp/go-build -gno-record-gcc-switches"
    

    Compiled with:

    RUN GOOS=js GOARCH=wasm go build -o /app cmd/ui/ui.go
    

    The console provides the following call stack when the button is clicked:

    panic: ValueOf: invalid value wasm_exec.js:50:14
    <empty string> wasm_exec.js:50:14
    goroutine 6 [running]: wasm_exec.js:50:14
    syscall/js.ValueOf(0x1e5e0, 0x5ab88, 0x6, 0x7ff800010000000f) wasm_exec.js:50:14
    	/usr/local/go/src/syscall/js/js.go:219 +0x106 wasm_exec.js:50:14
    syscall/js.Value.Set(0x7ff8000100000012, 0x41a078, 0x52ef6, 0x6, 0x1e5e0, 0x5ab88) wasm_exec.js:50:14
    	/usr/local/go/src/syscall/js/js.go:314 +0x7 wasm_exec.js:50:14
    syscall/js.handleEvent() wasm_exec.js:50:14
    	/usr/local/go/src/syscall/js/func.go:97 +0x25
    

    I'd be happy to help track this down ... it appears that the JS value passed to the syscall/js ValueOf() function is perhaps a wrapped type and doesn't match any of the types in the case statement included there (see https://github.com/golang/go/blob/0e953add9656c32a788e06438cd7b533e968b7f8/src/syscall/js/js.go#L162). I've looked through the webapi code and all the JS values appear to (properly) be aliases which I would expect to match a case, so I'm at a loss for where to continue looking.

    opened by smoyer64 10
  • Is the repository / account abandoned ?

    Is the repository / account abandoned ?

    It's currently broken (at least partially) for current version of Go. I have a fixing PR since March, that has not been approved/responded: https://github.com/gowebapi/webapi/pull/11

    I'm happy to help support, if you add me as a member of gowebapi.

    cheers

    opened by janpfeifer 7
  • RFE Include WebVR

    RFE Include WebVR

    I'm very happy to find your project here. I was just about to try and write myself a WebIDL parser to do exactly this, so well done and thanks.

    Anyway I'm not sure the best way to provide feedback? Basically I'm wanting to do some WebGL (v1) via Go/WASM, and hopefully from that also include WebVR support. I can see that you have WebXR support, but there are not many browsers supporting that so far. Do you have any plans to add WebVR?

    So far I managed to get my Go WASM creating a 'canvas' element:

    	canvas := webapi.GetWindow().Document().CreateElement("canvas", &webapi.Union{js.ValueOf("dom.Node")})
    	canvas.SetId("mycanvas")
    app.AppendChild(&canvas.Node)
    

    And finally, I can see that you have some full screen support in dom.go, but I cant see a method to requestFullscreen() or am I missing something obvious there?

    Sorry to ask so many questions, and keep up the good work!

    macos10.12.4 go1.12

    opened by WhiteHexagon 7
  • Go 1.18 drops syscall.js.Wrapper

    Go 1.18 drops syscall.js.Wrapper

    Because of performance reasons Go is dropping js.Wrapper. I noticed this today, as I was trying out the 1.18.1 beta.

    I suspect it should be an easy fix, but I haven't yet dived into it. Hopefully the fix will be backwards compatible -- since it only removed functionality.

    I'll try to do post benchmarking in a wasm game I occasionally develop.

    opened by janpfeifer 2
  • Fix invalid comparison to js.Undefined() in go1.14.

    Fix invalid comparison to js.Undefined() in go1.14.

    After the go 1.14 update the file dom/helper.go was failing to compile for wasm (it would still compiles if not wasm). the underlying syscall/js Value type must have changed, is my guess.

    But in any case, it now offers the safer IsUndefined() method. So I added it to the core/js/js.go wrappers and changed helper.go to use it.

    opened by janpfeifer 2
  • TypedArray Unavailable (Go 1.13)

    TypedArray Unavailable (Go 1.13)

    Error trying to build using Go v1.13:

    "/go/src/github.com/gowebapi/webapi/core/js/js_js.go:56:19: undefined: js.TypedArray"

    I commented out the references to this type in your code to get it building. Is that appropriate?

    opened by rshaalan 2
  • Pointers to scalar values (*string, *int, *bool) fail ValueOf

    Pointers to scalar values (*string, *int, *bool) fail ValueOf

    Functions that get a pointer to a string/int/bool should dereference the pointers before passing them to any js functions

    For example

    // SetTextContent setting attribute 'textContent' with
    // type string (idl: DOMString).
    func (_this *Node) SetTextContent(value *string) {
    	input := value
    	_this.Value_JS.Set("textContent", input)
    }
    

    could be

    // SetTextContent setting attribute 'textContent' with
    // type string (idl: DOMString).
    func (_this *Node) SetTextContent(value *string) {
    	if value != nil {
    		input := *value
    		_this.Value_JS.Set("textContent", input)
    	}
    }
    

    otherwise it panics panic: ValueOf: invalid value

    Similar,

    func (_this *Node) CloneNode(deep *bool) (_result *Node) {
    	var (
    		_args [1]interface{}
    		_end  int
    	)
    	if deep != nil {
    		_p0 := deep
    		_args[0] = _p0
    		_end++
    	}
    	_returned := _this.Value_JS.Call("cloneNode", _args[0:_end]...)
    	var (
    		_converted *Node // javascript: Node _what_return_name
    	)
    	_converted = NodeFromJS(_returned)
    	_result = _converted
    	return
    }
    

    could be

    func (_this *Node) CloneNode(deep *bool) (_result *Node) {
    	var (
    		_args [1]interface{}
    		_end  int
    	)
    	if deep != nil {
    		_p0 := *deep
    		_args[0] = _p0
    		_end++
    	}
    	_returned := _this.Value_JS.Call("cloneNode", _args[0:_end]...)
    	var (
    		_converted *Node // javascript: Node _what_return_name
    	)
    	_converted = NodeFromJS(_returned)
    	_result = _converted
    	return
    }
    
    opened by thegrumpylion 1
  • How to use indexeddb?

    How to use indexeddb?

    Would you mind to create an example how to use indexeddb? I managed to open a db request but have no clue to get db instance from event like below. request := webapi.GetWindow().IndexedDB().Open("test", nil) request.SetOnupgradeneeded(domcore.EventHandlerToJS(func(event *domcore.Event) interface{} { /* javascript version is: var db = event.target.result; var objStore = db.createObjectStore("names", { autoIncrement : true }); */ return nil })) `

    opened by ghost 1
  • Video  / Audio via https://developer.mozilla.org/en-US/docs/Web/API/WebCodecs_API

    Video / Audio via https://developer.mozilla.org/en-US/docs/Web/API/WebCodecs_API

    Thank You for this awesome project..

    I dont see https://developer.mozilla.org/en-US/docs/Web/API/WebCodecs_API in the code generated golang.

    Here is what i am up to:

    I want to make a Video player using golang wasm, and customise how the player looks and feels using GIO ( https://github.com/gioui) Gio can compile to web, desktop and mobile.

    The WebCodecs_API will allow me to build a custom player feeding the frames into it.

    Then i am thinking of using a webview for Desktop and Mobile using https://github.com/Inkeliz/gowebview, so that it also works on those targets.

    Please let me know if you have support for the webCodecs...

    opened by gedw99 0
Owner
Go Web API
Go Web API
Framework for building distributed services with Web Assembly

Tarmac Framework for building distributed services with Web Assembly Tarmac is a unique framework designed for the next generation of distributed syst

Benjamin Cane 207 Aug 8, 2022
DOM library for Go and WASM

Go DOM binding (and more) for WebAssembly This library provides a Go API for different Web APIs for WebAssembly target. It's in an active development,

Denys Smirnov 460 Aug 4, 2022
⚙️ Concept of Golang HTML render engine with frontend components and dynamic behavior

An HTML render engine concept that brings frontend-like components experience to the server side with native html/template on steroids. Supports any s

Yurii Zinets 534 Aug 14, 2022
Golang-WASM provides a simple idiomatic, and comprehensive API and bindings for working with WebAssembly for Go and JavaScript developers

A bridge and bindings for JS DOM API with Go WebAssembly. Written by Team Ortix - Hamza Ali and Chan Wen Xu. GOOS=js GOARCH=wasm go get -u github.com/

TeamOrtix 74 Jul 15, 2022
A package to build progressive web apps with Go programming language and WebAssembly.

Go-app is a package for building progressive web apps (PWA) with the Go programming language (Golang) and WebAssembly (Wasm). Shaping a UI is done by

Maxence Charriere 6.4k Aug 14, 2022
A package to build progressive web apps with Go programming language and WebAssembly.

Go-app is a package for building progressive web apps (PWA) with the Go programming language (Golang) and WebAssembly (Wasm). Shaping a UI is done by

Maxence Charriere 6.4k Aug 8, 2022
Bed and Breakfast web app written in Go

BOOKINGS AND RESERVATIONS This repository contains the files for my RareBnB application RareBnB is an "AirBnB" style clone providing a user the abilit

null 0 Jan 11, 2022
hdq - HTML DOM Query Language for Go+

hdq - HTML DOM Query Language for Go+ Summary about hdq hdq is a Go+ package for processing HTML documents. Tutorials Collect links of a html page How

Qiniu Cloud 28 Aug 10, 2022
Dom - A Go API for different Web APIs for WebAssembly target

Go DOM binding (and more) for WebAssembly This library provides a Go API for dif

Denys Smirnov 460 Aug 4, 2022
based on go lang build WEB development framework for go lang beginners .

based on go lang build WEB development framework for go lang beginners .

zhenfan.yu 1 Oct 31, 2021
Framework for building distributed services with Web Assembly

Tarmac Framework for building distributed services with Web Assembly Tarmac is a unique framework designed for the next generation of distributed syst

Benjamin Cane 207 Aug 8, 2022
DOM library for Go and WASM

Go DOM binding (and more) for WebAssembly This library provides a Go API for different Web APIs for WebAssembly target. It's in an active development,

Denys Smirnov 460 Aug 4, 2022
domui: DOM UI framework for Go

domui: DOM UI framework for Go

null 97 Jul 23, 2022
Gom: DOM building using Go

gom DOM building using Go Usage package main import "github.com/hadihammurabi/gom" func main() { dom := gom.H("html").Children( gom.H("head").Chi

Hadi Hidayat Hammurabi 0 Dec 16, 2021
A Simple Application written in go-lang that serves the index.html

go-web server A Simple Application written in go-lang that serves the index.html Running the Application, Well, make sure you have go installed to con

Aelpxy 1 Nov 24, 2021
Machine Learning libraries for Go Lang - Linear regression, Logistic regression, etc.

package ml - Machine Learning Libraries ###import "github.com/alonsovidales/go_ml" Package ml provides some implementations of usefull machine learnin

Alonso Vidales 192 Jul 27, 2022
bluemonday: a fast golang HTML sanitizer (inspired by the OWASP Java HTML Sanitizer) to scrub user generated content of XSS

bluemonday bluemonday is a HTML sanitizer implemented in Go. It is fast and highly configurable. bluemonday takes untrusted user generated content as

Microcosm 2.4k Aug 13, 2022
Simple system for writing HTML/XML as Go code. Better-performing replacement for html/template and text/template

Simple system for writing HTML as Go code. Use normal Go conditionals, loops and functions. Benefit from typing and code analysis. Better performance than templating. Tiny and dependency-free.

Nelo Mitranim 4 Apr 13, 2022
VMail - check the markup (HTML, CSS) of HTML email template compatibility with email clients

VMail - check the markup (HTML, CSS) of HTML email template compatibility with email clients Email clients use different rendering standards. This is

Alexey Vasiliev 20 Jul 28, 2022
This command line converts .html file into .html with images embed.

embed-html This command line converts .html file into .html with images embed. Install > go get github.com/gonejack/embed-html Usage > embed-html *.ht

会有猫的 0 Jan 13, 2022
Cairo in Go: vector to SVG, PDF, EPS, raster, HTML Canvas, etc.

Canvas is a common vector drawing target that can output SVG, PDF, EPS, raster images (PNG, JPG, GIF, ...), HTML Canvas through WASM, and OpenGL. It h

Taco de Wolff 1k Aug 16, 2022
go.rice is a Go package that makes working with resources such as html,js,css,images,templates, etc very easy.

go.rice go.rice is a Go package that makes working with resources such as html,js,css,images and templates easy. During development go.rice will load

Geert-Johan Riemer 2.3k Aug 4, 2022
Go package that handles HTML, JSON, XML and etc. responses

gores http response utility library for Go this package is very small and lightweight, useful for RESTful APIs. installation go get github.com/alioygu

Ali OYGUR 99 May 21, 2022
Converts PDF, DOC, DOCX, XML, HTML, RTF, etc to plain text

docconv A Go wrapper library to convert PDF, DOC, DOCX, XML, HTML, RTF, ODT, Pages documents and images (see optional dependencies below) to plain tex

Search.io 980 Aug 9, 2022
Golang evasion tool, execute-assembly .Net file

?? Frog For Automatic Scan ?? Doge For Defense Evasion&Offensive Security Doge-Assembly Golang evasion tool, execute-assembly .Net file Intro Are you

TimWhite 84 Jul 11, 2022
Compiler for a small language into x86-64 Assembly

Compiler This project is a small compiler, that compiles my own little language into X86-64 Assembly. It then uses yasm and ld to assemble and link in

Maurice Tollmien 241 Aug 8, 2022
Generate x86 Assembly with Go

Generate x86 Assembly with Go avo makes high-performance Go assembly easier to write, review and maintain. The avo package presents a familiar assembl

Michael McLoughlin 2.1k Aug 12, 2022
Compiler for a small language into x86-64 Assembly

Compiler This project is a small compiler, that compiles my own little language into X86-64 Assembly. It then uses yasm and ld to assemble and link in

Maurice Tollmien 241 Aug 8, 2022
Assembly syntax that makes you feel like you're writing code in a high-level language.

shasm Assembly syntax that makes you feel like you're writing code in a high-level language. Shasm is not an Assembler. Shasm simply compiles Shasm sy

Shoyaaa 14 Jun 5, 2021