CI / config (push) Canceled after 0s
CI / test-frontend (push) Canceled after 0s
CI / test-rust (push) Canceled after 0s
CI / test-e2e (push) Canceled after 0s
CI / test-e2e-release (push) Canceled after 0s
CI / build (push) Canceled after 0s
CI / release (push) Canceled after 0s
CI / docker (push) Canceled after 0s
CI / docker-website (push) Canceled after 0s
补齐普通用户自助账号、中文设置与快捷键提示,修复大型扩展安装和移动端弹窗,并按服务器能力限制不兼容扩展。 Co-Authored-By: Codex <noreply@anthropic.com>
132 lines
3.2 KiB
TypeScript
132 lines
3.2 KiB
TypeScript
import { syscall } from "../syscall.ts";
|
|
import type { CommandDef } from "../types/manifest.ts";
|
|
import type { SyscallMeta } from "@silverbulletmd/silverbullet/type/index";
|
|
|
|
/**
|
|
* System level syscalls
|
|
* @module
|
|
*/
|
|
|
|
/**
|
|
* Invoke a plug function
|
|
* @param name a string representing the name of the function to invoke ("plug.functionName")
|
|
* @param args arguments to pass to the function
|
|
* @returns
|
|
*/
|
|
export function invokeFunction(name: string, ...args: any[]): Promise<any> {
|
|
return syscall("system.invokeFunction", name, ...args);
|
|
}
|
|
|
|
/**
|
|
* Invoke a client command by name
|
|
* Note: only available on the client
|
|
* @param name name of the command
|
|
* @param args arguments to pass to the command
|
|
*/
|
|
export function invokeCommand(name: string, args?: string[]): Promise<any> {
|
|
return syscall("system.invokeCommand", name, args);
|
|
}
|
|
|
|
/**
|
|
* Lists all commands available
|
|
* @returns a map of all available commands
|
|
*/
|
|
export function listCommands(): Promise<Record<string, CommandDef>> {
|
|
return syscall("system.listCommands");
|
|
}
|
|
|
|
/**
|
|
* Lists all syscalls available
|
|
* @returns a list of all available syscalls
|
|
*/
|
|
export function listSyscalls(): Promise<SyscallMeta[]> {
|
|
return syscall("system.listSyscalls");
|
|
}
|
|
|
|
/**
|
|
* Trigger a reload of all plugs
|
|
* @returns
|
|
*/
|
|
export function reloadPlugs(): Promise<void> {
|
|
return syscall("system.reloadPlugs");
|
|
}
|
|
|
|
/**
|
|
* Make edited-on-disk state live and wait until the client is ready again.
|
|
*/
|
|
export function reboot(): Promise<void> {
|
|
return syscall("system.reboot");
|
|
}
|
|
|
|
/**
|
|
* Load (or reload) a single plug from a space file path.
|
|
*/
|
|
export function loadPlug(path: string): Promise<void> {
|
|
return syscall("system.loadPlug", path);
|
|
}
|
|
|
|
/**
|
|
* Unload a plug previously loaded from the given space file path.
|
|
* Returns true if a plug was unloaded.
|
|
*/
|
|
export function unloadPlug(path: string): Promise<boolean> {
|
|
return syscall("system.unloadPlug", path);
|
|
}
|
|
|
|
/**
|
|
* Returns the current mode of the system, either "ro" (read-only) or "rw" (read-write)
|
|
*/
|
|
export function getMode(): Promise<"ro" | "rw"> {
|
|
return syscall("system.getMode");
|
|
}
|
|
|
|
/**
|
|
* Returns the prefix set by SB_URL_PREFIX or "/" if the variable isn't set
|
|
*/
|
|
export function getURLPrefix(): Promise<string> {
|
|
return syscall("system.getURLPrefix");
|
|
}
|
|
|
|
/**
|
|
* Returns the base URI for this SilverBullet isntance
|
|
*/
|
|
export function getBaseURI(): Promise<string> {
|
|
return syscall("system.getBaseURI");
|
|
}
|
|
|
|
/**
|
|
* Returns the SilverBullet version
|
|
*/
|
|
export function getVersion(): Promise<string> {
|
|
return syscall("system.getVersion");
|
|
}
|
|
|
|
export type SystemCapabilities = {
|
|
shell: boolean;
|
|
runtimeApi: boolean;
|
|
};
|
|
|
|
/** Returns optional server capabilities available to the current space. */
|
|
export function getCapabilities(): Promise<SystemCapabilities> {
|
|
return syscall("system.getCapabilities");
|
|
}
|
|
|
|
export function getConfig<T = any>(
|
|
key: string,
|
|
defaultValue: any = undefined,
|
|
): Promise<T> {
|
|
return syscall("system.getConfig", key, defaultValue);
|
|
}
|
|
|
|
export function wipeClient(logout = false): Promise<void> {
|
|
return syscall("system.wipeClient", logout);
|
|
}
|
|
|
|
/**
|
|
* DEPRECATED
|
|
* Deletes all IndexedDB databases that are not connected to client (e.g. legacy databases)
|
|
*/
|
|
export function cleanDatabases(): Promise<boolean> {
|
|
return syscall("system.cleanDatabases");
|
|
}
|