import { getLogs } from "@plugos/plugos-syscall/sandbox"; import { LogEntry } from "@plugos/plugos/sandbox"; import { getText, hideBhs, showBhs, } from "@silverbulletmd/plugos-silverbullet-syscall/editor"; import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown"; import { getServerLogs } from "@silverbulletmd/plugos-silverbullet-syscall/sandbox"; import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system"; export async function parseServerPageCommand() { console.log(await invokeFunction("server", "parsePage", await getText())); } export async function parsePageCommand() { parsePage(await getText()); } export async function parsePage(text: string) { console.log("AST", JSON.stringify(await parseMarkdown(text), null, 2)); } export async function showLogsCommand() { let clientLogs = await getLogs(); let serverLogs = await getServerLogs(); await showBhs( `
Client logs (max 100)
${clientLogs
        .map((le) => `[${le.level}] ${le.message}`)
        .join("\n")}
Server logs (max 100)
${serverLogs
        .map((le) => `[${le.level}] ${le.message}`)
        .join("\n")}
`, ` var clientDiv = document.getElementById("client-log"); clientDiv.scrollTop = clientDiv.scrollHeight; var serverDiv = document.getElementById("server-log"); serverDiv.scrollTop = serverDiv.scrollHeight; ` ); } export async function hideBhsCommand() { await hideBhs(); }