//go:build wasm //:build wasm package verify import ( "git.smesh.lol/smesh/web/common/jsbridge/callback" "unsafe" ) //:wasmimport bridge verify_worker_on_message func wasmWorkerOnMessage(cbID int32) //:wasmimport bridge verify_worker_post func wasmWorkerPost(ptr *byte, length int32, cap int32) //:wasmimport bridge verify_worker_set_timeout func wasmWorkerSetTimeout(ms int32, cbID int32) (n int32) //:wasmimport bridge verify_worker_clear_timeout func wasmWorkerClearTimeout(handle int32) func WorkerOnMessage(fn func(msg string)) { wasmWorkerOnMessage(callback.RegisterS(fn)) } func WorkerPost(msg string) { wasmWorkerPost(unsafe.StringData(msg), int32(len(msg)), int32(len(msg))) } func WorkerSetTimeout(ms int32, fn func()) (n int32) { return wasmWorkerSetTimeout(ms, callback.Register0Once(fn)) } func WorkerClearTimeout(handle int32) { wasmWorkerClearTimeout(handle) }