diff --git a/packages/plugos/environments/node_worker.ts b/packages/plugos/environments/node_worker.ts index a15fd90..6993e4d 100644 --- a/packages/plugos/environments/node_worker.ts +++ b/packages/plugos/environments/node_worker.ts @@ -123,3 +123,7 @@ parentPort.on("message", (data: any) => { } }); }); + +process.on("uncaughtException", (e) => { + console.error("Uncaught error", e); +}); diff --git a/packages/plugs/core/core.plug.yaml b/packages/plugs/core/core.plug.yaml index 1bc1787..91c1887 100644 --- a/packages/plugs/core/core.plug.yaml +++ b/packages/plugs/core/core.plug.yaml @@ -105,6 +105,8 @@ functions: name: "Debug: Show Logs" key: "Ctrl-Alt-l" mac: "Cmd-Alt-l" + events: + - log:reload hideBhsCommand: path: ./debug.ts:hideBhsCommand command: diff --git a/packages/plugs/core/debug.ts b/packages/plugs/core/debug.ts index 217b7a0..38905bf 100644 --- a/packages/plugs/core/debug.ts +++ b/packages/plugs/core/debug.ts @@ -73,6 +73,12 @@ export async function showLogsCommand() { 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); ` ); } diff --git a/packages/web/components/panel.tsx b/packages/web/components/panel.tsx index 89be8c8..acd2981 100644 --- a/packages/web/components/panel.tsx +++ b/packages/web/components/panel.tsx @@ -1,15 +1,20 @@ import { useEffect, useRef } from "react"; // @ts-ignore import iframeHtml from "bundle-text:./panel.html"; +import { System } from "@plugos/plugos/system"; +import { SilverBulletHooks } from "@silverbulletmd/common/manifest"; +import { Editor } from "../editor"; export function Panel({ html, script, flex, + editor, }: { html: string; script?: string; flex: number; + editor: Editor; }) { const iFrameRef = useRef(null); useEffect(() => { @@ -40,7 +45,9 @@ export function Panel({ } let data = evt.data; if (!data) return; - console.log("Got message from panel", data); + if (data.type === "event") { + editor.dispatchAppEvent(data.name, data.args); + } }; window.addEventListener("message", messageListener); return () => { diff --git a/packages/web/components/panel_page.ts b/packages/web/components/panel_page.ts index 4465777..2fe1f1e 100644 --- a/packages/web/components/panel_page.ts +++ b/packages/web/components/panel_page.ts @@ -1,3 +1,8 @@ +declare global { + function syscall(name: string, ...args: any[]): Promise; + // function require(moduleName: string): any; +} + window.addEventListener("message", (message) => { const data = message.data; switch (data.type) { @@ -14,11 +19,12 @@ window.addEventListener("message", (message) => { } }); -function sendEvent(data: any) { +function sendEvent(name: string, ...args: any[]) { window.parent.postMessage( { type: "event", - data: data, + name, + args, }, "*" ); diff --git a/packages/web/editor.tsx b/packages/web/editor.tsx index f73936b..cec57bb 100644 --- a/packages/web/editor.tsx +++ b/packages/web/editor.tsx @@ -642,6 +642,7 @@ export class Editor { html={viewState.lhsHTML} script={viewState.lhsScript} flex={viewState.showLHS} + editor={editor} /> )}
@@ -650,6 +651,7 @@ export class Editor { html={viewState.rhsHTML} script={viewState.rhsScript} flex={viewState.showRHS} + editor={editor} /> )}
@@ -659,6 +661,7 @@ export class Editor { html={viewState.bhsHTML} script={viewState.bhsScript} flex={1} + editor={editor} /> )} diff --git a/packages/web/styles/editor.scss b/packages/web/styles/editor.scss index 8f45a18..496d906 100644 --- a/packages/web/styles/editor.scss +++ b/packages/web/styles/editor.scss @@ -110,7 +110,8 @@ color: #038138; } - .string,.string2 { + .string, + .string2 { color: #440377; } @@ -118,7 +119,6 @@ // background: black; // border-radius: 3px; //} - } .meta { @@ -140,6 +140,10 @@ font-weight: 900; } + .link { + cursor: pointer; + } + .link:not(.meta, .url) { color: #0330cb; text-decoration: underline; @@ -152,6 +156,7 @@ .url:not(.link) { color: #0330cb; text-decoration: underline; + cursor: pointer; } .atom { @@ -160,18 +165,15 @@ .wiki-link-page { color: #0330cb; - background-color: rgba(77,141,255,0.07); + background-color: rgba(77, 141, 255, 0.07); border-radius: 5px; padding: 0 5px; - //text-decoration: underline; + cursor: pointer; } .wiki-link { color: #a8abbd; - //background-color: rgba(77,141,255,0.07); } - - // Indentation of follow-up lines @mixin lineOverflow($baseIndent) { text-indent: -1 * ($baseIndent + 2ch);