nose-pluto/src/shared/types.ts

79 lines
1.5 KiB
TypeScript

export type Message =
| ErrorMessage
| InputMessage
| OutputMessage
| SaveFileMessage
| SessionStartMessage
| SessionUpdateMessage
| GameStartMessage
| StreamMessage
| CommandsMessage
export type CommandOutput = string | string[]
| { text: string, script?: string }
| { html: string, script?: string }
| { script: string }
| { game: string }
export type CommandResult = {
status: "ok" | "error"
output: CommandOutput
}
export type ErrorMessage = {
type: "error"
data: string
}
export type CommandsMessage = {
type: "commands"
data: string[]
}
export type OutputMessage = {
type: "output"
id?: string
data: CommandResult
}
export type InputMessage = {
type: "input"
id: string
session: string
data: CommandResult | CommandOutput
}
export type SaveFileMessage = {
type: "save-file"
id: string
session: string
data: CommandResult | CommandOutput
}
export type SessionStartMessage = {
type: "session:start"
data: {
NOSE_DIR: string
project: string
cwd: string
mode: string
}
}
export type SessionUpdateMessage = {
type: "session:update"
data: Record<string, string>
}
export type GameStartMessage = {
type: "game:start"
id: string
data: string
}
export type StreamMessage = {
type: "stream:start" | "stream:end" | "stream:append" | "stream:replace"
id: string
session: string
data: CommandOutput
}