Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to go 1.18 #4

Merged
merged 2 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ steps:
- golangci-lint run

- name: test
image: "golang:1.16.5-alpine3.13"
image: "golang:alpine3.15"
commands:
- apk add --no-cache wget
- wget https://taskfile.dev/install.sh
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tasks:
GOOS: js
GOARCH: wasm
cmds:
- go test -exec={{.GOPATH}}/bin/wasmbrowsertest ./web/
- go test -exec={{.GOPATH}}/bin/wasmbrowsertest -buildvcs=false ./web/

test:examples:
env:
Expand All @@ -27,7 +27,7 @@ tasks:
cmds:
- rm -rf /tmp/gweb-bin
- mkdir -p /tmp/gweb-bin/
- go build -o /tmp/gweb-bin/ ./...
- go build -buildvcs=false -o /tmp/gweb-bin/ ./...

test:
desc: "run go test for the library and examples"
Expand Down
5 changes: 5 additions & 0 deletions audio/media_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ type MediaStream struct {
js.Value
}

// Casts audio.MediaStream to js.Value
func (stream MediaStream) JSValue() js.Value {
return stream.Value
}

// PROPERTIES

// https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/active
Expand Down
4 changes: 2 additions & 2 deletions audio/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Value struct {

// overloaded methods

func (v Value) Call(method string, args ...interface{}) Value {
func (v Value) Call(method string, args ...any) Value {
result := v.Value.Call(method, args...)
return Value{Value: result}
}
Expand All @@ -21,7 +21,7 @@ func (v Value) Get(property string) Value {
return Value{Value: result}
}

func (v Value) New(args ...interface{}) Value {
func (v Value) New(args ...any) Value {
result := v.Value.New(args...)
return Value{Value: result}
}
Expand Down
21 changes: 18 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
module github.com/life4/gweb

go 1.13
go 1.18

require (
github.com/agnivade/wasmbrowsertest v0.3.5 // indirect
github.com/agnivade/wasmbrowsertest v0.4.0
github.com/stretchr/testify v1.7.0
)

require (
github.com/chromedp/cdproto v0.0.0-20211002082225-0242b9dca9f4 // indirect
github.com/chromedp/chromedp v0.7.4 // indirect
github.com/chromedp/sysutil v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-interpreter/wagon v0.6.0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.1.0 // indirect
github.com/google/pprof v0.0.0-20211001005136-7fe48b4c820b // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/mailru/easyjson v0.7.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.0.0-20211003122950-b1ebd4e1001c // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
63 changes: 34 additions & 29 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,52 +1,57 @@
github.com/agnivade/wasmbrowsertest v0.3.5 h1:U8ICR7Xa3LBGQb57HtbbXf5KAMjQhiWrCWlr1kD77Cw=
github.com/agnivade/wasmbrowsertest v0.3.5/go.mod h1:zQt6ZTdl338xxRaMW395qccVE2eQm0SjC/SDz0mPWQI=
github.com/chromedp/cdproto v0.0.0-20190614062957-d6d2f92b486d/go.mod h1:S8mB5wY3vV+vRIzf39xDXsw3XKYewW9X6rW2aEmkrSw=
github.com/chromedp/cdproto v0.0.0-20190621002710-8cbd498dd7a0 h1:4Wocv9f+KWF4GtZudyrn8JSBTgHQbGp86mcsoH7j1iQ=
github.com/chromedp/cdproto v0.0.0-20190621002710-8cbd498dd7a0/go.mod h1:S8mB5wY3vV+vRIzf39xDXsw3XKYewW9X6rW2aEmkrSw=
github.com/chromedp/chromedp v0.3.1-0.20190619195644-fd957a4d2901 h1:tg66ykM8VYqP9k4DFQwSMnYv84HNTruF+GR6kefFNg4=
github.com/chromedp/chromedp v0.3.1-0.20190619195644-fd957a4d2901/go.mod h1:mJdvfrVn594N9tfiPecUidF6W5jPRKHymqHfzbobPsM=
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/agnivade/wasmbrowsertest v0.4.0 h1:B2P8ZYqAmD3nmLkJaxuUFiv25J+2XUkOmhAJyfV0X0A=
github.com/agnivade/wasmbrowsertest v0.4.0/go.mod h1:baeI8tnJ+NNeVbOfF1/GaRmg6qiJOJ6BCnUASRFAtsk=
github.com/chromedp/cdproto v0.0.0-20210713064928-7d28b402946a/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U=
github.com/chromedp/cdproto v0.0.0-20211002082225-0242b9dca9f4 h1:5s+L1cvXzolXsfAChfBr6KmD86rJR5BTeJnz36vQCmo=
github.com/chromedp/cdproto v0.0.0-20211002082225-0242b9dca9f4/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U=
github.com/chromedp/chromedp v0.7.4 h1:U+0d3WbB/Oj4mDuBOI0P7S3PJEued5UZIl5AJ3QulwU=
github.com/chromedp/chromedp v0.7.4/go.mod h1:dBj+SXuQHznp6ZPwZeDDEBZKwclUwDLbZ0hjMialMYs=
github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic=
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/go-interpreter/wagon v0.5.1-0.20190713202023-55a163980b6c h1:DLLAPVFrk9iNzljMKF512CUmrFImQ6WU3sDiUS4IRqk=
github.com/go-interpreter/wagon v0.5.1-0.20190713202023-55a163980b6c/go.mod h1:5+b/MBYkclRZngKF5s6qrgWxSLgE9F5dFdO1hAueZLc=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f h1:Jnx61latede7zDD3DiiP4gmNz33uK0U5HDUaF0a/HVQ=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307 h1:vl4eIlySbjertFaNwiMjXsGrFVK25aOWLq7n+3gh2ls=
github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307/go.mod h1:BjPj+aVjl9FW/cCGiF3nGh5v+9Gd3VCgBQbod/GlMaQ=
github.com/go-interpreter/wagon v0.6.0 h1:BBxDxjiJiHgw9EdkYXAWs8NHhwnazZ5P2EWBW5hFNWw=
github.com/go-interpreter/wagon v0.6.0/go.mod h1:5+b/MBYkclRZngKF5s6qrgWxSLgE9F5dFdO1hAueZLc=
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.1.0 h1:7RFti/xnNkMJnrK7D1yQ/iCIB5OrrY/54/H930kIbHA=
github.com/gobwas/ws v1.1.0/go.mod h1:nzvNcVha5eUziGrbxFCo6qFIojQHjJV5cLYIbezhfL0=
github.com/google/pprof v0.0.0-20211001005136-7fe48b4c820b h1:GX4+fGLMW5XTmDXB3R6UhTwZIYqgAOdA19+Ea0+3CU4=
github.com/google/pprof v0.0.0-20211001005136-7fe48b4c820b/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190620125010-da37f6c1e481 h1:IaSjLMT6WvkoZZjspGxy3rdaTEmWLoRm49WbtVUi9sA=
github.com/mailru/easyjson v0.0.0-20190620125010-da37f6c1e481/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/orisano/pixelmatch v0.0.0-20210112091706-4fa4c7ba91d5 h1:1SoBaSPudixRecmlHXb/GxmaD3fLMtHIDN13QujwQuc=
github.com/orisano/pixelmatch v0.0.0-20210112091706-4fa4c7ba91d5/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/twitchyliquid64/golang-asm v0.0.0-20190126203739-365674df15fc h1:RTUQlKzoZZVG3umWNzOYeFecQLIh+dbxXvJp1zPQJTI=
github.com/twitchyliquid64/golang-asm v0.0.0-20190126203739-365674df15fc/go.mod h1:NoCfSFWosfqMqmmD7hApkirIK9ozpHjxRnRxs1l413A=
golang.org/x/sys v0.0.0-20190306220234-b354f8bf4d9e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190618155005-516e3c20635f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 h1:LepdCS8Gf/MVejFIt8lsiexZATdoGVyp5bcyS+rYoUI=
golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211003122950-b1ebd4e1001c h1:EyJTLQbOxvk8V6oDdD8ILR1BOs3nEJXThD6aqsiPNkM=
golang.org/x/sys v0.0.0-20211003122950-b1ebd4e1001c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
8 changes: 8 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build tools
// +build tools

package main

import (
_ "github.com/agnivade/wasmbrowsertest"
)
16 changes: 8 additions & 8 deletions web/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ type Console struct {

// LOGGING

func (console Console) log(fname, format string, args []interface{}) {
func (console Console) log(fname, format string, args []any) {
if format == "" {
console.Call(fname, args...)
} else {
console.Call(fname, append([]interface{}{format}, args...)...)
console.Call(fname, append([]any{format}, args...)...)
}
}

// https://developer.mozilla.org/en-US/docs/Web/API/Console/log
func (console Console) Log(format string, args ...interface{}) {
func (console Console) Log(format string, args ...any) {
console.log("log", format, args)
}

// https://developer.mozilla.org/en-US/docs/Web/API/Console/debug
func (console Console) Debug(format string, args ...interface{}) {
func (console Console) Debug(format string, args ...any) {
console.log("debug", format, args)
}

// https://developer.mozilla.org/en-US/docs/Web/API/Console/info
func (console Console) Info(format string, args ...interface{}) {
func (console Console) Info(format string, args ...any) {
console.log("info", format, args)
}

// https://developer.mozilla.org/en-US/docs/Web/API/Console/warn
func (console Console) Warning(format string, args ...interface{}) {
func (console Console) Warning(format string, args ...any) {
console.log("warn", format, args)
}

// https://developer.mozilla.org/en-US/docs/Web/API/Console/error
func (console Console) Error(format string, args ...interface{}) {
func (console Console) Error(format string, args ...any) {
console.log("error", format, args)
}

Expand Down Expand Up @@ -106,6 +106,6 @@ func (console Console) TimeLog(label string) {
}

// https://developer.mozilla.org/en-US/docs/Web/API/Console/trace
func (console Console) Trace(args ...interface{}) {
func (console Console) Trace(args ...any) {
console.Call("trace", args...)
}
8 changes: 4 additions & 4 deletions web/element.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ func (cls Class) Append(names ...string) {
if len(names) == 0 {
return
}
casted := make([]interface{}, len(names))
casted := make([]any, len(names))
for i, name := range names {
casted[i] = interface{}(name)
casted[i] = any(name)
}
cls.value.Get("classList").Call("add", casted...)
}
Expand All @@ -283,9 +283,9 @@ func (cls Class) Remove(names ...string) {
if len(names) == 0 {
return
}
casted := make([]interface{}, len(names))
casted := make([]any, len(names))
for i, name := range names {
casted[i] = interface{}(name)
casted[i] = any(name)
}
cls.value.Get("classList").Call("remove", casted...)
}
Expand Down
2 changes: 1 addition & 1 deletion web/event_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type EventTarget struct {
// Listen registers callback for the given event.
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
func (target EventTarget) Listen(event EventType, handler func(event Event)) {
wrapped := func(this js.Value, args []js.Value) interface{} {
wrapped := func(this js.Value, args []js.Value) any {
v := Value{Value: args[0]}
handler(v.Event())
return nil
Expand Down
2 changes: 1 addition & 1 deletion web/http_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (req HTTPRequest) Send(body []byte) HTTPResponse {
wg := sync.WaitGroup{}
wg.Add(1)
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/onreadystatechange
req.Set("onreadystatechange", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
req.Set("onreadystatechange", js.FuncOf(func(this js.Value, args []js.Value) any {
state := req.Get("readyState").Int()
if state == 4 || state == 0 {
wg.Done()
Expand Down
4 changes: 2 additions & 2 deletions web/http_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestHTTPRequest_GET(t *testing.T) {
is.Equal(resp.StatusCode(), 200)
is.Equal(resp.Status(), "")
is.Equal(resp.Headers().Get("Content-Type"), "application/json")
is.Equal(resp.Headers().Values(), []string{"content-length: 619", "content-type: application/json"})
is.Equal(resp.Headers().Values(), []string{"content-length: 701", "content-type: application/json"})
}

func TestHTTPRequest_POST(t *testing.T) {
Expand All @@ -24,7 +24,7 @@ func TestHTTPRequest_POST(t *testing.T) {
is.Equal(resp.StatusCode(), 200)
is.Equal(resp.Status(), "")
is.Equal(resp.Headers().Get("Content-Type"), "application/json")
is.Equal(resp.Headers().Values(), []string{"content-length: 723", "content-type: application/json"})
is.Equal(resp.Headers().Values(), []string{"content-length: 805", "content-type: application/json"})

data := struct {
Data string `json:"data"`
Expand Down
4 changes: 2 additions & 2 deletions web/media_devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ type MediaDevices struct {

// https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
func (devices MediaDevices) Audio() Promise {
params := map[string]interface{}{"audio": true}
params := map[string]any{"audio": true}
return devices.Call("getUserMedia", params).Promise()
}

// https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
func (devices MediaDevices) Video() Promise {
params := map[string]interface{}{"video": true}
params := map[string]any{"video": true}
return devices.Call("getUserMedia", params).Promise()
}
4 changes: 2 additions & 2 deletions web/promise.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Promise struct {

// Register callback for error handling
func (promise Promise) Catch(handler func(reason js.Value)) {
wrapper := func(then js.Value, args []js.Value) interface{} {
wrapper := func(then js.Value, args []js.Value) any {
handler(args[0])
return nil
}
Expand All @@ -21,7 +21,7 @@ func (promise Promise) Catch(handler func(reason js.Value)) {

// Register callback for sucsessful result handling
func (promise Promise) Then(handler func(value js.Value)) {
wrapper := func(then js.Value, args []js.Value) interface{} {
wrapper := func(then js.Value, args []js.Value) any {
handler(args[0])
return nil
}
Expand Down
26 changes: 22 additions & 4 deletions web/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type Value struct {
// overloaded methods

// Call calls the given method of the object.
func (v Value) Call(method string, args ...interface{}) Value {
result := v.Value.Call(method, args...)
func (v Value) Call(method string, args ...any) Value {
result := v.Value.Call(method, unwrapValues(args)...)
return Value{Value: result}
}

Expand All @@ -26,13 +26,18 @@ func (v Value) Get(property string) Value {
}

// Creates new instance of the JS class.
func (v Value) New(args ...interface{}) Value {
result := v.Value.New(args...)
func (v Value) New(args ...any) Value {
result := v.Value.New(unwrapValues(args)...)
return Value{Value: result}
}

// new methods

// Casts web.Value to js.Value
func (v Value) JSValue() js.Value {
return v.Value
}

// Represents the current value into Canvas
func (v Value) Canvas() Canvas {
return Canvas{HTMLElement: v.HTMLElement()}
Expand Down Expand Up @@ -109,3 +114,16 @@ func (v Value) OptionalString() string {
panic("bad type")
}
}

func unwrapValues(args []any) []any {
values := make([]any, len(args))
for i, arg := range args {
switch arg := arg.(type) {
case Value:
values[i] = arg.Value
default:
values[i] = arg
}
}
return values
}
2 changes: 1 addition & 1 deletion web/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (window Window) SetScrollY(pixels int) {

// https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY
func (window Window) RequestAnimationFrame(handler func(), recursive bool) {
wrapped := func(this js.Value, args []js.Value) interface{} {
wrapped := func(this js.Value, args []js.Value) any {
handler()
if recursive {
window.RequestAnimationFrame(handler, true)
Expand Down