1
0
silverbullet/web/syscalls/widget.ts
2023-10-29 10:02:50 +01:00

24 lines
586 B
TypeScript

import { CodeWidgetContent } from "$sb/types.ts";
import { SysCallMapping } from "../../plugos/system.ts";
import { Client } from "../client.ts";
export function widgetSyscalls(
client: Client,
): SysCallMapping {
return {
"widget.render": (
_ctx,
lang: string,
body: string,
): Promise<CodeWidgetContent> => {
const langCallback = client.system.codeWidgetHook.codeWidgetCallbacks.get(
lang,
);
if (!langCallback) {
throw new Error(`Code widget ${lang} not found`);
}
return langCallback(body);
},
};
}