chore(js): camelCase

This commit is contained in:
əlemi 2024-10-15 22:21:08 +02:00
parent c63a3ec73a
commit 9a4225cf0d
Signed by: alemi
GPG key ID: A4895B84D311642C
4 changed files with 28 additions and 28 deletions

View file

@ -32,13 +32,13 @@ impl BufferController {
}
/// Remove registered buffer callback
#[napi(js_name = "clear_callback")]
#[napi(js_name = "clearCallback")]
pub fn js_clear_callback(&self) {
self.clear_callback();
}
/// Get buffer path
#[napi(js_name = "get_path")]
#[napi(js_name = "path")]
pub fn js_path(&self) -> &str {
self.path()
}
@ -50,7 +50,7 @@ impl BufferController {
}
/// Return next buffer event if present
#[napi(js_name = "try_recv")]
#[napi(js_name = "tryRecv")]
pub async fn js_try_recv(&self) -> napi::Result<Option<BufferUpdate>> {
Ok(self.try_recv().await?)
}

View file

@ -34,19 +34,19 @@ pub async fn connect(config: crate::api::Config) -> napi::Result<crate::Client>
#[napi]
impl Client {
#[napi(js_name = "create_workspace")]
#[napi(js_name = "createWorkspace")]
/// create workspace with given id, if able to
pub async fn js_create_workspace(&self, workspace: String) -> napi::Result<()> {
Ok(self.create_workspace(workspace).await?)
}
#[napi(js_name = "delete_workspace")]
#[napi(js_name = "deleteWorkspace")]
/// delete workspace with given id, if able to
pub async fn js_delete_workspace(&self, workspace: String) -> napi::Result<()> {
Ok(self.delete_workspace(workspace).await?)
}
#[napi(js_name = "list_workspaces")]
#[napi(js_name = "listWorkspaces")]
/// list available workspaces
pub async fn js_list_workspaces(
&self,
@ -56,7 +56,7 @@ impl Client {
Ok(self.list_workspaces(owned, invited).await?)
}
#[napi(js_name = "invite_to_workspace")]
#[napi(js_name = "inviteToWorkspace")]
/// invite user to given workspace, if able to
pub async fn js_invite_to_workspace(
&self,
@ -66,31 +66,31 @@ impl Client {
Ok(self.invite_to_workspace(workspace, user).await?)
}
#[napi(js_name = "attach_workspace")]
#[napi(js_name = "attachWorkspace")]
/// join workspace with given id (will start its cursor controller)
pub async fn js_attach_workspace(&self, workspace: String) -> napi::Result<Workspace> {
Ok(self.attach_workspace(workspace).await?)
}
#[napi(js_name = "leave_workspace")]
#[napi(js_name = "leaveWorkspace")]
/// leave workspace and disconnect, returns true if workspace was active
pub async fn js_leave_workspace(&self, workspace: String) -> bool {
self.leave_workspace(&workspace)
}
#[napi(js_name = "get_workspace")]
#[napi(js_name = "getWorkspace")]
/// get workspace with given id, if it exists
pub fn js_get_workspace(&self, workspace: String) -> Option<Workspace> {
self.get_workspace(&workspace)
}
#[napi(js_name = "user")]
#[napi(js_name = "currentUser")]
/// return current sessions's user id
pub fn js_user(&self) -> JsUser {
self.user().clone().into()
pub fn js_current_user(&self) -> JsUser {
self.current_user().clone().into()
}
#[napi(js_name = "active_workspaces")]
#[napi(js_name = "activeWorkspaces")]
/// get list of all active workspaces
pub fn js_active_workspaces(&self) -> Vec<String> {
self.active_workspaces()

View file

@ -32,7 +32,7 @@ impl CursorController {
}
/// Clear the registered callback
#[napi(js_name = "clear_callback")]
#[napi(js_name = "clearCallback")]
pub fn js_clear_callback(&self) {
self.clear_callback();
}
@ -44,7 +44,7 @@ impl CursorController {
}
/// Get next cursor event if available without blocking
#[napi(js_name = "try_recv")]
#[napi(js_name = "tryRecv")]
pub async fn js_try_recv(&self) -> napi::Result<Option<crate::api::Cursor>> {
Ok(self.try_recv().await?.map(crate::api::Cursor::from))
}

View file

@ -50,13 +50,13 @@ impl Workspace {
}
/// List all user names currently in this workspace
#[napi(js_name = "user_list")]
#[napi(js_name = "userList")]
pub fn js_user_list(&self) -> Vec<JsUser> {
self.user_list().into_iter().map(JsUser::from).collect()
}
/// List all currently active buffers
#[napi(js_name = "active_buffers")]
#[napi(js_name = "activeBuffers")]
pub fn js_active_buffers(&self) -> Vec<String> {
self.active_buffers()
}
@ -68,25 +68,25 @@ impl Workspace {
}
/// Get a buffer controller by its name (path)
#[napi(js_name = "get_buffer")]
#[napi(js_name = "getBuffer")]
pub fn js_get_buffer(&self, path: String) -> Option<BufferController> {
self.get_buffer(&path)
}
/// Create a new buffer in the current workspace
#[napi(js_name = "create_buffer")]
#[napi(js_name = "createBuffer")]
pub async fn js_create_buffer(&self, path: String) -> napi::Result<()> {
Ok(self.create_buffer(&path).await?)
}
/// Attach to a workspace buffer, starting a BufferController
#[napi(js_name = "attach_buffer")]
#[napi(js_name = "attachBuffer")]
pub async fn js_attach_buffer(&self, path: String) -> napi::Result<BufferController> {
Ok(self.attach_buffer(&path).await?)
}
/// Delete a buffer from workspace
#[napi(js_name = "delete_buffer")]
#[napi(js_name = "deleteBuffer")]
pub async fn js_delete_buffer(&self, path: String) -> napi::Result<()> {
Ok(self.delete_buffer(&path).await?)
}
@ -96,7 +96,7 @@ impl Workspace {
Ok(JsEvent::from(self.recv().await?))
}
#[napi(js_name = "try_recv")]
#[napi(js_name = "tryRecv")]
pub async fn js_try_recv(&self) -> napi::Result<Option<JsEvent>> {
Ok(self.try_recv().await?.map(JsEvent::from))
}
@ -107,7 +107,7 @@ impl Workspace {
Ok(())
}
#[napi(js_name = "clear_callback")]
#[napi(js_name = "clearCallback")]
pub fn js_clear_callback(&self) -> napi::Result<()> {
self.clear_callback();
Ok(())
@ -130,24 +130,24 @@ impl Workspace {
/// Detach from an active buffer, stopping its underlying worker
/// this method returns true if no reference or last reference was held, false if there are still
/// dangling references to clear
#[napi(js_name = "detach_buffer")]
#[napi(js_name = "detachBuffer")]
pub async fn js_detach_buffer(&self, path: String) -> bool {
self.detach_buffer(&path)
}
/// Re-fetch remote buffer list
#[napi(js_name = "fetch_buffers")]
#[napi(js_name = "fetchBuffers")]
pub async fn js_fetch_buffers(&self) -> napi::Result<()> {
Ok(self.fetch_buffers().await?)
}
/// Re-fetch the list of all users in the workspace.
#[napi(js_name = "fetch_users")]
#[napi(js_name = "fetchUsers")]
pub async fn js_fetch_users(&self) -> napi::Result<()> {
Ok(self.fetch_users().await?)
}
/// List users attached to a specific buffer
#[napi(js_name = "list_buffer_users")]
#[napi(js_name = "listBufferUsers")]
pub async fn js_list_buffer_users(
&self,
path: String,