import type { Story } from "inkjs"; import type React from "preact/compat"; import type { TransitionStatus } from "react-transition-state"; import type { createPlugin } from "./plugins"; export type SavedGame = { id: string; title: string; steps: number; date: string; gameState: GameState[]; storyData: string; previousStoryData: string | null; }; export type ExportedGame = { savedGame: SavedGame; plugins: Record; }; export type Widget = { type: string; input: Record; output?: Record; }; export type Tag = Array; export type GameState = { id: string; lines: Array>; tags: Record; choices: Array<{ choice: string | Widget | Array; tags: Record; }>; selectedChoice?: number; widgets: Record; }; export type PageProps = { page: string; setPage: (page: string) => void; loading: boolean; }; export type Page = { id: string; title: string; component: "game" | string | ((props: PageProps) => React.ReactNode); }; type SharedSettings = { enableKeyboardInput?: boolean; enableGameScreen?: boolean; defaultTheme?: string; loadStory: () => Promise; defaultSaveName?: (currentState: GameState) => string; stickyTags?: string[]; gameName: string; shortGameName?: string; favicon?: string; autosave?: boolean; widgets?: Record>; pages: Page[]; }; export type IncomingSettings = SharedSettings & { plugins?: Array> | null | undefined>; }; export type Settings = SharedSettings & { plugins: Array; }; export type Toast = { id: string; title: React.ReactNode; description: React.ReactNode; showDelay?: number; hideDelay?: number; autoHide?: boolean; page?: string; }; type PluginToastFn = (currentState: GameState) => Array; type PluginChoiceProps = { context: "game" | "history"; input: Record; output?: Record; onCompletion: ({ output, variables, }: { output?: Record; variables?: Record; }) => void; autoFocus: boolean; disabled: boolean; }; type PluginTextProps = { input: Record; context: "game" | "history" | "screen"; }; type PluginLogProps = { currentState: GameState; location: "header" | "footer"; } | { input: Record; output?: Record; }; type PluginHeaderProps = { context: "game" | "history" | "screen"; currentState: GameState; transitionStatus: TransitionStatus | undefined; }; type PluginKnotProps = { context: "game" | "history" | "screen"; currentState: GameState; transitionStatus: TransitionStatus | undefined; }; type PluginKeyProps = { currentState: GameState; }; type PluginProcessTextLineProps = { line: string; context: "game" | "history" | "choice" | "history-choice" | "screen"; }; type PluginTextLineProps = { children: React.ReactNode; context: "game" | "history" | "choice" | "history-choice" | "screen"; }; type PluginHandleStoryLoadProps = { story: Story; }; export type PluginRegistry = { type: string; export?: () => unknown; import?: (data: unknown) => void; log?: (props: PluginLogProps) => string; toast?: PluginToastFn; page?: (props: PageProps) => React.ReactNode; footer?: (props: PluginKnotProps) => React.ReactNode; text?: (props: PluginTextProps) => React.ReactNode; choice?: (props: PluginChoiceProps) => React.ReactNode; header?: (props: PluginHeaderProps) => React.ReactNode; knot?: (props: PluginKnotProps) => React.ReactNode; nav?: (props: PageProps) => React.ReactNode; preload?: () => Promise; key?: (props: PluginKeyProps) => string | null; processTextLine?: (props: PluginProcessTextLineProps) => string; textLine?: (props: PluginTextLineProps) => React.ReactNode; handleStoryLoad?: (props: PluginHandleStoryLoadProps) => void; }; export {};