silverbullet/packages/server/syscalls/system.ts

22 lines
546 B
TypeScript
Raw Normal View History

2022-10-06 21:14:21 +08:00
import { SysCallMapping } from "../../plugos/system.ts";
import type { ExpressServer } from "../express_server.ts";
2022-04-27 01:04:36 +08:00
export function systemSyscalls(expressServer: ExpressServer): SysCallMapping {
return {
2022-10-06 21:14:21 +08:00
"system.invokeFunction": (
2022-04-27 01:04:36 +08:00
ctx,
env: string,
name: string,
...args: any[]
) => {
if (!ctx.plug) {
throw Error("No plug associated with context");
}
return ctx.plug.invoke(name, args);
},
2022-10-06 21:14:21 +08:00
"system.reloadPlugs": () => {
2022-04-27 01:04:36 +08:00
return expressServer.reloadPlugs();
},
};
}