2022-10-10 12:50:21 +00:00
import type { CommandDef } from "../../web/hooks/command.ts" ;
import { syscall } from "./syscall.ts" ;
2022-04-01 15:07:08 +00:00
2022-10-10 12:50:21 +00:00
export function invokeFunction (
2022-04-01 15:07:08 +00:00
name : string ,
. . . args : any [ ]
) : Promise < any > {
2023-08-28 15:12:15 +00:00
return syscall ( "system.invokeFunction" , name , . . . args ) ;
2022-04-01 15:07:08 +00:00
}
2022-04-26 17:04:36 +00:00
2022-09-06 12:36:06 +00:00
// Only available on the client
2023-11-25 17:57:00 +00:00
export function invokeCommand ( name : string , args? : string [ ] ) : Promise < any > {
return syscall ( "system.invokeCommand" , name , args ) ;
2022-07-11 07:08:22 +00:00
}
2022-09-06 12:36:06 +00:00
// Only available on the client
2022-10-10 12:50:21 +00:00
export function listCommands ( ) : Promise < { [ key : string ] : CommandDef } > {
2022-09-06 12:36:06 +00:00
return syscall ( "system.listCommands" ) ;
}
2022-10-10 12:50:21 +00:00
export function reloadPlugs() {
2022-04-26 18:31:31 +00:00
syscall ( "system.reloadPlugs" ) ;
2022-04-26 17:04:36 +00:00
}
2023-01-14 17:51:00 +00: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" ) ;
}