mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-21 23:04:49 +01:00
chore: last consistency fixes in glues
Co-authored-by: zaaarf <me@zaaarf.foo>
This commit is contained in:
parent
96a8b1a88f
commit
6f04c38779
6 changed files with 75 additions and 47 deletions
12
dist/java/src/mp/code/Client.java
vendored
12
dist/java/src/mp/code/Client.java
vendored
|
@ -34,17 +34,17 @@ public final class Client {
|
||||||
*/
|
*/
|
||||||
public static native Client connect(Config config) throws ConnectionException;
|
public static native Client connect(Config config) throws ConnectionException;
|
||||||
|
|
||||||
private static native User get_user(long self);
|
private static native User current_user(long self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets information about the current user.
|
* Gets information about the current user.
|
||||||
* @return a {@link User} object representing the user
|
* @return a {@link User} object representing the user
|
||||||
*/
|
*/
|
||||||
public User getUser() {
|
public User currentUser() {
|
||||||
return get_user(this.ptr);
|
return current_user(this.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native Workspace join_workspace(long self, String workspaceId) throws ConnectionException;
|
private static native Workspace attach_workspace(long self, String workspaceId) throws ConnectionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Joins a {@link Workspace} and returns it.
|
* Joins a {@link Workspace} and returns it.
|
||||||
|
@ -52,8 +52,8 @@ public final class Client {
|
||||||
* @return the relevant {@link Workspace}
|
* @return the relevant {@link Workspace}
|
||||||
* @throws ConnectionException if an error occurs in communicating with the server
|
* @throws ConnectionException if an error occurs in communicating with the server
|
||||||
*/
|
*/
|
||||||
public Workspace joinWorkspace(String workspaceId) throws ConnectionException {
|
public Workspace attachWorkspace(String workspaceId) throws ConnectionException {
|
||||||
return join_workspace(this.ptr, workspaceId);
|
return attach_workspace(this.ptr, workspaceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void create_workspace(long self, String workspaceId) throws ConnectionRemoteException;
|
private static native void create_workspace(long self, String workspaceId) throws ConnectionRemoteException;
|
||||||
|
|
30
dist/java/src/mp/code/Workspace.java
vendored
30
dist/java/src/mp/code/Workspace.java
vendored
|
@ -25,24 +25,24 @@ public final class Workspace {
|
||||||
Extensions.CLEANER.register(this, () -> free(ptr));
|
Extensions.CLEANER.register(this, () -> free(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native String get_workspace_id(long self);
|
private static native String id(long self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the unique identifier of the current workspace.
|
* Gets the unique identifier of the current workspace.
|
||||||
* @return the identifier
|
* @return the identifier
|
||||||
*/
|
*/
|
||||||
public String getWorkspaceId() {
|
public String id() {
|
||||||
return get_workspace_id(this.ptr);
|
return id(this.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native CursorController get_cursor(long self);
|
private static native CursorController cursor(long self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link CursorController} for the current workspace.
|
* Gets the {@link CursorController} for the current workspace.
|
||||||
* @return the {@link CursorController}
|
* @return the {@link CursorController}
|
||||||
*/
|
*/
|
||||||
public CursorController getCursor() {
|
public CursorController cursor() {
|
||||||
return get_cursor(this.ptr);
|
return cursor(this.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native BufferController get_buffer(long self, String path);
|
private static native BufferController get_buffer(long self, String path);
|
||||||
|
@ -57,7 +57,7 @@ public final class Workspace {
|
||||||
return Optional.ofNullable(get_buffer(this.ptr, path));
|
return Optional.ofNullable(get_buffer(this.ptr, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native String[] get_file_tree(long self, String filter, boolean strict);
|
private static native String[] filetree(long self, String filter, boolean strict);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the file tree for this workspace, optionally filtering it.
|
* Gets the file tree for this workspace, optionally filtering it.
|
||||||
|
@ -66,8 +66,8 @@ public final class Workspace {
|
||||||
* @return an array containing file tree as flat paths
|
* @return an array containing file tree as flat paths
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||||
public String[] getFileTree(Optional<String> filter, boolean strict) {
|
public String[] filetree(Optional<String> filter, boolean strict) {
|
||||||
return get_file_tree(this.ptr, filter.orElse(null), strict);
|
return filetree(this.ptr, filter.orElse(null), strict);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native String[] active_buffers(long self);
|
private static native String[] active_buffers(long self);
|
||||||
|
@ -102,7 +102,7 @@ public final class Workspace {
|
||||||
create_buffer(this.ptr, path);
|
create_buffer(this.ptr, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native BufferController attach_to_buffer(long self, String path) throws ConnectionException;
|
private static native BufferController attach_buffer(long self, String path) throws ConnectionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches to an existing buffer with the given path, if present.
|
* Attaches to an existing buffer with the given path, if present.
|
||||||
|
@ -110,19 +110,19 @@ public final class Workspace {
|
||||||
* @return the {@link BufferController} associated with that path
|
* @return the {@link BufferController} associated with that path
|
||||||
* @throws ConnectionException if an error occurs in communicating with the server, or if the buffer did not exist
|
* @throws ConnectionException if an error occurs in communicating with the server, or if the buffer did not exist
|
||||||
*/
|
*/
|
||||||
public BufferController attachToBuffer(String path) throws ConnectionException {
|
public BufferController attachBuffer(String path) throws ConnectionException {
|
||||||
return attach_to_buffer(ptr, path);
|
return attach_buffer(ptr, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native boolean detach_from_buffer(long self, String path);
|
private static native boolean detach_buffer(long self, String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detaches from a given buffer.
|
* Detaches from a given buffer.
|
||||||
* @param path the path of the buffer to detach from
|
* @param path the path of the buffer to detach from
|
||||||
* @return a boolean, true only if there are still dangling references preventing controller from stopping
|
* @return a boolean, true only if there are still dangling references preventing controller from stopping
|
||||||
*/
|
*/
|
||||||
public boolean detachFromBuffer(String path) {
|
public boolean detachBuffer(String path) {
|
||||||
return detach_from_buffer(this.ptr, path);
|
return detach_buffer(this.ptr, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void fetch_buffers(long self) throws ConnectionRemoteException;
|
private static native void fetch_buffers(long self) throws ConnectionRemoteException;
|
||||||
|
|
44
dist/lua/annotations.lua
vendored
44
dist/lua/annotations.lua
vendored
|
@ -162,12 +162,17 @@ function MaybeBufferUpdatePromise:and_then(cb) end
|
||||||
|
|
||||||
|
|
||||||
---@class (exact) Client
|
---@class (exact) Client
|
||||||
---@field id string uuid of local user
|
|
||||||
---@field username string name of local user
|
|
||||||
---@field active_workspaces string[] array of all currently active workspace names
|
|
||||||
---the effective local client, handling connecting to codemp server
|
---the effective local client, handling connecting to codemp server
|
||||||
local Client = {}
|
local Client = {}
|
||||||
|
|
||||||
|
---@return User
|
||||||
|
---current logged in user for this client
|
||||||
|
function Client:current_user() end
|
||||||
|
|
||||||
|
---@return string[]
|
||||||
|
---array of all currently active workspace names
|
||||||
|
function Client:active_workspaces() end
|
||||||
|
|
||||||
---@return NilPromise
|
---@return NilPromise
|
||||||
---@async
|
---@async
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
|
@ -179,7 +184,7 @@ function Client:refresh() end
|
||||||
---@async
|
---@async
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
---join requested workspace if possible and subscribe to event bus
|
---join requested workspace if possible and subscribe to event bus
|
||||||
function Client:join_workspace(ws) end
|
function Client:attach_workspace(ws) end
|
||||||
|
|
||||||
---@param ws string workspace id to create
|
---@param ws string workspace id to create
|
||||||
---@return NilPromise
|
---@return NilPromise
|
||||||
|
@ -222,26 +227,41 @@ function Client:get_workspace(ws) end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---@class User
|
||||||
|
---@field id string user uuid
|
||||||
|
---@field name string user display name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---@class (exact) Workspace
|
---@class (exact) Workspace
|
||||||
---@field name string workspace name
|
|
||||||
---@field cursor CursorController workspace cursor controller
|
|
||||||
---@field active_buffers string[] array of all currently active buffer names
|
|
||||||
---a joined codemp workspace
|
---a joined codemp workspace
|
||||||
local Workspace = {}
|
local Workspace = {}
|
||||||
|
|
||||||
|
---@return string
|
||||||
|
---workspace id
|
||||||
|
function Workspace:id() end
|
||||||
|
|
||||||
|
---@return string[]
|
||||||
|
---array of all currently active buffer names
|
||||||
|
function Workspace:active_buffers() end
|
||||||
|
|
||||||
|
---@return CursorController
|
||||||
|
---reference to workspace's CursorController
|
||||||
|
function Workspace:cursor() end
|
||||||
|
|
||||||
---@param path string relative path ("name") of new buffer
|
---@param path string relative path ("name") of new buffer
|
||||||
---@return NilPromise
|
---@return NilPromise
|
||||||
---@async
|
---@async
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
---create a new empty buffer
|
---create a new empty buffer
|
||||||
function Workspace:create(path) end
|
function Workspace:create_buffer(path) end
|
||||||
|
|
||||||
---@param path string relative path ("name") of buffer to delete
|
---@param path string relative path ("name") of buffer to delete
|
||||||
---@return NilPromise
|
---@return NilPromise
|
||||||
---@async
|
---@async
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
---delete buffer from workspace
|
---delete buffer from workspace
|
||||||
function Workspace:delete(path) end
|
function Workspace:delete_buffer(path) end
|
||||||
|
|
||||||
---@param path string relative path ("name") of buffer to get
|
---@param path string relative path ("name") of buffer to get
|
||||||
---@return BufferController?
|
---@return BufferController?
|
||||||
|
@ -253,12 +273,12 @@ function Workspace:get_buffer(path) end
|
||||||
---@async
|
---@async
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
---attach to a remote buffer, synching content and changes and returning its controller
|
---attach to a remote buffer, synching content and changes and returning its controller
|
||||||
function Workspace:attach(path) end
|
function Workspace:attach_buffer(path) end
|
||||||
|
|
||||||
---@param path string relative path ("name") of buffer to detach from
|
---@param path string relative path ("name") of buffer to detach from
|
||||||
---@return boolean success
|
---@return boolean success
|
||||||
---detach from an active buffer, closing all streams. returns false if there are still dangling references
|
---detach from an active buffer, closing all streams. returns false if there are still dangling references
|
||||||
function Workspace:detach(path) end
|
function Workspace:detach_buffer(path) end
|
||||||
|
|
||||||
---@param filter? string apply a filter to the return elements
|
---@param filter? string apply a filter to the return elements
|
||||||
---@param strict? boolean whether to strictly match or just check whether it starts with it
|
---@param strict? boolean whether to strictly match or just check whether it starts with it
|
||||||
|
@ -266,7 +286,7 @@ function Workspace:detach(path) end
|
||||||
---return the list of available buffers in this workspace, as relative paths from workspace root
|
---return the list of available buffers in this workspace, as relative paths from workspace root
|
||||||
function Workspace:filetree(filter, strict) end
|
function Workspace:filetree(filter, strict) end
|
||||||
|
|
||||||
---@return string[]
|
---@return User[]
|
||||||
---return all names of users currently in this workspace
|
---return all names of users currently in this workspace
|
||||||
function Workspace:user_list() end
|
function Workspace:user_list() end
|
||||||
|
|
||||||
|
|
25
dist/py/src/codemp/codemp.pyi
vendored
25
dist/py/src/codemp/codemp.pyi
vendored
|
@ -7,6 +7,13 @@ class Driver:
|
||||||
"""
|
"""
|
||||||
def stop(self) -> None: ...
|
def stop(self) -> None: ...
|
||||||
|
|
||||||
|
class User:
|
||||||
|
"""
|
||||||
|
A remote user, with uuid and username
|
||||||
|
"""
|
||||||
|
id: str
|
||||||
|
name: str
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
"""
|
"""
|
||||||
Configuration data structure for codemp clients
|
Configuration data structure for codemp clients
|
||||||
|
@ -40,7 +47,7 @@ class Client:
|
||||||
Handle to the actual client that manages the session. It manages the connection
|
Handle to the actual client that manages the session. It manages the connection
|
||||||
to a server and joining/creating new workspaces
|
to a server and joining/creating new workspaces
|
||||||
"""
|
"""
|
||||||
def join_workspace(self, workspace: str) -> Promise[Workspace]: ...
|
def attach_workspace(self, workspace: str) -> Promise[Workspace]: ...
|
||||||
def create_workspace(self, workspace: str) -> Promise[None]: ...
|
def create_workspace(self, workspace: str) -> Promise[None]: ...
|
||||||
def delete_workspace(self, workspace: str) -> Promise[None]: ...
|
def delete_workspace(self, workspace: str) -> Promise[None]: ...
|
||||||
def invite_to_workspace(self, workspace: str, username: str) -> Promise[None]: ...
|
def invite_to_workspace(self, workspace: str, username: str) -> Promise[None]: ...
|
||||||
|
@ -48,8 +55,7 @@ class Client:
|
||||||
def leave_workspace(self, workspace: str) -> bool: ...
|
def leave_workspace(self, workspace: str) -> bool: ...
|
||||||
def get_workspace(self, id: str) -> Workspace: ...
|
def get_workspace(self, id: str) -> Workspace: ...
|
||||||
def active_workspaces(self) -> list[str]: ...
|
def active_workspaces(self) -> list[str]: ...
|
||||||
def user_id(self) -> str: ...
|
def current_user(self) -> User: ...
|
||||||
def user_name(self) -> str: ...
|
|
||||||
def refresh(self) -> Promise[None]: ...
|
def refresh(self) -> Promise[None]: ...
|
||||||
|
|
||||||
class Event:
|
class Event:
|
||||||
|
@ -60,17 +66,18 @@ class Workspace:
|
||||||
Handle to a workspace inside codemp. It manages buffers.
|
Handle to a workspace inside codemp. It manages buffers.
|
||||||
A cursor is tied to the single workspace.
|
A cursor is tied to the single workspace.
|
||||||
"""
|
"""
|
||||||
def create(self, path: str) -> Promise[None]: ...
|
def create_buffer(self, path: str) -> Promise[None]: ...
|
||||||
def attach(self, path: str) -> Promise[BufferController]: ...
|
def attach_buffer(self, path: str) -> Promise[BufferController]: ...
|
||||||
def detach(self, path: str) -> bool: ...
|
def detach_buffer(self, path: str) -> bool: ...
|
||||||
def fetch_buffers(self) -> Promise[None]: ...
|
def fetch_buffers(self) -> Promise[None]: ...
|
||||||
def fetch_users(self) -> Promise[None]: ...
|
def fetch_users(self) -> Promise[None]: ...
|
||||||
def list_buffer_users(self, path: str) -> Promise[list[str]]: ...
|
def list_buffer_users(self, path: str) -> Promise[list[str]]: ...
|
||||||
def delete(self, path: str) -> Promise[None]: ...
|
def delete_buffer(self, path: str) -> Promise[None]: ...
|
||||||
def id(self) -> str: ...
|
def id(self) -> str: ...
|
||||||
def cursor(self) -> CursorController: ...
|
def cursor(self) -> CursorController: ...
|
||||||
def buffer_by_name(self, path: str) -> Optional[BufferController]: ...
|
def get_buffer(self, path: str) -> Optional[BufferController]: ...
|
||||||
def buffer_list(self) -> list[str]: ...
|
def user_list(self) -> list[User]: ...
|
||||||
|
def active_buffers(self) -> list[str]: ...
|
||||||
def filetree(self, filter: Optional[str], strict: bool) -> list[str]: ...
|
def filetree(self, filter: Optional[str], strict: bool) -> list[str]: ...
|
||||||
def recv(self) -> Promise[Event]: ...
|
def recv(self) -> Promise[Event]: ...
|
||||||
def try_recv(self) -> Promise[Optional[Event]]: ...
|
def try_recv(self) -> Promise[Optional[Event]]: ...
|
||||||
|
|
|
@ -6,6 +6,7 @@ use codemp_proto::workspace::workspace_event::Event as WorkspaceEventInner;
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pyclass)]
|
#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pyclass)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
|
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
/// Fired when the file tree changes.
|
/// Fired when the file tree changes.
|
||||||
/// Contains the modified buffer path (deleted, created or renamed).
|
/// Contains the modified buffer path (deleted, created or renamed).
|
||||||
|
|
|
@ -9,13 +9,13 @@ use jni_toolbox::jni;
|
||||||
|
|
||||||
/// Get the workspace id.
|
/// Get the workspace id.
|
||||||
#[jni(package = "mp.code", class = "Workspace")]
|
#[jni(package = "mp.code", class = "Workspace")]
|
||||||
fn get_workspace_id(workspace: &mut Workspace) -> String {
|
fn id(workspace: &mut Workspace) -> String {
|
||||||
workspace.id()
|
workspace.id()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a cursor controller by name and returns a pointer to it.
|
/// Get a cursor controller by name and returns a pointer to it.
|
||||||
#[jni(package = "mp.code", class = "Workspace")]
|
#[jni(package = "mp.code", class = "Workspace")]
|
||||||
fn get_cursor(workspace: &mut Workspace) -> crate::cursor::Controller {
|
fn cursor(workspace: &mut Workspace) -> crate::cursor::Controller {
|
||||||
workspace.cursor()
|
workspace.cursor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ fn get_buffer(workspace: &mut Workspace, path: String) -> Option<crate::buffer::
|
||||||
|
|
||||||
/// Get the filetree.
|
/// Get the filetree.
|
||||||
#[jni(package = "mp.code", class = "Workspace")]
|
#[jni(package = "mp.code", class = "Workspace")]
|
||||||
fn get_file_tree(workspace: &mut Workspace, filter: Option<String>, strict: bool) -> Vec<String> {
|
fn filetree(workspace: &mut Workspace, filter: Option<String>, strict: bool) -> Vec<String> {
|
||||||
workspace.filetree(filter.as_deref(), strict)
|
workspace.filetree(filter.as_deref(), strict)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +49,9 @@ fn create_buffer(workspace: &mut Workspace, path: String) -> Result<(), RemoteEr
|
||||||
super::tokio().block_on(workspace.create_buffer(&path))
|
super::tokio().block_on(workspace.create_buffer(&path))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attach to a buffer and return a pointer to its [crate::buffer::Controller].
|
/// Attach to a buffer and return a pointer to its [`crate::buffer::Controller`].
|
||||||
#[jni(package = "mp.code", class = "Workspace")]
|
#[jni(package = "mp.code", class = "Workspace")]
|
||||||
fn attach_to_buffer(
|
fn attach_buffer(
|
||||||
workspace: &mut Workspace,
|
workspace: &mut Workspace,
|
||||||
path: String,
|
path: String,
|
||||||
) -> Result<crate::buffer::Controller, ConnectionError> {
|
) -> Result<crate::buffer::Controller, ConnectionError> {
|
||||||
|
|
Loading…
Reference in a new issue