yarn-spinner-runner-ts
Version:
TypeScript parser, compiler, and runtime for Yarn Spinner 3.x with React adapter [NPM package](https://www.npmjs.com/package/yarn-spinner-runner-ts)
77 lines (76 loc) • 1.58 kB
TypeScript
export type Position = {
line: number;
column: number;
};
export interface NodeHeaderMap {
[key: string]: string;
}
export interface YarnDocument {
type: "Document";
enums: EnumDefinition[];
nodes: YarnNode[];
}
export interface EnumDefinition {
type: "Enum";
name: string;
cases: string[];
}
export interface YarnNode {
type: "Node";
title: string;
headers: NodeHeaderMap;
nodeTags?: string[];
when?: string[];
css?: string;
body: Statement[];
}
export type Statement = Line | Command | OptionGroup | IfBlock | OnceBlock | Jump | Detour | EnumBlock;
import type { MarkupParseResult } from "../markup/types.js";
export interface Line {
type: "Line";
speaker?: string;
text: string;
tags?: string[];
markup?: MarkupParseResult;
}
export interface Command {
type: "Command";
content: string;
}
export interface Jump {
type: "Jump";
target: string;
}
export interface Detour {
type: "Detour";
target: string;
}
export interface OptionGroup {
type: "OptionGroup";
options: Option[];
}
export interface Option {
type: "Option";
text: string;
body: Statement[];
tags?: string[];
css?: string;
markup?: MarkupParseResult;
condition?: string;
}
export interface IfBlock {
type: "If";
branches: Array<{
condition: string | null;
body: Statement[];
}>;
}
export interface OnceBlock {
type: "Once";
body: Statement[];
}
export interface EnumBlock {
type: "Enum";
name: string;
cases: string[];
}