diff --git a/src/ffi/js/buffer.rs b/src/ffi/js/buffer.rs index 9e141c7..2210418 100644 --- a/src/ffi/js/buffer.rs +++ b/src/ffi/js/buffer.rs @@ -22,7 +22,7 @@ impl BufferController { tokio::time::sleep(std::time::Duration::from_millis(200)).await; match _controller.recv().await { Ok(event) => { - tsfn.call(event, ThreadsafeFunctionCallMode::NonBlocking); //check this shit with tracing also we could use Ok(event) to get the error + tsfn.call(event, ThreadsafeFunctionCallMode::NonBlocking); //check this with tracing also we could use Ok(event) to get the error }, Err(crate::Error::Deadlocked) => continue, Err(e) => break tracing::warn!("error receiving: {}", e), @@ -32,6 +32,11 @@ impl BufferController { Ok(()) } + #[napi(js_name = "try_recv")] + pub async fn js_try_recv(&self) -> napi::Result> { + Ok(self.try_recv().await?) + } + #[napi(js_name = "recv")] pub async fn js_recv(&self) -> napi::Result { Ok(self.recv().await?.into()) @@ -41,4 +46,9 @@ impl BufferController { pub async fn js_send(&self, op: TextChange) -> napi::Result<()> { Ok(self.send(op).await?) } + + #[napi(js_name = "content")] + pub async fn js_content(&self) -> napi::Result { + Ok(self.content().await?) + } } diff --git a/src/ffi/js/cursor.rs b/src/ffi/js/cursor.rs index c84d90d..4b4e024 100644 --- a/src/ffi/js/cursor.rs +++ b/src/ffi/js/cursor.rs @@ -76,4 +76,9 @@ impl CursorController { Ok(self.try_recv().await? .map(|x| JsCursor::from(x))) } + + #[napi(js_name= "recv")] + pub async fn js_recv(&self) -> napi::Result { + Ok(self.recv().await?.into()) + } }