// Export new modular types export * from "./language"; export * from "./question"; /** * 代码运行结果 */ /** * UI 绑定的测试用例(支持编辑) */ export interface UITestCase { id: string | number; label?: string; inputs: { name: string; value: string; }[]; expected: string; } /** * 运行时的测试用例 */ export interface TestCase { id: string | number; input: any[]; // 函数参数列表 expected?: any; // 预期输出 } /** * 单个用例的运行结果 */ export interface TestCaseResult { id: string | number; status: "passed" | "failed" | "error"; input: any[]; output: any; // 实际输出 expected?: any; log?: string; // 该用例执行过程中的 console.log error?: string; // 错误信息 executionTime?: number; } /** * 代码运行结果 */ export interface RunResult { output: string; // 输出内容 error?: string; // 错误信息 executionTime: number; // 执行时间(毫秒) status: "success" | "error" | "timeout"; // 状态 testResults?: TestCaseResult[]; // 新增:结构化测试结果 } /** * 运行策略函数类型 */ export type RunnerStrategy = ( code: string, testCases?: TestCase[], ) => Promise; /** * 编辑器选项 */ export interface SmartCodeEditorOptions { // 容器配置 container: HTMLElement | string; // 编辑器配置 language?: string; // 默认语言 theme?: string; // 主题 value?: string; // 初始代码 readOnly?: boolean; // 只读模式 // 布局配置 showQuestionPanel?: boolean; // 显示试题面板 questionContent?: string; // 试题内容 questionMarkdown?: import("./question").QuestionMarkdownOptions; // Markdown 题目配置 defaultSplitRatio?: number; // 默认分割比例 0-1 // 语言配置 supportedLanguages?: string[]; // 支持的语言列表 enableLanguageSwitch?: boolean; // 允许切换语言 // 运行配置 enableRun?: boolean; // 启用代码运行 disableLocalRun?: boolean; // 禁用本地运行(用于完全托管给外部) customRunner?: ( code: string, language: string, testCases?: TestCase[], ) => Promise; // 自定义运行器 runTimeout?: number; // 运行超时时间(毫秒) enableSubmit?: boolean; // 启用代码提交 // ===== 新增:题目配置 ===== /** 题目完整配置(可选) */ questionConfig?: import("./question").QuestionConfig; /** 自定义语言模板映射(可选,会覆盖 questionConfig) */ languageTemplates?: import("./question").LanguageTemplates; // 回调函数 onChange?: (value: string) => void; onRun?: (result: RunResult) => void; onSubmit?: (code: string, language: string) => void; onLanguageChange?: (language: string) => void; // 智能提示配置 suggestOnTriggerCharacters?: boolean; quickSuggestions?: boolean | object; } /** * Monaco Editor 配置选项 */ export interface MonacoEditorOptions { language?: string; theme?: string; value?: string; readOnly?: boolean; minimap?: { enabled: boolean }; fontSize?: number; lineNumbers?: "on" | "off"; automaticLayout?: boolean; suggestOnTriggerCharacters?: boolean; quickSuggestions?: boolean | object; }