//go:build wasm //:build wasm package profile import ( "git.smesh.lol/smesh/web/common/jsbridge/callback" "unsafe" ) //:wasmimport bridge profile_send func wasmSend(ptr *byte, length int32, cap int32) //:wasmimport bridge profile_on_message func wasmOnMessage(cbID int32) //:wasmimport bridge profile_worker_on_message func wasmWorkerOnMessage(cbID int32) //:wasmimport bridge profile_worker_post func wasmWorkerPost(ptr *byte, length int32, cap int32) //:wasmimport bridge profile_worker_set_timeout func wasmWorkerSetTimeout(ms int32, cbID int32) (n int32) //:wasmimport bridge profile_worker_clear_timeout func wasmWorkerClearTimeout(handle int32) //:wasmimport bridge profile_worker_now_seconds func wasmWorkerNowSeconds() (n int64) func Send(msg string) { wasmSend(unsafe.StringData(msg), int32(len(msg)), int32(len(msg))) } func OnMessage(fn func(msg string)) { wasmOnMessage(callback.RegisterS(fn)) } 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) } func WorkerNowSeconds() (n int64) { return wasmWorkerNowSeconds() }