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
2023-08-27 12:13:18 +00:00
export function invoke (
name : string ,
. . . args : any [ ]
) : Promise < any > {
return syscall ( "system.invoke" , name , . . . args ) ;
}
// @deprecated use invoke instead
2022-10-10 12:50:21 +00:00
export function invokeFunction (
2022-04-05 15:02:17 +00:00
env : string ,
2022-04-01 15:07:08 +00:00
name : string ,
. . . args : any [ ]
) : Promise < any > {
2022-04-06 13:39:20 +00:00
return syscall ( "system.invokeFunction" , env , 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
2022-10-10 12:50:21 +00:00
export function invokeCommand ( name : string ) : Promise < any > {
2022-07-11 07:08:22 +00:00
return syscall ( "system.invokeCommand" , name ) ;
}
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" ) ;
}