2022-10-10 12:50:21 +00:00
|
|
|
import { getLogs } from "../../syscall/plugos-syscall/sandbox.ts";
|
2022-05-09 12:59:12 +00:00
|
|
|
import {
|
|
|
|
getText,
|
2022-09-30 15:06:12 +00:00
|
|
|
hidePanel,
|
2022-09-30 14:59:57 +00:00
|
|
|
showPanel,
|
2022-10-10 12:50:21 +00:00
|
|
|
} from "../../syscall/silverbullet-syscall/editor.ts";
|
|
|
|
import { parseMarkdown } from "../../syscall/silverbullet-syscall/markdown.ts";
|
|
|
|
import { getServerLogs } from "../../syscall/silverbullet-syscall/sandbox.ts";
|
2022-05-09 12:59:12 +00:00
|
|
|
|
|
|
|
export async function parsePageCommand() {
|
2022-07-04 13:51:04 +00:00
|
|
|
console.log(
|
|
|
|
"AST",
|
2022-10-12 09:47:13 +00:00
|
|
|
JSON.stringify(await parseMarkdown(await getText()), null, 2),
|
2022-07-04 13:51:04 +00:00
|
|
|
);
|
2022-05-09 12:59:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function showLogsCommand() {
|
|
|
|
let clientLogs = await getLogs();
|
|
|
|
let serverLogs = await getServerLogs();
|
|
|
|
|
2022-09-30 14:59:57 +00:00
|
|
|
await showPanel(
|
2022-09-30 15:06:12 +00:00
|
|
|
"bhs",
|
|
|
|
1,
|
2022-05-09 12:59:12 +00:00
|
|
|
`
|
|
|
|
<style>
|
|
|
|
#client-log-header {
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
top: 5px;
|
|
|
|
}
|
|
|
|
#server-log-header {
|
|
|
|
position: absolute;
|
|
|
|
right: 0;
|
|
|
|
top: 5px;
|
|
|
|
width: 50%;
|
|
|
|
}
|
|
|
|
#client-log {
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
top: 30px;
|
|
|
|
bottom: 0;
|
|
|
|
width: 50%;
|
|
|
|
overflow: scroll;
|
|
|
|
}
|
|
|
|
#server-log {
|
|
|
|
position: absolute;
|
|
|
|
right: 0;
|
|
|
|
top: 30px;
|
|
|
|
bottom: 0;
|
|
|
|
width: 50%;
|
|
|
|
overflow: scroll;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<div id="client-log-header">Client logs (max 100)</div>
|
|
|
|
<div id="client-log">
|
2022-10-12 09:47:13 +00:00
|
|
|
<pre>${
|
|
|
|
clientLogs
|
2022-05-09 12:59:12 +00:00
|
|
|
.map((le) => `[${le.level}] ${le.message}`)
|
2022-10-12 09:47:13 +00:00
|
|
|
.join("\n")
|
|
|
|
}</pre>
|
2022-05-09 12:59:12 +00:00
|
|
|
</div>
|
|
|
|
<div id="server-log-header">Server logs (max 100)</div>
|
|
|
|
<div id="server-log">
|
2022-10-12 09:47:13 +00:00
|
|
|
<pre>${
|
|
|
|
serverLogs
|
2022-05-09 12:59:12 +00:00
|
|
|
.map((le) => `[${le.level}] ${le.message}`)
|
2022-10-12 09:47:13 +00:00
|
|
|
.join("\n")
|
|
|
|
}</pre>
|
2022-05-09 12:59:12 +00:00
|
|
|
</div>`,
|
|
|
|
`
|
|
|
|
var clientDiv = document.getElementById("client-log");
|
|
|
|
clientDiv.scrollTop = clientDiv.scrollHeight;
|
|
|
|
var serverDiv = document.getElementById("server-log");
|
|
|
|
serverDiv.scrollTop = serverDiv.scrollHeight;
|
2022-05-11 18:10:45 +00:00
|
|
|
if(window.reloadInterval) {
|
|
|
|
clearInterval(window.reloadInterval);
|
|
|
|
}
|
|
|
|
window.reloadInterval = setInterval(() => {
|
|
|
|
sendEvent("log:reload");
|
|
|
|
}, 1000);
|
2022-10-12 09:47:13 +00:00
|
|
|
`,
|
2022-05-09 12:59:12 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function hideBhsCommand() {
|
2022-09-30 15:06:12 +00:00
|
|
|
await hidePanel("bhs");
|
2022-05-09 12:59:12 +00:00
|
|
|
}
|