From da28a739df92c5222d9ea0e19985aa16b8a5eb29 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath <2+defunkt@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:28:52 -0700 Subject: [PATCH] run scripts from the backend --- app/nose/bin/update.ts | 7 +++++-- app/src/js/scrollback.ts | 5 ++++- app/src/shared/types.ts | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/nose/bin/update.ts b/app/nose/bin/update.ts index 8ac2a8b..f36e2a3 100644 --- a/app/nose/bin/update.ts +++ b/app/nose/bin/update.ts @@ -13,7 +13,10 @@ export default async function () { if (/up to date/.test(out)) { return "Up to date." } else { - setTimeout(() => process.exit(), 1000) - return "Restarting in 1 second..." + setTimeout(() => process.exit(), 500) + return { + text: "Reloading in 3 seconds...", + script: `setTimeout(() => (window as any).location = window.location, 3000)` + } } } \ No newline at end of file diff --git a/app/src/js/scrollback.ts b/app/src/js/scrollback.ts index 5ca626d..bf4eed6 100644 --- a/app/src/js/scrollback.ts +++ b/app/src/js/scrollback.ts @@ -124,8 +124,11 @@ function processOutput(output: CommandOutput): ["html" | "text", string] { html = true content = output.html if (output.script) eval(output.script) + } else if ("text" in output) { + content = output.text + if (output.script) eval(output.script) } else if ("script" in output) { - eval(output.script) + eval(output.script!) } else { content = JSON.stringify(output) } diff --git a/app/src/shared/types.ts b/app/src/shared/types.ts index ff5bf43..d4c07cc 100644 --- a/app/src/shared/types.ts +++ b/app/src/shared/types.ts @@ -10,7 +10,9 @@ export type MessageType = "error" | "input" | "output" | "commands" | "save-file | "stream:start" | "stream:end" | "stream:append" | "stream:replace" export type CommandOutput = string | string[] - | { html: string, script?: string } | { script: string } + | { text: string, script?: string } + | { html: string, script?: string } + | { script: string } | { game: string } export type CommandResult = {