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

42 lines
1.1 KiB
TypeScript
Raw Normal View History

2026-03-02 16:22:54 +08:00
import type { MarkupParseResult } from "../markup/types";
2026-03-03 18:29:59 +08:00
/**
* Result emitted when the dialogue produces text/dialogue.
*/
2026-03-02 16:22:54 +08:00
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;
};
2026-03-03 18:29:59 +08:00
/**
* Result emitted when the dialogue presents options to the user.
*/
2026-03-02 16:22:54 +08:00
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;
};
2026-03-03 18:29:59 +08:00
/**
* Result emitted when the dialogue executes a command.
*/
2026-03-02 16:22:54 +08:00
export type CommandResult = {
type: "command";
command: string;
isDialogueEnd: boolean;
};
2026-03-03 18:29:59 +08:00
/**
* Union type of all possible runtime results emitted by the YarnRunner.
*/
2026-03-02 16:22:54 +08:00
export type RuntimeResult = TextResult | OptionsResult | CommandResult;