@flowgram.ai/minimap-plugin 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,128 @@
1
+ import { CSSProperties, FC } from 'react';
2
+ import { Rectangle, IPoint, Disposable } from '@flowgram.ai/utils';
3
+ import * as _flowgram_ai_core from '@flowgram.ai/core';
4
+ import { Layer } from '@flowgram.ai/core';
5
+
6
+ interface MinimapCanvasStyle {
7
+ canvasWidth: number;
8
+ canvasHeight: number;
9
+ canvasPadding: number;
10
+ canvasBackground: string;
11
+ canvasBorderRadius: number | undefined;
12
+ viewportBackground: string;
13
+ viewportBorderRadius: number | undefined;
14
+ viewportBorderColor: string;
15
+ viewportBorderWidth: number;
16
+ viewportBorderDashLength: number | undefined;
17
+ nodeColor: string;
18
+ nodeBorderRadius: number | undefined;
19
+ nodeBorderWidth: number;
20
+ nodeBorderColor: string | undefined;
21
+ overlayColor: string;
22
+ }
23
+ interface MinimapInactiveStyle {
24
+ scale: number;
25
+ opacity: number;
26
+ translateX: number;
27
+ translateY: number;
28
+ }
29
+ interface MinimapServiceOptions {
30
+ canvasStyle: Partial<MinimapCanvasStyle>;
31
+ canvasClassName: string;
32
+ enableInactiveDebounce: boolean;
33
+ enableActiveDebounce: boolean;
34
+ enableDisplayAllNodes: boolean;
35
+ activeDebounceTime: number;
36
+ inactiveDebounceTime: number;
37
+ }
38
+ interface MinimapLayerOptions {
39
+ disableLayer?: boolean;
40
+ panelStyles?: CSSProperties;
41
+ containerStyles?: CSSProperties;
42
+ inactiveStyle?: Partial<MinimapInactiveStyle>;
43
+ }
44
+ interface CreateMinimapPluginOptions extends MinimapLayerOptions, Partial<MinimapServiceOptions> {
45
+ }
46
+ interface MinimapRenderContext {
47
+ canvas: HTMLCanvasElement;
48
+ context2D: CanvasRenderingContext2D;
49
+ nodeRects: Rectangle[];
50
+ viewRect: Rectangle;
51
+ renderRect: Rectangle;
52
+ canvasRect: Rectangle;
53
+ scale: number;
54
+ offset: IPoint;
55
+ }
56
+
57
+ declare class FlowMinimapService {
58
+ private readonly document;
59
+ private readonly entityManager;
60
+ private readonly playgroundConfig;
61
+ readonly canvas: HTMLCanvasElement;
62
+ readonly context2D: CanvasRenderingContext2D;
63
+ activated: boolean;
64
+ private onActiveCallbacks;
65
+ private options;
66
+ private toDispose;
67
+ private initialized;
68
+ private isDragging;
69
+ private style;
70
+ private dragStart?;
71
+ constructor();
72
+ init(options?: Partial<MinimapServiceOptions>): void;
73
+ dispose(): void;
74
+ setActivate(activate: boolean): void;
75
+ onActive: (callback: (activated: boolean) => void) => Disposable;
76
+ private initStyle;
77
+ private setDebounce;
78
+ /**
79
+ * 触发渲染
80
+ */
81
+ private render;
82
+ private _render;
83
+ private createRenderContext;
84
+ private renderCanvas;
85
+ private calculateScaleAndOffset;
86
+ private get nodes();
87
+ private nodeTransforms;
88
+ private renderRect;
89
+ private viewRect;
90
+ private mountListener;
91
+ /** 计算画布坐标系下的矩形 */
92
+ private rectOnCanvas;
93
+ private isPointInRect;
94
+ private addEventListeners;
95
+ private removeEventListeners;
96
+ private handleWheel;
97
+ private handleStartDrag;
98
+ private handleDragging;
99
+ private handleEndDrag;
100
+ private handleCursor;
101
+ private isMouseInCanvas;
102
+ private updateScrollPosition;
103
+ }
104
+
105
+ interface MinimapProps {
106
+ service: FlowMinimapService;
107
+ panelStyles?: CSSProperties;
108
+ containerStyles?: CSSProperties;
109
+ inactiveStyle?: Partial<MinimapInactiveStyle>;
110
+ }
111
+ declare const MinimapRender: FC<MinimapProps>;
112
+
113
+ declare const MinimapDefaultCanvasStyle: MinimapCanvasStyle;
114
+ declare const MinimapDefaultInactiveStyle: MinimapInactiveStyle;
115
+ declare const MinimapDefaultOptions: MinimapServiceOptions;
116
+
117
+ declare const createMinimapPlugin: _flowgram_ai_core.PluginCreator<CreateMinimapPluginOptions>;
118
+
119
+ declare class FlowMinimapLayer extends Layer<MinimapLayerOptions> {
120
+ static type: string;
121
+ private readonly service;
122
+ readonly node: HTMLElement;
123
+ private readonly className;
124
+ constructor();
125
+ render(): JSX.Element;
126
+ }
127
+
128
+ export { type CreateMinimapPluginOptions, FlowMinimapLayer, FlowMinimapService, type MinimapCanvasStyle, MinimapDefaultCanvasStyle, MinimapDefaultInactiveStyle, MinimapDefaultOptions, type MinimapInactiveStyle, type MinimapLayerOptions, MinimapRender, type MinimapRenderContext, type MinimapServiceOptions, createMinimapPlugin };
@@ -0,0 +1,128 @@
1
+ import { CSSProperties, FC } from 'react';
2
+ import { Rectangle, IPoint, Disposable } from '@flowgram.ai/utils';
3
+ import * as _flowgram_ai_core from '@flowgram.ai/core';
4
+ import { Layer } from '@flowgram.ai/core';
5
+
6
+ interface MinimapCanvasStyle {
7
+ canvasWidth: number;
8
+ canvasHeight: number;
9
+ canvasPadding: number;
10
+ canvasBackground: string;
11
+ canvasBorderRadius: number | undefined;
12
+ viewportBackground: string;
13
+ viewportBorderRadius: number | undefined;
14
+ viewportBorderColor: string;
15
+ viewportBorderWidth: number;
16
+ viewportBorderDashLength: number | undefined;
17
+ nodeColor: string;
18
+ nodeBorderRadius: number | undefined;
19
+ nodeBorderWidth: number;
20
+ nodeBorderColor: string | undefined;
21
+ overlayColor: string;
22
+ }
23
+ interface MinimapInactiveStyle {
24
+ scale: number;
25
+ opacity: number;
26
+ translateX: number;
27
+ translateY: number;
28
+ }
29
+ interface MinimapServiceOptions {
30
+ canvasStyle: Partial<MinimapCanvasStyle>;
31
+ canvasClassName: string;
32
+ enableInactiveDebounce: boolean;
33
+ enableActiveDebounce: boolean;
34
+ enableDisplayAllNodes: boolean;
35
+ activeDebounceTime: number;
36
+ inactiveDebounceTime: number;
37
+ }
38
+ interface MinimapLayerOptions {
39
+ disableLayer?: boolean;
40
+ panelStyles?: CSSProperties;
41
+ containerStyles?: CSSProperties;
42
+ inactiveStyle?: Partial<MinimapInactiveStyle>;
43
+ }
44
+ interface CreateMinimapPluginOptions extends MinimapLayerOptions, Partial<MinimapServiceOptions> {
45
+ }
46
+ interface MinimapRenderContext {
47
+ canvas: HTMLCanvasElement;
48
+ context2D: CanvasRenderingContext2D;
49
+ nodeRects: Rectangle[];
50
+ viewRect: Rectangle;
51
+ renderRect: Rectangle;
52
+ canvasRect: Rectangle;
53
+ scale: number;
54
+ offset: IPoint;
55
+ }
56
+
57
+ declare class FlowMinimapService {
58
+ private readonly document;
59
+ private readonly entityManager;
60
+ private readonly playgroundConfig;
61
+ readonly canvas: HTMLCanvasElement;
62
+ readonly context2D: CanvasRenderingContext2D;
63
+ activated: boolean;
64
+ private onActiveCallbacks;
65
+ private options;
66
+ private toDispose;
67
+ private initialized;
68
+ private isDragging;
69
+ private style;
70
+ private dragStart?;
71
+ constructor();
72
+ init(options?: Partial<MinimapServiceOptions>): void;
73
+ dispose(): void;
74
+ setActivate(activate: boolean): void;
75
+ onActive: (callback: (activated: boolean) => void) => Disposable;
76
+ private initStyle;
77
+ private setDebounce;
78
+ /**
79
+ * 触发渲染
80
+ */
81
+ private render;
82
+ private _render;
83
+ private createRenderContext;
84
+ private renderCanvas;
85
+ private calculateScaleAndOffset;
86
+ private get nodes();
87
+ private nodeTransforms;
88
+ private renderRect;
89
+ private viewRect;
90
+ private mountListener;
91
+ /** 计算画布坐标系下的矩形 */
92
+ private rectOnCanvas;
93
+ private isPointInRect;
94
+ private addEventListeners;
95
+ private removeEventListeners;
96
+ private handleWheel;
97
+ private handleStartDrag;
98
+ private handleDragging;
99
+ private handleEndDrag;
100
+ private handleCursor;
101
+ private isMouseInCanvas;
102
+ private updateScrollPosition;
103
+ }
104
+
105
+ interface MinimapProps {
106
+ service: FlowMinimapService;
107
+ panelStyles?: CSSProperties;
108
+ containerStyles?: CSSProperties;
109
+ inactiveStyle?: Partial<MinimapInactiveStyle>;
110
+ }
111
+ declare const MinimapRender: FC<MinimapProps>;
112
+
113
+ declare const MinimapDefaultCanvasStyle: MinimapCanvasStyle;
114
+ declare const MinimapDefaultInactiveStyle: MinimapInactiveStyle;
115
+ declare const MinimapDefaultOptions: MinimapServiceOptions;
116
+
117
+ declare const createMinimapPlugin: _flowgram_ai_core.PluginCreator<CreateMinimapPluginOptions>;
118
+
119
+ declare class FlowMinimapLayer extends Layer<MinimapLayerOptions> {
120
+ static type: string;
121
+ private readonly service;
122
+ readonly node: HTMLElement;
123
+ private readonly className;
124
+ constructor();
125
+ render(): JSX.Element;
126
+ }
127
+
128
+ export { type CreateMinimapPluginOptions, FlowMinimapLayer, FlowMinimapService, type MinimapCanvasStyle, MinimapDefaultCanvasStyle, MinimapDefaultInactiveStyle, MinimapDefaultOptions, type MinimapInactiveStyle, type MinimapLayerOptions, MinimapRender, type MinimapRenderContext, type MinimapServiceOptions, createMinimapPlugin };