silverbullet/plug-api/syscalls/system.ts

58 lines
1.6 KiB
TypeScript
Raw Normal View History

import type { CommandDef } from "../../lib/command.ts";
2024-02-29 22:23:05 +08:00
import type { SyscallMeta } from "../types.ts";
import type { ParseTree } from "../lib/tree.ts";
import { syscall } from "../syscall.ts";
2022-04-01 23:07:08 +08:00
export function invokeFunction(
2022-04-01 23:07:08 +08:00
name: string,
...args: any[]
): Promise<any> {
2023-08-28 23:12:15 +08:00
return syscall("system.invokeFunction", name, ...args);
2022-04-01 23:07:08 +08:00
}
2022-04-27 01:04:36 +08:00
2022-09-06 20:36:06 +08:00
// Only available on the client
export function invokeCommand(name: string, args?: string[]): Promise<any> {
return syscall("system.invokeCommand", name, args);
2022-07-11 15:08:22 +08:00
}
2022-09-06 20:36:06 +08:00
// Only available on the client
export function listCommands(): Promise<{ [key: string]: CommandDef }> {
2022-09-06 20:36:06 +08:00
return syscall("system.listCommands");
}
export function listSyscalls(): Promise<SyscallMeta[]> {
return syscall("system.listSyscalls");
}
export function invokeSpaceFunction(
name: string,
...args: any[]
): Promise<any> {
return syscall("system.invokeSpaceFunction", name, ...args);
}
export function applyAttributeExtractors(
tags: string[],
text: string,
tree: ParseTree,
): Promise<Record<string, any>[]> {
return syscall("system.applyAttributeExtractors", tags, text, tree);
}
export function reloadPlugs() {
return syscall("system.reloadPlugs");
2022-04-27 01:04:36 +08:00
}
2023-01-15 01:51:00 +08:00
// Returns what runtime environment this plug is run in, e.g. "server" or "client" can be undefined, which would mean a hybrid environment (such as mobile)
export function getEnv(): Promise<string | undefined> {
return syscall("system.getEnv");
}
export function getMode(): Promise<"ro" | "rw"> {
return syscall("system.getMode");
}
export function getVersion(): Promise<string> {
return syscall("system.getVersion");
}