@krainovsd/graph 0.13.0-beta3 → 0.14.0-beta.2
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 +772 -466
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/constants/force-controls.js +4 -2
- package/lib/esm/constants/force-controls.js.map +1 -1
- package/lib/esm/constants/highlight-controls.js +9 -16
- package/lib/esm/constants/highlight-controls.js.map +1 -1
- package/lib/esm/constants/link-controls.js +17 -30
- package/lib/esm/constants/link-controls.js.map +1 -1
- package/lib/esm/constants/node-controls.js +4 -2
- package/lib/esm/constants/node-controls.js.map +1 -1
- package/lib/esm/index.js +8 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/module/GraphCanvas/GraphCanvas.js +265 -74
- package/lib/esm/module/GraphCanvas/GraphCanvas.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/force-settings.js +11 -1
- package/lib/esm/module/GraphCanvas/constants/force-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/graph-settings.js +17 -5
- package/lib/esm/module/GraphCanvas/constants/graph-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/highlight-settings.js +5 -3
- package/lib/esm/module/GraphCanvas/constants/highlight-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/index.js +5 -2
- package/lib/esm/module/GraphCanvas/constants/index.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/link-settings.js +19 -10
- package/lib/esm/module/GraphCanvas/constants/link-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/node-settings.js +13 -3
- package/lib/esm/module/GraphCanvas/constants/node-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/force-settings-getter.js +4 -2
- package/lib/esm/module/GraphCanvas/lib/settings/force-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/graph-settings-getter.js +4 -0
- package/lib/esm/module/GraphCanvas/lib/settings/graph-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/highlight-settings-getter.js +4 -2
- package/lib/esm/module/GraphCanvas/lib/settings/highlight-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/link-settings-getter.js +8 -5
- package/lib/esm/module/GraphCanvas/lib/settings/link-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js +14 -2
- package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.js +5 -2
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js +5 -2
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/compute-graph-bounds.js +26 -0
- package/lib/esm/module/GraphCanvas/lib/utils/compute-graph-bounds.js.map +1 -0
- package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js +40 -30
- package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/is-empty-object.js +11 -0
- package/lib/esm/module/GraphCanvas/lib/utils/is-empty-object.js.map +1 -0
- package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js +5 -2
- package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/draw-links.js +47 -62
- package/lib/esm/module/GraphCanvas/slices/draw-links.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/draw-nodes.js +9 -4
- package/lib/esm/module/GraphCanvas/slices/draw-nodes.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-dnd.js +21 -4
- package/lib/esm/module/GraphCanvas/slices/init-dnd.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-draw.js +1 -52
- package/lib/esm/module/GraphCanvas/slices/init-draw.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-pointer.js +6 -34
- package/lib/esm/module/GraphCanvas/slices/init-pointer.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-simulation.js +12 -2
- package/lib/esm/module/GraphCanvas/slices/init-simulation.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-zoom.js +85 -16
- package/lib/esm/module/GraphCanvas/slices/init-zoom.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/update-link-cache.js +33 -3
- package/lib/esm/module/GraphCanvas/slices/update-link-cache.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/update-node-cache.js +61 -16
- package/lib/esm/module/GraphCanvas/slices/update-node-cache.js.map +1 -1
- package/lib/index.d.ts +85 -46
- package/package.json +3 -2
|
@@ -1,17 +1,29 @@
|
|
|
1
|
+
import './force-settings.js';
|
|
2
|
+
import './highlight-settings.js';
|
|
3
|
+
import './link-settings.js';
|
|
4
|
+
import './node-settings.js';
|
|
1
5
|
import '@krainovsd/js-helpers';
|
|
2
6
|
import { dragPlaceCoefficientGetter } from '../lib/utils/drag-place-coefficient-getter.js';
|
|
3
7
|
import 'd3-array';
|
|
4
8
|
|
|
5
9
|
const GRAPH_SETTINGS = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
zoomAnimation: true,
|
|
11
|
+
zoomAnimationDuration: 300,
|
|
12
|
+
zoomToNodeScale: 5,
|
|
13
|
+
zoomToFitMargin: 0.25,
|
|
14
|
+
zoomExtent: null,
|
|
15
|
+
zoomExtentMargin: 0.3,
|
|
16
|
+
translateExtent: null,
|
|
17
|
+
translateExtentCoefficient: null,
|
|
18
|
+
translateExtentOverlap: 0.3,
|
|
10
19
|
dragPlaceCoefficient: dragPlaceCoefficientGetter,
|
|
11
20
|
zoomInitial: null,
|
|
12
21
|
showDrawTime: true,
|
|
13
22
|
showDrawTimeEveryTick: false,
|
|
14
23
|
};
|
|
24
|
+
const PERFORMANCE_GRAPH_SETTINGS = {
|
|
25
|
+
...GRAPH_SETTINGS,
|
|
26
|
+
};
|
|
15
27
|
|
|
16
|
-
export { GRAPH_SETTINGS };
|
|
28
|
+
export { GRAPH_SETTINGS, PERFORMANCE_GRAPH_SETTINGS };
|
|
17
29
|
//# sourceMappingURL=graph-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-settings.js","sources":["../../../../../src/module/GraphCanvas/constants/graph-settings.ts"],"sourcesContent":["import { dragPlaceCoefficientGetter } from \"../lib\";\nimport type { GraphSettingsInterface } from \"../types/graph-settings\";\n\nexport const GRAPH_SETTINGS: Required<GraphSettingsInterface<Record<string, unknown>>> = {\n
|
|
1
|
+
{"version":3,"file":"graph-settings.js","sources":["../../../../../src/module/GraphCanvas/constants/graph-settings.ts"],"sourcesContent":["import { dragPlaceCoefficientGetter } from \"../lib\";\nimport type { GraphSettingsInterface } from \"../types/graph-settings\";\n\nexport const GRAPH_SETTINGS: Required<GraphSettingsInterface<Record<string, unknown>>> = {\n zoomAnimation: true,\n zoomAnimationDuration: 300,\n zoomToNodeScale: 5,\n zoomToFitMargin: 0.25,\n zoomExtent: null,\n zoomExtentMargin: 0.3,\n translateExtent: null,\n translateExtentCoefficient: null,\n translateExtentOverlap: 0.3,\n dragPlaceCoefficient: dragPlaceCoefficientGetter,\n zoomInitial: null,\n showDrawTime: true,\n showDrawTimeEveryTick: false,\n};\n\nexport const PERFORMANCE_GRAPH_SETTINGS: Required<GraphSettingsInterface<Record<string, unknown>>> =\n {\n ...GRAPH_SETTINGS,\n };\n"],"names":[],"mappings":";;;;;;;;AAGa,MAAA,cAAc,GAA8D;AACvF,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,qBAAqB,EAAE,GAAG;AAC1B,IAAA,eAAe,EAAE,CAAC;AAClB,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,gBAAgB,EAAE,GAAG;AACrB,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,0BAA0B,EAAE,IAAI;AAChC,IAAA,sBAAsB,EAAE,GAAG;AAC3B,IAAA,oBAAoB,EAAE,0BAA0B;AAChD,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,YAAY,EAAE,IAAI;AAClB,IAAA,qBAAqB,EAAE,KAAK;;AAGjB,MAAA,0BAA0B,GACrC;AACE,IAAA,GAAG,cAAc;;;;;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const HIGHLIGHT_SETTINGS = {
|
|
2
2
|
highlightByHoverNode: true,
|
|
3
3
|
highlightByHoverLink: true,
|
|
4
|
-
|
|
5
|
-
highlightDownFrames: 5,
|
|
4
|
+
highlightDuration: 150,
|
|
6
5
|
linkHoverExtraZone: 2,
|
|
7
6
|
/** Node */
|
|
8
7
|
highlightByNodeOnlyRoot: true,
|
|
@@ -57,6 +56,9 @@ const HIGHLIGHT_SETTINGS = {
|
|
|
57
56
|
highlightByLinkForArrowBorderColor: null,
|
|
58
57
|
highlightByLinkForArrowBorderSizingAdditional: 0,
|
|
59
58
|
};
|
|
59
|
+
const PERFORMANCE_HIGHLIGHT_SETTINGS = {
|
|
60
|
+
...HIGHLIGHT_SETTINGS,
|
|
61
|
+
};
|
|
60
62
|
|
|
61
|
-
export { HIGHLIGHT_SETTINGS };
|
|
63
|
+
export { HIGHLIGHT_SETTINGS, PERFORMANCE_HIGHLIGHT_SETTINGS };
|
|
62
64
|
//# sourceMappingURL=highlight-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight-settings.js","sources":["../../../../../src/module/GraphCanvas/constants/highlight-settings.ts"],"sourcesContent":["import type { HighlightSettingsInterface } from \"../types/highlight-settings\";\n\nexport const HIGHLIGHT_SETTINGS: Required<HighlightSettingsInterface> = {\n highlightByHoverNode: true,\n highlightByHoverLink: true,\n
|
|
1
|
+
{"version":3,"file":"highlight-settings.js","sources":["../../../../../src/module/GraphCanvas/constants/highlight-settings.ts"],"sourcesContent":["import type { HighlightSettingsInterface } from \"../types/highlight-settings\";\n\nexport const HIGHLIGHT_SETTINGS: Required<HighlightSettingsInterface> = {\n highlightByHoverNode: true,\n highlightByHoverLink: true,\n highlightDuration: 150,\n linkHoverExtraZone: 2,\n /** Node */\n highlightByNodeOnlyRoot: true,\n highlightByNodeForNodeColorFading: false,\n highlightByNodeForNodeColor: null,\n highlightByNodeForNodeSizingAdditional: 0.5,\n highlightByNodeForNodeSizingAdditionalCoefficient: 0.35,\n highlightByNodeForNodeFadingMin: 0.21,\n highlightByNodeForNodeBorderColor: null,\n highlightByNodeForNodeBorderSizingAdditional: 0,\n\n highlightByLinkForNodeColorFading: false,\n highlightByLinkForNodeColor: null,\n highlightByLinkForNodeSizingAdditional: 0.5,\n highlightByLinkForNodeSizingAdditionalCoefficient: 0.35,\n highlightByLinkForNodeFadingMin: 0.21,\n highlightByLinkForNodeBorderColor: null,\n highlightByLinkForNodeBorderSizingAdditional: 0,\n /** Text */\n highlightByNodeForTextShiftXAdditional: 0,\n highlightByNodeForTextShiftYAdditional: 2,\n highlightByNodeForTextSizingAdditional: 1,\n highlightByNodeForTextWeightAdditional: 0,\n highlightByNodeForTextFadingMin: 0.21,\n\n highlightByLinkForTextShiftXAdditional: 0,\n highlightByLinkForTextShiftYAdditional: 2,\n highlightByLinkForTextSizingAdditional: 1,\n highlightByLinkForTextWeightAdditional: 0,\n highlightByLinkForTextFadingMin: 0.21,\n /** Label */\n highlightByNodeForLabelFadingMin: 0.21,\n highlightByNodeForLabelSizingAdditional: 1,\n highlightByNodeForLabelWeightAdditional: 0,\n\n highlightByLinkForLabelFadingMin: 0.21,\n highlightByLinkForLabelSizingAdditional: 1,\n highlightByLinkForLabelWeightAdditional: 0,\n /** Link */\n highlightByNodeForLinkFadingMin: 0.21,\n highlightByNodeForLinkSizeAdditional: 0,\n highlightByNodeForLinkColor: null,\n\n highlightByLinkForLinkFadingMin: 0.21,\n highlightByLinkForLinkSizeAdditional: 0,\n highlightByLinkForLinkColor: null,\n /** Arrow */\n highlightByNodeForArrowFadingMin: 0.21,\n highlightByNodeForArrowSizeAdditional: 0,\n highlightByNodeForArrowColor: null,\n highlightByNodeForArrowBorderColor: null,\n highlightByNodeForArrowBorderSizingAdditional: 0,\n\n highlightByLinkForArrowFadingMin: 0.21,\n highlightByLinkForArrowSizeAdditional: 0,\n highlightByLinkForArrowColor: null,\n highlightByLinkForArrowBorderColor: null,\n highlightByLinkForArrowBorderSizingAdditional: 0,\n};\n\nexport const PERFORMANCE_HIGHLIGHT_SETTINGS: Required<HighlightSettingsInterface> = {\n ...HIGHLIGHT_SETTINGS,\n};\n"],"names":[],"mappings":"AAEa,MAAA,kBAAkB,GAAyC;AACtE,IAAA,oBAAoB,EAAE,IAAI;AAC1B,IAAA,oBAAoB,EAAE,IAAI;AAC1B,IAAA,iBAAiB,EAAE,GAAG;AACtB,IAAA,kBAAkB,EAAE,CAAC;;AAErB,IAAA,uBAAuB,EAAE,IAAI;AAC7B,IAAA,iCAAiC,EAAE,KAAK;AACxC,IAAA,2BAA2B,EAAE,IAAI;AACjC,IAAA,sCAAsC,EAAE,GAAG;AAC3C,IAAA,iDAAiD,EAAE,IAAI;AACvD,IAAA,+BAA+B,EAAE,IAAI;AACrC,IAAA,iCAAiC,EAAE,IAAI;AACvC,IAAA,4CAA4C,EAAE,CAAC;AAE/C,IAAA,iCAAiC,EAAE,KAAK;AACxC,IAAA,2BAA2B,EAAE,IAAI;AACjC,IAAA,sCAAsC,EAAE,GAAG;AAC3C,IAAA,iDAAiD,EAAE,IAAI;AACvD,IAAA,+BAA+B,EAAE,IAAI;AACrC,IAAA,iCAAiC,EAAE,IAAI;AACvC,IAAA,4CAA4C,EAAE,CAAC;;AAE/C,IAAA,sCAAsC,EAAE,CAAC;AACzC,IAAA,sCAAsC,EAAE,CAAC;AACzC,IAAA,sCAAsC,EAAE,CAAC;AACzC,IAAA,sCAAsC,EAAE,CAAC;AACzC,IAAA,+BAA+B,EAAE,IAAI;AAErC,IAAA,sCAAsC,EAAE,CAAC;AACzC,IAAA,sCAAsC,EAAE,CAAC;AACzC,IAAA,sCAAsC,EAAE,CAAC;AACzC,IAAA,sCAAsC,EAAE,CAAC;AACzC,IAAA,+BAA+B,EAAE,IAAI;;AAErC,IAAA,gCAAgC,EAAE,IAAI;AACtC,IAAA,uCAAuC,EAAE,CAAC;AAC1C,IAAA,uCAAuC,EAAE,CAAC;AAE1C,IAAA,gCAAgC,EAAE,IAAI;AACtC,IAAA,uCAAuC,EAAE,CAAC;AAC1C,IAAA,uCAAuC,EAAE,CAAC;;AAE1C,IAAA,+BAA+B,EAAE,IAAI;AACrC,IAAA,oCAAoC,EAAE,CAAC;AACvC,IAAA,2BAA2B,EAAE,IAAI;AAEjC,IAAA,+BAA+B,EAAE,IAAI;AACrC,IAAA,oCAAoC,EAAE,CAAC;AACvC,IAAA,2BAA2B,EAAE,IAAI;;AAEjC,IAAA,gCAAgC,EAAE,IAAI;AACtC,IAAA,qCAAqC,EAAE,CAAC;AACxC,IAAA,4BAA4B,EAAE,IAAI;AAClC,IAAA,kCAAkC,EAAE,IAAI;AACxC,IAAA,6CAA6C,EAAE,CAAC;AAEhD,IAAA,gCAAgC,EAAE,IAAI;AACtC,IAAA,qCAAqC,EAAE,CAAC;AACxC,IAAA,4BAA4B,EAAE,IAAI;AAClC,IAAA,kCAAkC,EAAE,IAAI;AACxC,IAAA,6CAA6C,EAAE,CAAC;;AAGrC,MAAA,8BAA8B,GAAyC;AAClF,IAAA,GAAG,kBAAkB;;;;;"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { FORCE_SETTINGS, PERFORMANCE_FORCE_SETTINGS } from './force-settings.js';
|
|
2
|
+
export { GRAPH_SETTINGS, PERFORMANCE_GRAPH_SETTINGS } from './graph-settings.js';
|
|
3
|
+
export { HIGHLIGHT_SETTINGS, PERFORMANCE_HIGHLIGHT_SETTINGS } from './highlight-settings.js';
|
|
4
|
+
export { LINK_OPTIONS, LINK_SETTINGS, PERFORMANCE_LINK_OPTIONS, PERFORMANCE_LINK_SETTINGS } from './link-settings.js';
|
|
5
|
+
export { NODE_OPTIONS, NODE_SETTINGS, PERFOMANCE_NODE_OPTIONS, PERFORMANCE_NODE_SETTINGS } from './node-settings.js';
|
|
3
6
|
|
|
4
7
|
const GRAPH_CACHE_TYPE = {
|
|
5
8
|
NodeOptions: "nodeOptions",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/module/GraphCanvas/constants/index.ts"],"sourcesContent":["export * from \"./common-settings\";\nexport * from \"./force-settings\";\nexport * from \"./graph-settings\";\nexport * from \"./highlight-settings\";\nexport * from \"./link-settings\";\nexport * from \"./node-settings\";\n\nexport const GRAPH_CACHE_TYPE = {\n NodeOptions: \"nodeOptions\",\n LinkOptions: \"linkOptions\",\n NodeText: \"nodeText\",\n NodeLabel: \"nodeLabel\",\n} as const;\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/module/GraphCanvas/constants/index.ts"],"sourcesContent":["export * from \"./common-settings\";\nexport * from \"./force-settings\";\nexport * from \"./graph-settings\";\nexport * from \"./highlight-settings\";\nexport * from \"./link-settings\";\nexport * from \"./node-settings\";\n\nexport const GRAPH_CACHE_TYPE = {\n NodeOptions: \"nodeOptions\",\n LinkOptions: \"linkOptions\",\n NodeText: \"nodeText\",\n NodeLabel: \"nodeLabel\",\n} as const;\n"],"names":[],"mappings":";;;;;;AAOa,MAAA,gBAAgB,GAAG;AAC9B,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,SAAS,EAAE,WAAW;;;;;"}
|
|
@@ -1,31 +1,40 @@
|
|
|
1
1
|
const LINK_SETTINGS = {
|
|
2
|
+
smartCache: true,
|
|
2
3
|
prettyDraw: true,
|
|
3
|
-
curve:
|
|
4
|
+
curve: true,
|
|
4
5
|
linkScaleSwitch: 1,
|
|
5
|
-
linkColorAfterScaleSwitch: "#
|
|
6
|
+
linkColorAfterScaleSwitch: "#C5C5C5FF",
|
|
6
7
|
linkColorBeforeScaleSwitch: "#999",
|
|
7
8
|
linkWidthAfterScaleSwitch: 0.1,
|
|
8
9
|
linkWidthBeforeScaleSwitch: 1,
|
|
9
10
|
arrow: true,
|
|
10
11
|
arrowByHighlight: true,
|
|
11
12
|
particles: true,
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
// spawn one more particle for N px
|
|
14
|
+
particleCountByDistance: 25,
|
|
15
|
+
// speed for 1px
|
|
16
|
+
particleSpeedByDistance: 50,
|
|
14
17
|
};
|
|
15
18
|
const LINK_OPTIONS = {
|
|
16
19
|
alpha: 1,
|
|
17
20
|
arrowAlpha: 1,
|
|
18
21
|
arrowSize: 2,
|
|
19
|
-
arrowBorderColor: "#
|
|
22
|
+
arrowBorderColor: "#C5C5C5FF",
|
|
20
23
|
arrowBorderWidth: 0.1,
|
|
21
24
|
particleAlpha: 1,
|
|
22
|
-
particleColor: "#
|
|
23
|
-
particleBorderColor: "#
|
|
25
|
+
particleColor: "#C5C5C5FF",
|
|
26
|
+
particleBorderColor: "#C5C5C5FF",
|
|
24
27
|
particleBorderWidth: 0.1,
|
|
25
|
-
particleCount: 2,
|
|
26
28
|
particleRadius: 0.5,
|
|
27
|
-
|
|
29
|
+
};
|
|
30
|
+
const PERFORMANCE_LINK_SETTINGS = {
|
|
31
|
+
...LINK_SETTINGS,
|
|
32
|
+
particles: false,
|
|
33
|
+
prettyDraw: false,
|
|
34
|
+
};
|
|
35
|
+
const PERFORMANCE_LINK_OPTIONS = {
|
|
36
|
+
...LINK_OPTIONS,
|
|
28
37
|
};
|
|
29
38
|
|
|
30
|
-
export { LINK_OPTIONS, LINK_SETTINGS };
|
|
39
|
+
export { LINK_OPTIONS, LINK_SETTINGS, PERFORMANCE_LINK_OPTIONS, PERFORMANCE_LINK_SETTINGS };
|
|
31
40
|
//# sourceMappingURL=link-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-settings.js","sources":["../../../../../src/module/GraphCanvas/constants/link-settings.ts"],"sourcesContent":["import type { LinkOptionsInterface, LinkSettingsInterface } from \"../types/link-settings\";\n\nexport const LINK_SETTINGS: Omit<\n Required<LinkSettingsInterface<Record<string, unknown>, Record<string, unknown>>>,\n \"options\"\n> = {\n prettyDraw: true,\n curve:
|
|
1
|
+
{"version":3,"file":"link-settings.js","sources":["../../../../../src/module/GraphCanvas/constants/link-settings.ts"],"sourcesContent":["import type { LinkOptionsInterface, LinkSettingsInterface } from \"../types/link-settings\";\n\nexport const LINK_SETTINGS: Omit<\n Required<LinkSettingsInterface<Record<string, unknown>, Record<string, unknown>>>,\n \"options\"\n> = {\n smartCache: true,\n prettyDraw: true,\n curve: true,\n linkScaleSwitch: 1,\n linkColorAfterScaleSwitch: \"#C5C5C5FF\",\n linkColorBeforeScaleSwitch: \"#999\",\n linkWidthAfterScaleSwitch: 0.1,\n linkWidthBeforeScaleSwitch: 1,\n arrow: true,\n arrowByHighlight: true,\n particles: true,\n // spawn one more particle for N px\n particleCountByDistance: 25,\n // speed for 1px\n particleSpeedByDistance: 50,\n};\n\nexport const LINK_OPTIONS: Omit<\n Required<LinkOptionsInterface<Record<string, unknown>, Record<string, unknown>>>,\n \"color\" | \"width\" | \"drawLink\" | \"drawExtraLink\" | \"arrowColor\"\n> = {\n alpha: 1,\n arrowAlpha: 1,\n arrowSize: 2,\n arrowBorderColor: \"#C5C5C5FF\",\n arrowBorderWidth: 0.1,\n particleAlpha: 1,\n particleColor: \"#C5C5C5FF\",\n particleBorderColor: \"#C5C5C5FF\",\n particleBorderWidth: 0.1,\n particleRadius: 0.5,\n};\n\nexport const PERFORMANCE_LINK_SETTINGS: Omit<\n Required<LinkSettingsInterface<Record<string, unknown>, Record<string, unknown>>>,\n \"options\"\n> = {\n ...LINK_SETTINGS,\n particles: false,\n prettyDraw: false,\n};\n\nexport const PERFORMANCE_LINK_OPTIONS: Omit<\n Required<LinkOptionsInterface<Record<string, unknown>, Record<string, unknown>>>,\n \"color\" | \"width\" | \"drawLink\" | \"drawExtraLink\" | \"arrowColor\"\n> = {\n ...LINK_OPTIONS,\n};\n"],"names":[],"mappings":"AAEa,MAAA,aAAa,GAGtB;AACF,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,eAAe,EAAE,CAAC;AAClB,IAAA,yBAAyB,EAAE,WAAW;AACtC,IAAA,0BAA0B,EAAE,MAAM;AAClC,IAAA,yBAAyB,EAAE,GAAG;AAC9B,IAAA,0BAA0B,EAAE,CAAC;AAC7B,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,gBAAgB,EAAE,IAAI;AACtB,IAAA,SAAS,EAAE,IAAI;;AAEf,IAAA,uBAAuB,EAAE,EAAE;;AAE3B,IAAA,uBAAuB,EAAE,EAAE;;AAGhB,MAAA,YAAY,GAGrB;AACF,IAAA,KAAK,EAAE,CAAC;AACR,IAAA,UAAU,EAAE,CAAC;AACb,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,gBAAgB,EAAE,WAAW;AAC7B,IAAA,gBAAgB,EAAE,GAAG;AACrB,IAAA,aAAa,EAAE,CAAC;AAChB,IAAA,aAAa,EAAE,WAAW;AAC1B,IAAA,mBAAmB,EAAE,WAAW;AAChC,IAAA,mBAAmB,EAAE,GAAG;AACxB,IAAA,cAAc,EAAE,GAAG;;AAGR,MAAA,yBAAyB,GAGlC;AACF,IAAA,GAAG,aAAa;AAChB,IAAA,SAAS,EAAE,KAAK;AAChB,IAAA,UAAU,EAAE,KAAK;;AAGN,MAAA,wBAAwB,GAGjC;AACF,IAAA,GAAG,YAAY;;;;;"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const NODE_SETTINGS = {
|
|
2
|
+
smartCache: true,
|
|
3
|
+
textScaleSteps: [],
|
|
2
4
|
nodeRadiusFlexible: true,
|
|
3
5
|
nodeRadiusLinkCountForStep: 5,
|
|
4
6
|
nodeRadiusIncrementByStep: 1,
|
|
@@ -35,14 +37,14 @@ const NODE_OPTIONS = {
|
|
|
35
37
|
textShiftX: 0,
|
|
36
38
|
textFont: "Arial",
|
|
37
39
|
textAlign: "center",
|
|
38
|
-
textColor: "#
|
|
40
|
+
textColor: "#d2d2d2",
|
|
39
41
|
textStyle: "normal",
|
|
40
42
|
textWeight: 500,
|
|
41
43
|
textGap: 0,
|
|
42
44
|
label: null,
|
|
43
45
|
labelAlpha: 1,
|
|
44
46
|
labelAlign: "center",
|
|
45
|
-
labelColor: "#
|
|
47
|
+
labelColor: "#ffffff",
|
|
46
48
|
labelFont: "Arial",
|
|
47
49
|
labelGap: 0,
|
|
48
50
|
labelSize: 3.5,
|
|
@@ -50,6 +52,14 @@ const NODE_OPTIONS = {
|
|
|
50
52
|
labelWeight: 500,
|
|
51
53
|
labelWidth: 20,
|
|
52
54
|
};
|
|
55
|
+
const PERFORMANCE_NODE_SETTINGS = {
|
|
56
|
+
...NODE_SETTINGS,
|
|
57
|
+
nodeRadiusFlexible: false,
|
|
58
|
+
nodeSizeFlexible: false,
|
|
59
|
+
};
|
|
60
|
+
const PERFOMANCE_NODE_OPTIONS = {
|
|
61
|
+
...NODE_OPTIONS,
|
|
62
|
+
};
|
|
53
63
|
|
|
54
|
-
export { NODE_OPTIONS, NODE_SETTINGS };
|
|
64
|
+
export { NODE_OPTIONS, NODE_SETTINGS, PERFOMANCE_NODE_OPTIONS, PERFORMANCE_NODE_SETTINGS };
|
|
55
65
|
//# sourceMappingURL=node-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-settings.js","sources":["../../../../../src/module/GraphCanvas/constants/node-settings.ts"],"sourcesContent":["import type { NodeOptionsInterface, NodeSettingsInterface } from \"../types/node-settings\";\n\nexport const NODE_SETTINGS: Omit<\n Required<NodeSettingsInterface<Record<string, unknown>, Record<string, unknown>>>,\n \"options\" | \"idGetter\"\n> = {\n nodeRadiusFlexible: true,\n nodeRadiusLinkCountForStep: 5,\n nodeRadiusIncrementByStep: 1,\n nodeRadiusMaxLinearSteps: 5,\n nodeRadiusLinkCountDividerForLog: 25,\n nodeRadiusLogFactor: 2.5,\n nodeSizeFlexible: true,\n nodeSizeLinkCountForStep: 5,\n nodeSizeIncrementByStep: 0.1,\n nodeSizeMaxLinearSteps: 5,\n nodeSizeLinkCountDividerForLog: 25,\n nodeSizeLogFactor: 2.5,\n textScaleMin: 1.5,\n textScaleMax: 18,\n textSizeMin: 3.5,\n textSizeMax: 1.5,\n textShiftYMin: 4,\n textShiftYMax: 2.5,\n textNodeDebug: false,\n};\n\nexport const NODE_OPTIONS: Omit<\n Required<NodeOptionsInterface<Record<string, unknown>, Record<string, unknown>>>,\n | \"color\"\n | \"text\"\n | \"textVisible\"\n | \"textSize\"\n | \"textShiftY\"\n | \"nodeDraw\"\n | \"nodeExtraDraw\"\n | \"textDraw\"\n | \"textExtraDraw\"\n> = {\n shape: \"circle\",\n height: 10,\n width: 15,\n borderRadius: 0,\n radius: 4,\n alpha: 1,\n labelXPadding: 1,\n labelYPadding: 1,\n borderWidth: 0.1,\n borderColor: \"#000000FF\",\n textAlpha: 1,\n textWidth: 20,\n textShiftX: 0,\n textFont: \"Arial\",\n textAlign: \"center\" as CanvasTextAlign,\n textColor: \"#
|
|
1
|
+
{"version":3,"file":"node-settings.js","sources":["../../../../../src/module/GraphCanvas/constants/node-settings.ts"],"sourcesContent":["import type { NodeOptionsInterface, NodeSettingsInterface } from \"../types/node-settings\";\n\nexport const NODE_SETTINGS: Omit<\n Required<NodeSettingsInterface<Record<string, unknown>, Record<string, unknown>>>,\n \"options\" | \"idGetter\"\n> = {\n smartCache: true,\n textScaleSteps: [],\n nodeRadiusFlexible: true,\n nodeRadiusLinkCountForStep: 5,\n nodeRadiusIncrementByStep: 1,\n nodeRadiusMaxLinearSteps: 5,\n nodeRadiusLinkCountDividerForLog: 25,\n nodeRadiusLogFactor: 2.5,\n nodeSizeFlexible: true,\n nodeSizeLinkCountForStep: 5,\n nodeSizeIncrementByStep: 0.1,\n nodeSizeMaxLinearSteps: 5,\n nodeSizeLinkCountDividerForLog: 25,\n nodeSizeLogFactor: 2.5,\n textScaleMin: 1.5,\n textScaleMax: 18,\n textSizeMin: 3.5,\n textSizeMax: 1.5,\n textShiftYMin: 4,\n textShiftYMax: 2.5,\n textNodeDebug: false,\n};\n\nexport const NODE_OPTIONS: Omit<\n Required<NodeOptionsInterface<Record<string, unknown>, Record<string, unknown>>>,\n | \"color\"\n | \"text\"\n | \"textVisible\"\n | \"textSize\"\n | \"textShiftY\"\n | \"nodeDraw\"\n | \"nodeExtraDraw\"\n | \"textDraw\"\n | \"textExtraDraw\"\n> = {\n shape: \"circle\",\n height: 10,\n width: 15,\n borderRadius: 0,\n radius: 4,\n alpha: 1,\n labelXPadding: 1,\n labelYPadding: 1,\n borderWidth: 0.1,\n borderColor: \"#000000FF\",\n textAlpha: 1,\n textWidth: 20,\n textShiftX: 0,\n textFont: \"Arial\",\n textAlign: \"center\" as CanvasTextAlign,\n textColor: \"#d2d2d2\",\n textStyle: \"normal\",\n textWeight: 500,\n textGap: 0,\n label: null,\n labelAlpha: 1,\n labelAlign: \"center\",\n labelColor: \"#ffffff\",\n labelFont: \"Arial\",\n labelGap: 0,\n labelSize: 3.5,\n labelStyle: \"normal\",\n labelWeight: 500,\n labelWidth: 20,\n};\n\nexport const PERFORMANCE_NODE_SETTINGS: Omit<\n Required<NodeSettingsInterface<Record<string, unknown>, Record<string, unknown>>>,\n \"options\" | \"idGetter\"\n> = {\n ...NODE_SETTINGS,\n nodeRadiusFlexible: false,\n nodeSizeFlexible: false,\n};\n\nexport const PERFOMANCE_NODE_OPTIONS: Omit<\n Required<NodeOptionsInterface<Record<string, unknown>, Record<string, unknown>>>,\n |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AAE;AACb,IAAA,UAAU,EAAE,CAAC;AACb,IAAA,QAAQ,EAAE,OAAO;AACjB,IAAA,SAAS,EAAE,QAA2B;AACtC,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,SAAS,EAAE,QAAQ;AACnB,IAAA,UAAU,EAAE,GAAG;AACf,IAAA,OAAO,EAAE,CAAC;AACV,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,UAAU,EAAE,CAAC;AACb,IAAA,UAAU,EAAE,QAAQ;AACpB,IAAA,UAAU,EAAE,SAAS;AACrB,IAAA,SAAS,EAAE,OAAO;AAClB,IAAA,QAAQ,EAAE,CAAC;AACX,IAAA,SAAS,EAAE,GAAG;AACd,IAAA,UAAU,EAAE,QAAQ;AACpB,IAAA,WAAW,EAAE,GAAG;AAChB,IAAA,UAAU,EAAE,EAAE;;AAGH,MAAA,yBAAyB,GAGlC;AACF,IAAA,GAAG,aAAa;AAChB,IAAA,kBAAkB,EAAE,KAAK;AACzB,IAAA,gBAAgB,EAAE,KAAK;;AAGZ,MAAA,uBAAuB,GAWhC;AACF,IAAA,GAAG,YAAY;;;;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FORCE_SETTINGS } from '../../constants/force-settings.js';
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
2
|
+
import '../../constants/graph-settings.js';
|
|
3
|
+
import '../../constants/highlight-settings.js';
|
|
4
|
+
import '../../constants/link-settings.js';
|
|
5
|
+
import '../../constants/node-settings.js';
|
|
4
6
|
|
|
5
7
|
function forceSettingsGetter(settings, prevSettings) {
|
|
6
8
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"force-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/force-settings-getter.ts"],"sourcesContent":["import { FORCE_SETTINGS } from \"../../constants\";\nimport type { ForceSettingsInterface } from \"../../types\";\n\nexport function forceSettingsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n settings: ForceSettingsInterface<NodeData, LinkData> | undefined,\n prevSettings?: Required<ForceSettingsInterface<NodeData, LinkData>>,\n): Required<ForceSettingsInterface<NodeData, LinkData>> {\n return {\n ...(prevSettings ?? (FORCE_SETTINGS as Required<ForceSettingsInterface<NodeData, LinkData>>)),\n ...settings,\n };\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"force-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/force-settings-getter.ts"],"sourcesContent":["import { FORCE_SETTINGS } from \"../../constants\";\nimport type { ForceSettingsInterface } from \"../../types\";\n\nexport function forceSettingsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n settings: ForceSettingsInterface<NodeData, LinkData> | undefined,\n prevSettings?: Required<ForceSettingsInterface<NodeData, LinkData>>,\n): Required<ForceSettingsInterface<NodeData, LinkData>> {\n return {\n ...(prevSettings ?? (FORCE_SETTINGS as Required<ForceSettingsInterface<NodeData, LinkData>>)),\n ...settings,\n };\n}\n"],"names":[],"mappings":";;;;;;AAGgB,SAAA,mBAAmB,CAIjC,QAAgE,EAChE,YAAmE,EAAA;IAEnE,OAAO;AACL,QAAA,IAAI,YAAY,IAAK,cAAuE,CAAC;AAC7F,QAAA,GAAG,QAAQ;KACZ;AACH;;;;"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import '../../constants/force-settings.js';
|
|
1
2
|
import { GRAPH_SETTINGS } from '../../constants/graph-settings.js';
|
|
3
|
+
import '../../constants/highlight-settings.js';
|
|
4
|
+
import '../../constants/link-settings.js';
|
|
5
|
+
import '../../constants/node-settings.js';
|
|
2
6
|
|
|
3
7
|
function graphSettingsGetter(settings, prevSettings) {
|
|
4
8
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/graph-settings-getter.ts"],"sourcesContent":["import { GRAPH_SETTINGS } from \"../../constants\";\nimport type { GraphSettingsInterface } from \"../../types/graph-settings\";\n\nexport function graphSettingsGetter<NodeData extends Record<string, unknown>>(\n settings: GraphSettingsInterface<NodeData> | undefined,\n prevSettings?: Required<GraphSettingsInterface<NodeData>>,\n): Required<GraphSettingsInterface<NodeData>> {\n return {\n ...(prevSettings ?? GRAPH_SETTINGS),\n ...settings,\n };\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/graph-settings-getter.ts"],"sourcesContent":["import { GRAPH_SETTINGS } from \"../../constants\";\nimport type { GraphSettingsInterface } from \"../../types/graph-settings\";\n\nexport function graphSettingsGetter<NodeData extends Record<string, unknown>>(\n settings: GraphSettingsInterface<NodeData> | undefined,\n prevSettings?: Required<GraphSettingsInterface<NodeData>>,\n): Required<GraphSettingsInterface<NodeData>> {\n return {\n ...(prevSettings ?? GRAPH_SETTINGS),\n ...settings,\n };\n}\n"],"names":[],"mappings":";;;;;;AAGgB,SAAA,mBAAmB,CACjC,QAAsD,EACtD,YAAyD,EAAA;IAEzD,OAAO;AACL,QAAA,IAAI,YAAY,IAAI,cAAc,CAAC;AACnC,QAAA,GAAG,QAAQ;KACZ;AACH;;;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '
|
|
1
|
+
import '../../constants/force-settings.js';
|
|
2
|
+
import '../../constants/graph-settings.js';
|
|
3
3
|
import { HIGHLIGHT_SETTINGS } from '../../constants/highlight-settings.js';
|
|
4
|
+
import '../../constants/link-settings.js';
|
|
5
|
+
import '../../constants/node-settings.js';
|
|
4
6
|
|
|
5
7
|
function highlightSettingsGetter(settings, prevSettings) {
|
|
6
8
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/highlight-settings-getter.ts"],"sourcesContent":["import { HIGHLIGHT_SETTINGS } from \"../../constants\";\nimport type { HighlightSettingsInterface } from \"../../types\";\n\nexport function highlightSettingsGetter(\n settings: HighlightSettingsInterface | undefined,\n prevSettings?: Required<HighlightSettingsInterface>,\n): Required<HighlightSettingsInterface> {\n return {\n ...(prevSettings ?? HIGHLIGHT_SETTINGS),\n ...settings,\n };\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"highlight-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/highlight-settings-getter.ts"],"sourcesContent":["import { HIGHLIGHT_SETTINGS } from \"../../constants\";\nimport type { HighlightSettingsInterface } from \"../../types\";\n\nexport function highlightSettingsGetter(\n settings: HighlightSettingsInterface | undefined,\n prevSettings?: Required<HighlightSettingsInterface>,\n): Required<HighlightSettingsInterface> {\n return {\n ...(prevSettings ?? HIGHLIGHT_SETTINGS),\n ...settings,\n };\n}\n"],"names":[],"mappings":";;;;;;AAGgB,SAAA,uBAAuB,CACrC,QAAgD,EAChD,YAAmD,EAAA;IAEnD,OAAO;AACL,QAAA,IAAI,YAAY,IAAI,kBAAkB,CAAC;AACvC,QAAA,GAAG,QAAQ;KACZ;AACH;;;;"}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '
|
|
1
|
+
import '../../constants/force-settings.js';
|
|
2
|
+
import '../../constants/graph-settings.js';
|
|
3
|
+
import '../../constants/highlight-settings.js';
|
|
3
4
|
import { LINK_SETTINGS, LINK_OPTIONS } from '../../constants/link-settings.js';
|
|
5
|
+
import '../../constants/node-settings.js';
|
|
4
6
|
|
|
5
7
|
function linkSettingsGetter(settings, prevSettings) {
|
|
6
8
|
return { ...(prevSettings ?? LINK_SETTINGS), ...settings };
|
|
7
9
|
}
|
|
8
10
|
function linkOptionsGetter() {
|
|
11
|
+
const aboveScale = this.areaTransform && this.areaTransform.k > this.linkSettings.linkScaleSwitch;
|
|
9
12
|
return {
|
|
10
13
|
...LINK_OPTIONS,
|
|
11
14
|
drawExtraLink: null,
|
|
12
15
|
drawLink: null,
|
|
13
|
-
color:
|
|
16
|
+
color: aboveScale
|
|
14
17
|
? this.linkSettings.linkColorAfterScaleSwitch
|
|
15
18
|
: this.linkSettings.linkColorBeforeScaleSwitch,
|
|
16
|
-
arrowColor:
|
|
19
|
+
arrowColor: aboveScale
|
|
17
20
|
? this.linkSettings.linkColorAfterScaleSwitch
|
|
18
21
|
: this.linkSettings.linkColorBeforeScaleSwitch,
|
|
19
|
-
width:
|
|
22
|
+
width: aboveScale
|
|
20
23
|
? this.linkSettings.linkWidthAfterScaleSwitch
|
|
21
24
|
: this.linkSettings.linkWidthBeforeScaleSwitch,
|
|
22
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/link-settings-getter.ts"],"sourcesContent":["import type { GraphCanvas } from \"../../GraphCanvas\";\nimport { LINK_OPTIONS, LINK_SETTINGS } from \"../../constants\";\nimport type { LinkOptionsInterface, LinkSettingsInterface } from \"../../types\";\n\nexport function linkSettingsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n settings: LinkSettingsInterface<NodeData, LinkData> | undefined,\n prevSettings?: Required<Omit<LinkSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<LinkSettingsInterface<NodeData, LinkData>, \"options\">,\n): Required<Omit<LinkSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<LinkSettingsInterface<NodeData, LinkData>, \"options\"> {\n return { ...(prevSettings ?? LINK_SETTINGS), ...settings };\n}\n\nexport function linkOptionsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>): Required<LinkOptionsInterface<NodeData, LinkData>> {\n return {\n ...LINK_OPTIONS,\n drawExtraLink: null,\n drawLink: null,\n color
|
|
1
|
+
{"version":3,"file":"link-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/link-settings-getter.ts"],"sourcesContent":["import type { GraphCanvas } from \"../../GraphCanvas\";\nimport { LINK_OPTIONS, LINK_SETTINGS } from \"../../constants\";\nimport type { LinkOptionsInterface, LinkSettingsInterface } from \"../../types\";\n\nexport function linkSettingsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n settings: LinkSettingsInterface<NodeData, LinkData> | undefined,\n prevSettings?: Required<Omit<LinkSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<LinkSettingsInterface<NodeData, LinkData>, \"options\">,\n): Required<Omit<LinkSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<LinkSettingsInterface<NodeData, LinkData>, \"options\"> {\n return { ...(prevSettings ?? LINK_SETTINGS), ...settings };\n}\n\nexport function linkOptionsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>): Required<LinkOptionsInterface<NodeData, LinkData>> {\n const aboveScale = this.areaTransform && this.areaTransform.k > this.linkSettings.linkScaleSwitch;\n\n return {\n ...LINK_OPTIONS,\n drawExtraLink: null,\n drawLink: null,\n color: aboveScale\n ? this.linkSettings.linkColorAfterScaleSwitch\n : this.linkSettings.linkColorBeforeScaleSwitch,\n arrowColor: aboveScale\n ? this.linkSettings.linkColorAfterScaleSwitch\n : this.linkSettings.linkColorBeforeScaleSwitch,\n width: aboveScale\n ? this.linkSettings.linkWidthAfterScaleSwitch\n : this.linkSettings.linkWidthBeforeScaleSwitch,\n };\n}\n"],"names":[],"mappings":";;;;;;AAIgB,SAAA,kBAAkB,CAIhC,QAA+D,EAC/D,YAC4D,EAAA;IAG5D,OAAO,EAAE,IAAI,YAAY,IAAI,aAAa,CAAC,EAAE,GAAG,QAAQ,EAAE;AAC5D;SAEgB,iBAAiB,GAAA;AAI/B,IAAA,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,eAAe;IAEjG,OAAO;AACL,QAAA,GAAG,YAAY;AACf,QAAA,aAAa,EAAE,IAAI;AACnB,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,KAAK,EAAE;AACL,cAAE,IAAI,CAAC,YAAY,CAAC;AACpB,cAAE,IAAI,CAAC,YAAY,CAAC,0BAA0B;AAChD,QAAA,UAAU,EAAE;AACV,cAAE,IAAI,CAAC,YAAY,CAAC;AACpB,cAAE,IAAI,CAAC,YAAY,CAAC,0BAA0B;AAChD,QAAA,KAAK,EAAE;AACL,cAAE,IAAI,CAAC,YAAY,CAAC;AACpB,cAAE,IAAI,CAAC,YAAY,CAAC,0BAA0B;KACjD;AACH;;;;"}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { colorGetter } from '../../../../lib/color-getter.js';
|
|
2
2
|
import '@krainovsd/js-helpers';
|
|
3
|
-
import '
|
|
3
|
+
import '../../constants/force-settings.js';
|
|
4
|
+
import '../../constants/graph-settings.js';
|
|
5
|
+
import '../../constants/highlight-settings.js';
|
|
6
|
+
import '../../constants/link-settings.js';
|
|
4
7
|
import { NODE_SETTINGS, NODE_OPTIONS } from '../../constants/node-settings.js';
|
|
5
8
|
|
|
6
9
|
function nodeSettingsGetter(settings, prevNodeSettings) {
|
|
7
|
-
|
|
10
|
+
const result = {
|
|
8
11
|
...(prevNodeSettings ?? NODE_SETTINGS),
|
|
9
12
|
idGetter: nodeIdGetter,
|
|
10
13
|
...settings,
|
|
11
14
|
};
|
|
15
|
+
if (result.smartCache && (!result.textScaleSteps || result.textScaleSteps.length === 0)) {
|
|
16
|
+
const step = (result.textScaleMax - result.textScaleMin) / 9;
|
|
17
|
+
const steps = [];
|
|
18
|
+
for (let i = 0; i < 10; i++) {
|
|
19
|
+
steps.push(result.textScaleMin + i * step);
|
|
20
|
+
}
|
|
21
|
+
result.textScaleSteps = steps;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
12
24
|
}
|
|
13
25
|
const color = colorGetter();
|
|
14
26
|
function nodeOptionsGetter(node) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/node-settings-getter.ts"],"sourcesContent":["import type { ZoomTransform } from \"d3-zoom\";\nimport { colorGetter } from \"@/lib\";\nimport type { GraphCanvas } from \"../../GraphCanvas\";\nimport { NODE_OPTIONS, NODE_SETTINGS } from \"../../constants\";\nimport type { NodeInterface, NodeOptionsInterface, NodeSettingsInterface } from \"../../types\";\n\nexport function nodeSettingsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n settings: NodeSettingsInterface<NodeData, LinkData> | undefined,\n prevNodeSettings?: Required<Omit<NodeSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<NodeSettingsInterface<NodeData, LinkData>, \"options\">,\n): Required<Omit<NodeSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<NodeSettingsInterface<NodeData, LinkData>, \"options\"> {\n
|
|
1
|
+
{"version":3,"file":"node-settings-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/settings/node-settings-getter.ts"],"sourcesContent":["import type { ZoomTransform } from \"d3-zoom\";\nimport { colorGetter } from \"@/lib\";\nimport type { GraphCanvas } from \"../../GraphCanvas\";\nimport { NODE_OPTIONS, NODE_SETTINGS } from \"../../constants\";\nimport type { NodeInterface, NodeOptionsInterface, NodeSettingsInterface } from \"../../types\";\n\nexport function nodeSettingsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n settings: NodeSettingsInterface<NodeData, LinkData> | undefined,\n prevNodeSettings?: Required<Omit<NodeSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<NodeSettingsInterface<NodeData, LinkData>, \"options\">,\n): Required<Omit<NodeSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<NodeSettingsInterface<NodeData, LinkData>, \"options\"> {\n const result = {\n ...(prevNodeSettings ?? NODE_SETTINGS),\n idGetter: nodeIdGetter,\n ...settings,\n };\n if (result.smartCache && (!result.textScaleSteps || result.textScaleSteps.length === 0)) {\n const step = (result.textScaleMax - result.textScaleMin) / 9;\n const steps: number[] = [];\n for (let i = 0; i < 10; i++) {\n steps.push(result.textScaleMin + i * step);\n }\n result.textScaleSteps = steps;\n }\n return result as Required<Omit<NodeSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<NodeSettingsInterface<NodeData, LinkData>, \"options\">;\n}\n\nconst color = colorGetter();\n\nexport function nodeOptionsGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n this: GraphCanvas<NodeData, LinkData>,\n node: NodeInterface<NodeData>,\n): Required<NodeOptionsInterface<NodeData, LinkData>> {\n const { textShiftY, textSize } = nodeTextSizeGetter(this.areaTransform, this.nodeSettings);\n\n return {\n ...NODE_OPTIONS,\n nodeDraw: null,\n nodeExtraDraw: null,\n textDraw: null,\n textExtraDraw: null,\n color: color(String(node.group ?? \"_DEFAULT\")),\n textVisible: Boolean(this.areaTransform.k > this.nodeSettings.textScaleMin),\n text: node.name ?? node.id.toString(),\n textShiftY,\n textSize,\n };\n}\n\nexport function nodeTextSizeGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n transform: ZoomTransform | undefined,\n nodeSettings: Required<Omit<NodeSettingsInterface<NodeData, LinkData>, \"options\">> &\n Pick<NodeSettingsInterface<NodeData, LinkData>, \"options\">,\n) {\n let textSize: number = nodeSettings.textSizeMin;\n let textShiftY: number = nodeSettings.textShiftYMin;\n\n if (transform) {\n if (transform.k >= nodeSettings.textScaleMax) {\n textSize = nodeSettings.textSizeMax;\n textShiftY = nodeSettings.textShiftYMax;\n } else if (transform.k > nodeSettings.textScaleMin) {\n textSize =\n nodeSettings.textSizeMin +\n ((transform.k - nodeSettings.textScaleMin) *\n (nodeSettings.textSizeMax - nodeSettings.textSizeMin)) /\n (nodeSettings.textScaleMax - nodeSettings.textScaleMin);\n\n textShiftY =\n nodeSettings.textShiftYMin +\n ((transform.k - nodeSettings.textScaleMin) *\n (nodeSettings.textShiftYMax - nodeSettings.textShiftYMin)) /\n (nodeSettings.textScaleMax - nodeSettings.textScaleMin);\n }\n }\n\n return { textSize, textShiftY };\n}\n\nexport type NodeRadiusGetterOptions = {\n linkCount: number | undefined;\n radiusFlexible: boolean;\n radiusInitial: number;\n radiusLinkCountForStep: number;\n radiusIncrementByStep: number;\n radiusMaxLinearSteps: number;\n radiusLogFactor: number;\n radiusLinkCountDividerForLog: number;\n};\n\nexport function nodeRadiusGetter({\n radiusFlexible,\n linkCount,\n radiusInitial,\n radiusIncrementByStep,\n radiusLinkCountDividerForLog,\n radiusLinkCountForStep,\n radiusLogFactor,\n radiusMaxLinearSteps,\n}: NodeRadiusGetterOptions) {\n if (!radiusFlexible || !linkCount) return radiusInitial;\n const steps = linkCount / radiusLinkCountForStep;\n\n if (steps < radiusMaxLinearSteps) {\n return steps * radiusIncrementByStep + radiusInitial;\n }\n\n return (\n radiusInitial +\n radiusMaxLinearSteps * radiusIncrementByStep +\n radiusLogFactor * Math.log10(linkCount / radiusLinkCountDividerForLog)\n );\n}\n\nexport type NodeSizeGetterOptions = {\n linkCount: number | undefined;\n sizeFlexible: boolean;\n widthInitial: number;\n heightInitial: number;\n sizeLinkCountForStep: number;\n sizeIncrementByStep: number;\n sizeMaxLinearSteps: number;\n sizeLogFactor: number;\n sizeLinkCountDividerForLog: number;\n};\n\nexport function nodeSizeGetter({\n heightInitial,\n linkCount,\n sizeFlexible,\n widthInitial,\n sizeIncrementByStep,\n sizeLinkCountDividerForLog,\n sizeLinkCountForStep,\n sizeLogFactor,\n sizeMaxLinearSteps,\n}: NodeSizeGetterOptions) {\n let additionalSizeCoefficient = 1;\n if (sizeFlexible && linkCount != undefined) {\n const steps = linkCount / sizeLinkCountForStep;\n if (steps < sizeMaxLinearSteps) {\n additionalSizeCoefficient += steps * sizeIncrementByStep;\n } else {\n additionalSizeCoefficient +=\n sizeMaxLinearSteps * sizeIncrementByStep +\n sizeLogFactor * Math.log10(linkCount / sizeLinkCountDividerForLog);\n }\n }\n\n return {\n width: widthInitial * additionalSizeCoefficient,\n height: heightInitial * additionalSizeCoefficient,\n additionalSizeCoefficient,\n };\n}\n\nexport function nodeIdGetter<NodeData extends Record<string, unknown>>(\n node: NodeInterface<NodeData>,\n) {\n return node.id;\n}\n"],"names":[],"mappings":";;;;;;;;AAMgB,SAAA,kBAAkB,CAIhC,QAA+D,EAC/D,gBAC4D,EAAA;AAG5D,IAAA,MAAM,MAAM,GAAG;AACb,QAAA,IAAI,gBAAgB,IAAI,aAAa,CAAC;AACtC,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,GAAG,QAAQ;KACZ;AACD,IAAA,IAAI,MAAM,CAAC,UAAU,KAAK,CAAC,MAAM,CAAC,cAAc,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE;AACvF,QAAA,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,CAAC;QAC5D,MAAM,KAAK,GAAa,EAAE;AAC1B,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;YAC3B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,CAAC,GAAG,IAAI,CAAC;;AAE5C,QAAA,MAAM,CAAC,cAAc,GAAG,KAAK;;AAE/B,IAAA,OAAO,MACqD;AAC9D;AAEA,MAAM,KAAK,GAAG,WAAW,EAAE;AAErB,SAAU,iBAAiB,CAK/B,IAA6B,EAAA;AAE7B,IAAA,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC;IAE1F,OAAO;AACL,QAAA,GAAG,YAAY;AACf,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,aAAa,EAAE,IAAI;AACnB,Q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
|
|
|
1
1
|
import { COMMON_SETTINGS } from '../../constants/common-settings.js';
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
2
|
+
import '../../constants/force-settings.js';
|
|
3
|
+
import '../../constants/graph-settings.js';
|
|
4
|
+
import '../../constants/highlight-settings.js';
|
|
5
|
+
import '../../constants/link-settings.js';
|
|
6
|
+
import '../../constants/node-settings.js';
|
|
4
7
|
|
|
5
8
|
function calculateCurveLinkPositionByNode(xStart, yStart, xEnd, yEnd, sourceNode, targetNode, groupIndex, arrowSize = 0) {
|
|
6
9
|
const sourceRadius = (sourceNode._radius ?? COMMON_SETTINGS.nodeRadius) + (sourceNode._borderWidth ?? 0) * 0.5;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-curve-link-position-by-node.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.ts"],"sourcesContent":["import { COMMON_SETTINGS } from \"../../constants\";\nimport type { NodeInterface } from \"../../types\";\n\nexport function calculateCurveLinkPositionByNode<NodeData extends Record<string, unknown>>(\n xStart: number,\n yStart: number,\n xEnd: number,\n yEnd: number,\n sourceNode: NodeInterface<NodeData>,\n targetNode: NodeInterface<NodeData>,\n groupIndex: number,\n arrowSize: number = 0,\n) {\n const sourceRadius =\n (sourceNode._radius ?? COMMON_SETTINGS.nodeRadius) + (sourceNode._borderWidth ?? 0) * 0.5;\n const targetRadius =\n (targetNode._radius ?? COMMON_SETTINGS.nodeRadius) + (targetNode._borderWidth ?? 0) * 0.5;\n const effectiveTargetRadius = targetRadius + arrowSize * 0.9;\n\n const mx = (xStart + xEnd) * 0.5;\n const my = (yStart + yEnd) * 0.5;\n const dx = xEnd - xStart;\n const dy = yEnd - yStart;\n const lenSq = dx * dx + dy * dy;\n const len = lenSq > 0 ? Math.sqrt(lenSq) : 1;\n\n const nx = -dy / len;\n const ny = dx / len;\n\n const offset = 0.12 * len * groupIndex;\n\n const xControl = mx + nx * offset;\n const yControl = my + ny * offset;\n\n const [xStartP, yStartP] = adjustPoint(xStart, yStart, xControl, yControl, sourceRadius);\n const [xEndP, yEndP] = adjustPoint(xEnd, yEnd, xControl, yControl, effectiveTargetRadius);\n const [xEndArrow, yEndArrow] = adjustPoint(xEnd, yEnd, xControl, yControl, targetRadius);\n\n return {\n xStart: xStartP,\n yStart: yStartP,\n xEnd: xEndP,\n yEnd: yEndP,\n xControl,\n yControl,\n xEndArrow,\n yEndArrow,\n };\n}\n\nfunction adjustPoint(\n x: number,\n y: number,\n xControl: number,\n yControl: number,\n radius: number,\n): [number, number] {\n const dxToControl = xControl - x;\n const dyToControl = yControl - y;\n const distToControl = Math.sqrt(dxToControl * dxToControl + dyToControl * dyToControl) || 1;\n\n return [x + (dxToControl / distToControl) * radius, y + (dyToControl / distToControl) * radius];\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculate-curve-link-position-by-node.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.ts"],"sourcesContent":["import { COMMON_SETTINGS } from \"../../constants\";\nimport type { NodeInterface } from \"../../types\";\n\nexport function calculateCurveLinkPositionByNode<NodeData extends Record<string, unknown>>(\n xStart: number,\n yStart: number,\n xEnd: number,\n yEnd: number,\n sourceNode: NodeInterface<NodeData>,\n targetNode: NodeInterface<NodeData>,\n groupIndex: number,\n arrowSize: number = 0,\n) {\n const sourceRadius =\n (sourceNode._radius ?? COMMON_SETTINGS.nodeRadius) + (sourceNode._borderWidth ?? 0) * 0.5;\n const targetRadius =\n (targetNode._radius ?? COMMON_SETTINGS.nodeRadius) + (targetNode._borderWidth ?? 0) * 0.5;\n const effectiveTargetRadius = targetRadius + arrowSize * 0.9;\n\n const mx = (xStart + xEnd) * 0.5;\n const my = (yStart + yEnd) * 0.5;\n const dx = xEnd - xStart;\n const dy = yEnd - yStart;\n const lenSq = dx * dx + dy * dy;\n const len = lenSq > 0 ? Math.sqrt(lenSq) : 1;\n\n const nx = -dy / len;\n const ny = dx / len;\n\n const offset = 0.12 * len * groupIndex;\n\n const xControl = mx + nx * offset;\n const yControl = my + ny * offset;\n\n const [xStartP, yStartP] = adjustPoint(xStart, yStart, xControl, yControl, sourceRadius);\n const [xEndP, yEndP] = adjustPoint(xEnd, yEnd, xControl, yControl, effectiveTargetRadius);\n const [xEndArrow, yEndArrow] = adjustPoint(xEnd, yEnd, xControl, yControl, targetRadius);\n\n return {\n xStart: xStartP,\n yStart: yStartP,\n xEnd: xEndP,\n yEnd: yEndP,\n xControl,\n yControl,\n xEndArrow,\n yEndArrow,\n };\n}\n\nfunction adjustPoint(\n x: number,\n y: number,\n xControl: number,\n yControl: number,\n radius: number,\n): [number, number] {\n const dxToControl = xControl - x;\n const dyToControl = yControl - y;\n const distToControl = Math.sqrt(dxToControl * dxToControl + dyToControl * dyToControl) || 1;\n\n return [x + (dxToControl / distToControl) * radius, y + (dyToControl / distToControl) * radius];\n}\n"],"names":[],"mappings":";;;;;;;SAGgB,gCAAgC,CAC9C,MAAc,EACd,MAAc,EACd,IAAY,EACZ,IAAY,EACZ,UAAmC,EACnC,UAAmC,EACnC,UAAkB,EAClB,YAAoB,CAAC,EAAA;IAErB,MAAM,YAAY,GAChB,CAAC,UAAU,CAAC,OAAO,IAAI,eAAe,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,YAAY,IAAI,CAAC,IAAI,GAAG;IAC3F,MAAM,YAAY,GAChB,CAAC,UAAU,CAAC,OAAO,IAAI,eAAe,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,YAAY,IAAI,CAAC,IAAI,GAAG;AAC3F,IAAA,MAAM,qBAAqB,GAAG,YAAY,GAAG,SAAS,GAAG,GAAG;IAE5D,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI,IAAI,GAAG;IAChC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI,IAAI,GAAG;AAChC,IAAA,MAAM,EAAE,GAAG,IAAI,GAAG,MAAM;AACxB,IAAA,MAAM,EAAE,GAAG,I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AChC,IAAA,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC;IAE3F,OAAO,CAAC,CAAC,GAAG,CAAC,WAAW,GAAG,aAAa,IAAI,MAAM,EAAE,CAAC,GAAG,CAAC,WAAW,GAAG,aAAa,IAAI,MAAM,CAAC;AACjG;;;;"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { COMMON_SETTINGS } from '../../constants/common-settings.js';
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
2
|
+
import '../../constants/force-settings.js';
|
|
3
|
+
import '../../constants/graph-settings.js';
|
|
4
|
+
import '../../constants/highlight-settings.js';
|
|
5
|
+
import '../../constants/link-settings.js';
|
|
6
|
+
import '../../constants/node-settings.js';
|
|
4
7
|
|
|
5
8
|
function calculateLinkPositionByNode(xStart, yStart, xEnd, yEnd, sourceNode, targetNode, arrowSize = 0) {
|
|
6
9
|
const sourcePoint = getLinkPoint({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-link-position-by-node.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/calculate-link-position-by-node.ts"],"sourcesContent":["import { COMMON_SETTINGS } from \"../../constants\";\nimport type { NodeInterface } from \"../../types\";\n\ntype Point = {\n x: number;\n y: number;\n};\n\nexport function calculateLinkPositionByNode<NodeData extends Record<string, unknown>>(\n xStart: number,\n yStart: number,\n xEnd: number,\n yEnd: number,\n sourceNode: NodeInterface<NodeData>,\n targetNode: NodeInterface<NodeData>,\n arrowSize = 0,\n) {\n const sourcePoint = getLinkPoint({\n xStart,\n yStart,\n xEnd,\n yEnd,\n arrowSize: 0,\n node: sourceNode,\n oppositeNode: targetNode,\n });\n const targetPoint = getLinkPoint({\n xStart: xEnd,\n yStart: yEnd,\n xEnd: xStart,\n yEnd: yStart,\n arrowSize: arrowSize > 0 ? arrowSize * 0.9 : 0,\n node: targetNode,\n oppositeNode: sourceNode,\n });\n const targetPointArrow = getLinkPoint({\n xStart: xEnd,\n yStart: yEnd,\n xEnd: xStart,\n yEnd: yStart,\n arrowSize: 0,\n node: targetNode,\n oppositeNode: sourceNode,\n });\n\n const distance =\n targetPoint && sourcePoint\n ? Math.sqrt((targetPoint.x - sourcePoint.x) ** 2 + (targetPoint.y - sourcePoint.y) ** 2)\n : 0;\n\n return {\n xStart: sourcePoint.x,\n yStart: sourcePoint.y,\n xEnd: targetPoint.x,\n yEnd: targetPoint.y,\n xEndArrow: targetPointArrow.x,\n yEndArrow: targetPointArrow.y,\n distance,\n };\n}\n\ntype GetLinkPointProps<NodeData extends Record<string, unknown>> = {\n xStart: number;\n yStart: number;\n xEnd: number;\n yEnd: number;\n arrowSize: number;\n node: NodeInterface<NodeData>;\n oppositeNode: NodeInterface<NodeData>;\n};\nfunction getLinkPoint<NodeData extends Record<string, unknown>>(opts: GetLinkPointProps<NodeData>) {\n let nodePoint: Point;\n switch (opts.node._shape) {\n case \"circle\": {\n nodePoint = getCircleIntersection({\n x: opts.xStart,\n y: opts.yStart,\n radius:\n (opts.node._radius ?? COMMON_SETTINGS.nodeRadius) +\n (opts.node._borderWidth ? opts.node._borderWidth / 2 : 0),\n oppositeX: opts.xEnd,\n oppositeY: opts.yEnd,\n arrowSize: opts.arrowSize,\n });\n break;\n }\n case \"square\":\n case \"text\": {\n nodePoint = getRectangleIntersection({\n arrowSize: opts.arrowSize,\n x: opts.xStart,\n y: opts.yStart,\n height: (opts.node._height ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),\n width: (opts.node._width ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),\n oppositeX: opts.xEnd,\n oppositeY: opts.yEnd,\n borderRadius: opts.node._shape === \"text\" ? 0 : (opts.node._borderRadius ?? 0),\n });\n break;\n }\n default: {\n nodePoint = getCircleIntersection({\n x: opts.xStart,\n y: opts.yStart,\n radius: opts.node._radius ?? COMMON_SETTINGS.nodeRadius,\n oppositeX: opts.xEnd,\n oppositeY: opts.yEnd,\n arrowSize: opts.arrowSize,\n });\n }\n }\n\n return nodePoint;\n}\n\ntype GetCircleIntersection = {\n x: number;\n y: number;\n radius: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n};\n\nfunction getCircleIntersection(opts: GetCircleIntersection): Point {\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n const dr = Math.sqrt(dx * dx + dy * dy);\n\n const radius = opts.radius + opts.arrowSize;\n\n return {\n x: opts.x + (dx * radius) / dr,\n y: opts.y + (dy * radius) / dr,\n };\n}\n\ntype GetRectangleIntersection = {\n x: number;\n y: number;\n width: number;\n height: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n borderRadius: number;\n};\n\nfunction getRectangleIntersection(opts: GetRectangleIntersection): Point {\n const halfWidth = opts.width / 2;\n const halfHeight = opts.height / 2;\n\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n\n let relX: number, relY: number;\n\n if (Math.abs(dx) <= halfWidth && Math.abs(dy) <= halfHeight) {\n const distToRight = halfWidth - dx;\n const distToLeft = halfWidth + dx;\n const distToTop = halfHeight - dy;\n const distToBottom = halfHeight + dy;\n\n const minDist = Math.min(distToRight, distToLeft, distToTop, distToBottom);\n\n relX = minDist === distToRight ? halfWidth : minDist === distToLeft ? -halfWidth : dx;\n relY = minDist === distToTop ? halfHeight : minDist === distToBottom ? -halfHeight : dy;\n } else {\n const absDx = Math.abs(dx);\n const absDy = Math.abs(dy);\n\n if (halfWidth * absDy < halfHeight * absDx) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n if (Math.abs(relY) > halfHeight) {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n }\n } else {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n if (Math.abs(relX) > halfWidth) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n }\n }\n }\n\n if (opts.borderRadius != undefined) {\n const { x, y } = squareRadiusFix(relX, relY, halfWidth, halfHeight, opts.borderRadius);\n if (x != undefined) relX = x;\n if (y != undefined) relY = y;\n }\n\n if (opts.arrowSize > 0) {\n const edgeDist = Math.sqrt(relX * relX + relY * relY);\n const scale = (edgeDist + opts.arrowSize) / edgeDist;\n relX *= scale;\n relY *= scale;\n }\n\n return {\n x: opts.x + relX,\n y: opts.y + relY,\n };\n}\n\n// eslint-disable-next-line no-warning-comments\n// TODO: Need upgrade\nfunction squareRadiusFix(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n borderRadius: number,\n) {\n const epsilon = 1e-6;\n const absX = Math.abs(relX);\n const absY = Math.abs(relY);\n\n let side: string | null = null;\n if (absX >= halfWidth - epsilon) {\n side = relX > 0 ? \"right\" : \"left\";\n } else if (absY >= halfHeight - epsilon) {\n side = relY > 0 ? \"top\" : \"bottom\";\n }\n\n if (side) {\n const topBound = halfHeight - borderRadius;\n const bottomBound = -topBound;\n const rightBound = halfWidth - borderRadius;\n const leftBound = -rightBound;\n\n switch (side) {\n case \"right\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-bottom\");\n }\n break;\n case \"left\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-bottom\");\n }\n break;\n case \"top\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-left\");\n }\n break;\n case \"bottom\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-left\");\n }\n break;\n default:\n break;\n }\n }\n\n return { x: undefined, y: undefined };\n}\n\nfunction checkIntersection(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner: Parameters<typeof intersectWithCircle>[5],\n) {\n const intersect = intersectWithCircle(relX, relY, halfWidth, halfHeight, r, corner);\n\n return intersect ?? { x: undefined, y: undefined };\n}\n\nfunction intersectWithCircle(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner:\n | \"right-top\"\n | \"right-bottom\"\n | \"left-top\"\n | \"left-bottom\"\n | \"top-right\"\n | \"top-left\"\n | \"bottom-right\"\n | \"bottom-left\",\n) {\n switch (corner) {\n case \"top-right\":\n corner = \"right-top\";\n break;\n case \"bottom-right\":\n corner = \"right-bottom\";\n break;\n case \"top-left\":\n corner = \"left-top\";\n break;\n case \"bottom-left\":\n corner = \"left-bottom\";\n break;\n default:\n break;\n }\n\n let cx: number, cy: number;\n switch (corner) {\n case \"right-top\":\n cx = halfWidth - r;\n cy = halfHeight - r;\n break;\n case \"right-bottom\":\n cx = halfWidth - r;\n cy = -halfHeight + r;\n break;\n case \"left-top\":\n cx = -halfWidth + r;\n cy = halfHeight - r;\n break;\n case \"left-bottom\":\n cx = -halfWidth + r;\n cy = -halfHeight + r;\n break;\n default:\n return null;\n }\n\n const a = relX ** 2 + relY ** 2;\n if (a === 0) return null;\n\n const b = -2 * (relX * cx + relY * cy);\n const c = cx ** 2 + cy ** 2 - r ** 2;\n const discriminant = b ** 2 - 4 * a * c;\n\n if (discriminant < 0) return null;\n const sqrtD = Math.sqrt(discriminant);\n\n const t2 = (-b - sqrtD) / (2 * a);\n const t1 = (-b + sqrtD) / (2 * a);\n const t = t2 > 0 ? t2 : t1 > 0 ? t1 : null;\n\n if (t === null || t >= 1) return null;\n\n const x = t * relX;\n const y = t * relY;\n\n let valid = false;\n switch (corner) {\n case \"right-top\":\n valid = x >= cx && y >= cy;\n break;\n case \"right-bottom\":\n valid = x >= cx && y <= cy;\n break;\n case \"left-top\":\n valid = x <= cx && y >= cy;\n break;\n case \"left-bottom\":\n valid = x <= cx && y <= cy;\n break;\n default:\n break;\n }\n\n return valid ? { x, y } : null;\n}\n"],"names":[],"mappings":";;;;SAQgB,2BAA2B,CACzC,MAAc,EACd,MAAc,EACd,IAAY,EACZ,IAAY,EACZ,UAAmC,EACnC,UAAmC,EACnC,SAAS,GAAG,CAAC,EAAA;IAEb,MAAM,WAAW,GAAG,YAAY,CAAC;QAC/B,MAAM;QACN,MAAM;QACN,IAAI;QACJ,IAAI;AACJ,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,IAAI,EAAE,UAEP,CAAA,CAAC;IACF,MAAM,WAAW,GAAG,YAAY,CAAC;AAC/B,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,SAAS,EAAE,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,GAAG,GAAG,CAAC;AAC9C,QAAA,IAAI,EAAE,UAEP,CAAA,CAAC;IACF,MAAM,gBAAgB,GAAG,YAAY,CAAC;AACpC,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,IAAI,EAAE,UAEP,CAAA,CAAC;AAEF,IAAA,MAAM,QAAQ,GACZ,WAAW,IAAI;AACb,UAAE,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,KAAK,CAAC;UACrF,CAAC;IAEP,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,GAAG,CAAC,GAAG,CAAC;IAEvC,IAAI,YAAY,GAAG,CAAC;AAAE,QAAA,OAAO,IAAI;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;AAErC,IAAA,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC;AACjC,IAAA,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI;AAE1C,IAAA,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;AAErC,IAAA,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI;AAClB,IAAA,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI;IAElB,IAAI,KAAK,GAAG,KAAK;IACjB,QAAQ,MAAM;AACZ,QAAA,KAAK,WAAW;YACd,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,cAAc;YACjB,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,UAAU;YACb,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,aAAa;YAChB,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;;AAKJ,IAAA,OAAO,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI;AAChC;;;;"}
|
|
1
|
+
{"version":3,"file":"calculate-link-position-by-node.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/calculate-link-position-by-node.ts"],"sourcesContent":["import { COMMON_SETTINGS } from \"../../constants\";\nimport type { NodeInterface } from \"../../types\";\n\ntype Point = {\n x: number;\n y: number;\n};\n\nexport function calculateLinkPositionByNode<NodeData extends Record<string, unknown>>(\n xStart: number,\n yStart: number,\n xEnd: number,\n yEnd: number,\n sourceNode: NodeInterface<NodeData>,\n targetNode: NodeInterface<NodeData>,\n arrowSize = 0,\n) {\n const sourcePoint = getLinkPoint({\n xStart,\n yStart,\n xEnd,\n yEnd,\n arrowSize: 0,\n node: sourceNode,\n oppositeNode: targetNode,\n });\n const targetPoint = getLinkPoint({\n xStart: xEnd,\n yStart: yEnd,\n xEnd: xStart,\n yEnd: yStart,\n arrowSize: arrowSize > 0 ? arrowSize * 0.9 : 0,\n node: targetNode,\n oppositeNode: sourceNode,\n });\n const targetPointArrow = getLinkPoint({\n xStart: xEnd,\n yStart: yEnd,\n xEnd: xStart,\n yEnd: yStart,\n arrowSize: 0,\n node: targetNode,\n oppositeNode: sourceNode,\n });\n\n const distance =\n targetPoint && sourcePoint\n ? Math.sqrt((targetPoint.x - sourcePoint.x) ** 2 + (targetPoint.y - sourcePoint.y) ** 2)\n : 0;\n\n return {\n xStart: sourcePoint.x,\n yStart: sourcePoint.y,\n xEnd: targetPoint.x,\n yEnd: targetPoint.y,\n xEndArrow: targetPointArrow.x,\n yEndArrow: targetPointArrow.y,\n distance,\n };\n}\n\ntype GetLinkPointProps<NodeData extends Record<string, unknown>> = {\n xStart: number;\n yStart: number;\n xEnd: number;\n yEnd: number;\n arrowSize: number;\n node: NodeInterface<NodeData>;\n oppositeNode: NodeInterface<NodeData>;\n};\nfunction getLinkPoint<NodeData extends Record<string, unknown>>(opts: GetLinkPointProps<NodeData>) {\n let nodePoint: Point;\n switch (opts.node._shape) {\n case \"circle\": {\n nodePoint = getCircleIntersection({\n x: opts.xStart,\n y: opts.yStart,\n radius:\n (opts.node._radius ?? COMMON_SETTINGS.nodeRadius) +\n (opts.node._borderWidth ? opts.node._borderWidth / 2 : 0),\n oppositeX: opts.xEnd,\n oppositeY: opts.yEnd,\n arrowSize: opts.arrowSize,\n });\n break;\n }\n case \"square\":\n case \"text\": {\n nodePoint = getRectangleIntersection({\n arrowSize: opts.arrowSize,\n x: opts.xStart,\n y: opts.yStart,\n height: (opts.node._height ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),\n width: (opts.node._width ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),\n oppositeX: opts.xEnd,\n oppositeY: opts.yEnd,\n borderRadius: opts.node._shape === \"text\" ? 0 : (opts.node._borderRadius ?? 0),\n });\n break;\n }\n default: {\n nodePoint = getCircleIntersection({\n x: opts.xStart,\n y: opts.yStart,\n radius: opts.node._radius ?? COMMON_SETTINGS.nodeRadius,\n oppositeX: opts.xEnd,\n oppositeY: opts.yEnd,\n arrowSize: opts.arrowSize,\n });\n }\n }\n\n return nodePoint;\n}\n\ntype GetCircleIntersection = {\n x: number;\n y: number;\n radius: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n};\n\nfunction getCircleIntersection(opts: GetCircleIntersection): Point {\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n const dr = Math.sqrt(dx * dx + dy * dy);\n\n const radius = opts.radius + opts.arrowSize;\n\n return {\n x: opts.x + (dx * radius) / dr,\n y: opts.y + (dy * radius) / dr,\n };\n}\n\ntype GetRectangleIntersection = {\n x: number;\n y: number;\n width: number;\n height: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n borderRadius: number;\n};\n\nfunction getRectangleIntersection(opts: GetRectangleIntersection): Point {\n const halfWidth = opts.width / 2;\n const halfHeight = opts.height / 2;\n\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n\n let relX: number, relY: number;\n\n if (Math.abs(dx) <= halfWidth && Math.abs(dy) <= halfHeight) {\n const distToRight = halfWidth - dx;\n const distToLeft = halfWidth + dx;\n const distToTop = halfHeight - dy;\n const distToBottom = halfHeight + dy;\n\n const minDist = Math.min(distToRight, distToLeft, distToTop, distToBottom);\n\n relX = minDist === distToRight ? halfWidth : minDist === distToLeft ? -halfWidth : dx;\n relY = minDist === distToTop ? halfHeight : minDist === distToBottom ? -halfHeight : dy;\n } else {\n const absDx = Math.abs(dx);\n const absDy = Math.abs(dy);\n\n if (halfWidth * absDy < halfHeight * absDx) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n if (Math.abs(relY) > halfHeight) {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n }\n } else {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n if (Math.abs(relX) > halfWidth) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n }\n }\n }\n\n if (opts.borderRadius != undefined) {\n const { x, y } = squareRadiusFix(relX, relY, halfWidth, halfHeight, opts.borderRadius);\n if (x != undefined) relX = x;\n if (y != undefined) relY = y;\n }\n\n if (opts.arrowSize > 0) {\n const edgeDist = Math.sqrt(relX * relX + relY * relY);\n const scale = (edgeDist + opts.arrowSize) / edgeDist;\n relX *= scale;\n relY *= scale;\n }\n\n return {\n x: opts.x + relX,\n y: opts.y + relY,\n };\n}\n\n// eslint-disable-next-line no-warning-comments\n// TODO: Need upgrade\nfunction squareRadiusFix(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n borderRadius: number,\n) {\n const epsilon = 1e-6;\n const absX = Math.abs(relX);\n const absY = Math.abs(relY);\n\n let side: string | null = null;\n if (absX >= halfWidth - epsilon) {\n side = relX > 0 ? \"right\" : \"left\";\n } else if (absY >= halfHeight - epsilon) {\n side = relY > 0 ? \"top\" : \"bottom\";\n }\n\n if (side) {\n const topBound = halfHeight - borderRadius;\n const bottomBound = -topBound;\n const rightBound = halfWidth - borderRadius;\n const leftBound = -rightBound;\n\n switch (side) {\n case \"right\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-bottom\");\n }\n break;\n case \"left\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-bottom\");\n }\n break;\n case \"top\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-left\");\n }\n break;\n case \"bottom\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-left\");\n }\n break;\n default:\n break;\n }\n }\n\n return { x: undefined, y: undefined };\n}\n\nfunction checkIntersection(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner: Parameters<typeof intersectWithCircle>[5],\n) {\n const intersect = intersectWithCircle(relX, relY, halfWidth, halfHeight, r, corner);\n\n return intersect ?? { x: undefined, y: undefined };\n}\n\nfunction intersectWithCircle(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner:\n | \"right-top\"\n | \"right-bottom\"\n | \"left-top\"\n | \"left-bottom\"\n | \"top-right\"\n | \"top-left\"\n | \"bottom-right\"\n | \"bottom-left\",\n) {\n switch (corner) {\n case \"top-right\":\n corner = \"right-top\";\n break;\n case \"bottom-right\":\n corner = \"right-bottom\";\n break;\n case \"top-left\":\n corner = \"left-top\";\n break;\n case \"bottom-left\":\n corner = \"left-bottom\";\n break;\n default:\n break;\n }\n\n let cx: number, cy: number;\n switch (corner) {\n case \"right-top\":\n cx = halfWidth - r;\n cy = halfHeight - r;\n break;\n case \"right-bottom\":\n cx = halfWidth - r;\n cy = -halfHeight + r;\n break;\n case \"left-top\":\n cx = -halfWidth + r;\n cy = halfHeight - r;\n break;\n case \"left-bottom\":\n cx = -halfWidth + r;\n cy = -halfHeight + r;\n break;\n default:\n return null;\n }\n\n const a = relX ** 2 + relY ** 2;\n if (a === 0) return null;\n\n const b = -2 * (relX * cx + relY * cy);\n const c = cx ** 2 + cy ** 2 - r ** 2;\n const discriminant = b ** 2 - 4 * a * c;\n\n if (discriminant < 0) return null;\n const sqrtD = Math.sqrt(discriminant);\n\n const t2 = (-b - sqrtD) / (2 * a);\n const t1 = (-b + sqrtD) / (2 * a);\n const t = t2 > 0 ? t2 : t1 > 0 ? t1 : null;\n\n if (t === null || t >= 1) return null;\n\n const x = t * relX;\n const y = t * relY;\n\n let valid = false;\n switch (corner) {\n case \"right-top\":\n valid = x >= cx && y >= cy;\n break;\n case \"right-bottom\":\n valid = x >= cx && y <= cy;\n break;\n case \"left-top\":\n valid = x <= cx && y >= cy;\n break;\n case \"left-bottom\":\n valid = x <= cx && y <= cy;\n break;\n default:\n break;\n }\n\n return valid ? { x, y } : null;\n}\n"],"names":[],"mappings":";;;;;;;SAQgB,2BAA2B,CACzC,MAAc,EACd,MAAc,EACd,IAAY,EACZ,IAAY,EACZ,UAAmC,EACnC,UAAmC,EACnC,SAAS,GAAG,CAAC,EAAA;IAEb,MAAM,WAAW,GAAG,YAAY,CAAC;QAC/B,MAAM;QACN,MAAM;QACN,IAAI;QACJ,IAAI;AACJ,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,IAAI,EAAE,UAEP,CAAA,CAAC;IACF,MAAM,WAAW,GAAG,YAAY,CAAC;AAC/B,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,SAAS,EAAE,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,GAAG,GAAG,CAAC;AAC9C,QAAA,IAAI,EAAE,UAEP,CAAA,CAAC;IAC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AG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,UAAU;YACb,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,aAAa;YAChB,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;;AAKJ,IAAA,OAAO,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI;AAChC;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function computeGraphBounds(nodes) {
|
|
2
|
+
if (!nodes.length)
|
|
3
|
+
return null;
|
|
4
|
+
let minX = Infinity;
|
|
5
|
+
let minY = Infinity;
|
|
6
|
+
let maxX = -Infinity;
|
|
7
|
+
let maxY = -Infinity;
|
|
8
|
+
for (const node of nodes) {
|
|
9
|
+
if (node.x === null || node.x === undefined || node.y === null || node.y === undefined)
|
|
10
|
+
continue;
|
|
11
|
+
if (node.visible === false)
|
|
12
|
+
continue;
|
|
13
|
+
let radius = node._radius;
|
|
14
|
+
radius ??= Math.max(node._width ?? 0, node._height ?? 0) / 2;
|
|
15
|
+
minX = Math.min(minX, node.x - radius);
|
|
16
|
+
minY = Math.min(minY, node.y - radius);
|
|
17
|
+
maxX = Math.max(maxX, node.x + radius);
|
|
18
|
+
maxY = Math.max(maxY, node.y + radius);
|
|
19
|
+
}
|
|
20
|
+
if (!isFinite(minX))
|
|
21
|
+
return null;
|
|
22
|
+
return { minX, minY, maxX, maxY };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { computeGraphBounds };
|
|
26
|
+
//# sourceMappingURL=compute-graph-bounds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute-graph-bounds.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/compute-graph-bounds.ts"],"sourcesContent":["import type { NodeInterface } from \"../../types\";\n\nexport interface GraphBounds {\n minX: number;\n minY: number;\n maxX: number;\n maxY: number;\n}\n\nexport function computeGraphBounds<NodeData extends Record<string, unknown>>(\n nodes: NodeInterface<NodeData>[],\n): GraphBounds | null {\n if (!nodes.length) return null;\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const node of nodes) {\n if (node.x === null || node.x === undefined || node.y === null || node.y === undefined)\n continue;\n if (node.visible === false) continue;\n\n let radius = node._radius;\n radius ??= Math.max(node._width ?? 0, node._height ?? 0) / 2;\n minX = Math.min(minX, node.x - radius);\n minY = Math.min(minY, node.y - radius);\n maxX = Math.max(maxX, node.x + radius);\n maxY = Math.max(maxY, node.y + radius);\n }\n\n if (!isFinite(minX)) return null;\n\n return { minX, minY, maxX, maxY };\n}\n"],"names":[],"mappings":"AASM,SAAU,kBAAkB,CAChC,KAAgC,EAAA;IAEhC,IAAI,CAAC,KAAK,CAAC,MAAM;AAAE,QAAA,OAAO,IAAI;IAE9B,IAAI,IAAI,GAAG,QAAQ;IACnB,IAAI,IAAI,GAAG,QAAQ;AACnB,IAAA,IAAI,IAAI,GAAG,CAAC,QAAQ;AACpB,IAAA,IAAI,IAAI,GAAG,CAAC,QAAQ;AAEpB,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC,KAAK,SAAS;YACpF;AACF,QAAA,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK;YAAE;AAE5B,QAAA,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO;AACzB,QAAA,MAAM,KAAK,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC;AAC5D,QAAA,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,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