@krainovsd/graph 0.13.0-beta1 → 0.14.0-beta-7.1

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.
Files changed (80) hide show
  1. package/lib/cjs/index.cjs +1297 -606
  2. package/lib/cjs/index.cjs.map +1 -1
  3. package/lib/esm/constants/force-controls.js +4 -2
  4. package/lib/esm/constants/force-controls.js.map +1 -1
  5. package/lib/esm/constants/highlight-controls.js +9 -16
  6. package/lib/esm/constants/highlight-controls.js.map +1 -1
  7. package/lib/esm/constants/link-controls.js +17 -30
  8. package/lib/esm/constants/link-controls.js.map +1 -1
  9. package/lib/esm/constants/node-controls.js +4 -2
  10. package/lib/esm/constants/node-controls.js.map +1 -1
  11. package/lib/esm/index.js +8 -7
  12. package/lib/esm/index.js.map +1 -1
  13. package/lib/esm/module/GraphCanvas/GraphCanvas.js +305 -81
  14. package/lib/esm/module/GraphCanvas/GraphCanvas.js.map +1 -1
  15. package/lib/esm/module/GraphCanvas/constants/force-settings.js +11 -1
  16. package/lib/esm/module/GraphCanvas/constants/force-settings.js.map +1 -1
  17. package/lib/esm/module/GraphCanvas/constants/graph-settings.js +17 -5
  18. package/lib/esm/module/GraphCanvas/constants/graph-settings.js.map +1 -1
  19. package/lib/esm/module/GraphCanvas/constants/highlight-settings.js +5 -3
  20. package/lib/esm/module/GraphCanvas/constants/highlight-settings.js.map +1 -1
  21. package/lib/esm/module/GraphCanvas/constants/index.js +5 -2
  22. package/lib/esm/module/GraphCanvas/constants/index.js.map +1 -1
  23. package/lib/esm/module/GraphCanvas/constants/link-settings.js +19 -9
  24. package/lib/esm/module/GraphCanvas/constants/link-settings.js.map +1 -1
  25. package/lib/esm/module/GraphCanvas/constants/node-settings.js +13 -3
  26. package/lib/esm/module/GraphCanvas/constants/node-settings.js.map +1 -1
  27. package/lib/esm/module/GraphCanvas/lib/settings/force-settings-getter.js +4 -2
  28. package/lib/esm/module/GraphCanvas/lib/settings/force-settings-getter.js.map +1 -1
  29. package/lib/esm/module/GraphCanvas/lib/settings/graph-settings-getter.js +4 -0
  30. package/lib/esm/module/GraphCanvas/lib/settings/graph-settings-getter.js.map +1 -1
  31. package/lib/esm/module/GraphCanvas/lib/settings/highlight-settings-getter.js +4 -2
  32. package/lib/esm/module/GraphCanvas/lib/settings/highlight-settings-getter.js.map +1 -1
  33. package/lib/esm/module/GraphCanvas/lib/settings/link-settings-getter.js +8 -5
  34. package/lib/esm/module/GraphCanvas/lib/settings/link-settings-getter.js.map +1 -1
  35. package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js +14 -2
  36. package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js.map +1 -1
  37. package/lib/esm/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.js +45 -0
  38. package/lib/esm/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.js.map +1 -0
  39. package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js +42 -37
  40. package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js.map +1 -1
  41. package/lib/esm/module/GraphCanvas/lib/utils/compute-graph-bounds.js +26 -0
  42. package/lib/esm/module/GraphCanvas/lib/utils/compute-graph-bounds.js.map +1 -0
  43. package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js +40 -30
  44. package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js.map +1 -1
  45. package/lib/esm/module/GraphCanvas/lib/utils/is-empty-object.js +11 -0
  46. package/lib/esm/module/GraphCanvas/lib/utils/is-empty-object.js.map +1 -0
  47. package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js +5 -2
  48. package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js.map +1 -1
  49. package/lib/esm/module/GraphCanvas/lib/utils/link-by-pointer-getter.js +72 -26
  50. package/lib/esm/module/GraphCanvas/lib/utils/link-by-pointer-getter.js.map +1 -1
  51. package/lib/esm/module/GraphCanvas/lib/utils/node-by-pointer-getter.js +1 -5
  52. package/lib/esm/module/GraphCanvas/lib/utils/node-by-pointer-getter.js.map +1 -1
  53. package/lib/esm/module/GraphCanvas/lib/utils/pointer-getter.js +16 -8
  54. package/lib/esm/module/GraphCanvas/lib/utils/pointer-getter.js.map +1 -1
  55. package/lib/esm/module/GraphCanvas/slices/draw-links.js +115 -77
  56. package/lib/esm/module/GraphCanvas/slices/draw-links.js.map +1 -1
  57. package/lib/esm/module/GraphCanvas/slices/draw-nodes.js +9 -4
  58. package/lib/esm/module/GraphCanvas/slices/draw-nodes.js.map +1 -1
  59. package/lib/esm/module/GraphCanvas/slices/init-area.js +1 -1
  60. package/lib/esm/module/GraphCanvas/slices/init-area.js.map +1 -1
  61. package/lib/esm/module/GraphCanvas/slices/init-dnd.js +20 -13
  62. package/lib/esm/module/GraphCanvas/slices/init-dnd.js.map +1 -1
  63. package/lib/esm/module/GraphCanvas/slices/init-draw.js +14 -52
  64. package/lib/esm/module/GraphCanvas/slices/init-draw.js.map +1 -1
  65. package/lib/esm/module/GraphCanvas/slices/init-pointer.js +51 -72
  66. package/lib/esm/module/GraphCanvas/slices/init-pointer.js.map +1 -1
  67. package/lib/esm/module/GraphCanvas/slices/init-resize.js +11 -0
  68. package/lib/esm/module/GraphCanvas/slices/init-resize.js.map +1 -1
  69. package/lib/esm/module/GraphCanvas/slices/init-selection.js +152 -0
  70. package/lib/esm/module/GraphCanvas/slices/init-selection.js.map +1 -0
  71. package/lib/esm/module/GraphCanvas/slices/init-simulation.js +12 -2
  72. package/lib/esm/module/GraphCanvas/slices/init-simulation.js.map +1 -1
  73. package/lib/esm/module/GraphCanvas/slices/init-zoom.js +88 -16
  74. package/lib/esm/module/GraphCanvas/slices/init-zoom.js.map +1 -1
  75. package/lib/esm/module/GraphCanvas/slices/update-link-cache.js +63 -3
  76. package/lib/esm/module/GraphCanvas/slices/update-link-cache.js.map +1 -1
  77. package/lib/esm/module/GraphCanvas/slices/update-node-cache.js +61 -16
  78. package/lib/esm/module/GraphCanvas/slices/update-node-cache.js.map +1 -1
  79. package/lib/index.d.ts +127 -62
  80. package/package.json +3 -2
@@ -1,16 +1,42 @@
1
- import { isObject } from '@krainovsd/js-helpers';
1
+ import '../constants/force-settings.js';
2
+ import '../constants/graph-settings.js';
3
+ import '../constants/highlight-settings.js';
4
+ import '../constants/link-settings.js';
5
+ import '../constants/node-settings.js';
2
6
  import { nodeOptionsGetter, nodeRadiusGetter, nodeSizeGetter } from '../lib/settings/node-settings-getter.js';
7
+ import '@krainovsd/js-helpers';
3
8
  import 'd3-array';
4
9
  import { nodeIterationExtractor } from '../lib/utils/node-iteration-extractor.js';
5
10
  import { getTextLines } from './draw-text.js';
6
11
 
