ttrpg-tools/src/yarn-spinner/runtime/results.ts

42 lines
1.1 KiB
TypeScript

import type { MarkupParseResult } from "../markup/types";
/**
* Result emitted when the dialogue produces text/dialogue.
*/
export type TextResult = {
type: "text";
text: string;
speaker?: string;
tags?: string[];
markup?: MarkupParseResult;
nodeCss?: string; // Node-level CSS from &css{} header
scene?: string; // Scene name from node header
isDialogueEnd: boolean;
};
/**
* Result emitted when the dialogue presents options to the user.
*/
export type OptionsResult = {
type: "options";
options: { text: string; tags?: string[]; css?: string; markup?: MarkupParseResult }[];
nodeCss?: string; // Node-level CSS from &css{} header
scene?: string; // Scene name from node header
isDialogueEnd: boolean;
};
/**
* Result emitted when the dialogue executes a command.
*/
export type CommandResult = {
type: "command";
command: string;
isDialogueEnd: boolean;
};
/**
* Union type of all possible runtime results emitted by the YarnRunner.
*/
export type RuntimeResult = TextResult | OptionsResult | CommandResult;