import { getLogs } from "../../syscall/plugos-syscall/sandbox.ts"; import { getText, hidePanel, showPanel, } from "../../syscall/silverbullet-syscall/editor.ts"; import { parseMarkdown } from "../../syscall/silverbullet-syscall/markdown.ts"; import { getServerLogs } from "../../syscall/silverbullet-syscall/sandbox.ts"; export async function parsePageCommand() { console.log( "AST", JSON.stringify(await parseMarkdown(await getText()), null, 2) ); } export async function showLogsCommand() { let clientLogs = await getLogs(); let serverLogs = await getServerLogs(); await showPanel( "bhs", 1, `
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; if(window.reloadInterval) { clearInterval(window.reloadInterval); } window.reloadInterval = setInterval(() => { sendEvent("log:reload"); }, 1000); ` ); } export async function hideBhsCommand() { await hidePanel("bhs"); }