7
- function updateNodeCache(types) {
8
- this.nodeOptionsCache = {};
12
+ function updateNodeCache() {
9
13
  if (!this.context)
10
14
  return;
15
+ const currentZoom = this.areaTransform.k;
16
+ const options = this.nodeOptionsCache.length === 0;
17
+ const label = this.cachedNodeLabel.length === 0;
18
+ let text = this.cachedNodeText.length === 0;
19
+ if (this.nodeSettings.smartCache &&
20
+ this._lastNodeZoomK !== undefined &&
21
+ !options &&
22
+ !text &&
23
+ !label) {
24
+ const thresholds = this.nodeSettings.textScaleSteps;
25
+ if (thresholds && thresholds.length > 0) {
26
+ const min = Math.min(this._lastNodeZoomK, currentZoom);
27
+ const max = Math.max(this._lastNodeZoomK, currentZoom);
28
+ const crossed = thresholds.some((t) => t >= min && t <= max);
29
+ this._lastNodeZoomK = currentZoom;
30
+ if (!crossed)
31
+ return;
32
+ }
33
+ this.cachedNodeText.length = 0;
34
+ text = true;
35
+ }
36
+ this._lastNodeZoomK = currentZoom;
11
37
  for (let i = 0; i < this.nodes.length; i++) {
12
38
  const node = this.nodes[i];
13
- if (types === true || (isObject(types) && types.options)) {
39
+ if (options) {
14
40
  const nodeOptions = nodeIterationExtractor(node, i, this.nodes, this, this.nodeSettings.options ?? {}, nodeOptionsGetter);
15
41
  const radius = nodeOptions.shape === "circle"
16
42
  ? nodeRadiusGetter({
@@ -61,11 +87,19 @@ function updateNodeCache(types) {
61
87
  nodeOptions.height = node.visible === false ? 0 : height;
62
88
  nodeOptions.radius = node.visible === false ? 0 : radius;
63
89
  nodeOptions.labelSize = labelSize;
64
- this.nodeOptionsCache[node.id] = nodeOptions;
90
+ this.nodeOptionsCache[i] = nodeOptions;
65
91
  }
66
- const nodeOptions = this.nodeOptionsCache[node.id];
92
+ let nodeOptions = this.nodeOptionsCache[i];
93
+ if (!nodeOptions)
94
+ continue;
67
95
  /** label */
68
- if (types === true || (isObject(types) && types.label)) {
96
+ if (label) {
97
+ if (!options) {
98
+ nodeOptions = nodeIterationExtractor(node, i, this.nodes, this, this.nodeSettings.options ?? {}, nodeOptionsGetter);
99
+ const cache = this.nodeOptionsCache[i];
100
+ if (cache)
101
+ cache.label = nodeOptions.label;
102
+ }
69
103
  /** label in not text shape */
70
104
  if (nodeOptions.shape !== "text" && nodeOptions.label) {
71
105
  this.context.font = `${nodeOptions.labelStyle} normal ${nodeOptions.labelWeight} ${nodeOptions.labelSize}px ${nodeOptions.labelFont}`;
@@ -73,7 +107,7 @@ function updateNodeCache(types) {
73
107
  this.context.textAlign = nodeOptions.labelAlign;
74
108
  if (nodeOptions.labelWidth == undefined ||
75
109
  this.context.measureText(nodeOptions.label).width <= nodeOptions.labelWidth) {
76
- this.cachedNodeLabel[node.id] = [nodeOptions.label];
110
+ this.cachedNodeLabel[i] = [nodeOptions.label];
77
111
  }
78
112
  const { lines } = getTextLines({
79
113
  context: this.context,
@@ -86,7 +120,7 @@ function updateNodeCache(types) {
86
120
  textStyle: nodeOptions.labelStyle,
87
121
  textWeight: nodeOptions.labelWeight,
88
122
  });
89
- this.cachedNodeLabel[node.id] = lines;
123
+ this.cachedNodeLabel[i] = lines;
90
124
  /** label in text shape */
91
125
  }
92
126
  else if (nodeOptions.shape === "text" && nodeOptions.label) {
@@ -110,18 +144,29 @@ function updateNodeCache(types) {
110
144
  (lines.length - 1) * nodeOptions.labelGap +
111
145
  nodeOptions.labelYPadding;
112
146
  nodeOptions.width = maxSize + nodeOptions.labelXPadding;
113
- this.cachedNodeLabel[node.id] = lines;
147
+ this.cachedNodeLabel[i] = lines;
148
+ }
149
+ else {
150
+ this.cachedNodeLabel[i] = [];
114
151
  }
115
152
  }
116
153
  /** text */
117
- if (nodeOptions.text && (types === true || (isObject(types) && types.text))) {
154
+ if (text) {
155
+ if (!options) {
156
+ nodeOptions = nodeIterationExtractor(node, i, this.nodes, this, this.nodeSettings.options ?? {}, nodeOptionsGetter);
157
+ const cache = this.nodeOptionsCache[i];
158
+ if (cache) {
159
+ cache.text = nodeOptions.text;
160
+ cache.textVisible = nodeOptions.textVisible;
161
+ }
162
+ }
163
+ if (!nodeOptions.text) {
164
+ this.cachedNodeText[i] = [];
165
+ return;
166
+ }
118
167
  this.context.font = `${nodeOptions.textStyle} normal ${nodeOptions.textWeight} ${nodeOptions.textSize}px ${nodeOptions.textFont}`;
119
168
  this.context.fillStyle = nodeOptions.textColor;
120
169
  this.context.textAlign = nodeOptions.textAlign;
121
- if (nodeOptions.textWidth == undefined ||
122
- this.context.measureText(nodeOptions.text).width <= nodeOptions.textWidth) {
123
- this.cachedNodeText[node.id] = [nodeOptions.text];
124
- }
125
170
  const { lines } = getTextLines({
126
171
  context: this.context,
127
172
  maxWidth: nodeOptions.textWidth,
@@ -133,7 +178,7 @@ function updateNodeCache(types) {
133
178
  textStyle: nodeOptions.textStyle,
134
179
  textWeight: nodeOptions.textWeight,
135
180
  });
136
- this.cachedNodeText[node.id] = lines;
181
+ this.cachedNodeText[i] = lines;
137
182
  }
138
183
  }
139
184
  }
@@ -1 +1 @@
1
- {"version":3,"file":"update-node-cache.js","sources":["../../../../../src/module/GraphCanvas/slices/update-node-cache.ts"],"sourcesContent":["import { isObject } from \"@krainovsd/js-helpers\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport {\n nodeIterationExtractor,\n nodeOptionsGetter,\n nodeRadiusGetter,\n nodeSizeGetter,\n} from \"../lib\";\nimport { getTextLines } from \"./draw-text\";\n\ntype NodeCache = {\n options: boolean;\n text: boolean;\n label: boolean;\n};\n\nexport function updateNodeCache<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>, types: boolean | NodeCache) {\n this.nodeOptionsCache = {};\n if (!this.context) return;\n\n for (let i = 0; i < this.nodes.length; i++) {\n const node = this.nodes[i];\n if (types === true || (isObject(types) && types.options)) {\n const nodeOptions = nodeIterationExtractor(\n node,\n i,\n this.nodes,\n this,\n this.nodeSettings.options ?? {},\n nodeOptionsGetter,\n );\n const radius =\n nodeOptions.shape === \"circle\"\n ? nodeRadiusGetter({\n radiusFlexible: this.nodeSettings.nodeRadiusFlexible,\n radiusInitial: nodeOptions.radius,\n radiusIncrementByStep: this.nodeSettings.nodeRadiusIncrementByStep,\n radiusLinkCountForStep: this.nodeSettings.nodeRadiusLinkCountForStep,\n radiusMaxLinearSteps: this.nodeSettings.nodeRadiusMaxLinearSteps,\n radiusLogFactor: this.nodeSettings.nodeRadiusLogFactor,\n radiusLinkCountDividerForLog: this.nodeSettings.nodeRadiusLinkCountDividerForLog,\n linkCount: node.linkCount,\n })\n : nodeOptions.radius;\n\n let width = nodeOptions.width;\n let height = nodeOptions.height;\n let labelSize = nodeOptions.labelSize;\n if (nodeOptions.shape === \"square\") {\n const size = nodeSizeGetter({\n heightInitial: nodeOptions.height,\n widthInitial: nodeOptions.width,\n linkCount: node.linkCount,\n sizeFlexible: this.nodeSettings.nodeSizeFlexible,\n sizeIncrementByStep: this.nodeSettings.nodeSizeIncrementByStep,\n sizeLinkCountForStep: this.nodeSettings.nodeSizeLinkCountForStep,\n sizeMaxLinearSteps: this.nodeSettings.nodeSizeMaxLinearSteps,\n sizeLogFactor: this.nodeSettings.nodeSizeLogFactor,\n sizeLinkCountDividerForLog: this.nodeSettings.nodeSizeLinkCountDividerForLog,\n });\n width = size.width;\n height = size.height;\n }\n if (nodeOptions.shape === \"text\") {\n width = nodeOptions.width;\n const size = nodeSizeGetter({\n heightInitial: nodeOptions.height,\n widthInitial: width,\n linkCount: node.linkCount,\n sizeFlexible: this.nodeSettings.nodeSizeFlexible,\n sizeIncrementByStep: this.nodeSettings.nodeSizeIncrementByStep,\n sizeLinkCountForStep: this.nodeSettings.nodeSizeLinkCountForStep,\n sizeMaxLinearSteps: this.nodeSettings.nodeSizeMaxLinearSteps,\n sizeLogFactor: this.nodeSettings.nodeSizeLogFactor,\n sizeLinkCountDividerForLog: this.nodeSettings.nodeSizeLinkCountDividerForLog,\n });\n\n labelSize *= size.additionalSizeCoefficient;\n }\n\n nodeOptions.width = node.visible === false ? 0 : width;\n nodeOptions.height = node.visible === false ? 0 : height;\n nodeOptions.radius = node.visible === false ? 0 : radius;\n nodeOptions.labelSize = labelSize;\n this.nodeOptionsCache[node.id] = nodeOptions;\n }\n\n const nodeOptions = this.nodeOptionsCache[node.id];\n /** label */\n if (types === true || (isObject(types) && types.label)) {\n /** label in not text shape */\n if (nodeOptions.shape !== \"text\" && nodeOptions.label) {\n this.context.font = `${nodeOptions.labelStyle} normal ${nodeOptions.labelWeight} ${nodeOptions.labelSize}px ${nodeOptions.labelFont}`;\n this.context.fillStyle = nodeOptions.labelColor;\n this.context.textAlign = nodeOptions.labelAlign;\n\n if (\n nodeOptions.labelWidth == undefined ||\n this.context.measureText(nodeOptions.label).width <= nodeOptions.labelWidth\n ) {\n this.cachedNodeLabel[node.id] = [nodeOptions.label];\n }\n\n const { lines } = getTextLines({\n context: this.context,\n maxWidth: nodeOptions.labelWidth,\n text: nodeOptions.label,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textSize: nodeOptions.labelSize,\n textStyle: nodeOptions.labelStyle,\n textWeight: nodeOptions.labelWeight,\n });\n this.cachedNodeLabel[node.id] = lines;\n /** label in text shape */\n } else if (nodeOptions.shape === \"text\" && nodeOptions.label) {\n const textInfo = getTextLines({\n context: this.context,\n text: nodeOptions.label,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textSize: nodeOptions.labelSize,\n maxWidth: nodeOptions.labelWidth,\n textStyle: nodeOptions.labelStyle,\n textWeight: nodeOptions.textWeight,\n });\n const textNodeParameters = [textInfo.currentMaxSize, nodeOptions.labelSize];\n const lines = textInfo.lines;\n const textSizeCoefficient = nodeOptions.labelSize / textNodeParameters[1];\n const maxSize = textNodeParameters[0] * textSizeCoefficient;\n\n nodeOptions.height =\n lines.length * nodeOptions.labelSize +\n (lines.length - 1) * nodeOptions.labelGap +\n nodeOptions.labelYPadding;\n\n nodeOptions.width = maxSize + nodeOptions.labelXPadding;\n this.cachedNodeLabel[node.id] = lines;\n }\n }\n\n /** text */\n if (nodeOptions.text && (types === true || (isObject(types) && types.text))) {\n this.context.font = `${nodeOptions.textStyle} normal ${nodeOptions.textWeight} ${nodeOptions.textSize}px ${nodeOptions.textFont}`;\n this.context.fillStyle = nodeOptions.textColor;\n this.context.textAlign = nodeOptions.textAlign;\n\n if (\n nodeOptions.textWidth == undefined ||\n this.context.measureText(nodeOptions.text).width <= nodeOptions.textWidth\n ) {\n this.cachedNodeText[node.id] = [nodeOptions.text];\n }\n\n const { lines } = getTextLines({\n context: this.context,\n maxWidth: nodeOptions.textWidth,\n text: nodeOptions.text,\n textAlign: nodeOptions.textAlign,\n textColor: nodeOptions.textColor,\n textFont: nodeOptions.textFont,\n textSize: nodeOptions.textSize,\n textStyle: nodeOptions.textStyle,\n textWeight: nodeOptions.textWeight,\n });\n this.cachedNodeText[node.id] = lines;\n }\n }\n}\n"],"names":[],"mappings":";;;;;;AAgBM,SAAU,eAAe,CAGU,KAA0B,EAAA;AACjE,IAAA,IAAI,CAAC,gBAAgB,GAAG,EAAE;IAC1B,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE;AAEnB,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,M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AAC,QAAQ;gBAC9B,SAAS,EAAE,WAAW,CAAC,SAAS;gBAChC,UAAU,EAAE,WAAW,CAAC,UAAU;AACnC,aAAA,CAAC;YACF,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK;;;AAG1C;;;;"}
1
+ {"version":3,"file":"update-node-cache.js","sources":["../../../../../src/module/GraphCanvas/slices/update-node-cache.ts"],"sourcesContent":["import type { GraphCanvas } from \"../GraphCanvas\";\nimport {\n nodeIterationExtractor,\n nodeOptionsGetter,\n nodeRadiusGetter,\n nodeSizeGetter,\n} from \"../lib\";\nimport { getTextLines } from \"./draw-text\";\n\nexport function updateNodeCache<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.context) return;\n\n const currentZoom = this.areaTransform.k;\n const options = this.nodeOptionsCache.length === 0;\n const label = this.cachedNodeLabel.length === 0;\n let text = this.cachedNodeText.length === 0;\n\n if (\n this.nodeSettings.smartCache &&\n this._lastNodeZoomK !== undefined &&\n !options &&\n !text &&\n !label\n ) {\n const thresholds = this.nodeSettings.textScaleSteps;\n if (thresholds && thresholds.length > 0) {\n const min = Math.min(this._lastNodeZoomK, currentZoom);\n const max = Math.max(this._lastNodeZoomK, currentZoom);\n const crossed = thresholds.some((t) => t >= min && t <= max);\n this._lastNodeZoomK = currentZoom;\n if (!crossed) return;\n }\n this.cachedNodeText.length = 0;\n text = true;\n }\n this._lastNodeZoomK = currentZoom;\n\n for (let i = 0; i < this.nodes.length; i++) {\n const node = this.nodes[i];\n if (options) {\n const nodeOptions = nodeIterationExtractor(\n node,\n i,\n this.nodes,\n this,\n this.nodeSettings.options ?? {},\n nodeOptionsGetter,\n );\n const radius =\n nodeOptions.shape === \"circle\"\n ? nodeRadiusGetter({\n radiusFlexible: this.nodeSettings.nodeRadiusFlexible,\n radiusInitial: nodeOptions.radius,\n radiusIncrementByStep: this.nodeSettings.nodeRadiusIncrementByStep,\n radiusLinkCountForStep: this.nodeSettings.nodeRadiusLinkCountForStep,\n radiusMaxLinearSteps: this.nodeSettings.nodeRadiusMaxLinearSteps,\n radiusLogFactor: this.nodeSettings.nodeRadiusLogFactor,\n radiusLinkCountDividerForLog: this.nodeSettings.nodeRadiusLinkCountDividerForLog,\n linkCount: node.linkCount,\n })\n : nodeOptions.radius;\n\n let width = nodeOptions.width;\n let height = nodeOptions.height;\n let labelSize = nodeOptions.labelSize;\n if (nodeOptions.shape === \"square\") {\n const size = nodeSizeGetter({\n heightInitial: nodeOptions.height,\n widthInitial: nodeOptions.width,\n linkCount: node.linkCount,\n sizeFlexible: this.nodeSettings.nodeSizeFlexible,\n sizeIncrementByStep: this.nodeSettings.nodeSizeIncrementByStep,\n sizeLinkCountForStep: this.nodeSettings.nodeSizeLinkCountForStep,\n sizeMaxLinearSteps: this.nodeSettings.nodeSizeMaxLinearSteps,\n sizeLogFactor: this.nodeSettings.nodeSizeLogFactor,\n sizeLinkCountDividerForLog: this.nodeSettings.nodeSizeLinkCountDividerForLog,\n });\n width = size.width;\n height = size.height;\n }\n if (nodeOptions.shape === \"text\") {\n width = nodeOptions.width;\n const size = nodeSizeGetter({\n heightInitial: nodeOptions.height,\n widthInitial: width,\n linkCount: node.linkCount,\n sizeFlexible: this.nodeSettings.nodeSizeFlexible,\n sizeIncrementByStep: this.nodeSettings.nodeSizeIncrementByStep,\n sizeLinkCountForStep: this.nodeSettings.nodeSizeLinkCountForStep,\n sizeMaxLinearSteps: this.nodeSettings.nodeSizeMaxLinearSteps,\n sizeLogFactor: this.nodeSettings.nodeSizeLogFactor,\n sizeLinkCountDividerForLog: this.nodeSettings.nodeSizeLinkCountDividerForLog,\n });\n\n labelSize *= size.additionalSizeCoefficient;\n }\n\n nodeOptions.width = node.visible === false ? 0 : width;\n nodeOptions.height = node.visible === false ? 0 : height;\n nodeOptions.radius = node.visible === false ? 0 : radius;\n nodeOptions.labelSize = labelSize;\n this.nodeOptionsCache[i] = nodeOptions;\n }\n\n let nodeOptions = this.nodeOptionsCache[i];\n if (!nodeOptions) continue;\n /** label */\n if (label) {\n if (!options) {\n nodeOptions = nodeIterationExtractor(\n node,\n i,\n this.nodes,\n this,\n this.nodeSettings.options ?? {},\n nodeOptionsGetter,\n );\n const cache = this.nodeOptionsCache[i];\n if (cache) cache.label = nodeOptions.label;\n }\n /** label in not text shape */\n if (nodeOptions.shape !== \"text\" && nodeOptions.label) {\n this.context.font = `${nodeOptions.labelStyle} normal ${nodeOptions.labelWeight} ${nodeOptions.labelSize}px ${nodeOptions.labelFont}`;\n this.context.fillStyle = nodeOptions.labelColor;\n this.context.textAlign = nodeOptions.labelAlign;\n\n if (\n nodeOptions.labelWidth == undefined ||\n this.context.measureText(nodeOptions.label).width <= nodeOptions.labelWidth\n ) {\n this.cachedNodeLabel[i] = [nodeOptions.label];\n }\n\n const { lines } = getTextLines({\n context: this.context,\n maxWidth: nodeOptions.labelWidth,\n text: nodeOptions.label,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textSize: nodeOptions.labelSize,\n textStyle: nodeOptions.labelStyle,\n textWeight: nodeOptions.labelWeight,\n });\n this.cachedNodeLabel[i] = lines;\n /** label in text shape */\n } else if (nodeOptions.shape === \"text\" && nodeOptions.label) {\n const textInfo = getTextLines({\n context: this.context,\n text: nodeOptions.label,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textSize: nodeOptions.labelSize,\n maxWidth: nodeOptions.labelWidth,\n textStyle: nodeOptions.labelStyle,\n textWeight: nodeOptions.textWeight,\n });\n const textNodeParameters = [textInfo.currentMaxSize, nodeOptions.labelSize];\n const lines = textInfo.lines;\n const textSizeCoefficient = nodeOptions.labelSize / textNodeParameters[1];\n const maxSize = textNodeParameters[0] * textSizeCoefficient;\n\n nodeOptions.height =\n lines.length * nodeOptions.labelSize +\n (lines.length - 1) * nodeOptions.labelGap +\n nodeOptions.labelYPadding;\n\n nodeOptions.width = maxSize + nodeOptions.labelXPadding;\n this.cachedNodeLabel[i] = lines;\n } else {\n this.cachedNodeLabel[i] = [];\n }\n }\n\n /** text */\n if (text) {\n if (!options) {\n nodeOptions = nodeIterationExtractor(\n node,\n i,\n this.nodes,\n this,\n this.nodeSettings.options ?? {},\n nodeOptionsGetter,\n );\n const cache = this.nodeOptionsCache[i];\n if (cache) {\n cache.text = nodeOptions.text;\n cache.textVisible = nodeOptions.textVisible;\n }\n }\n if (!nodeOptions.text) {\n this.cachedNodeText[i] = [];\n return;\n }\n this.context.font = `${nodeOptions.textStyle} normal ${nodeOptions.textWeight} ${nodeOptions.textSize}px ${nodeOptions.textFont}`;\n this.context.fillStyle = nodeOptions.textColor;\n this.context.textAlign = nodeOptions.textAlign;\n const { lines } = getTextLines({\n context: this.context,\n maxWidth: nodeOptions.textWidth,\n text: nodeOptions.text,\n textAlign: nodeOptions.textAlign,\n textColor: nodeOptions.textColor,\n textFont: nodeOptions.textFont,\n textSize: nodeOptions.textSize,\n textStyle: nodeOptions.textStyle,\n textWeight: nodeOptions.textWeight,\n });\n this.cachedNodeText[i] = lines;\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;SASgB,eAAe,GAAA;IAI7B,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE;AAEnB,IAAA,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,KAAK,CAAC;IAClD,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC;IAC/C,IAAI,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC;AAE3C,IAAA,IACE,IAAI,CAAC,YAAY,CAAC,UAAU;QAC5B,IAAI,CAAC,cAAc,KAAK,SAAS;AACjC,QAAA,CAAC,OAAO;AACR,QAAA,CAAC,IAAI;QACL,CAAC,KAA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,CAAC,GAAG,KAAK;;;AAGpC;;;;"}
package/lib/index.d.ts CHANGED
@@ -26,6 +26,7 @@ interface NodeInterface<NodeData extends Record<string, unknown>> extends Simula
26
26
  highlight?: boolean;
27
27
  visible?: boolean;
28
28
  image?: HTMLImageElement;
29
+ _selected?: boolean;
29
30
  data?: NodeData;
30
31
  }
31
32
  type NodeShape = "circle" | "square" | "text";
@@ -36,16 +37,26 @@ interface LinkInterface<NodeData extends Record<string, unknown>, LinkData exten
36
37
  data?: LinkData;
37
38
  highlight?: boolean;
38
39
  visible?: boolean;
40
+ _selected?: boolean;
41
+ _groupIndex?: number;
42
+ _groupSize?: number;
43
+ _self?: boolean;
44
+ _x1?: number;
45
+ _y1?: number;
46
+ _x2?: number;
47
+ _y2?: number;
48
+ _cx?: number;
49
+ _cy?: number;
50
+ _ax?: number;
51
+ _ay?: number;
39
52
  }
40
53
  type LinkParticle = {
41
- step: number;
42
54
  index: number;
43
- prev: LinkParticle | undefined;
44
- next: LinkParticle | undefined;
45
55
  x?: number;
46
56
  y?: number;
47
- sourceId: string | number;
48
- targetId: string | number;
57
+ _distanceTraveled?: number;
58
+ _lastDistance?: number;
59
+ _lastTime?: number;
49
60
  };
50
61
 
51
62
  type NodeIterationPropsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Return = number> = (this: GraphCanvas<NodeData, LinkData>, node: NodeInterface<NodeData>, i: number, nodes: NodeInterface<NodeData>[]) => Return;
@@ -53,6 +64,12 @@ type LinkIterationPropsInterface<NodeData extends Record<string, unknown>, LinkD
53
64
  type NodeIterationPropsNoThisInterface<NodeData extends Record<string, unknown>, Return = number> = (node: NodeInterface<NodeData>, i: number, nodes: NodeInterface<NodeData>[]) => Return;
54
65
  type LinkIterationPropsNoThisInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Return = number> = (link: LinkInterface<NodeData, LinkData>, i: number, links: LinkInterface<NodeData, LinkData>[]) => Return;
55
66
 
67
+ type PrecomputeForceSettingsInterface = {
68
+ precompute?: boolean;
69
+ precomputeMaxTimeMs?: number;
70
+ precomputeMaxTicks?: number;
71
+ precomputeDisableForcesAfter?: boolean;
72
+ };
56
73
  type ForceSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
57
74
  forces?: boolean;
58
75
  xForce?: boolean;
@@ -83,15 +100,21 @@ type ForceSettingsInterface<NodeData extends Record<string, unknown>, LinkData e
83
100
  xStrength?: NodeIterationPropsNoThisInterface<NodeData> | number;
84
101
  yPosition?: NodeIterationPropsNoThisInterface<NodeData> | number;
85
102
  yStrength?: NodeIterationPropsNoThisInterface<NodeData> | number;
86
- };
103
+ } & PrecomputeForceSettingsInterface;
87
104
 
88
105
  declare const FORCE_SETTINGS: Required<ForceSettingsInterface<Record<string, unknown>, Record<string, unknown>>>;
106
+ declare const PERFORMANCE_FORCE_SETTINGS: Required<ForceSettingsInterface<Record<string, unknown>, Record<string, unknown>>>;
89
107
 
90
108
  type GraphSettingsInterface<NodeData extends Record<string, unknown>> = {
91
- zoomExtent?: [number, number];
92
- translateExtent?: [[number?, number?], [number?, number?]];
93
- translateExtentCoefficient?: number | [number, number];
94
- translateExtentEnable?: boolean;
109
+ zoomAnimation?: boolean;
110
+ zoomAnimationDuration?: number;
111
+ zoomToNodeScale?: number;
112
+ zoomToFitMargin?: number;
113
+ zoomExtent?: [number, number] | null;
114
+ zoomExtentMargin?: number;
115
+ translateExtent?: [[number?, number?], [number?, number?]] | null;
116
+ translateExtentCoefficient?: number | [number, number] | null;
117
+ translateExtentOverlap?: number;
95
118
  zoomInitial?: {
96
119
  k?: number;
97
120
  x?: number;
@@ -103,11 +126,11 @@ type GraphSettingsInterface<NodeData extends Record<string, unknown>> = {
103
126
  };
104
127
 
105
128
  declare const GRAPH_SETTINGS: Required<GraphSettingsInterface<Record<string, unknown>>>;
129
+ declare const PERFORMANCE_GRAPH_SETTINGS: Required<GraphSettingsInterface<Record<string, unknown>>>;
106
130
 
107
131
  type HighlightSettingsInterface = HighlighCommonSettingsInterface & HighlightByNodeForNodeSettingsInterface & HighlightByNodeForLabelSettingsInterface & HighlightByNodeForTextSettingsInterface & HighlightByNodeForLinkSettingsInterface & HighlightByNodeForArrowSettingsInterface & HighlightByLinkForNodeSettingsInterface & HighlightByLinkForTextSettingsInterface & HighlightByLinkForLabelSettingsInterface & HighlightByLinkForLinkSettingsInterface & HighlightByLinkForArrowSettingsInterface;
108
132
  type HighlighCommonSettingsInterface = {
109
- highlightDownFrames?: number;
110
- highlightUpFrames?: number;
133
+ highlightDuration?: number;
111
134
  highlightByHoverNode?: boolean;
112
135
  highlightByHoverLink?: boolean;
113
136
  linkHoverExtraZone?: number;
@@ -181,14 +204,17 @@ type HighlightByLinkForArrowSettingsInterface = {
181
204
  };
182
205
 
183
206
  declare const HIGHLIGHT_SETTINGS: Required<HighlightSettingsInterface>;
207
+ declare const PERFORMANCE_HIGHLIGHT_SETTINGS: Required<HighlightSettingsInterface>;
184
208
 
185
209
  type LinkSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
210
+ smartCache?: boolean;
186
211
  prettyDraw?: boolean;
212
+ curve?: boolean;
187
213
  arrow?: boolean;
188
214
  arrowByHighlight?: boolean;
189
215
  particles?: boolean;
190
- particleFlexSpeed?: boolean;
191
- particleFlexSpeedCoefficient?: number;
216
+ particleCountByDistance?: number;
217
+ particleSpeedByDistance?: number;
192
218
  linkScaleSwitch?: number;
193
219
  linkWidthBeforeScaleSwitch?: number;
194
220
  linkWidthAfterScaleSwitch?: number;
@@ -216,16 +242,18 @@ type LinkOptionsParticleInterface = {
216
242
  particleAlpha?: number;
217
243
  particleColor?: string;
218
244
  particleRadius?: number;
219
- particleCount?: number;
220
- particleSteps?: number;
221
245
  particleBorderWidth?: number;
222
246
  particleBorderColor?: string;
223
247
  };
224
248
 
225
249
  declare const LINK_SETTINGS: Omit<Required<LinkSettingsInterface<Record<string, unknown>, Record<string, unknown>>>, "options">;
226
250
  declare const LINK_OPTIONS: Omit<Required<LinkOptionsInterface<Record<string, unknown>, Record<string, unknown>>>, "color" | "width" | "drawLink" | "drawExtraLink" | "arrowColor">;
251
+ declare const PERFORMANCE_LINK_SETTINGS: Omit<Required<LinkSettingsInterface<Record<string, unknown>, Record<string, unknown>>>, "options">;
252
+ declare const PERFORMANCE_LINK_OPTIONS: Omit<Required<LinkOptionsInterface<Record<string, unknown>, Record<string, unknown>>>, "color" | "width" | "drawLink" | "drawExtraLink" | "arrowColor">;
227
253
 
228
254
  type NodeSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
255
+ smartCache?: boolean;
256
+ textScaleSteps?: number[];
229
257
  nodeRadiusFlexible?: boolean;
230
258
  nodeRadiusLinkCountForStep?: number;
231
259
  nodeRadiusIncrementByStep?: number;
@@ -297,6 +325,8 @@ type NodeOptionsLabelInterface = {
297
325
 
298
326
  declare const NODE_SETTINGS: Omit<Required<NodeSettingsInterface<Record<string, unknown>, Record<string, unknown>>>, "options" | "idGetter">;
299
327
  declare const NODE_OPTIONS: Omit<Required<NodeOptionsInterface<Record<string, unknown>, Record<string, unknown>>>, "color" | "text" | "textVisible" | "textSize" | "textShiftY" | "nodeDraw" | "nodeExtraDraw" | "textDraw" | "textExtraDraw">;
328
+ declare const PERFORMANCE_NODE_SETTINGS: Omit<Required<NodeSettingsInterface<Record<string, unknown>, Record<string, unknown>>>, "options" | "idGetter">;
329
+ declare const PERFOMANCE_NODE_OPTIONS: Omit<Required<NodeOptionsInterface<Record<string, unknown>, Record<string, unknown>>>, "color" | "text" | "textVisible" | "textSize" | "textShiftY" | "nodeDraw" | "nodeExtraDraw" | "textDraw" | "textExtraDraw">;
300
330
 
301
331
  declare const GRAPH_CACHE_TYPE: {
302
332
  readonly NodeOptions: "nodeOptions";
@@ -321,6 +351,9 @@ type ListenersInterface<NodeData extends Record<string, unknown>, LinkData exten
321
351
  onEndDragFinished?: (this: GraphCanvas<NodeData, LinkData>, event: DragEventInterface<NodeData>) => void;
322
352
  onDrawFinished?: (this: GraphCanvas<NodeData, LinkData>) => void;
323
353
  onSimulationEnd?: (this: GraphCanvas<NodeData, LinkData>) => void;
354
+ onSelectionIn?: (this: GraphCanvas<NodeData, LinkData>, node: NodeInterface<NodeData> | undefined, link: LinkInterface<NodeData, LinkData> | undefined) => void;
355
+ onSelectionOut?: (this: GraphCanvas<NodeData, LinkData>, node: NodeInterface<NodeData> | undefined, link: LinkInterface<NodeData, LinkData> | undefined) => void;
356
+ onSelectionEnd?: (this: GraphCanvas<NodeData, LinkData>, nodes: NodeInterface<NodeData>[], links: LinkInterface<NodeData, LinkData>[]) => void;
324
357
  };
325
358
 
326
359
  type GraphCanvasInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
@@ -341,7 +374,7 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
341
374
  /** initial data */
342
375
  protected nodes: NodeInterface<NodeData>[];
343
376
  protected links: LinkInterface<NodeData, LinkData>[];
344
- protected particles: Record<string, LinkParticle[]>;
377
+ protected particles: (LinkParticle[] | undefined)[];
345
378
  protected width: number;
346
379
  protected height: number;
347
380
  protected root: HTMLElement;
@@ -358,39 +391,57 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
358
391
  protected context: CanvasRenderingContext2D | null | undefined;
359
392
  protected simulation: GraphCanvasSimulation<NodeData, LinkData> | undefined;
360
393
  protected areaTransform: ZoomTransform;
361
- protected areaRect: DOMRect | undefined;
362
- protected draw: (this: GraphCanvas<NodeData, LinkData>, recursive?: boolean) => void;
394
+ protected _translateExtent: [[number, number], [number, number]] | undefined;
395
+ protected draw: (this: GraphCanvas<NodeData, LinkData>) => void;
363
396
  protected eventAbortController: AbortController;
364
- protected cachedNodeText: CachedNodeTextInterface;
365
- protected cachedNodeLabel: CachedNodeTextInterface;
366
- protected linkOptionsCache: Record<string, Required<LinkOptionsInterface<NodeData, LinkData>>>;
367
- protected nodeOptionsCache: Record<string, Required<NodeOptionsInterface<NodeData, LinkData>>>;
397
+ protected cachedNodeText: (string[] | undefined)[];
398
+ protected cachedNodeLabel: (string[] | undefined)[];
399
+ protected linkOptionsCache: (Required<LinkOptionsInterface<NodeData, LinkData>> | undefined)[];
400
+ protected nodeOptionsCache: (Required<NodeOptionsInterface<NodeData, LinkData>> | undefined)[];
368
401
  protected isDragging: boolean;
369
402
  protected highlightedNode: NodeInterface<NodeData> | null;
370
403
  protected highlightedLink: LinkInterface<NodeData, LinkData> | null;
371
404
  protected highlightedNeighbors: Set<string | number> | null;
372
405
  protected highlightProgress: number;
373
- protected highlightWorking: boolean;
406
+ protected highlightStart: number | null;
407
+ protected highlightPositive: boolean;
408
+ protected highlightController: AbortController | undefined;
409
+ protected _lastNodeZoomK: number | undefined;
410
+ protected _lastLinkZoomK: number | undefined;
411
+ protected _zoomAnimating: boolean;
412
+ protected isSelecting: boolean;
413
+ protected selectionRect: {
414
+ x1: number;
415
+ y1: number;
416
+ x2: number;
417
+ y2: number;
418
+ } | null;
419
+ protected get areaRect(): DOMRect | undefined;
374
420
  protected get simulationWorking(): boolean;
375
421
  constructor({ links, nodes, root, forceSettings, linkSettings, listeners, nodeSettings, graphSettings, highlightSettings, }: GraphCanvasInterface<NodeData, LinkData>);
376
422
  get dpi(): number;
377
- getData(): Pick<GraphCanvasInterface<NodeData, LinkData>, "nodes" | "links">;
378
- changeData(options: Pick<Partial<GraphCanvasInterface<NodeData, LinkData>>, "links" | "nodes">, alpha?: number, clearCache?: boolean | GraphCanvasCacheKeys[]): void;
379
- changeSettings(options: Omit<Partial<GraphCanvasInterface<NodeData, LinkData>>, "links" | "nodes" | "listeners">, clearCache?: boolean | GraphCanvasCacheKeys[]): undefined;
380
- updateRect(): void;
381
- updateSize(): void;
382
- clearCache(keys: boolean | GraphCanvasCacheKeys[]): void;
383
- tick(): void;
384
- restart(alpha?: number): void;
385
- start(): void;
386
- stop(): void;
387
- create(): void;
388
- destroy(): void;
389
- protected clearHTMLElements(): void;
390
- protected updateSimulation(): void;
391
- protected clearState(): void;
392
- protected updateData(alpha?: number, clearCache?: boolean | GraphCanvasCacheKeys[]): void;
393
- protected init(): void;
423
+ getData: () => Pick<GraphCanvasInterface<NodeData, LinkData>, "nodes" | "links">;
424
+ fitToView: (margin?: number, duration?: number) => void;
425
+ focusOnNode: (nodeId: string | number, scale?: number, duration?: number) => void;
426
+ changeData: (options: Pick<Partial<GraphCanvasInterface<NodeData, LinkData>>, "links" | "nodes">, alpha?: number, clearCache?: boolean | GraphCanvasCacheKeys[], precompute?: boolean) => void;
427
+ changeSettings: (options: Omit<Partial<GraphCanvasInterface<NodeData, LinkData>>, "links" | "nodes" | "listeners">, clearCache?: boolean | GraphCanvasCacheKeys[], precompute?: boolean) => undefined;
428
+ updateRect: () => void;
429
+ updateSize: () => void;
430
+ clearCache: (keys: boolean | GraphCanvasCacheKeys[]) => void;
431
+ tick: () => void;
432
+ restart: (alpha?: number, options?: Partial<PrecomputeForceSettingsInterface>) => void;
433
+ start: () => void;
434
+ stop: () => void;
435
+ create: () => void;
436
+ destroy: () => void;
437
+ protected getPointerAreaPosition: (event: MouseEvent | TouchEvent) => number[];
438
+ protected clearHTMLElements: () => void;
439
+ protected updateSimulation: (precompute?: boolean) => void;
440
+ protected clearState: () => void;
441
+ protected init: () => void;
442
+ protected updateData: (alpha?: number, clearCache?: boolean | GraphCanvasCacheKeys[], precompute?: boolean) => void;
443
+ protected animateHighlight: (node: NodeInterface<NodeData> | undefined, link: LinkInterface<NodeData, LinkData> | undefined, baseDuration?: number) => void;
444
+ protected animateZoom: (area: HTMLCanvasElement, target: ZoomTransform, start: ZoomTransform, duration: number) => void;
394
445
  }
395
446
 
396
447
  declare function forceSettingsGetter<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(settings: ForceSettingsInterface<NodeData, LinkData> | undefined, prevSettings?: Required<ForceSettingsInterface<NodeData, LinkData>>): Required<ForceSettingsInterface<NodeData, LinkData>>;
@@ -439,7 +490,15 @@ declare function nodeIdGetter<NodeData extends Record<string, unknown>>(node: No
439
490
 
440
491
  declare function highlightSettingsGetter(settings: HighlightSettingsInterface | undefined, prevSettings?: Required<HighlightSettingsInterface>): Required<HighlightSettingsInterface>;
441
492
 
442
- declare function pointerGetter(mouseEvent: MouseEvent | TouchEvent, areaRect: DOMRect, areaTransform: ZoomTransform): number[];
493
+ interface GraphBounds {
494
+ minX: number;
495
+ minY: number;
496
+ maxX: number;
497
+ maxY: number;
498
+ }
499
+ declare function computeGraphBounds<NodeData extends Record<string, unknown>>(nodes: NodeInterface<NodeData>[]): GraphBounds | null;
500
+
501
+ declare function pointerGetter(mouseEvent: MouseEvent | TouchEvent, areaRect: DOMRect | undefined, areaTransform: ZoomTransform): number[];
443
502
 
444
503
  declare function dragPlaceCoefficientGetter<NodeData extends Record<string, unknown>>(node: NodeInterface<NodeData>, pointerX: number, pointerY: number): number | undefined;
445
504
 
@@ -449,23 +508,24 @@ declare function linkIterationExtractor<NodeData extends Record<string, unknown>
449
508
  declare function linkIterationExtractor<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Result extends string | number | boolean | Record<string, unknown> | unknown[]>(link: LinkInterface<NodeData, LinkData>, i: number, links: LinkInterface<NodeData, LinkData>[], state: GraphCanvas<NodeData, LinkData>, option: LinkIterationPropsInterface<NodeData, LinkData, Result> | Result, optionConstantGetter: LinkIterationPropsInterface<NodeData, LinkData, Required<Result>> | Required<Result>): Required<Result>;
450
509
 
451
510
  type NodeByPointerGetterOptions<NodeData extends Record<string, unknown>> = {
452
- mouseEvent: MouseEvent | TouchEvent;
453
- areaRect: DOMRect | undefined;
454
- areaTransform: ZoomTransform;
511
+ pointerX: number;
512
+ pointerY: number;
455
513
  nodes: NodeInterface<NodeData>[];
456
514
  };
457
- declare function nodeByPointerGetter<NodeData extends Record<string, unknown>>({ areaRect, areaTransform, mouseEvent, nodes, }: NodeByPointerGetterOptions<NodeData>): NodeInterface<NodeData> | undefined;
515
+ declare function nodeByPointerGetter<NodeData extends Record<string, unknown>>({ pointerX, pointerY, nodes, }: NodeByPointerGetterOptions<NodeData>): NodeInterface<NodeData> | undefined;
458
516
 
459
517
  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: GraphCanvas<NodeData, LinkData>, option: NodeIterationPropsInterface<NodeData, LinkData, Result> | Result, optionConstantGetter: undefined): Result;
460
518
  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: GraphCanvas<NodeData, LinkData>, option: NodeIterationPropsInterface<NodeData, LinkData, Result> | Result, optionConstantGetter: NodeIterationPropsInterface<NodeData, LinkData, Result> | Result): Required<Result>;
461
519
 
462
- declare function calculateLinkPositionByNode<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(link: LinkInterface<NodeData, LinkData>, arrowSize?: number): {
463
- x1: number;
464
- y1: number;
465
- x2: number;
466
- y2: number;
520
+ declare function calculateLinkPositionByNode<NodeData extends Record<string, unknown>>(xStart: number, yStart: number, xEnd: number, yEnd: number, sourceNode: NodeInterface<NodeData>, targetNode: NodeInterface<NodeData>, arrowSize?: number): {
521
+ xStart: number;
522
+ yStart: number;
523
+ xEnd: number;
524
+ yEnd: number;
525
+ xEndArrow: number;
526
+ yEndArrow: number;
467
527
  distance: number;
468
- } | null;
528
+ };
469
529
 
470
530
  declare function animationByProgress(initial: number, additional: number, progress: number): number;
471
531
 
@@ -483,20 +543,23 @@ type GetParticlePositionOptions = {
483
543
  yStart: number;
484
544
  xEnd: number;
485
545
  yEnd: number;
486
- totalSteps: number;
487
- totalCount: number;
546
+ xControl: number;
547
+ yControl: number;
488
548
  distance: number;
549
+ totalCount: number;
550
+ speed: number;
489
551
  };
490
552
  declare function getParticlePosition(opts: GetParticlePositionOptions): void;
553
+ declare function approximateQuadraticBezierLength(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): number;
491
554
 
492
555
  type LinkByPointerGetterOptions<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
493
- mouseEvent: MouseEvent | TouchEvent;
494
- areaRect: DOMRect | undefined;
495
- areaTransform: ZoomTransform;
556
+ pointerX: number;
557
+ pointerY: number;
496
558
  links: LinkInterface<NodeData, LinkData>[];
497
559
  linkHoverExtraZone: number;
560
+ curve: boolean;
498
561
  };
499
- declare function linkByPointerGetter<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>({ areaRect, areaTransform, mouseEvent, links, linkHoverExtraZone, }: LinkByPointerGetterOptions<NodeData, LinkData>): LinkInterface<NodeData, LinkData> | undefined;
562
+ declare function linkByPointerGetter<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>({ pointerX, pointerY, links, linkHoverExtraZone, curve, }: LinkByPointerGetterOptions<NodeData, LinkData>): LinkInterface<NodeData, LinkData> | undefined;
500
563
 
501
564
  type NodeHighlightOptions<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
502
565
  nodeOptions: Required<NodeOptionsInterface<NodeData, LinkData>>;
@@ -582,9 +645,11 @@ declare function extractLinkPointIds<NodeData extends Record<string, unknown>, L
582
645
  targetId: string | number;
583
646
  };
584
647
 
585
- declare function getDrawLink<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(): (this: GraphCanvas<NodeData, LinkData>, link: LinkInterface<NodeData, LinkData>) => void;
648
+ declare function isEmptyObject(obj: Record<string, unknown>): boolean;
649
+
650
+ declare function getDrawLink<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(): (this: GraphCanvas<NodeData, LinkData>, link: LinkInterface<NodeData, LinkData>, index: number) => void;
586
651
 
587
- declare function getDrawNode<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(nodeRenders: (() => void)[], textRenders: (() => void)[]): (this: GraphCanvas<NodeData, LinkData>, node: NodeInterface<NodeData>) => void;
652
+ declare function getDrawNode<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(nodeRenders: (() => void)[], textRenders: (() => void)[]): (this: GraphCanvas<NodeData, LinkData>, node: NodeInterface<NodeData>, index: number) => void;
588
653
 
589
654
  type DrawTextOptions = {
590
655
  lines: string[];
@@ -682,5 +747,5 @@ declare const NODE_OPTIONS_NODE_CONTROLS: GraphSettingsInputInterface<keyof Node
682
747
  declare const NODE_OPTIONS_TEXT_CONTROLS: GraphSettingsInputInterface<keyof NodeOptionsTextInterface>[];
683
748
  declare const NODE_OPTIONS_LABEL_CONTROLS: GraphSettingsInputInterface<keyof NodeOptionsLabelInterface>[];
684
749
 
685
- export { COMMON_SETTINGS, FORCE_CONTROLS, FORCE_SETTINGS, GRAPH_CACHE_TYPE, GRAPH_SETTINGS, GraphCanvas, HIGHLIGHT_BY_LINK_FOR_ARROW_CONTROLS, HIGHLIGHT_BY_LINK_FOR_LABEL_CONTROLS, HIGHLIGHT_BY_LINK_FOR_LINK_CONTROLS, HIGHLIGHT_BY_LINK_FOR_NODE_CONTROLS, HIGHLIGHT_BY_LINK_FOR_TEXT_CONTROLS, HIGHLIGHT_BY_NODE_FOR_ARROW_CONTROLS, HIGHLIGHT_BY_NODE_FOR_LABEL_CONTROLS, HIGHLIGHT_BY_NODE_FOR_LINK_CONTROLS, HIGHLIGHT_BY_NODE_FOR_NODE_CONTROLS, HIGHLIGHT_BY_NODE_FOR_TEXT_CONTROLS, HIGHLIGHT_COMMON_CONTROLS, HIGHLIGHT_SETTINGS, LINK_OPTIONS, LINK_OPTIONS_ARROW_CONTROLS, LINK_OPTIONS_LINK_CONTROLS, LINK_OPTIONS_PARTICLE_CONTROLS, LINK_SETTINGS, LINK_SETTINGS_CONTROLS, NODE_OPTIONS, NODE_OPTIONS_LABEL_CONTROLS, NODE_OPTIONS_NODE_CONTROLS, NODE_OPTIONS_TEXT_CONTROLS, NODE_SETTINGS, NODE_SETTINGS_CONTROLS, animationByProgress, calculateLinkPositionByNode, colorGetter, colorToRgb, dragPlaceCoefficientGetter, drawText, extractLinkPointIds, extractRgb, fadeRgb, forceSettingsGetter, getDrawLink, getDrawNode, getParticlePosition, graphSettingsGetter, highlightSettingsGetter, isNodeVisible, isOverlapsNode, linkByPointerGetter, linkFade, linkHighlight, linkIterationExtractor, linkOptionsGetter, linkSettingsGetter, listenersGetter, nodeByPointerGetter, nodeFade, nodeHighlight, nodeIdGetter, nodeIterationExtractor, nodeOptionsGetter, nodeRadiusGetter, nodeSettingsGetter, nodeSizeGetter, nodeTextSizeGetter, pointerGetter, rgbAnimationByProgress };
686
- export type { CachedNodeTextInterface, DragEventInterface, ForceSettingsInterface, GraphCanvasCacheKeys, GraphCanvasInterface, GraphCanvasSimulation, GraphSettingsInputInterface, GraphSettingsInterface, HighlighCommonSettingsInterface, HighlightByLinkForArrowSettingsInterface, HighlightByLinkForLabelSettingsInterface, HighlightByLinkForLinkSettingsInterface, HighlightByLinkForNodeSettingsInterface, HighlightByLinkForTextSettingsInterface, HighlightByNodeForArrowSettingsInterface, HighlightByNodeForLabelSettingsInterface, HighlightByNodeForLinkSettingsInterface, HighlightByNodeForNodeSettingsInterface, HighlightByNodeForTextSettingsInterface, HighlightSettingsInterface, LinkByPointerGetterOptions, LinkInterface, LinkIterationPropsInterface, LinkIterationPropsNoThisInterface, LinkOptionsArrowInterface, LinkOptionsInterface, LinkOptionsLinkInterface, LinkOptionsParticleInterface, LinkParticle, LinkSettingsInterface, ListenersInterface, NodeByPointerGetterOptions, NodeInterface, NodeIterationPropsInterface, NodeIterationPropsNoThisInterface, NodeOptionsInterface, NodeOptionsLabelInterface, NodeOptionsNodeInterface, NodeOptionsTextInterface, NodeRadiusGetterOptions, NodeSettingsInterface, NodeShape, NodeSizeGetterOptions, RGB, TextStyleEnum, ZoomEventInterface };
750
+ export { COMMON_SETTINGS, FORCE_CONTROLS, FORCE_SETTINGS, GRAPH_CACHE_TYPE, GRAPH_SETTINGS, GraphCanvas, HIGHLIGHT_BY_LINK_FOR_ARROW_CONTROLS, HIGHLIGHT_BY_LINK_FOR_LABEL_CONTROLS, HIGHLIGHT_BY_LINK_FOR_LINK_CONTROLS, HIGHLIGHT_BY_LINK_FOR_NODE_CONTROLS, HIGHLIGHT_BY_LINK_FOR_TEXT_CONTROLS, HIGHLIGHT_BY_NODE_FOR_ARROW_CONTROLS, HIGHLIGHT_BY_NODE_FOR_LABEL_CONTROLS, HIGHLIGHT_BY_NODE_FOR_LINK_CONTROLS, HIGHLIGHT_BY_NODE_FOR_NODE_CONTROLS, HIGHLIGHT_BY_NODE_FOR_TEXT_CONTROLS, HIGHLIGHT_COMMON_CONTROLS, HIGHLIGHT_SETTINGS, LINK_OPTIONS, LINK_OPTIONS_ARROW_CONTROLS, LINK_OPTIONS_LINK_CONTROLS, LINK_OPTIONS_PARTICLE_CONTROLS, LINK_SETTINGS, LINK_SETTINGS_CONTROLS, NODE_OPTIONS, NODE_OPTIONS_LABEL_CONTROLS, NODE_OPTIONS_NODE_CONTROLS, NODE_OPTIONS_TEXT_CONTROLS, NODE_SETTINGS, NODE_SETTINGS_CONTROLS, PERFOMANCE_NODE_OPTIONS, PERFORMANCE_FORCE_SETTINGS, PERFORMANCE_GRAPH_SETTINGS, PERFORMANCE_HIGHLIGHT_SETTINGS, PERFORMANCE_LINK_OPTIONS, PERFORMANCE_LINK_SETTINGS, PERFORMANCE_NODE_SETTINGS, animationByProgress, approximateQuadraticBezierLength, calculateLinkPositionByNode, colorGetter, colorToRgb, computeGraphBounds, dragPlaceCoefficientGetter, drawText, extractLinkPointIds, extractRgb, fadeRgb, forceSettingsGetter, getDrawLink, getDrawNode, getParticlePosition, graphSettingsGetter, highlightSettingsGetter, isEmptyObject, isNodeVisible, isOverlapsNode, linkByPointerGetter, linkFade, linkHighlight, linkIterationExtractor, linkOptionsGetter, linkSettingsGetter, listenersGetter, nodeByPointerGetter, nodeFade, nodeHighlight, nodeIdGetter, nodeIterationExtractor, nodeOptionsGetter, nodeRadiusGetter, nodeSettingsGetter, nodeSizeGetter, nodeTextSizeGetter, pointerGetter, rgbAnimationByProgress };
751
+ export type { CachedNodeTextInterface, DragEventInterface, ForceSettingsInterface, GraphBounds, GraphCanvasCacheKeys, GraphCanvasInterface, GraphCanvasSimulation, GraphSettingsInputInterface, GraphSettingsInterface, HighlighCommonSettingsInterface, HighlightByLinkForArrowSettingsInterface, HighlightByLinkForLabelSettingsInterface, HighlightByLinkForLinkSettingsInterface, HighlightByLinkForNodeSettingsInterface, HighlightByLinkForTextSettingsInterface, HighlightByNodeForArrowSettingsInterface, HighlightByNodeForLabelSettingsInterface, HighlightByNodeForLinkSettingsInterface, HighlightByNodeForNodeSettingsInterface, HighlightByNodeForTextSettingsInterface, HighlightSettingsInterface, LinkByPointerGetterOptions, LinkInterface, LinkIterationPropsInterface, LinkIterationPropsNoThisInterface, LinkOptionsArrowInterface, LinkOptionsInterface, LinkOptionsLinkInterface, LinkOptionsParticleInterface, LinkParticle, LinkSettingsInterface, ListenersInterface, NodeByPointerGetterOptions, NodeInterface, NodeIterationPropsInterface, NodeIterationPropsNoThisInterface, NodeOptionsInterface, NodeOptionsLabelInterface, NodeOptionsNodeInterface, NodeOptionsTextInterface, NodeRadiusGetterOptions, NodeSettingsInterface, NodeShape, NodeSizeGetterOptions, PrecomputeForceSettingsInterface, RGB, TextStyleEnum, ZoomEventInterface };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krainovsd/graph",
3
- "version": "0.13.0-beta1",
3
+ "version": "0.14.0-beta-7.1",
4
4
  "description": "Krainov graph",
5
5
  "type": "module",
6
6
  "author": "KrainovSD <denislosev48@gmail.com>",
@@ -62,7 +62,8 @@
62
62
  "@vitejs/plugin-vue": "5.2.4",
63
63
  "@krainovsd/vue-ui": "0.4.0-beta.23",
64
64
  "@krainovsd/vue-icons": "0.1.4",
65
- "sass-embedded": "1.81.0"
65
+ "sass-embedded": "1.81.0",
66
+ "@fontsource/nunito": "5.2.7"
66
67
  },
67
68
  "dependencies": {
68
69
  "@krainovsd/js-helpers": "^0.16.5",