1
0
silverbullet/packages/web/syscalls/system.ts
Zef Hemel 76636dd9b1 Work
2022-04-26 19:04:36 +02:00

27 lines
629 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();
},
};
}