Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Yuji Ito <llamerada.jp@gmail.com>
  • Loading branch information
llamerada-jp committed Jul 11, 2022
1 parent b9fdb0e commit 1c14e88
Show file tree
Hide file tree
Showing 5 changed files with 5,084 additions and 996 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/dist/colonio.wasm
/dist/index.html
/dist/index.js
/dist/oinari.wasm
/dist/*.wasm
/dist/wasm_exec.js
/dist/worker.js
/keys.json
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ setup:
rm -rf build/colonio
git clone -b $(COLONIO_BRANCH) --depth=1 https://github.com/llamerada-jp/colonio.git build/colonio
$(MAKE) -C build/colonio build
npm install
npm install

build: $(COLONIO_FILES) $(GO_FILES) $(OINARI_FILES) bin/seed dist/index.html src/keys.ts
GOOS=js GOARCH=wasm go build -o dist/oinari.wasm ./cmd/agent/*.go
npm run build

test:
test: $(COLONIO_FILES) $(GO_FILES) $(OINARI_FILES) bin/seed src/keys.ts
GOOS=js GOARCH=wasm go build -o dist/test_js.wasm ./cmd/test_js/*.go
npm t

bin/seed: $(GO_FILES)
Expand Down
36 changes: 36 additions & 0 deletions cmd/test_js/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//go:build js && wasm
// +build js,wasm

package main

import (
"context"
"fmt"
"syscall/js"
)

const instanceName = "goTest"

var jsInstance js.Value

func setup(ctx context.Context) {
fmt.Println("setup")
}

func main() {
ctx, cancel := context.WithCancel(context.Background())
jsInstance = js.Global().Get(instanceName)
jsInstance.Set("stop", js.FuncOf(func(this js.Value, args []js.Value) any {
cancel()
return nil
}))

setup(ctx)
for {
fmt.Println("loop")
select {
case <-ctx.Done():
return
}
}
}
Loading

0 comments on commit 1c14e88

Please sign in to comment.