Compare commits
No commits in common. "da28a739df92c5222d9ea0e19985aa16b8a5eb29" and "c411678db227b134072ebb1bc752bb2fc844c034" have entirely different histories.
da28a739df
...
c411678db2
|
|
@ -13,10 +13,7 @@ export default async function () {
|
|||
if (/up to date/.test(out)) {
|
||||
return "Up to date."
|
||||
} else {
|
||||
setTimeout(() => process.exit(), 500)
|
||||
return {
|
||||
text: "Reloading in 3 seconds...",
|
||||
script: `setTimeout(() => (window as any).location = window.location, 3000)`
|
||||
}
|
||||
setTimeout(() => process.exit(), 1000)
|
||||
return "Restarting in 1 second..."
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// The scrollback shows your history of interacting with the shell.
|
||||
// input, output, etc
|
||||
|
||||
import { scrollback, $$ } from "./dom.js"
|
||||
import { scrollback, $, $$ } from "./dom.js"
|
||||
import { randomId } from "../shared/utils.js"
|
||||
import type { CommandOutput } from "../shared/types.js"
|
||||
|
||||
|
|
@ -123,12 +123,6 @@ function processOutput(output: CommandOutput): ["html" | "text", string] {
|
|||
} else if ("html" in output) {
|
||||
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!)
|
||||
} else {
|
||||
content = JSON.stringify(output)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,7 @@ export type MessageType = "error" | "input" | "output" | "commands" | "save-file
|
|||
| "game:start"
|
||||
| "stream:start" | "stream:end" | "stream:append" | "stream:replace"
|
||||
|
||||
export type CommandOutput = string | string[]
|
||||
| { text: string, script?: string }
|
||||
| { html: string, script?: string }
|
||||
| { script: string }
|
||||
| { game: string }
|
||||
export type CommandOutput = string | string[] | { html: string } | { game: string }
|
||||
|
||||
export type CommandResult = {
|
||||
status: "ok" | "error"
|
||||
|
|
|
|||
|
|
@ -47,11 +47,8 @@ export function processExecOutput(output: string | any): ["ok" | "error", Comman
|
|||
} else if (typeof output === "object") {
|
||||
if (output.error) {
|
||||
return ["error", output.error]
|
||||
} else if (isJSX(output)) {
|
||||
} else if (output.tag && output.props && output.children) {
|
||||
return ["ok", { html: output.toString() }]
|
||||
} else if (output.html && isJSX(output.html)) {
|
||||
output.html = output.html.toString()
|
||||
return ["ok", output]
|
||||
} else {
|
||||
return ["ok", output]
|
||||
}
|
||||
|
|
@ -80,8 +77,4 @@ function errorMessage(error: Error | any): string {
|
|||
let msg = `${error.name}: ${error.message}`
|
||||
if (error.stack) msg += `\n${error.stack}`
|
||||
return msg
|
||||
}
|
||||
|
||||
function isJSX(obj: any): boolean {
|
||||
return 'tag' in obj && 'props' in obj && 'children' in obj
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user