import React from 'react'; import { AdjTable, Transform, NodeType, LinkDirection, LinkType, GLinkDetail, GraphType } from './graphInterface'; export declare type AnyFunction = (...args: any[]) => any; export declare type DeepReadonly = { readonly [P in keyof T]: T[P] extends AnyFunction ? T[P] : T[P] extends ReadonlySet ? ReadonlySet : T[P] extends ReadonlyMap ? ReadonlyMap : T[P] extends Set ? ReadonlySet> : T[P] extends Map ? ReadonlyMap> : T[P] extends Array ? ReadonlyArray> : T[P] extends string | boolean | number | Symbol ? T[P] : DeepReadonly; }; export interface Patch { op: 'replace' | 'remove' | 'add'; path: PropertyKey[]; value?: any; } export interface Flags { /**表示选中 */ select: boolean; /**高亮 */ hselect: boolean; /**表示是人为添加 */ isMan: boolean; /**目前感觉没什么用,表示是否为新添加的节点,但在后续处理中,也没有用到 */ isNew: boolean; /**处于锁定状态 */ lock: boolean; /**强调的状态 */ emphasis: boolean; } export declare type GraphChangeEvent = { trigger: 'init' | 'edit' | 'patch' | 'backSync'; /**一个数字版本号,每次图有变更事件,这个版本号都会更新 */ version: number; cleared: boolean; /**表示图的缩放等视图变化 */ viewChanged?: boolean; /**图的数据变化 */ dataChanged?: boolean; /**图选择状态的变化 */ selectedChanged?: boolean; /**表示有哪些类型的flag发生了变化 */ flagsChanged?: Flags; /** * 当trigger为patch时,表示是否为正向的patch,即redo */ isChangesPatches?: boolean; /**数据被修改的patches */ patches?: { changesPatches: Patch[]; inversePatches: Patch[]; }; animateEffect: any; }; export declare type NodeTag = { cnt: number; hasLike: boolean; priority: number; /** * 标签底色 */ fill: string; /** * 标签id */ id: string; /** * 标签名称 */ label: string; /** * 固定值 */ shareRange: number; /** * type=user会显示右侧,type=sys会显示左侧 */ type: 'user' | 'sys'; }; interface TaskStatus { resultId: number; status: number; } interface TaskResult { id: number; taskId: number; executor?: string; duration?: number; match?: number; start?: number; complete?: number; total?: number; pageSize?: number; pageIndex?: number; startTime?: number; endTime?: number; vector?: { id: string; title: string; checked: boolean; }[]; tableHeader?: string[]; tableData?: Array<[number, string]>; } interface GNode_Base { x: number; y: number; original: boolean; id: string; /** * 获取一个节点的最上的父节点 * 如一个节点被合并了,则父节点就是他的合并节点。档案下面的节点的父节点都是这个档案节点。 * 就是说,这个节点被哪个节点包含了。 * 如果没有,则返回当前节点的id */ getTopNodeId(): string; readonly isDefaultZero: void; } interface GNode_Normal extends GNode_Base { readonly type: NodeType.NORMAL; avatar: string; mergeId?: string; /**如果处于下钻状态,是否已经被钻出 */ drilledOut?: boolean; tags: NodeTag[]; dataType: string; visual: boolean; archiveId?: string; readonly mergeNode: GNode_Merge | undefined; readonly archiveNode: GNode_Archive | undefined; readonly isVisual: void; } interface GNode_Merge extends GNode_Base { readonly type: NodeType.MERGE; readonly mergeNodeIds: ReadonlySet; readonly subNodes: void; addMergeNode(node: string | GNode_Normal | GNode_Archive): void; removeMergeNode(node: string | GNode_Normal | GNode_Archive): void; } interface GNode_Archive extends GNode_Base { type: NodeType.ARCHIVE; avatar: string; mergeId?: string; dataType: string; readonly mergeNode: GNode_Merge | undefined; readonly subNodes: GNode_Normal[]; readonly subNodeIds: ReadonlySet; readonly subLinkDetailIds: ReadonlySet; readonly tags: ReadonlyArray; readonly mainNode: GNode_Normal; onIter(expand: boolean, force: boolean): void; } export declare type LinkInfoConf = { /**key为label,value为数量 */ labelMap: Map; /**key为linkDetail.dataType,value为数量,这个其实没用,但老版本用到了,为了向下兼容,也一起计算一下 */ s2t: boolean; t2s: boolean; }; interface GLink_Base { readonly sourceNode: GNode; readonly targetNode: GNode; label: string; d: LinkDirection.NONE; labelMap: LinkInfoConf['labelMap']; } interface GLink_Normal extends GLink_Base { readonly type: LinkType.NORMAL; isUnderArchive: boolean; readonly isUnderMerge: void; readonly mergeLinkId: void; } interface GLink_Merge extends GLink_Base { readonly type: LinkType.MERGE; readonly isOnlyDrill: void; readonly mergeLinks: ReadonlySet; } interface GLink_Drill extends GLink_Base { readonly type: LinkType.DRILL; readonly isDashed: void; readonly isDrilled: void; readonly isUnderMerge: void; } /** * 节点的交叉类型 */ export declare type GNode = GNode_Normal | GNode_Merge | GNode_Archive; /** * 边的交叉类型 */ export declare type GLink = GLink_Normal | GLink_Merge | GLink_Drill; export interface Graph { /** * 可以在图中进行任意存储的数据,通用的业务逻辑并不处理这个数据 */ extraData: any; readonly id: string; readonly isDrafting: boolean; readonly transform: Transform; /**获取邻接表 */ readonly adjTable: DeepReadonly; readonly isTemp: boolean; readonly isDirty: boolean; readonly selectedNodesAll: DeepReadonly; selectedNodesCount: number; readonly selectedLinksAll: DeepReadonly; readonly selectedNodes: DeepReadonly; readonly selectedLinksCount: number; readonly selectedLinks: DeepReadonly; getNodesByFlag(flagType: keyof Flags): ReadonlySet; getLinksByFlag(flagType: keyof Flags): ReadonlySet; linkDetailIter(): IterableIterator>; nodeIter(): IterableIterator>; linkIter(): IterableIterator>; clearAnimateEffect: void; saved(changed?: { newId?: string; newName?: string; newType?: GraphType; }): void; } export declare type AppInitConfig = { /**配置图区常驻组件 */ permanentComponent?: { component: React.JSXElementConstructor; position: 'top' | 'left'; size?: number; }; /**配置内置的功能 */ buildinConfig?: { cmdConfs?: { [cmdKey: string]: boolean; }; cmdOthers?: boolean; }; disableWidgets?: string[]; /** * 禁用图区的前进后退功能 * 通过这个可以增加图区的性能,降低内存消耗 */ disableUndoRedo?: boolean; }; declare class AppBaseCls { appInitConfig?: AppInitConfig; readonly graph: Graph; getAppConfigValue(key: string): any; getAppConfigValueAsOneType(key: string): string; /**执行命令 */ execCmd(cmdKey: string, cmdArgs: any): Promise; /**模拟一个命令的点击 */ clickCmd(cmdKey: string, index?: number, e?: MouseEvent): void; /**展示命令的组件 */ showCmdComponent(cmdKey: string, props: any): void; /**轻应用初始化时调用 */ protected onInit(): void; /**图区数据变化时调用 */ onGraphChange(e: GraphChangeEvent): void; taskRun(taskKey: string, params: { [key: string]: any; }, globalProps?: { [key: string]: any; }): Promise; taskGetStatus(taskId: string): Promise; taskGetResult(taskId: string): Promise; backendRequest(file: string, func: string, params?: { [key: string]: string | number; }): Promise; } export declare const AppBase: typeof AppBaseCls; export declare type PermanentComponentProps = { app: AppBaseCls; graph: Graph; }; interface TaskResultCls { app: AppBaseCls; taskId: string; } export declare const TaskResult: React.JSXElementConstructor; export declare type TaskResultComponentProps = TaskResultCls; export {};