@vtj/coder
Version:
VVTJ.PRO 是一个开源的、AI 驱动的 Vue3 企业级应用开发平台,通过 AI 智能体与可视化编排实现高效开发,并支持导出标准 Vue 代码以避免平台锁定。
50 lines (49 loc) • 2.14 kB
TypeScript
import { BlockSchema, MaterialDescription } from '@vtj/core';
/**
* 全局 API 配置:DSL 中 this.$xxx 形式 → Composition API 等价物
*/
export interface GlobalApiConfig {
/** 需要 import 的标识符(如 useAttrs),无则为 null */
composable: string | null;
/** composable 的来源包(如 'vue'、'vue-router') */
from: string;
/** 顶层声明语句(无则不生成) */
declare: string | null;
/** 替换后的名称(this.$attrs → attrs) */
replace: string;
}
/**
* 框架无关的基础全局 API 映射表
* 包含 Vue 原生、vue-router、vue-i18n、@vtj/renderer
* 不含任何 UI 库(element-plus / ant-design-vue 等)
*/
export declare const GLOBAL_API_MAP: Record<string, GlobalApiConfig>;
/**
* UI 库专属全局 API 映射(按包名分组)
* 同名 key 会在运行时覆盖 GLOBAL_API_MAP 中的同名条目
*/
export declare const UI_GLOBAL_API_MAPS: Record<string, Record<string, GlobalApiConfig>>;
/** 已知 UI 库包名列表 */
export declare const UI_PACKAGES: string[];
/**
* 从 componentMap 探测当前激活的 UI 库包名
*/
export declare function detectUIPackage(componentMap: Map<string, MaterialDescription>): string | null;
/**
* 构建有效 API 映射:基础 Map + 当前 UI 库 Map(UI 库覆盖同名 key)
*/
export declare function buildEffectiveApiMap(uiPackage: string | null): Record<string, GlobalApiConfig>;
/**
* 全局 API 检测器
* 走读 DSL 中所有 JSExpression / JSFunction 的 value 字符串
* 识别使用到的 this.$xxx,返回出现的 API 名集合
*/
export declare function detectGlobalApis(dsl: BlockSchema, effectiveMap?: Record<string, GlobalApiConfig>): Set<string>;
/**
* 根据检测到的全局 API 生成顶层声明语句
*/
export declare function generateGlobalApiDeclares(apis: Set<string>, effectiveMap?: Record<string, GlobalApiConfig>): string[];
/**
* 收集全局 API 需要导入的标识符,按来源包分组
*/
export declare function collectGlobalApiImports(apis: Set<string>, effectiveMap?: Record<string, GlobalApiConfig>): Record<string, string[]>;