import * as arrow from './arrow' import * as rectangle from './rectangle' import * as circle from './circle' import * as triangle from './triangle' import * as polygon from './polygon' import * as line from './line' import * as text from './text' import * as icon from './icon' import * as image from './image' import { ArrowData } from './arrow' import { RectangleData } from './rectangle' import { CircleData } from './circle' import { TriangleData } from './triangle' import { PolygonData } from './polygon' import { LineData } from './line' import { TextData } from './text' import { IconData } from './icon' import { ImageData } from './image' import { Pos } from '@/utils/math' const _components = { arrow, rectangle, circle, triangle, polygon, line, text, icon, image } export const components = _components as Components export type Components = { [key in keyof typeof _components]: (typeof _components)[key] & { getSnapInfos?: (items: DrawItem) => ComponentSnapInfo[] } } export type ComponentValue = Components[T][K] export type DrawDataItem = { arrow: ArrowData, rectangle: RectangleData, circle: CircleData, triangle: TriangleData, polygon: PolygonData, line: LineData, text: TextData, icon: IconData, image: ImageData, } export type ShapeType = keyof DrawDataItem export type DrawData = { [k in ShapeType]?: DrawDataItem[k][] } export type DrawItem = DrawDataItem[T] export type SnapPoint = Pos & { view?: boolean } export type ComponentSnapInfo = { point: SnapPoint, links: Pos[] linkDirections: Pos[], linkAngle: number[] }