// src/types.ts import { ReactNode } from "react"; // Language definition export interface Language { code: string; name: string; nativeName?: string; supportsSource?: boolean; supportsTarget?: boolean; progress: number; cardCount: number; } // Translation service provider export interface Provider { id: string; name: string; } // Translation history item export interface TranslationHistoryItem { id: number; text: string; translation: string; from: string; to: string; provider: string; timestamp: number; } // Response from translation API export interface TranslationResponse { translation: string; source: string; target: string; provider: string; characters: number; } // Error response from API export interface ErrorResponse { error: string; details?: any; } // Props for components export interface LanguageSelectorProps { value: string; onChange: (value: string) => void; languages: Language[]; showCharCount?: boolean; charCount?: number; showCopyButton?: boolean; onCopy?: () => void; setMore?: (t: { text: string; lang: string }) => void; text?: string; disabled?: boolean; } export interface TextAreaProps { value: string; onChange: (value: string) => void; lang?: string; transliteration?: TransliterationOptions; placeholder: string; readOnly?: boolean; } export interface ProviderSelectorProps { value: string; onChange: (value: string) => void; providers: Provider[]; } export interface TranslationHistoryProps { items: TranslationHistoryItem[]; languages: Language[]; providers: Provider[]; } export interface TransliterationOptions extends Language { scripts: TransliterationLanguage[]; } export interface TransliterationLanguage extends Language { toScripts: Language[]; } export type Meaning = { pos: string; // part of speech; meaning: string[]; etymology: string; references?: any; }; export type Prompts = { translate: string; }; export type AnalyzeRes = { word: string; syllables: string[]; ipa: string; pos: POS; }; type POS = string; export type WordData = { spelling: string; lang: string; ipa: string; meanings: Meaning[]; references?: any; }; // app proper // Mock data for the app export type UserStats = { streakDays: number; cardsLearned: number; minutesStudied: number; dueToday: number; }; export type UserData = { id: number; name: string; stats: UserStats; }; export type DeckResponse = { lesson: { name: string; description: string; language: string; id: number; cardCount: number; }; cards: CardResponse[]; }; export interface SRSProgress { repetitionCount: number; easeFactor: number; interval: number; nextReviewDate: number; lastReviewed: number; isMastered: boolean; } export interface ReviewResult { cardId: number; accuracy: number; reviewTime: number; } export type CardResponse = { id: number; text: string; note: string | null; progress: SRSProgress; expression: { id: number; ipa: Array<{ ipa: string; tags: string[] }>; spelling: string; type: ExpressionType; syllables: number | null; confidence: number; lang: string; frequency: number; prosody: any; senses: Sense[]; isBookmarked: boolean; }; }; export type Sense = { etymology: string; pos: string; forms: Array<{ form: string; tags: string[] }>; related: any; senses: Array<{ glosses: string[]; links: Array<[string, string]> }>; }; export type SyllableProsody = { isLong: boolean; tone: number; lang: string }; export interface Deck { id: number; name: string; description: string; cardCount: number; dueCards: number; progress: number; language: string; } export interface Card { id: number; front: ReactNode; back: ReactNode; language: string; difficulty: number; nextReview: Date; interval: number; easeFactor: number; } export type ExpressionType = "word" | "expression" | "syllable"; export type ExpressionSearchParams = { lang?: string; spelling?: string; pos?: string; syllables?: { num: number; sign: string }; // ">" | "<" | "=" frequency?: { num: number; above: boolean }; type?: ExpressionType; }; export type SyllableRes = { input: string; result: SyllableToken[] }; export type SyllableToken = [IPACharacter, SyllablePart]; export type IPACharacter = string; // one char mostly export enum SyllablePart { INITIAL = "#", OTHER_ONSET = "C", VOWEL = "V", OTHER_VOWEL = "v", FINAL_VOWEL = ">", OTHER_OFFSET = "c", CODA = "$", } export type ProsodyWordDB = Omit & { syllables: string; }; export interface ProsodyWord { id: number; spelling: string; frequency: number | null; lang: string; ipa: string; tags: string; syllables: ProsodySyllable[]; notes: string | null; } // -o is spelling, -/ is ipa export type ProsodySyllable = { ipa: string; spelling: string; long: boolean; notes: string | null; onseto: string; onset: string; nucleuso: string; nucleus: string; codao: string; coda: string; rhymeo: string; rhyme: string; tonen: string; tonenm: string; tone: string; };