yarnspinner2js
Version:
Converts a Yarn Spinner script string to a js object
70 lines (56 loc) • 1.04 kB
TypeScript
interface Settings {
ignoreHeaderParameters?: string[]
normalizeText?: boolean
}
interface Node {
title: string
parameters: NodeParameters
body: Line[]
}
interface NodeParameters {
[key: string]: string
}
type Line = OptionsBlock | Speech | ifBlock | Variable | Jump | Command
interface Speech {
type: "speech"
name: string
text: string
condition: string
id: string
}
interface Option {
type: "option"
text: string
body: Line[]
condition: string
id: string
}
interface OptionsBlock {
type: "options-block"
options: Option[]
}
interface ifBlockItem {
type: "if-block-item"
condition: string
body: Line[]
}
interface ifBlock {
type: "if-block"
items: ifBlockItem[]
}
interface Variable {
type: "declare" | "set"
name: string
value: string
}
interface Jump {
type: "jump"
to: string
}
interface Command {
type: "command"
name: string
parameters: string[]
}
declare function parseYarnSpinner(yarnRaw: string, settings?: Settings): Node[];
export { parseYarnSpinner };