verify_wasm.mx raw
1 //go:build wasm
2 //:build wasm
3
4 package verify
5
6 import (
7 "git.smesh.lol/smesh/web/common/jsbridge/callback"
8 "unsafe"
9 )
10
11 //:wasmimport bridge verify_worker_on_message
12 func wasmWorkerOnMessage(cbID int32)
13
14 //:wasmimport bridge verify_worker_post
15 func wasmWorkerPost(ptr *byte, length int32, cap int32)
16
17 //:wasmimport bridge verify_worker_set_timeout
18 func wasmWorkerSetTimeout(ms int32, cbID int32) (n int32)
19
20 //:wasmimport bridge verify_worker_clear_timeout
21 func wasmWorkerClearTimeout(handle int32)
22
23 func WorkerOnMessage(fn func(msg string)) {
24 wasmWorkerOnMessage(callback.RegisterS(fn))
25 }
26
27 func WorkerPost(msg string) {
28 wasmWorkerPost(unsafe.StringData(msg), int32(len(msg)), int32(len(msg)))
29 }
30
31 func WorkerSetTimeout(ms int32, fn func()) (n int32) {
32 return wasmWorkerSetTimeout(ms, callback.Register0Once(fn))
33 }
34
35 func WorkerClearTimeout(handle int32) { wasmWorkerClearTimeout(handle) }
36