import { CNodePropsTypeEnum, SlotRenderType } from '../const/schema'; import { CSSType, DEV_CONFIG_KEY } from './base'; import { CPage } from '../Page'; import { CNode } from '../Page/RootNode/Node'; export type NormalPropType = string | boolean | number | Record | undefined | null; type IValue = `${SlotRenderType}`; export type RenderPropType = { type: CNodePropsTypeEnum.SLOT | `${CNodePropsTypeEnum.SLOT}`; params?: string[]; renderType: SlotRenderType | IValue; value: CNodeDataType | CNodeDataType[]; }; export type JSExpressionPropType = { type: CNodePropsTypeEnum.EXPRESSION | `${CNodePropsTypeEnum.EXPRESSION}`; value: string; }; export type TBaseFunction = { /** TODO: 编辑器使,存储函数的源码,用于编辑器使用 */ sourceCode?: string; /** 编辑器使用 */ tsType?: string; /** 可直接在浏览器运行的代码 */ value: string; /** 函数名称 */ name?: string; }; export type FunctionPropType = { type: CNodePropsTypeEnum.FUNCTION | `${CNodePropsTypeEnum.FUNCTION}`; } & TBaseFunction; export declare enum LogicType { JUMP_LINK = "JUMP_LINK", RUN_CODE = "RUN_CODE", REQUEST_API = "REQUEST_API", /** 调用节点方法 */ CALL_NODE_METHOD = "CALL_NODE_METHOD", ASSIGN_VALUE = "ASSIGN_VALUE" } export type TDynamicValue = string | number | JSExpressionPropType | FunctionPropType; export type TBaseActionNode = { id: string; next?: string | number; }; /** 存储开发中的一些临时状态 */ export type TActionFlowDevConfig = { pageModel: CPage; currentNode: CNode; defaultSetterMap: Record; }; export type TLogicJumpLinkItem = { type: LogicType.JUMP_LINK | `${LogicType.JUMP_LINK}`; link: TDynamicValue; [DEV_CONFIG_KEY]?: TActionFlowDevConfig; } & TBaseActionNode; /** 🌧️函数类型 */ export type TLogicRunCodeItem = { /** 函数最好有返回值 */ type: LogicType.RUN_CODE | `${LogicType.RUN_CODE}`; [DEV_CONFIG_KEY]?: TActionFlowDevConfig; } & TBaseFunction & TBaseActionNode; export type TLogicCallNodeMethodItem = { type: LogicType.CALL_NODE_METHOD | `${LogicType.CALL_NODE_METHOD}`; nodeId: string; methodName: string; args?: TDynamicValue[]; /** 返回值的变量名 */ returnVarName?: string; [DEV_CONFIG_KEY]?: TActionFlowDevConfig; } & TBaseActionNode; export type TLogicRequestAPIItem = { type: LogicType.REQUEST_API | `${LogicType.REQUEST_API}`; /** 直接获取具体的 API path, 完整的 host, 特殊场景使用,一般使用 apiId, 可以控制环境切换 */ apiPath: TDynamicValue; /** 默认 get */ method?: 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE'; query?: Record; body?: Record; header?: Record; afterSuccessResponse?: TLogicItemHandlerFlow; afterFailedResponse?: TLogicItemHandlerFlow; /** 响应变量名 */ responseVarName?: string; /** 额外的数据 */ extra?: Record; [DEV_CONFIG_KEY]?: TActionFlowDevConfig; } & TBaseActionNode; export declare enum AssignValueType { /** 组件内的局部变量,没有响应性, 只在当前的上下文中有效 */ MEMORY = "MEMORY", STATE = "STATE" } export type TAssignValueType = `${AssignValueType}`; export type TargetValueNameObject = { nodeId: string; keyPath: string; }; /** 赋值操作 */ export type TLogicAssignValueItem = { type: LogicType.ASSIGN_VALUE | `${LogicType.ASSIGN_VALUE}`; valueType: AssignValueType | TAssignValueType; currentValue: TDynamicValue; /** 如果是 STATE 类型需要 nodeId, 否则只用填 string */ targetValueName?: TargetValueNameObject | string; [DEV_CONFIG_KEY]?: TActionFlowDevConfig; } & TBaseActionNode; export type TLogicItemHandlerFlow = (TLogicJumpLinkItem | TLogicRunCodeItem | TLogicRequestAPIItem | TLogicCallNodeMethodItem | TLogicAssignValueItem)[]; export type TActionLogicItem = { type: CNodePropsTypeEnum.ACTION | `${CNodePropsTypeEnum.ACTION}`; handler: TLogicItemHandlerFlow; /** 调用方传入的参数列表 */ params?: string[]; }; export type SpecialProp = RenderPropType | JSExpressionPropType | FunctionPropType | TActionLogicItem; export type CPropDataType = NormalPropType | SpecialProp | CPropObjDataType; export type CPropObjDataType = { [key: string]: CPropDataType | CPropDataType[] | Record; }; export declare const PropsDataStructDescribe: any; export declare const DevKey: string[]; export type ClassNameType = { name: string; status?: JSExpressionPropType; }; /** 支持注入到运行时组件的引擎内置变量名列表 */ export declare enum ENGEnvEnum { COMPONENTS = "COMPONENTS" } export type CNodeDataType = { id?: string; title?: string; componentName: string; /** 节点类型 */ type?: 'dynamic' | 'normal'; /** 所有的 props 的 value 需要支持表达式 $$context */ props?: CPropObjDataType; state?: Record; /** 当前节点的事件处理逻辑,会被压缩为 prop 传入 */ eventListener?: { name: string; /** 处理程序 */ func: TActionLogicItem; }[]; nodeName?: string; children?: (string | CNodeDataType)[]; /** * only used in dev mode, if you are run in prod, this key will be undefined * * @type {Record} */ configure?: { /** 由于一个 prop 可能会有多个设置器,这里用来存储当前使用的那个设置器 */ propsSetter?: Record; advanceSetter?: Record; /** 开发模式下中的临时状态存储 */ devState?: { condition?: boolean | JSExpressionPropType; props?: CPropObjDataType; }; /** 当前节点是否时容器节点 */ isContainer?: boolean; }; classNames?: ClassNameType[]; css?: CSSType; /** css 属性有顺序 */ style?: { property: string; value: JSExpressionPropType | string; }[]; refId?: string; methods?: FunctionPropType[]; loop?: { open: boolean; data: any[] | JSExpressionPropType; forName?: string; forIndex?: string; key?: JSExpressionPropType | string; name?: string; }; /** 需要注入运行时组件的环境变量列表,可以在组件内部通过 props 获取 */ injectEnvList?: (ENGEnvEnum | `${ENGEnvEnum}`)[]; condition?: boolean | JSExpressionPropType; extra?: ExtraT; }; export declare const CNodeDataStructDescribe: any; export {};