1
0
silverbullet/packages/web/syscalls/system.ts
2022-05-09 14:59:12 +02:00

31 lines
756 B
TypeScript

import { SysCallMapping } from "@plugos/plugos/system";
import type { Editor } from "../editor";
export function systemSyscalls(editor: Editor): SysCallMapping {
return {
"system.invokeFunction": async (
ctx,
env: string,
name: string,
...args: any[]
) => {
if (!ctx.plug) {
throw Error("No plug associated with context");
}
if (env === "client") {
return ctx.plug.invoke(name, args);
}
return editor.space.invokeFunction(ctx.plug, env, name, args);
},
"system.reloadPlugs": async () => {
return editor.reloadPlugs();
},
"sandbox.getServerLogs": async (ctx) => {
return editor.space.proxySyscall(ctx.plug, "sandbox.getLogs", []);
},
};
}