variable-layout-config.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { Scope } from '@flowgram.ai/variable-core';
  2. import { VariableEngine } from '@flowgram.ai/variable-core';
  3. import { FlowNodeEntity, FlowDocument } from '@flowgram.ai/document';
  4. import { type FlowNodeScope, type ScopeChainNode } from './types';
  5. interface TransformerContext {
  6. scope: FlowNodeScope;
  7. document: FlowDocument;
  8. variableEngine: VariableEngine;
  9. }
  10. export interface VariableLayoutConfig {
  11. /**
  12. * 节点的子节点输出变量,不能被后续节点所访问,用于固定布局场景
  13. * @param node
  14. * @returns
  15. */
  16. isNodeChildrenPrivate?: (node: ScopeChainNode) => boolean;
  17. /**
  18. * 用于自由画布场景,部分场景通过连线或者其他交互形式来表达节点之间的父子关系,需要可配置化
  19. */
  20. getFreeChildren?: (node: FlowNodeEntity) => FlowNodeEntity[];
  21. getFreeParent?: (node: FlowNodeEntity) => FlowNodeEntity | undefined;
  22. /**
  23. * 对依赖作用域进行微调
  24. */
  25. transformDeps?: (scopes: Scope[], ctx: TransformerContext) => Scope[];
  26. /**
  27. * 对依赖作用域进行微调
  28. */
  29. transformCovers?: (scopes: Scope[], ctx: TransformerContext) => Scope[];
  30. }
  31. export const VariableLayoutConfig = Symbol('VariableLayoutConfig');