Skip to content

Commit 2486f7d

Browse files
maxmcdSean-Der
authored andcommitted
Upgrade wasm to support go 1.12+
1 parent 221030b commit 2486f7d

File tree

4 files changed

+700
-455
lines changed

4 files changed

+700
-455
lines changed

Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
FROM golang:1.11.2-stretch
1+
FROM golang:1.15
22

33
RUN apt-get update && \
4-
curl -sL https://deb.nodesource.com/setup_11.x | bash -\
4+
curl -sL https://deb.nodesource.com/setup_12.x | bash -\
55
&& apt-get install -y --no-install-recommends \
6-
nodejs=11.2.0* \
6+
nodejs=12.* \
77
&& apt-get clean \
88
&& rm -rf /var/lib/apt/lists/*
99

1010
WORKDIR /go/src/github.com/maxmcd/webtty
11-
12-

web-client/package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@
99
"main": "src/app.ts",
1010
"scripts": {
1111
"build": "npm run go-build && parcel build src/index.html --public-url .",
12-
"go-build":
13-
"mkdir -p ./dist/ && touch ./dist/foo && rm ./dist/* && GOOS=js GOARCH=wasm go build -o ./dist/main.wasm ./src",
12+
"go-build": "mkdir -p ./dist/ && touch ./dist/foo && rm ./dist/* && GOOS=js GOARCH=wasm go build -o ./dist/main.wasm ./src",
1413
"serve": "parcel serve src/index.html",
1514
"test": "echo notests",
1615
"deploy": "npm run build && gh-pages -d dist"
1716
},
1817
"author": "Max McDonnell",
1918
"license": "MIT",
2019
"dependencies": {
21-
"@babel/core": "^7.1.5",
22-
"@babel/runtime-corejs2": "^7.1.5",
20+
"@babel/runtime-corejs2": "^7.12.5",
2321
"gh-pages": "^2.0.1",
2422
"parcel-bundler": "^1.10.3",
25-
"typescript": "^3.1.6",
26-
"xterm": "^3.8.0"
23+
"xterm": "3.8.0"
24+
},
25+
"devDependencies": {
26+
"@babel/core": "^7.12.10",
27+
"@babel/plugin-transform-runtime": "^7.12.10",
28+
"cssnano": "^4.1.10",
29+
"typescript": "^3.9.7"
2730
}
2831
}

web-client/src/main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var (
1717
nonce string
1818
)
1919

20-
func encode(i []js.Value) {
20+
func encode(this js.Value, i []js.Value) interface{} {
2121
encoded, err := func() (string, string) {
2222
answerSd := sd.SessionDescription{
2323
Sdp: i[0].String(),
@@ -37,9 +37,10 @@ func encode(i []js.Value) {
3737
return sd.Encode(answerSd), ""
3838
}()
3939
i[1].Invoke(encoded, err)
40+
return nil
4041
}
4142

42-
func decode(i []js.Value) {
43+
func decode(this js.Value, i []js.Value) interface{} {
4344
sdp, tkbsl, err := func() (string, string, string) {
4445
offer, err := sd.Decode(i[0].String())
4546
if err != nil {
@@ -55,9 +56,10 @@ func decode(i []js.Value) {
5556
return offer.Sdp, offer.TenKbSiteLoc, ""
5657
}()
5758
i[1].Invoke(sdp, tkbsl, err)
59+
return nil
5860
}
5961

6062
func registerCallbacks() {
61-
js.Global().Set("encode", js.NewCallback(encode))
62-
js.Global().Set("decode", js.NewCallback(decode))
63+
js.Global().Set("encode", js.FuncOf(encode))
64+
js.Global().Set("decode", js.FuncOf(decode))
6365
}

0 commit comments

Comments
 (0)