@krainovsd/graph 0.9.0 → 0.10.0-rc2
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.
- package/lib/cjs/index.cjs +2672 -1803
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.js +12 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/lib/draw-time.js +5 -1
- package/lib/esm/lib/draw-time.js.map +1 -1
- package/lib/esm/lib/get-controls-info.js +451 -224
- package/lib/esm/lib/get-controls-info.js.map +1 -1
- package/lib/esm/module/GraphCanvas/GraphCanvas.js +44 -934
- package/lib/esm/module/GraphCanvas/GraphCanvas.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/settings.js +70 -47
- package/lib/esm/module/GraphCanvas/constants/settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js +12 -1
- package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js +270 -0
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js.map +1 -0
- package/lib/esm/module/GraphCanvas/lib/utils/drag-place-coefficient-getter.js +2 -2
- package/lib/esm/module/GraphCanvas/lib/utils/drag-place-coefficient-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js +19 -4
- package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js +29 -4
- package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/is-overlaps-node.js +53 -4
- package/lib/esm/module/GraphCanvas/lib/utils/is-overlaps-node.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/link-by-pointer-getter.js +2 -2
- package/lib/esm/module/GraphCanvas/lib/utils/link-by-pointer-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/node-by-pointer-getter.js +3 -13
- package/lib/esm/module/GraphCanvas/lib/utils/node-by-pointer-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/draw-links.js +207 -0
- package/lib/esm/module/GraphCanvas/slices/draw-links.js.map +1 -0
- package/lib/esm/module/GraphCanvas/slices/draw-nodes.js +367 -0
- package/lib/esm/module/GraphCanvas/slices/draw-nodes.js.map +1 -0
- package/lib/esm/module/GraphCanvas/{lib/utils → slices}/draw-text.js +30 -7
- package/lib/esm/module/GraphCanvas/slices/draw-text.js.map +1 -0
- package/lib/esm/module/GraphCanvas/slices/init-area.js +31 -0
- package/lib/esm/module/GraphCanvas/slices/init-area.js.map +1 -0
- package/lib/esm/module/GraphCanvas/slices/init-dnd.js +62 -0
- package/lib/esm/module/GraphCanvas/slices/init-dnd.js.map +1 -0
- package/lib/esm/module/GraphCanvas/slices/init-draw.js +84 -0
- package/lib/esm/module/GraphCanvas/slices/init-draw.js.map +1 -0
- package/lib/esm/module/GraphCanvas/slices/init-pointer.js +211 -0
- package/lib/esm/module/GraphCanvas/slices/init-pointer.js.map +1 -0
- package/lib/esm/module/GraphCanvas/slices/init-resize.js +28 -0
- package/lib/esm/module/GraphCanvas/slices/init-resize.js.map +1 -0
- package/lib/esm/module/GraphCanvas/slices/init-simulation.js +172 -0
- package/lib/esm/module/GraphCanvas/slices/init-simulation.js.map +1 -0
- package/lib/esm/module/GraphCanvas/slices/init-zoom.js +36 -0
- package/lib/esm/module/GraphCanvas/slices/init-zoom.js.map +1 -0
- package/lib/index.d.ts +197 -154
- package/package.json +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-radius.js +0 -20
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-radius.js.map +0 -1
- package/lib/esm/module/GraphCanvas/lib/utils/draw-text.js.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SimulationNodeDatum, SimulationLinkDatum, Simulation } from 'd3-force';
|
|
2
1
|
import { D3ZoomEvent, ZoomTransform } from 'd3-zoom';
|
|
2
|
+
import { SimulationNodeDatum, SimulationLinkDatum, Simulation } from 'd3-force';
|
|
3
3
|
import { D3DragEvent } from 'd3-drag';
|
|
4
4
|
|
|
5
5
|
interface NodeInterface<NodeData extends Record<string, unknown>> extends SimulationNodeDatum {
|
|
@@ -8,17 +8,61 @@ interface NodeInterface<NodeData extends Record<string, unknown>> extends Simula
|
|
|
8
8
|
group?: number | string;
|
|
9
9
|
neighbors?: (string | number)[];
|
|
10
10
|
_radius?: number;
|
|
11
|
+
_width?: number;
|
|
12
|
+
_height?: number;
|
|
13
|
+
_borderRadius?: number;
|
|
11
14
|
_visible?: boolean;
|
|
15
|
+
_shape?: NodeShape;
|
|
12
16
|
name?: string;
|
|
13
|
-
data?: NodeData;
|
|
14
17
|
drag?: boolean;
|
|
18
|
+
data?: NodeData;
|
|
15
19
|
}
|
|
16
|
-
type
|
|
20
|
+
type NodeShape = "circle" | "square" | "text" | "icon";
|
|
21
|
+
type CachedNodeTextInterface = Record<string | number, string[] | undefined>;
|
|
22
|
+
type CachedTextNodeParametersMap = Record<string | number, [number, number] | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* 1. Initial max size of text
|
|
25
|
+
* 2. Initial size of text
|
|
26
|
+
*/
|
|
27
|
+
type CachedTextNodeParametersInterface = [number, number];
|
|
17
28
|
|
|
18
29
|
interface LinkInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> extends SimulationLinkDatum<NodeInterface<NodeData>> {
|
|
19
30
|
data?: LinkData;
|
|
20
31
|
}
|
|
21
32
|
|
|
33
|
+
type GraphSettingsInputRange<I extends string> = {
|
|
34
|
+
type: "range";
|
|
35
|
+
min: number;
|
|
36
|
+
max: number;
|
|
37
|
+
step: number;
|
|
38
|
+
initialValue: number;
|
|
39
|
+
id: I;
|
|
40
|
+
label: string;
|
|
41
|
+
};
|
|
42
|
+
type GraphSettingsInputCheckBox<I extends string> = {
|
|
43
|
+
type: "checkbox";
|
|
44
|
+
id: I;
|
|
45
|
+
initialValue: boolean;
|
|
46
|
+
label: string;
|
|
47
|
+
};
|
|
48
|
+
type GraphSettingsInputColorBox<I extends string> = {
|
|
49
|
+
type: "color";
|
|
50
|
+
id: I;
|
|
51
|
+
initialValue: string;
|
|
52
|
+
label: string;
|
|
53
|
+
};
|
|
54
|
+
type GraphSettingsInputSelect<I extends string> = {
|
|
55
|
+
type: "select";
|
|
56
|
+
id: I;
|
|
57
|
+
initialValue: string;
|
|
58
|
+
label: string;
|
|
59
|
+
options: {
|
|
60
|
+
label: string;
|
|
61
|
+
value: string;
|
|
62
|
+
}[];
|
|
63
|
+
};
|
|
64
|
+
type GraphSettingsInputInterface<I extends string> = GraphSettingsInputRange<I> | GraphSettingsInputCheckBox<I> | GraphSettingsInputColorBox<I> | GraphSettingsInputSelect<I>;
|
|
65
|
+
|
|
22
66
|
type ZoomEventInterface = D3ZoomEvent<HTMLCanvasElement, unknown>;
|
|
23
67
|
type DragEventInterface<NodeData extends Record<string, unknown>> = D3DragEvent<HTMLElement, unknown, NodeInterface<NodeData>>;
|
|
24
68
|
type ListenersInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
|
|
@@ -38,36 +82,8 @@ type ListenersInterface<NodeData extends Record<string, unknown>, LinkData exten
|
|
|
38
82
|
};
|
|
39
83
|
|
|
40
84
|
type GraphSettingsInterface<NodeData extends Record<string, unknown>> = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
highlightByNodeLinkFadingMin?: number;
|
|
44
|
-
highlightByNodeArrowFadingMin?: number;
|
|
45
|
-
highlightByNodeNodeColorFadingMin?: number;
|
|
46
|
-
highlightByNodeTextFadingMin?: number;
|
|
47
|
-
highlightByNodeNodeSizingAdditional?: number;
|
|
48
|
-
highlightByNodeTextSizingAdditional?: number;
|
|
49
|
-
highlightByNodeTextShiftXAdditional?: number;
|
|
50
|
-
highlightByNodeTextShiftYAdditional?: number;
|
|
51
|
-
highlightByNodeTextWeightAdditional?: number;
|
|
52
|
-
highlightByNodeTextWidthAdditional?: number;
|
|
53
|
-
highlightByLinkOnlyRoot?: boolean;
|
|
54
|
-
highlightByLinkNodeFadingMin?: number;
|
|
55
|
-
highlightByLinkLinkFadingMin?: number;
|
|
56
|
-
highlightByLinkArrowFadingMin?: number;
|
|
57
|
-
highlightByLinkNodeColorFadingMin?: number;
|
|
58
|
-
highlightByLinkTextFadingMin?: number;
|
|
59
|
-
highlightByLinkNodeSizingAdditional?: number;
|
|
60
|
-
highlightByLinkTextSizingAdditional?: number;
|
|
61
|
-
highlightByLinkTextShiftXAdditional?: number;
|
|
62
|
-
highlightByLinkTextShiftYAdditional?: number;
|
|
63
|
-
highlightByLinkTextWeightAdditional?: number;
|
|
64
|
-
highlightByLinkTextWidthAdditional?: number;
|
|
65
|
-
highlightByHoverNode?: boolean;
|
|
66
|
-
highlightByHoverLink?: boolean;
|
|
67
|
-
hoverLinkThreshold?: number;
|
|
68
|
-
highlightDownStep?: number;
|
|
69
|
-
highlightUpStep?: number;
|
|
70
|
-
stickAfterDrag?: boolean;
|
|
85
|
+
highlightDownFrames?: number;
|
|
86
|
+
highlightUpFrames?: number;
|
|
71
87
|
zoomExtent?: [number, number];
|
|
72
88
|
translateExtent?: [[number?, number?], [number?, number?]];
|
|
73
89
|
translateExtentCoefficient?: number | [number, number];
|
|
@@ -77,16 +93,18 @@ type GraphSettingsInterface<NodeData extends Record<string, unknown>> = {
|
|
|
77
93
|
x?: number;
|
|
78
94
|
y?: number;
|
|
79
95
|
} | null;
|
|
80
|
-
dragPlaceCoefficient?: (node: NodeInterface<NodeData>, pxEvent: number, pyEvent: number
|
|
81
|
-
nodeRadiusInitial?: number;
|
|
82
|
-
nodeRadiusCoefficient?: number;
|
|
83
|
-
nodeRadiusFactor?: number;
|
|
84
|
-
nodeRadiusFlexible?: boolean;
|
|
96
|
+
dragPlaceCoefficient?: (node: NodeInterface<NodeData>, pxEvent: number, pyEvent: number) => number | undefined;
|
|
85
97
|
showDrawTime?: boolean;
|
|
86
98
|
showDrawTimeEveryTick?: boolean;
|
|
87
99
|
};
|
|
88
100
|
type ForceSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
|
|
89
|
-
|
|
101
|
+
forces?: boolean;
|
|
102
|
+
xForce?: boolean;
|
|
103
|
+
yForce?: boolean;
|
|
104
|
+
chargeForce?: boolean;
|
|
105
|
+
centerForce?: boolean;
|
|
106
|
+
collideForce?: boolean;
|
|
107
|
+
linkForce?: boolean;
|
|
90
108
|
collideOffMax?: {
|
|
91
109
|
nodes: number;
|
|
92
110
|
links: number;
|
|
@@ -106,21 +124,36 @@ type ForceSettingsInterface<NodeData extends Record<string, unknown>, LinkData e
|
|
|
106
124
|
y?: number;
|
|
107
125
|
};
|
|
108
126
|
centerStrength?: number;
|
|
109
|
-
|
|
127
|
+
xPosition?: NodeIterationPropsInterface<NodeData, LinkData> | number;
|
|
110
128
|
xStrength?: NodeIterationPropsInterface<NodeData, LinkData> | number;
|
|
111
|
-
|
|
129
|
+
yPosition?: NodeIterationPropsInterface<NodeData, LinkData> | number;
|
|
112
130
|
yStrength?: NodeIterationPropsInterface<NodeData, LinkData> | number;
|
|
113
131
|
};
|
|
114
132
|
type NodeSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
|
|
115
133
|
cache?: boolean;
|
|
116
134
|
idGetter?: NodeIterationPropsInterface<NodeData, LinkData, string | number>;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
135
|
+
highlightByNodeOnlyRoot?: boolean;
|
|
136
|
+
highlightByNodeNodeFadingMin?: number;
|
|
137
|
+
highlightByNodeNodeColorFadingMin?: number;
|
|
138
|
+
highlightByNodeNodeSizingAdditional?: number;
|
|
139
|
+
highlightByNodeNodeSizingAdditionalCoefficient?: number;
|
|
140
|
+
highlightByNodeTextFadingMin?: number;
|
|
141
|
+
highlightByNodeTextSizingAdditional?: number;
|
|
142
|
+
highlightByNodeTextShiftXAdditional?: number;
|
|
143
|
+
highlightByNodeTextShiftYAdditional?: number;
|
|
144
|
+
highlightByNodeTextWeightAdditional?: number;
|
|
145
|
+
highlightByNodeTextWidthAdditional?: number;
|
|
146
|
+
highlightByLinkNodeFadingMin?: number;
|
|
147
|
+
highlightByLinkNodeColorFadingMin?: number;
|
|
148
|
+
highlightByLinkTextFadingMin?: number;
|
|
149
|
+
highlightByLinkNodeSizingAdditional?: number;
|
|
150
|
+
highlightByLinkNodeSizingAdditionalCoefficient?: number;
|
|
151
|
+
highlightByLinkTextSizingAdditional?: number;
|
|
152
|
+
highlightByLinkTextShiftXAdditional?: number;
|
|
153
|
+
highlightByLinkTextShiftYAdditional?: number;
|
|
154
|
+
highlightByLinkTextWeightAdditional?: number;
|
|
155
|
+
highlightByLinkTextWidthAdditional?: number;
|
|
156
|
+
highlightByHoverNode?: boolean;
|
|
124
157
|
highlightByNodeNodeFading?: boolean;
|
|
125
158
|
highlightByNodeNodeSizing?: boolean;
|
|
126
159
|
highlightByNodeTextFading?: boolean;
|
|
@@ -131,11 +164,31 @@ type NodeOptionsInterface<NodeData extends Record<string, unknown>, LinkData ext
|
|
|
131
164
|
highlightByLinkTextFading?: boolean;
|
|
132
165
|
highlightByLinkTextSizing?: boolean;
|
|
133
166
|
highlightByLinkNodeColor?: boolean;
|
|
167
|
+
nodeRadiusCoefficient?: number;
|
|
168
|
+
nodeRadiusFactor?: number;
|
|
169
|
+
nodeRadiusFlexible?: boolean;
|
|
170
|
+
nodeSizeFlexible?: boolean;
|
|
171
|
+
nodeSizeCoefficient?: number;
|
|
172
|
+
nodeSizeFactor?: number;
|
|
173
|
+
textNodeDebug?: boolean;
|
|
174
|
+
options?: NodeIterationPropsInterface<NodeData, LinkData, NodeOptionsInterface<NodeData, LinkData>> | NodeOptionsInterface<NodeData, LinkData>;
|
|
175
|
+
};
|
|
176
|
+
type NodeOptionsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
|
|
177
|
+
nodeDraw?: ((node: NodeInterface<NodeData>, options: Required<NodeOptionsInterface<NodeData, LinkData>>, state: GraphState<NodeData, LinkData>) => void) | null;
|
|
178
|
+
textDraw?: ((node: NodeInterface<NodeData>, options: Required<NodeOptionsInterface<NodeData, LinkData>>, state: GraphState<NodeData, LinkData>) => void) | null;
|
|
179
|
+
nodeExtraDraw?: ((node: NodeInterface<NodeData>, options: Required<NodeOptionsInterface<NodeData, LinkData>>, state: GraphState<NodeData, LinkData>) => void) | null;
|
|
180
|
+
textExtraDraw?: ((node: NodeInterface<NodeData>, options: Required<NodeOptionsInterface<NodeData, LinkData>>, state: GraphState<NodeData, LinkData>) => void) | null;
|
|
181
|
+
shape?: NodeShape;
|
|
182
|
+
width?: number;
|
|
183
|
+
height?: number;
|
|
184
|
+
borderRadius?: number;
|
|
134
185
|
borderColor?: string;
|
|
135
186
|
borderWidth?: number;
|
|
136
187
|
radius?: number;
|
|
137
188
|
alpha?: number;
|
|
138
189
|
color?: string;
|
|
190
|
+
textNodeYPadding?: number;
|
|
191
|
+
textNodeXPadding?: number;
|
|
139
192
|
textVisible?: boolean;
|
|
140
193
|
text?: string | null;
|
|
141
194
|
textAlpha?: number;
|
|
@@ -153,7 +206,22 @@ type NodeOptionsInterface<NodeData extends Record<string, unknown>, LinkData ext
|
|
|
153
206
|
type NodeIterationPropsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Return = number> = (node: NodeInterface<NodeData>, i: number, nodes: NodeInterface<NodeData>[], state?: GraphState<NodeData, LinkData>) => Return;
|
|
154
207
|
type LinkSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
|
|
155
208
|
particles?: boolean;
|
|
209
|
+
pretty?: boolean;
|
|
210
|
+
arrow?: boolean;
|
|
211
|
+
arrowByHighlight?: boolean;
|
|
156
212
|
cache?: boolean;
|
|
213
|
+
particleFlexSpeed?: boolean;
|
|
214
|
+
particleFlexSpeedCoefficient?: number;
|
|
215
|
+
highlightByNodeLinkFadingMin?: number;
|
|
216
|
+
highlightByNodeArrowFadingMin?: number;
|
|
217
|
+
highlightByLinkArrowFadingMin?: number;
|
|
218
|
+
highlightByLinkLinkFadingMin?: number;
|
|
219
|
+
highlightByHoverLink?: boolean;
|
|
220
|
+
highlightByNodeLinkFading?: boolean;
|
|
221
|
+
highlightByNodeArrowFading?: boolean;
|
|
222
|
+
highlightByLinkLinkFading?: boolean;
|
|
223
|
+
highlightByLinkArrowFading?: boolean;
|
|
224
|
+
hoverLinkThreshold?: number;
|
|
157
225
|
options?: LinkIterationPropsInterface<NodeData, LinkData, LinkOptionsInterface<NodeData, LinkData>> | LinkOptionsInterface<NodeData, LinkData>;
|
|
158
226
|
};
|
|
159
227
|
type LinkOptionsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
|
|
@@ -162,16 +230,13 @@ type LinkOptionsInterface<NodeData extends Record<string, unknown>, LinkData ext
|
|
|
162
230
|
alpha?: number;
|
|
163
231
|
color?: string;
|
|
164
232
|
width?: number;
|
|
165
|
-
highlightByNodeLinkFading?: boolean;
|
|
166
|
-
highlightByNodeArrowFading?: boolean;
|
|
167
|
-
highlightByLinkLinkFading?: boolean;
|
|
168
|
-
highlightByLinkArrowFading?: boolean;
|
|
169
|
-
pretty?: boolean;
|
|
170
|
-
arrow?: boolean;
|
|
171
233
|
arrowAlpha?: number;
|
|
172
234
|
arrowColor?: string;
|
|
173
235
|
arrowSize?: number;
|
|
174
|
-
|
|
236
|
+
arrowBorderColor?: string;
|
|
237
|
+
arrowBorderWidth?: number;
|
|
238
|
+
particleBorderColor?: string;
|
|
239
|
+
particleBorderWidth?: number;
|
|
175
240
|
particleAlpha?: number;
|
|
176
241
|
particleColor?: string;
|
|
177
242
|
particleRadius?: number;
|
|
@@ -222,48 +287,51 @@ type RGB = {
|
|
|
222
287
|
};
|
|
223
288
|
type GraphParticle = {
|
|
224
289
|
step: number;
|
|
225
|
-
|
|
290
|
+
index: number;
|
|
291
|
+
prev: GraphParticle | undefined;
|
|
292
|
+
next: GraphParticle | undefined;
|
|
226
293
|
x?: number;
|
|
227
294
|
y?: number;
|
|
228
|
-
sourceId: number;
|
|
229
|
-
targetId: number;
|
|
295
|
+
sourceId: string | number;
|
|
296
|
+
targetId: string | number;
|
|
230
297
|
};
|
|
231
298
|
|
|
232
299
|
declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> {
|
|
233
300
|
/** initial data */
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
301
|
+
protected nodes: NodeInterface<NodeData>[];
|
|
302
|
+
protected links: LinkInterface<NodeData, LinkData>[];
|
|
303
|
+
protected particles: Record<string, GraphParticle[]>;
|
|
304
|
+
protected width: number;
|
|
305
|
+
protected height: number;
|
|
306
|
+
protected root: HTMLElement;
|
|
307
|
+
protected container: HTMLDivElement | undefined | null;
|
|
308
|
+
protected area: HTMLCanvasElement | null | undefined;
|
|
242
309
|
/** settings */
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
310
|
+
protected graphSettings: Required<GraphSettingsInterface<NodeData>>;
|
|
311
|
+
protected forceSettings: Required<ForceSettingsInterface<NodeData, LinkData>>;
|
|
312
|
+
protected nodeSettings: Required<Omit<NodeSettingsInterface<NodeData, LinkData>, "options">> & Pick<NodeSettingsInterface<NodeData, LinkData>, "options">;
|
|
313
|
+
protected linkSettings: Required<Omit<LinkSettingsInterface<NodeData, LinkData>, "options">> & Pick<LinkSettingsInterface<NodeData, LinkData>, "options">;
|
|
314
|
+
protected listeners: ListenersInterface<NodeData, LinkData>;
|
|
248
315
|
/** service */
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
316
|
+
protected context: CanvasRenderingContext2D | null | undefined;
|
|
317
|
+
protected simulation: GraphCanvasSimulation<NodeData, LinkData> | undefined;
|
|
318
|
+
protected areaTransform: ZoomTransform;
|
|
319
|
+
protected areaRect: DOMRect | undefined;
|
|
320
|
+
protected draw: (this: GraphCanvas<NodeData, LinkData>) => void;
|
|
321
|
+
protected eventAbortController: AbortController;
|
|
322
|
+
protected cachedNodeText: CachedNodeTextInterface;
|
|
323
|
+
protected cachedTextNodeParameters: CachedTextNodeParametersMap;
|
|
324
|
+
protected linkOptionsCache: Record<string, Required<LinkOptionsInterface<NodeData, LinkData>>>;
|
|
325
|
+
protected nodeOptionsCache: Record<string, Required<NodeOptionsInterface<NodeData, LinkData>>>;
|
|
326
|
+
protected isDragging: boolean;
|
|
327
|
+
protected highlightedNode: NodeInterface<NodeData> | null;
|
|
328
|
+
protected highlightedLink: LinkInterface<NodeData, LinkData> | null;
|
|
329
|
+
protected highlightedNeighbors: Set<string | number> | null;
|
|
330
|
+
protected highlightProgress: number;
|
|
331
|
+
protected highlightWorking: boolean;
|
|
332
|
+
protected highlightDrawing: boolean;
|
|
333
|
+
protected get simulationWorking(): boolean;
|
|
334
|
+
protected get state(): GraphState<NodeData, LinkData>;
|
|
267
335
|
constructor({ links, nodes, root, forceSettings, linkSettings, listeners, nodeSettings, graphSettings, }: GraphCanvasInterface<NodeData, LinkData>);
|
|
268
336
|
get dpi(): number;
|
|
269
337
|
getData(): Pick<GraphCanvasInterface<NodeData, LinkData>, "nodes" | "links">;
|
|
@@ -277,22 +345,12 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
|
|
|
277
345
|
stop(): void;
|
|
278
346
|
create(): void;
|
|
279
347
|
destroy(): void;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
private init;
|
|
287
|
-
private initSimulation;
|
|
288
|
-
private initSimulationForces;
|
|
289
|
-
private initCollideForce;
|
|
290
|
-
private initArea;
|
|
291
|
-
private initDraw;
|
|
292
|
-
private initResize;
|
|
293
|
-
private initPointer;
|
|
294
|
-
private initDnd;
|
|
295
|
-
private initZoom;
|
|
348
|
+
protected clearHTMLElements(): void;
|
|
349
|
+
protected updateSimulation(): void;
|
|
350
|
+
protected clearState(): void;
|
|
351
|
+
protected updateData(alpha?: number): void;
|
|
352
|
+
protected updateSize(): void;
|
|
353
|
+
protected init(): void;
|
|
296
354
|
}
|
|
297
355
|
|
|
298
356
|
declare function linkOptionsGetter<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(_: LinkInterface<NodeData, LinkData>, __: number, ___: LinkInterface<NodeData, LinkData>[], state?: GraphState<NodeData, LinkData>): Required<LinkOptionsInterface<NodeData, LinkData>>;
|
|
@@ -315,36 +373,18 @@ type NodeByPointerGetterOptions<NodeData extends Record<string, unknown>> = {
|
|
|
315
373
|
areaRect: DOMRect | undefined;
|
|
316
374
|
areaTransform: ZoomTransform;
|
|
317
375
|
nodes: NodeInterface<NodeData>[];
|
|
318
|
-
graphSettings: Required<GraphSettingsInterface<NodeData>>;
|
|
319
376
|
};
|
|
320
|
-
declare function nodeByPointerGetter<NodeData extends Record<string, unknown>>({ areaRect, areaTransform, mouseEvent, nodes,
|
|
377
|
+
declare function nodeByPointerGetter<NodeData extends Record<string, unknown>>({ areaRect, areaTransform, mouseEvent, nodes, }: NodeByPointerGetterOptions<NodeData>): NodeInterface<NodeData> | undefined;
|
|
321
378
|
|
|
322
379
|
declare function nodeIterationExtractor<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Result extends string | number | boolean | Record<string, unknown> | unknown[] | undefined | null>(node: NodeInterface<NodeData>, i: number, nodes: NodeInterface<NodeData>[], state: GraphState<NodeData, LinkData>, option: NodeIterationPropsInterface<NodeData, LinkData, Result> | Result, optionConstantGetter: undefined): Result;
|
|
323
380
|
declare function nodeIterationExtractor<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Result extends string | number | boolean | Record<string, unknown> | unknown[] | undefined | null>(node: NodeInterface<NodeData>, i: number, nodes: NodeInterface<NodeData>[], state: GraphState<NodeData, LinkData>, option: NodeIterationPropsInterface<NodeData, LinkData, Result> | Result, optionConstantGetter: NodeIterationPropsInterface<NodeData, LinkData, Result> | Result): Required<Result>;
|
|
324
381
|
|
|
325
|
-
|
|
326
|
-
id: string | number;
|
|
327
|
-
x: number;
|
|
328
|
-
y: number;
|
|
329
|
-
text: string;
|
|
330
|
-
textSize: number;
|
|
331
|
-
textStyle: TextStyleEnum;
|
|
332
|
-
textWeight: number;
|
|
333
|
-
textFont: string;
|
|
334
|
-
textColor: string;
|
|
335
|
-
textGap: number;
|
|
336
|
-
textAlign: CanvasTextAlign;
|
|
337
|
-
context: CanvasRenderingContext2D;
|
|
338
|
-
cachedNodeText: CachedNodeTextInterface;
|
|
339
|
-
maxWidth?: number;
|
|
340
|
-
};
|
|
341
|
-
declare function drawText({ context, id, textAlign, textColor, textFont, textStyle, textGap, textWeight, textSize, text, x, y, cachedNodeText, maxWidth, }: DrawTextOptions): void;
|
|
342
|
-
|
|
343
|
-
declare function calculateLinkPositionByRadius<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(link: LinkInterface<NodeData, LinkData>, arrowSize?: number): {
|
|
382
|
+
declare function calculateLinkPositionByNode<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(link: LinkInterface<NodeData, LinkData>, arrowSize?: number): {
|
|
344
383
|
x1: number;
|
|
345
384
|
y1: number;
|
|
346
385
|
x2: number;
|
|
347
386
|
y2: number;
|
|
387
|
+
distance: number;
|
|
348
388
|
} | null;
|
|
349
389
|
|
|
350
390
|
declare function animationByProgress(initial: number, additional: number, progress: number): number;
|
|
@@ -356,6 +396,8 @@ type GetParticlePositionOptions = {
|
|
|
356
396
|
xEnd: number;
|
|
357
397
|
yEnd: number;
|
|
358
398
|
totalSteps: number;
|
|
399
|
+
totalCount: number;
|
|
400
|
+
distance: number;
|
|
359
401
|
};
|
|
360
402
|
declare function getParticlePosition(opts: GetParticlePositionOptions): void;
|
|
361
403
|
|
|
@@ -364,9 +406,31 @@ type LinkByPointerGetterOptions<NodeData extends Record<string, unknown>, LinkDa
|
|
|
364
406
|
areaRect: DOMRect | undefined;
|
|
365
407
|
areaTransform: ZoomTransform;
|
|
366
408
|
links: LinkInterface<NodeData, LinkData>[];
|
|
367
|
-
|
|
409
|
+
linkSettings: Required<Omit<LinkSettingsInterface<NodeData, LinkData>, "options">> & Pick<LinkSettingsInterface<NodeData, LinkData>, "options">;
|
|
410
|
+
};
|
|
411
|
+
declare function linkByPointerGetter<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>({ areaRect, areaTransform, mouseEvent, links, linkSettings, }: LinkByPointerGetterOptions<NodeData, LinkData>): LinkInterface<NodeData, LinkData> | undefined;
|
|
412
|
+
|
|
413
|
+
declare function getDrawLink<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(state: GraphState<NodeData, LinkData>): (this: GraphCanvas<NodeData, LinkData>, link: LinkInterface<NodeData, LinkData>, index: number) => void;
|
|
414
|
+
|
|
415
|
+
declare function getDrawNode<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(nodeRenders: (() => void)[], textRenders: (() => void)[], state: GraphState<NodeData, LinkData>): (this: GraphCanvas<NodeData, LinkData>, node: NodeInterface<NodeData>, index: number) => void;
|
|
416
|
+
|
|
417
|
+
type DrawTextOptions = {
|
|
418
|
+
id: string | number;
|
|
419
|
+
x: number;
|
|
420
|
+
y: number;
|
|
421
|
+
text: string;
|
|
422
|
+
textSize: number;
|
|
423
|
+
textStyle: TextStyleEnum;
|
|
424
|
+
textWeight: number;
|
|
425
|
+
textFont: string;
|
|
426
|
+
textColor: string;
|
|
427
|
+
textGap: number;
|
|
428
|
+
textAlign: CanvasTextAlign;
|
|
429
|
+
context: CanvasRenderingContext2D;
|
|
430
|
+
cachedNodeText: CachedNodeTextInterface;
|
|
431
|
+
maxWidth?: number;
|
|
368
432
|
};
|
|
369
|
-
declare function
|
|
433
|
+
declare function drawText({ context, id, textAlign, textColor, textFont, textStyle, textGap, textWeight, textSize, text, x, y, cachedNodeText, maxWidth, }: DrawTextOptions): void;
|
|
370
434
|
|
|
371
435
|
declare function colorToRgb(color: string): string | null;
|
|
372
436
|
|
|
@@ -380,32 +444,11 @@ declare function fadeRgb(color: RGB, fade: number): RGB;
|
|
|
380
444
|
|
|
381
445
|
declare function rgbAnimationByProgress(start: RGB, end: RGB, progress: number): RGB;
|
|
382
446
|
|
|
383
|
-
type GraphSettingsInputRange<I extends string> = {
|
|
384
|
-
type: "range";
|
|
385
|
-
min: number;
|
|
386
|
-
max: number;
|
|
387
|
-
step: number;
|
|
388
|
-
initialValue: number;
|
|
389
|
-
id: I;
|
|
390
|
-
label: string;
|
|
391
|
-
};
|
|
392
|
-
type GraphSettingsInputCheckBox<I extends string> = {
|
|
393
|
-
type: "checkbox";
|
|
394
|
-
id: I;
|
|
395
|
-
initialValue: boolean;
|
|
396
|
-
label: string;
|
|
397
|
-
};
|
|
398
|
-
type GraphSettingsInputColorBox<I extends string> = {
|
|
399
|
-
type: "color";
|
|
400
|
-
id: I;
|
|
401
|
-
initialValue: string;
|
|
402
|
-
label: string;
|
|
403
|
-
};
|
|
404
|
-
type GraphSettingsInputInterface<I extends string> = GraphSettingsInputRange<I> | GraphSettingsInputCheckBox<I> | GraphSettingsInputColorBox<I>;
|
|
405
|
-
|
|
406
447
|
declare function getForceControls<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(keys?: (keyof ForceSettingsInterface<NodeData, LinkData>)[]): GraphSettingsInputInterface<keyof ForceSettingsInterface<NodeData, LinkData>>[];
|
|
407
448
|
declare function getGraphControls<NodeData extends Record<string, unknown>>(keys?: (keyof GraphSettingsInterface<NodeData>)[]): GraphSettingsInputInterface<keyof GraphSettingsInterface<NodeData>>[];
|
|
408
|
-
declare function
|
|
409
|
-
declare function
|
|
449
|
+
declare function getNodeSettingControls<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(keys?: keyof Omit<Required<NodeSettingsInterface<NodeData, LinkData>>, "options" | "idGetter">): GraphSettingsInputInterface<"cache" | "highlightByNodeOnlyRoot" | "highlightByNodeNodeFadingMin" | "highlightByNodeNodeColorFadingMin" | "highlightByNodeNodeSizingAdditional" | "highlightByNodeNodeSizingAdditionalCoefficient" | "highlightByNodeTextFadingMin" | "highlightByNodeTextSizingAdditional" | "highlightByNodeTextShiftXAdditional" | "highlightByNodeTextShiftYAdditional" | "highlightByNodeTextWeightAdditional" | "highlightByNodeTextWidthAdditional" | "highlightByLinkNodeFadingMin" | "highlightByLinkNodeColorFadingMin" | "highlightByLinkTextFadingMin" | "highlightByLinkNodeSizingAdditional" | "highlightByLinkNodeSizingAdditionalCoefficient" | "highlightByLinkTextSizingAdditional" | "highlightByLinkTextShiftXAdditional" | "highlightByLinkTextShiftYAdditional" | "highlightByLinkTextWeightAdditional" | "highlightByLinkTextWidthAdditional" | "highlightByHoverNode" | "highlightByNodeNodeFading" | "highlightByNodeNodeSizing" | "highlightByNodeTextFading" | "highlightByNodeTextSizing" | "highlightByNodeNodeColor" | "highlightByLinkNodeFading" | "highlightByLinkNodeSizing" | "highlightByLinkTextFading" | "highlightByLinkTextSizing" | "highlightByLinkNodeColor" | "nodeRadiusCoefficient" | "nodeRadiusFactor" | "nodeRadiusFlexible" | "nodeSizeFlexible" | "nodeSizeCoefficient" | "nodeSizeFactor" | "textNodeDebug">[];
|
|
450
|
+
declare function getNodeOptionsControls<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(keys?: (keyof NodeOptionsInterface<NodeData, LinkData>)[]): GraphSettingsInputInterface<keyof NodeOptionsInterface<NodeData, LinkData>>[];
|
|
451
|
+
declare function getLinkSettingsControls<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(keys?: keyof Omit<Required<LinkSettingsInterface<NodeData, LinkData>>, "options">): GraphSettingsInputInterface<"cache" | "particles" | "pretty" | "arrow" | "arrowByHighlight" | "particleFlexSpeed" | "particleFlexSpeedCoefficient" | "highlightByNodeLinkFadingMin" | "highlightByNodeArrowFadingMin" | "highlightByLinkArrowFadingMin" | "highlightByLinkLinkFadingMin" | "highlightByHoverLink" | "highlightByNodeLinkFading" | "highlightByNodeArrowFading" | "highlightByLinkLinkFading" | "highlightByLinkArrowFading" | "hoverLinkThreshold">[];
|
|
452
|
+
declare function getLinkOptionsControls<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(keys?: (keyof LinkOptionsInterface<NodeData, LinkData>)[]): GraphSettingsInputInterface<keyof LinkOptionsInterface<NodeData, LinkData>>[];
|
|
410
453
|
|
|
411
|
-
export { type CachedNodeTextInterface, type DragEventInterface, type ForceSettingsInterface, GraphCanvas, type GraphCanvasInterface, type GraphCanvasSimulation, type GraphParticle, type GraphSettingsInterface, type GraphState, type LinkInterface, type LinkIterationPropsInterface, type LinkOptionsInterface, type LinkSettingsInterface, type ListenersInterface, type NodeInterface, type NodeIterationPropsInterface, type NodeOptionsInterface, type NodeSettingsInterface, type RGB, type TextStyleEnum, type ZoomEventInterface, animationByProgress,
|
|
454
|
+
export { type CachedNodeTextInterface, type CachedTextNodeParametersInterface, type CachedTextNodeParametersMap, type DragEventInterface, type ForceSettingsInterface, GraphCanvas, type GraphCanvasInterface, type GraphCanvasSimulation, type GraphParticle, type GraphSettingsInputInterface, type GraphSettingsInterface, type GraphState, type LinkInterface, type LinkIterationPropsInterface, type LinkOptionsInterface, type LinkSettingsInterface, type ListenersInterface, type NodeInterface, type NodeIterationPropsInterface, type NodeOptionsInterface, type NodeSettingsInterface, type NodeShape, type RGB, type TextStyleEnum, type ZoomEventInterface, animationByProgress, calculateLinkPositionByNode, colorToRgb, drawText, extractRgb, fadeRgb, getDrawLink, getDrawNode, getForceControls, getGraphControls, getLinkOptionsControls, getLinkSettingsControls, getNodeOptionsControls, getNodeSettingControls, getParticlePosition, linkByPointerGetter, linkIterationExtractor, linkOptionsGetter, nodeByPointerGetter, nodeIterationExtractor, nodeOptionsGetter, nodeRadiusGetter, rgbAnimationByProgress };
|
package/package.json
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
function calculateLinkPositionByRadius(link, arrowSize = 0) {
|
|
2
|
-
const source = link.source;
|
|
3
|
-
const target = link.target;
|
|
4
|
-
if (typeof source != "object" || typeof target != "object")
|
|
5
|
-
return null;
|
|
6
|
-
const dx = (target.x ?? 0) - (source.x ?? 0);
|
|
7
|
-
const dy = (target.y ?? 0) - (source.y ?? 0);
|
|
8
|
-
const dr = Math.sqrt(dx * dx + dy * dy);
|
|
9
|
-
const sourceRadius = source._radius ?? 0;
|
|
10
|
-
const targetRadius = (target._radius ?? 0) + (arrowSize > 0 ? arrowSize * 0.85 : 0);
|
|
11
|
-
return {
|
|
12
|
-
x1: (source.x ?? 0) + (dx * sourceRadius) / dr,
|
|
13
|
-
y1: (source.y ?? 0) + (dy * sourceRadius) / dr,
|
|
14
|
-
x2: (target.x ?? 0) - (dx * targetRadius) / dr,
|
|
15
|
-
y2: (target.y ?? 0) - (dy * targetRadius) / dr,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { calculateLinkPositionByRadius };
|
|
20
|
-
//# sourceMappingURL=calculate-link-position-by-radius.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-link-position-by-radius.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/calculate-link-position-by-radius.ts"],"sourcesContent":["import type { LinkInterface } from \"@/types\";\n\nexport function calculateLinkPositionByRadius<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(link: LinkInterface<NodeData, LinkData>, arrowSize = 0) {\n const source = link.source;\n const target = link.target;\n\n if (typeof source != \"object\" || typeof target != \"object\") return null;\n\n const dx = (target.x ?? 0) - (source.x ?? 0);\n const dy = (target.y ?? 0) - (source.y ?? 0);\n const dr = Math.sqrt(dx * dx + dy * dy);\n const sourceRadius = source._radius ?? 0;\n const targetRadius = (target._radius ?? 0) + (arrowSize > 0 ? arrowSize * 0.85 : 0);\n\n return {\n x1: (source.x ?? 0) + (dx * sourceRadius) / dr,\n y1: (source.y ?? 0) + (dy * sourceRadius) / dr,\n x2: (target.x ?? 0) - (dx * targetRadius) / dr,\n y2: (target.y ?? 0) - (dy * targetRadius) / dr,\n };\n}\n"],"names":[],"mappings":"SAEgB,6BAA6B,CAG3C,IAAuC,EAAE,SAAS,GAAG,CAAC,EAAA;AACtD,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;AAC1B,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;IAE1B,IAAI,OAAO,MAAM,IAAI,QAAQ,IAAI,OAAO,MAAM,IAAI,QAAQ;AAAE,QAAA,OAAO,IAAI;AAEvE,IAAA,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5C,IAAA,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5C,IAAA,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACvC,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,IAAI,CAAC;IACxC,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,KAAK,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC;IAEnF,OAAO;AACL,QAAA,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,YAAY,IAAI,EAAE;AAC9C,QAAA,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,YAAY,IAAI,EAAE;AAC9C,QAAA,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,YAAY,IAAI,EAAE;AAC9C,QAAA,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,YAAY,IAAI,EAAE;KAC/C;AACH;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"draw-text.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/draw-text.ts"],"sourcesContent":["import type { CachedNodeTextInterface } from \"@/types\";\nimport type { TextStyleEnum } from \"../../types\";\n\nexport type DrawTextOptions = {\n id: string | number;\n x: number;\n y: number;\n text: string;\n textSize: number;\n textStyle: TextStyleEnum;\n textWeight: number;\n textFont: string;\n textColor: string;\n textGap: number;\n textAlign: CanvasTextAlign;\n context: CanvasRenderingContext2D;\n cachedNodeText: CachedNodeTextInterface;\n maxWidth?: number;\n};\n\nconst SPACE = \" \";\n\nexport function drawText({\n context,\n id,\n textAlign,\n textColor,\n textFont,\n textStyle,\n textGap,\n textWeight,\n textSize,\n text,\n x,\n y,\n cachedNodeText,\n maxWidth,\n}: DrawTextOptions) {\n context.font = `${textStyle} normal ${textWeight} ${textSize}px ${textFont}`;\n context.fillStyle = textColor;\n context.textAlign = textAlign;\n\n if (cachedNodeText[id] != undefined) {\n cachedNodeText[id].forEach((line, index) => {\n context.fillText(line, x, y + index * textSize + index * textGap);\n });\n\n return;\n }\n\n if (maxWidth == undefined || context.measureText(text).width <= maxWidth) {\n cachedNodeText[id] = [text];\n context.fillText(text, x, y);\n\n return;\n }\n\n const spaceWidth = context.measureText(\" \").width;\n const lines: string[] = [];\n let lineWidth = 0;\n let line = \"\";\n\n for (const word of text.split(\" \")) {\n const size = context.measureText(word).width;\n lineWidth += size;\n\n if (line === \"\") {\n line = word;\n\n continue;\n }\n if (lineWidth > maxWidth) {\n lineWidth = 0;\n lines.push(line);\n line = word;\n } else {\n lineWidth += spaceWidth;\n line += `${SPACE}${word}`;\n }\n }\n\n if (line !== \"\") lines.push(line);\n\n cachedNodeText[id] = lines;\n lines.forEach((line, index) => {\n context.fillText(line, x, y + index * textSize + index * textGap);\n });\n}\n"],"names":[],"mappings":"AAoBA,MAAM,KAAK,GAAG,GAAG;AAED,SAAA,QAAQ,CAAC,EACvB,OAAO,EACP,EAAE,EACF,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,CAAC,EACD,CAAC,EACD,cAAc,EACd,QAAQ,GACQ,EAAA;AAChB,IAAA,OAAO,CAAC,IAAI,GAAG,CAAA,EAAG,SAAS,CAAA,QAAA,EAAW,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAA,GAAA,EAAM,QAAQ,CAAA,CAAE;AAC5E,IAAA,OAAO,CAAC,SAAS,GAAG,SAAS;AAC7B,IAAA,OAAO,CAAC,SAAS,GAAG,SAAS;AAE7B,IAAA,IAAI,cAAc,CAAC,EAAE,CAAC,IAAI,SAAS,EAAE;QACnC,cAAc,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,KAAI;AACzC,YAAA,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;AACnE,SAAC,CAAC;QAEF;;AAGF,IAAA,IAAI,QAAQ,IAAI,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,QAAQ,EAAE;AACxE,QAAA,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;QAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QAE5B;;IAGF,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK;IACjD,MAAM,KAAK,GAAa,EAAE;IAC1B,IAAI,SAAS,GAAG,CAAC;IACjB,IAAI,IAAI,GAAG,EAAE;IAEb,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QAClC,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK;QAC5C,SAAS,IAAI,IAAI;AAEjB,QAAA,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,IAAI,GAAG,IAAI;YAEX;;AAEF,QAAA,IAAI,SAAS,GAAG,QAAQ,EAAE;YACxB,SAAS,GAAG,CAAC;AACb,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAChB,IAAI,GAAG,IAAI;;aACN;YACL,SAAS,IAAI,UAAU;AACvB,YAAA,IAAI,IAAI,CAAG,EAAA,KAAK,CAAG,EAAA,IAAI,EAAE;;;IAI7B,IAAI,IAAI,KAAK,EAAE;AAAE,QAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;AAEjC,IAAA,cAAc,CAAC,EAAE,CAAC,GAAG,KAAK;IAC1B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,KAAI;AAC5B,QAAA,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;AACnE,KAAC,CAAC;AACJ;;;;"}
|