import { Emitter } from 'mitt'; import { FormItem, LockState, Pen } from '../pen'; import { Options } from '../options'; import { Theme } from '../theme'; import { Point } from '../point'; import { Rect } from '../rect'; import { Event, Trigger } from '../event'; export interface Meta2dData { pens: Pen[]; x: number; y: number; scale: number; origin: Point; center: Point; locked?: LockState; websocket?: string; mqtt?: string; mqttOptions?: { clientId?: string; username?: string; password?: string; customClientId?: boolean; }; mqttTopics?: string; websocketProtocols?: string | string[]; background?: string; globalAlpha?: number; socketCbJs?: string; initJs?: string; grid?: boolean; gridColor?: string; gridSize?: number; gridRotate?: number; rule?: boolean; ruleColor?: string; fromArrow?: string; toArrow?: string; lineAnimateDraws?: { [key: string]: string; }; lineWidth?: number; lineColor?: string; color?: string; textColor?: string; penBackground?: string; paths?: { [key: string]: string; }; bkImage?: string; http?: string; httpTimeInterval?: number; httpHeaders?: HeadersInit; version?: string; id?: string; _id?: string; https?: HttpOptions[]; width?: number; height?: number; networkInterval?: number; networks?: Network[]; iot?: Iot; sqls?: Sql[]; iconUrls?: string[]; mockData?: Function; name?: string; enableMock?: boolean; minScale?: number; maxScale?: number; template?: string; cancelFirstConnect?: boolean; component?: boolean; theme?: string; themeOnlyCanvas?: boolean; smoothNum?: number; triggers?: Trigger[]; dataPoints?: string[]; dataset?: { devices?: DataMock[]; }; dataEvents?: Event[]; fits?: Fit[]; disableTranslate?: boolean; disableScale?: boolean; asyncTranslate?: boolean; } export interface Fit { id?: string; name?: string; x?: number; y?: number; ex?: number; ey?: number; width?: number; height?: number; children?: string[]; active?: boolean; left?: boolean; right?: boolean; top?: boolean; bottom?: boolean; leftValue?: number; rightValue?: number; topValue?: number; bottomValue?: number; } export interface DataMock { id: string; label?: string; mock?: string; type?: string; enableMock?: boolean; } export interface Network { name?: string; protocol?: 'mqtt' | 'websocket' | 'http' | 'iot' | 'sql' | 'ADIIOT' | 'SSE'; type?: string; url?: string; protocols?: string; topics?: string; options?: { clientId?: string; username?: string; password?: string; customClientId?: boolean; }; headers?: any; method?: string; body?: any; withCredentials?: boolean; data?: Network; interval?: number; times?: number; index?: number; devices?: any[]; dbId?: string; sql?: string; enable?: boolean; once?: boolean; socketCbJs?: string; socketFn?: Function; children?: any[]; } export interface Iot { protocol?: 'mqtt' | 'websocket'; url?: string; host?: string; devices?: { deviceId: string; properties: string[]; token: string; }[]; list?: { label: string; key: string; }[]; tree?: any; token?: string; enable?: boolean; room?: string; computes?: any[]; interval?: any; times?: number; } export interface Sql { interval?: number; sql?: string; dbId?: string; dbType?: string; name?: string; bindId?: string; index?: number; method?: string; pageSize?: number; current?: number; keys?: string[]; enable?: boolean; } export interface HttpOptions { http?: string; httpTimeInterval?: number; httpHeaders?: HeadersInit; method?: string; body?: BodyInit | null; times?: number; } export declare enum EditType { Add = 0, Update = 1, Delete = 2, Replace = 3 } export interface EditAction { type?: EditType; initPens?: Pen[]; pens?: Pen[]; step?: number; origin?: Point; scale?: number; } export interface Meta2dStore { id: string; data: Meta2dData; pens: { [key: string]: Pen; }; histories?: EditAction[]; historyIndex?: number; path2dMap: WeakMap; animateMap: WeakMap; bindDatas: { [key: string]: { id: string; formItem: FormItem; }[]; }; bind?: { [key: string]: { id: string; key: string; }[]; }; active?: Pen[]; hover?: Pen; lastHover?: Pen; hoverContainer?: Pen; lastHoverContainer?: Pen; activeAnchor?: Point; hoverAnchor?: Point; pointAt?: Point; pointAtIndex?: number; animates: Set; options: Options; theme: Theme; emitter: Emitter; dpiRatio?: number; clipboard?: Meta2dClipboard; patchFlagsBackground?: boolean; patchFlagsTop?: boolean; bkImg?: HTMLImageElement; fillWorldTextRect?: boolean; cacheDatas?: { data: Meta2dData; }[]; patchFlagsLast?: boolean; messageEvents?: { [key: string]: { pen: Pen; event: Event; }[]; }; templatePens?: { [key: string]: Pen; }; sameTemplate?: boolean; lastScale?: number; pensNetwork?: { [key: string]: { url?: string; method?: string; headers?: any; body?: any; }; }; globalTriggers?: { [key: string]: Trigger[]; }; styles?: any; } export interface Meta2dClipboard { meta2d?: boolean; pens: Pen[]; origin: Point; scale: number; offset?: number; page: string; initRect?: Rect; pos?: Point; mousePos?: Point; } export declare const createStore: () => Meta2dStore; export declare const useStore: (id?: string) => Meta2dStore; export declare const clearStore: (store: Meta2dStore, template?: string) => void;