Skip to content

Commit

Permalink
chore(js): camelCase
Browse files Browse the repository at this point in the history
  • Loading branch information
alemidev committed Oct 15, 2024
1 parent c63a3ec commit 9a4225c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions src/ffi/js/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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?)
}
Expand Down
22 changes: 11 additions & 11 deletions src/ffi/js/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/ffi/js/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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))
}
Expand Down
24 changes: 12 additions & 12 deletions src/ffi/js/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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?)
}
Expand All @@ -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))
}
Expand All @@ -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(())
Expand All @@ -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,
Expand Down

0 comments on commit 9a4225c

Please sign in to comment.