1
0
silverbullet/packages/web/syscalls/system.ts

27 lines
629 B
TypeScript
Raw Normal View History

2022-04-25 08:33:38 +00:00
import { SysCallMapping } from "@plugos/plugos/system";
2022-04-26 17:04:36 +00:00
import type { Editor } from "../editor";
2022-03-25 11:03:06 +00:00
2022-04-26 17:04:36 +00:00
export function systemSyscalls(editor: Editor): SysCallMapping {
2022-03-25 11:03:06 +00:00
return {
2022-04-05 15:02:17 +00:00
"system.invokeFunction": async (
ctx,
2022-04-05 15:02:17 +00:00
env: string,
name: string,
...args: any[]
) => {
2022-03-25 11:03:06 +00:00
if (!ctx.plug) {
throw Error("No plug associated with context");
}
2022-04-05 15:02:17 +00:00
if (env === "client") {
return ctx.plug.invoke(name, args);
}
2022-04-26 17:04:36 +00:00
return editor.space.invokeFunction(ctx.plug, env, name, args);
},
"system.reloadPlugs": async () => {
return editor.reloadPlugs();
2022-03-25 11:03:06 +00:00
},
};
}