import type { CommandDef } from "../../lib/command.ts"; import type { SyscallMeta } from "../types.ts"; import type { ParseTree } from "../lib/tree.ts"; import { syscall } from "../syscall.ts"; import type { Config } from "$type/config.ts"; export function invokeFunction( name: string, ...args: any[] ): Promise { return syscall("system.invokeFunction", name, ...args); } // Only available on the client export function invokeCommand(name: string, args?: string[]): Promise { return syscall("system.invokeCommand", name, args); } // Only available on the client export function listCommands(): Promise<{ [key: string]: CommandDef }> { return syscall("system.listCommands"); } export function listSyscalls(): Promise { return syscall("system.listSyscalls"); } export function invokeSpaceFunction( name: string, ...args: any[] ): Promise { return syscall("system.invokeSpaceFunction", name, ...args); } export function applyAttributeExtractors( tags: string[], text: string, tree: ParseTree, ): Promise[]> { return syscall("system.applyAttributeExtractors", tags, text, tree); } /** * Loads a particular space configuration key (or all of them when no key is spacified) * @param key the key to load, when not specified, all keys are loaded * @returns either the value of the key or all keys as a Record */ export async function getSpaceConfig( key?: string, defaultValue?: any, ): Promise { return (await syscall("system.getSpaceConfig", key)) ?? defaultValue; } export function reloadPlugs(): Promise { return syscall("system.reloadPlugs"); } export function reloadConfig(): Promise { return syscall("system.reloadConfig"); } // 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 { return syscall("system.getEnv"); } export function getMode(): Promise<"ro" | "rw"> { return syscall("system.getMode"); } export function getVersion(): Promise { return syscall("system.getVersion"); }