1
0
silverbullet/webapp/syscalls/system.ts

24 lines
546 B
TypeScript
Raw Normal View History

2022-04-05 15:02:17 +00:00
import { SysCallMapping } from "../../plugos/system";
import { Space } from "../../common/spaces/space";
2022-03-25 11:03:06 +00:00
2022-04-07 13:21:30 +00:00
export function systemSyscalls(space: Space): 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-05 15:02:17 +00:00
return space.invokeFunction(ctx.plug, env, name, args);
2022-03-25 11:03:06 +00:00
},
};
}