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