@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.
Files changed (68) hide show
  1. package/lib/cjs/index.cjs +772 -466
  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 +265 -74
  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 -10
  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 +5 -2
  38. package/lib/esm/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.js.map +1 -1
  39. package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js +5 -2
  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/slices/draw-links.js +47 -62
  50. package/lib/esm/module/GraphCanvas/slices/draw-links.js.map +1 -1
  51. package/lib/esm/module/GraphCanvas/slices/draw-nodes.js +9 -4
  52. package/lib/esm/module/GraphCanvas/slices/draw-nodes.js.map +1 -1
  53. package/lib/esm/module/GraphCanvas/slices/init-dnd.js +21 -4
  54. package/lib/esm/module/GraphCanvas/slices/init-dnd.js.map +1 -1
  55. package/lib/esm/module/GraphCanvas/slices/init-draw.js +1 -52
  56. package/lib/esm/module/GraphCanvas/slices/init-draw.js.map +1 -1
  57. package/lib/esm/module/GraphCanvas/slices/init-pointer.js +6 -34
  58. package/lib/esm/module/GraphCanvas/slices/init-pointer.js.map +1 -1
  59. package/lib/esm/module/GraphCanvas/slices/init-simulation.js +12 -2
  60. package/lib/esm/module/GraphCanvas/slices/init-simulation.js.map +1 -1
  61. package/lib/esm/module/GraphCanvas/slices/init-zoom.js +85 -16
  62. package/lib/esm/module/GraphCanvas/slices/init-zoom.js.map +1 -1
  63. package/lib/esm/module/GraphCanvas/slices/update-link-cache.js +33 -3
  64. package/lib/esm/module/GraphCanvas/slices/update-link-cache.js.map +1 -1
  65. package/lib/esm/module/GraphCanvas/slices/update-node-cache.js +61 -16
  66. package/lib/esm/module/GraphCanvas/slices/update-node-cache.js.map +1 -1
  67. package/lib/index.d.ts +85 -46
  68. package/package.json +3 -2
@@ -1,41 +1,110 @@
1
1
  import { isArray } from '@krainovsd/js-helpers';
2
2
  import { select } from 'd3-selection';
3
3
  import { zoom, ZoomTransform } from 'd3-zoom';
4
+ import '../constants/force-settings.js';
5
+ import '../constants/graph-settings.js';
6
+ import '../constants/highlight-settings.js';
7
+ import '../constants/link-settings.js';
8
+ import '../constants/node-settings.js';
9
+ import { computeGraphBounds } from '../lib/utils/compute-graph-bounds.js';
10
+ import 'd3-array';
4
11
  import { updateLinkCache } from './update-link-cache.js';
5
12
  import { updateNodeCache } from './update-node-cache.js';
6
13
 
14
+ const DEFAULT_ZOOM_EXTENT = [0.3, 10];
15
+ const DEFAULT_TRANSLATE_EXTENT_COEFFICIENT = 8;
16
+ const DEFAULT_MARGIN = 0.25;
7
17
  function initZoom(currentZoom) {
8
18
  if (!this.area)
9
19
  throw new Error("bad init data");
20
+ const bounds = computeGraphBounds(this.nodes);
21
+ const zoomExtent = resolveZoomExtent(this.graphSettings.zoomExtent, this.width, this.height, this.graphSettings.zoomExtentMargin ?? DEFAULT_MARGIN, bounds);
22
+ const translateExtent = resolveTranslateExtent(this.graphSettings.translateExtent, this.graphSettings.translateExtentCoefficient, this.graphSettings.translateExtentOverlap, this.width, this.height, zoomExtent, bounds);
23
+ this._translateExtent = translateExtent;
10
24
  const zoomInstance = zoom()
11
- .scaleExtent(this.graphSettings.zoomExtent)
25
+ .scaleExtent(zoomExtent)
12
26
  .on("zoom", (event) => {
27
+ if (this._zoomAnimating)
28
+ return;
13
29
  this.listeners.onZoom?.call?.(this, event);
14
30
  const oldTransform = this.areaTransform;
15
31
  this.areaTransform = event.transform;
16
32
  if (this.areaTransform.k !== oldTransform.k) {
17
33
  updateLinkCache.call(this);
18
- updateNodeCache.call(this, true);
34
+ updateNodeCache.call(this);
19
35
  }
20
- if (!this.simulationWorking && !this.highlightWorking)
21
- requestAnimationFrame(() => this.draw());
36
+ this.tick();
22
37
  });
23
- if (this.graphSettings.translateExtentEnable) {
24
- const coefficient = this.graphSettings.translateExtentCoefficient;
25
- const [coefficientX, coefficientY] = isArray(coefficient)
26
- ? coefficient
27
- : [coefficient, coefficient];
28
- const [[minX = -this.width * coefficientX, minY = -this.height * coefficientY], [maxX = this.width * coefficientX, maxY = this.height * coefficientY],] = this.graphSettings.translateExtent;
29
- zoomInstance.translateExtent([
30
- [minX, minY],
31
- [maxX, maxY],
32
- ]);
33
- }
38
+ zoomInstance.translateExtent(translateExtent);
34
39
  select(this.area).call(zoomInstance).on("dblclick.zoom", null);
35
40
  const zoomInitial = currentZoom ?? this.graphSettings.zoomInitial;
36
- this.areaTransform = new ZoomTransform(zoomInitial?.k ?? 1, zoomInitial?.x ?? this.width / 2, zoomInitial?.y ?? this.height / 2);
41
+ this.areaTransform = new ZoomTransform(Math.max(zoomInitial?.k ?? 1, zoomExtent[0]), zoomInitial?.x ?? this.width / 2, zoomInitial?.y ?? this.height / 2);
37
42
  zoom().transform(select(this.area), this.areaTransform);
38
43
  }
44
+ function resolveZoomExtent(userExtent, viewWidth, viewHeight, margin, bounds) {
45
+ if (userExtent &&
46
+ userExtent.length === 2 &&
47
+ userExtent[0] != undefined &&
48
+ userExtent[1] != undefined) {
49
+ return userExtent;
50
+ }
51
+ if (!bounds)
52
+ return DEFAULT_ZOOM_EXTENT;
53
+ const graphWidth = bounds.maxX - bounds.minX;
54
+ const graphHeight = bounds.maxY - bounds.minY;
55
+ if (graphWidth === 0 || graphHeight === 0)
56
+ return DEFAULT_ZOOM_EXTENT;
57
+ const scaleToFit = (1 - margin) / Math.max(graphWidth / viewWidth, graphHeight / viewHeight);
58
+ return [scaleToFit, DEFAULT_ZOOM_EXTENT[1]];
59
+ }
60
+ function resolveTranslateExtent(userExtent, userCoefficient, overlap, viewWidth, viewHeight, zoomExtent, bounds) {
61
+ if (userExtent && userExtent.length >= 2 && isArray(userExtent[0]) && isArray(userExtent[1])) {
62
+ return [
63
+ [
64
+ userExtent[0][0] ?? -viewWidth * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,
65
+ userExtent[0][1] ?? -viewHeight * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,
66
+ ],
67
+ [
68
+ userExtent[1][0] ?? viewWidth * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,
69
+ userExtent[1][1] ?? viewHeight * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,
70
+ ],
71
+ ];
72
+ }
73
+ if (userCoefficient) {
74
+ const [cx, cy] = isArray(userCoefficient)
75
+ ? userCoefficient
76
+ : [userCoefficient, userCoefficient];
77
+ return [
78
+ [-viewWidth * cx, -viewHeight * cy],
79
+ [viewWidth * cx, viewHeight * cy],
80
+ ];
81
+ }
82
+ if (!bounds) {
83
+ return [
84
+ [
85
+ -viewWidth * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,
86
+ -viewHeight * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,
87
+ ],
88
+ [
89
+ viewWidth * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,
90
+ viewHeight * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,
91
+ ],
92
+ ];
93
+ }
94
+ const minZoom = zoomExtent[0];
95
+ const zoomViewWidth = viewWidth / minZoom;
96
+ const zoomViewHeight = viewHeight / minZoom;
97
+ const graphWidth = bounds.maxX - bounds.minX;
98
+ const graphHeight = bounds.maxY - bounds.minY;
99
+ const minX = bounds.minX + overlap * graphWidth - zoomViewWidth;
100
+ const maxX = bounds.maxX - overlap * graphWidth + zoomViewWidth;
101
+ const minY = bounds.minY + overlap * graphHeight - zoomViewHeight;
102
+ const maxY = bounds.maxY - overlap * graphHeight + zoomViewHeight;
103
+ return [
104
+ [minX, minY],
105
+ [maxX, maxY],
106
+ ];
107
+ }
39
108
 
40
109
  export { initZoom };
41
110
  //# sourceMappingURL=init-zoom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-zoom.js","sources":["../../../../../src/module/GraphCanvas/slices/init-zoom.ts"],"sourcesContent":["import { isArray } from \"@krainovsd/js-helpers\";\nimport { select as d3Select } from \"d3-selection\";\nimport { ZoomTransform, zoom } from \"d3-zoom\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport type { ZoomEventInterface } from \"../types\";\nimport { updateLinkCache } from \"./update-link-cache\";\nimport { updateNodeCache } from \"./update-node-cache\";\n\nexport function initZoom<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>, currentZoom?: ZoomTransform) {\n if (!this.area) throw new Error(\"bad init data\");\n\n const zoomInstance = zoom<HTMLCanvasElement, unknown>()\n .scaleExtent(this.graphSettings.zoomExtent)\n .on(\"zoom\", (event: ZoomEventInterface) => {\n this.listeners.onZoom?.call?.(this, event);\n const oldTransform = this.areaTransform;\n this.areaTransform = event.transform;\n if (this.areaTransform.k !== oldTransform.k) {\n updateLinkCache.call<\n GraphCanvas<NodeData, LinkData>,\n Parameters<typeof updateLinkCache>,\n ReturnType<typeof updateLinkCache>\n >(this);\n updateNodeCache.call<\n GraphCanvas<NodeData, LinkData>,\n Parameters<typeof updateNodeCache>,\n ReturnType<typeof updateNodeCache>\n >(this, true);\n }\n\n if (!this.simulationWorking && !this.highlightWorking)\n requestAnimationFrame(() => this.draw());\n });\n\n if (this.graphSettings.translateExtentEnable) {\n const coefficient = this.graphSettings.translateExtentCoefficient;\n const [coefficientX, coefficientY] = isArray(coefficient)\n ? coefficient\n : [coefficient, coefficient];\n\n const [\n [minX = -this.width * coefficientX, minY = -this.height * coefficientY],\n [maxX = this.width * coefficientX, maxY = this.height * coefficientY],\n ] = this.graphSettings.translateExtent;\n\n zoomInstance.translateExtent([\n [minX, minY],\n [maxX, maxY],\n ]);\n }\n\n d3Select(this.area).call(zoomInstance).on(\"dblclick.zoom\", null);\n\n const zoomInitial = currentZoom ?? this.graphSettings.zoomInitial;\n this.areaTransform = new ZoomTransform(\n zoomInitial?.k ?? 1,\n zoomInitial?.x ?? this.width / 2,\n zoomInitial?.y ?? this.height / 2,\n );\n zoom<HTMLCanvasElement, unknown>().transform(d3Select(this.area), this.areaTransform);\n}\n"],"names":["d3Select"],"mappings":";;;;;;AAQM,SAAU,QAAQ,CAGiB,WAA2B,EAAA;IAClE,IAAI,CAAC,IAAI,CAAC,IAAI;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAEhD,MAAM,YAAY,GAAG,IAAI;AACtB,SAAA,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU;AACzC,SAAA,EAAE,CAAC,MAAM,EAAE,CAAC,KAAyB,KAAI;AACxC,QAAA,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,CAAC;AAC1C,QAAA,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa;AACvC,QAAA,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,SAAS;Q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E,CAAC,IAAI,CAAC,EACnB,WAAW,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,EAChC,WAAW,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAClC;AACD,IAAA,IAAI,EAA8B,CAAC,SAAS,CAACA,MAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC;AACvF;;;;"}
1
+ {"version":3,"file":"init-zoom.js","sources":["../../../../../src/module/GraphCanvas/slices/init-zoom.ts"],"sourcesContent":["import { isArray } from \"@krainovsd/js-helpers\";\nimport { select as d3Select } from \"d3-selection\";\nimport { ZoomTransform, zoom } from \"d3-zoom\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport { computeGraphBounds } from \"../lib\";\nimport type { ZoomEventInterface } from \"../types\";\nimport { updateLinkCache } from \"./update-link-cache\";\nimport { updateNodeCache } from \"./update-node-cache\";\n\nconst DEFAULT_ZOOM_EXTENT: [number, number] = [0.3, 10];\nconst DEFAULT_TRANSLATE_EXTENT_COEFFICIENT = 8;\nconst DEFAULT_MARGIN = 0.25;\n\nexport function initZoom<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>, currentZoom?: ZoomTransform) {\n if (!this.area) throw new Error(\"bad init data\");\n\n const bounds = computeGraphBounds(this.nodes);\n const zoomExtent = resolveZoomExtent(\n this.graphSettings.zoomExtent,\n this.width,\n this.height,\n this.graphSettings.zoomExtentMargin ?? DEFAULT_MARGIN,\n bounds,\n );\n const translateExtent = resolveTranslateExtent(\n this.graphSettings.translateExtent,\n this.graphSettings.translateExtentCoefficient,\n this.graphSettings.translateExtentOverlap,\n this.width,\n this.height,\n zoomExtent,\n bounds,\n );\n this._translateExtent = translateExtent;\n\n const zoomInstance = zoom<HTMLCanvasElement, unknown>()\n .scaleExtent(zoomExtent)\n .on(\"zoom\", (event: ZoomEventInterface) => {\n if (this._zoomAnimating) return;\n this.listeners.onZoom?.call?.(this, event);\n const oldTransform = this.areaTransform;\n this.areaTransform = event.transform;\n if (this.areaTransform.k !== oldTransform.k) {\n updateLinkCache.call<\n GraphCanvas<NodeData, LinkData>,\n Parameters<typeof updateLinkCache>,\n ReturnType<typeof updateLinkCache>\n >(this);\n updateNodeCache.call<\n GraphCanvas<NodeData, LinkData>,\n Parameters<typeof updateNodeCache>,\n ReturnType<typeof updateNodeCache>\n >(this);\n }\n this.tick();\n });\n\n zoomInstance.translateExtent(translateExtent);\n d3Select(this.area).call(zoomInstance).on(\"dblclick.zoom\", null);\n\n const zoomInitial = currentZoom ?? this.graphSettings.zoomInitial;\n this.areaTransform = new ZoomTransform(\n Math.max(zoomInitial?.k ?? 1, zoomExtent[0]),\n zoomInitial?.x ?? this.width / 2,\n zoomInitial?.y ?? this.height / 2,\n );\n zoom<HTMLCanvasElement, unknown>().transform(d3Select(this.area), this.areaTransform);\n}\n\nfunction resolveZoomExtent(\n userExtent: [number, number] | null,\n viewWidth: number,\n viewHeight: number,\n margin: number,\n bounds: ReturnType<typeof computeGraphBounds>,\n): [number, number] {\n if (\n userExtent &&\n userExtent.length === 2 &&\n userExtent[0] != undefined &&\n userExtent[1] != undefined\n ) {\n return userExtent;\n }\n if (!bounds) return DEFAULT_ZOOM_EXTENT;\n const graphWidth = bounds.maxX - bounds.minX;\n const graphHeight = bounds.maxY - bounds.minY;\n if (graphWidth === 0 || graphHeight === 0) return DEFAULT_ZOOM_EXTENT;\n const scaleToFit = (1 - margin) / Math.max(graphWidth / viewWidth, graphHeight / viewHeight);\n return [scaleToFit, DEFAULT_ZOOM_EXTENT[1]];\n}\n\nfunction resolveTranslateExtent(\n userExtent: [[number?, number?], [number?, number?]] | null,\n userCoefficient: number | [number, number] | null,\n overlap: number,\n viewWidth: number,\n viewHeight: number,\n zoomExtent: [number, number],\n bounds: ReturnType<typeof computeGraphBounds>,\n): [[number, number], [number, number]] {\n if (userExtent && userExtent.length >= 2 && isArray(userExtent[0]) && isArray(userExtent[1])) {\n return [\n [\n userExtent[0][0] ?? -viewWidth * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,\n userExtent[0][1] ?? -viewHeight * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,\n ],\n [\n userExtent[1][0] ?? viewWidth * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,\n userExtent[1][1] ?? viewHeight * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,\n ],\n ];\n }\n if (userCoefficient) {\n const [cx, cy] = isArray(userCoefficient)\n ? userCoefficient\n : [userCoefficient, userCoefficient];\n return [\n [-viewWidth * cx, -viewHeight * cy],\n [viewWidth * cx, viewHeight * cy],\n ];\n }\n if (!bounds) {\n return [\n [\n -viewWidth * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,\n -viewHeight * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,\n ],\n [\n viewWidth * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,\n viewHeight * DEFAULT_TRANSLATE_EXTENT_COEFFICIENT,\n ],\n ];\n }\n\n const minZoom = zoomExtent[0];\n const zoomViewWidth = viewWidth / minZoom;\n const zoomViewHeight = viewHeight / minZoom;\n const graphWidth = bounds.maxX - bounds.minX;\n const graphHeight = bounds.maxY - bounds.minY;\n\n const minX = bounds.minX + overlap * graphWidth - zoomViewWidth;\n const maxX = bounds.maxX - overlap * graphWidth + zoomViewWidth;\n const minY = bounds.minY + overlap * graphHeight - zoomViewHeight;\n const maxY = bounds.maxY - overlap * graphHeight + zoomViewHeight;\n\n return [\n [minX, minY],\n [maxX, maxY],\n ];\n}\n"],"names":["d3Select"],"mappings":";;;;;;;;;;;;;AASA,MAAM,mBAAmB,GAAqB,CAAC,GAAG,EAAE,EAAE,CAAC;AACvD,MAAM,oCAAoC,GAAG,CAAC;AAC9C,MAAM,cAAc,GAAG,IAAI;AAErB,SAAU,QAAQ,CAGiB,WAA2B,EAAA;IAClE,IAAI,CAAC,IAAI,CAAC,IAAI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AA,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC;AAC7B,IAAA,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO;AACzC,IAAA,MAAM,cAAc,GAAG,UAAU,GAAG,OAAO;IAC3C,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI;IAC5C,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI;IAE7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa;IAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa;IAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,OAAO,GAAG,WAAW,GAAG,cAAc;IACjE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,OAAO,GAAG,WAAW,GAAG,cAAc;IAEjE,OAAO;QACL,CAAC,IAAI,EAAE,IAAI,CAAC;QACZ,CAAC,IAAI,EAAE,IAAI,CAAC;KACb;AACH;;;;"}
@@ -1,3 +1,8 @@
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';
1
6
  import { linkOptionsGetter } from '../lib/settings/link-settings-getter.js';
2
7
  import '@krainovsd/js-helpers';
3
8
  import { linkIterationExtractor } from '../lib/utils/link-iteration-extractor.js';
@@ -5,16 +10,41 @@ import 'd3-array';
5
10
  import { extractLinkPointIds } from '../lib/utils/extract-link-point-ids.js';
6
11
 
7
12
  function updateLinkCache() {
8
- this.linkOptionsCache = {};
13
+ if (!this.context)
14
+ return;
15
+ const current = this.areaTransform.k;
16
+ if (this.linkSettings.smartCache &&
17
+ this._lastLinkZoomK !== undefined &&
18
+ this.linkOptionsCache.length > 0) {
19
+ const corner = this.linkSettings.linkScaleSwitch;
20
+ const prev = this._lastLinkZoomK;
21
+ this._lastLinkZoomK = current;
22
+ if (!((prev <= corner && current >= corner) || (prev >= corner && current <= corner))) {
23
+ return;
24
+ }
25
+ for (let i = 0; i < this.links.length; i++) {
26
+ const link = this.links[i];
27
+ const linkOptions = linkIterationExtractor(link, i, this.links, this, this.linkSettings.options ?? {}, linkOptionsGetter);
28
+ const cache = this.linkOptionsCache[i];
29
+ if (cache) {
30
+ cache.color = linkOptions.color;
31
+ cache.arrowColor = linkOptions.arrowColor;
32
+ cache.width = linkOptions.width;
33
+ }
34
+ }
35
+ return;
36
+ }
37
+ this._lastLinkZoomK = current;
38
+ this.linkOptionsCache.length = 0;
9
39
  const groupMap = {};
10
40
  const groupSelfMap = {};
11
41
  for (let i = 0; i < this.links.length; i++) {
12
42
  const link = this.links[i];
13
43
  const { sourceId, targetId } = extractLinkPointIds(link);
14
44
  const linkOptions = linkIterationExtractor(link, i, this.links, this, this.linkSettings.options ?? {}, linkOptionsGetter);
15
- const id = `${targetId}${sourceId}`;
16
- this.linkOptionsCache[id] = linkOptions;
45
+ this.linkOptionsCache[i] = linkOptions;
17
46
  if (this.linkSettings.curve) {
47
+ const id = `${targetId}${sourceId}`;
18
48
  if (sourceId === targetId) {
19
49
  groupSelfMap[id] ??= 0;
20
50
  link._groupIndex = ++groupSelfMap[id];
@@ -1 +1 @@
1
- {"version":3,"file":"update-link-cache.js","sources":["../../../../../src/module/GraphCanvas/slices/update-link-cache.ts"],"sourcesContent":["import type { GraphCanvas } from \"../GraphCanvas\";\nimport { extractLinkPointIds, linkIterationExtractor, linkOptionsGetter } from \"../lib\";\n\nexport function updateLinkCache<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n this.linkOptionsCache = {};\n\n const groupMap: Record<string, number> = {};\n const groupSelfMap: Record<string, number> = {};\n for (let i = 0; i < this.links.length; i++) {\n const link = this.links[i];\n const { sourceId, targetId } = extractLinkPointIds(link);\n\n const linkOptions = linkIterationExtractor(\n link,\n i,\n this.links,\n this,\n this.linkSettings.options ?? {},\n linkOptionsGetter,\n );\n const id = `${targetId}${sourceId}`;\n this.linkOptionsCache[id] = linkOptions;\n\n if (this.linkSettings.curve) {\n if (sourceId === targetId) {\n groupSelfMap[id] ??= 0;\n link._groupIndex = ++groupSelfMap[id];\n link._self = true;\n continue;\n }\n const reverseId = `${sourceId}${targetId}`;\n groupMap[reverseId] ??= 0;\n groupMap[reverseId]++;\n groupMap[id] ??= 0;\n link._groupIndex = indexToPosition(++groupMap[id]);\n link._self = false;\n }\n }\n if (this.linkSettings.curve) {\n for (const link of this.links) {\n const { sourceId, targetId } = extractLinkPointIds(link);\n const id = `${targetId}${sourceId}`;\n link._groupSize = link._self ? (groupSelfMap[id] ?? 1) : (groupMap[id] ?? 1);\n }\n }\n}\n\nfunction indexToPosition(n: number): number {\n if (n === 1) return 0;\n\n const index = n >> 1;\n return n & 1 ? -(index * 2) : index * 2;\n\n // return n & 1 ? -(n >> 1) : n >> 1;\n}\n"],"names":[],"mappings":";;;;;;SAGgB,eAAe,GAAA;AAI7B,IAAA,IAAI,CAAC,gBAAgB,GAAG,EAAE;IAE1B,MAAM,QAAQ,GAA2B,EAAE;IAC3C,MAAM,YAAY,GAA2B,EAAE;AAC/C,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1B,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAAC;QAExD,MAAM,WAAW,GAAG,sBAAsB,CACxC,IAAI,EACJ,CAAC,EACD,IAAI,CAAC,KAAK,EACV,IAAI,EACJ,IAAI,CAAC,YAAY,CAAC,OAAO,IAAI,EAAE,EAC/B,iBAAiB,CAClB;AACD,QAAA,MAAM,EAAE,GAA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ErB,IAAA,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC;AACpB,IAAA,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;;AAGzC;;;;"}
1
+ {"version":3,"file":"update-link-cache.js","sources":["../../../../../src/module/GraphCanvas/slices/update-link-cache.ts"],"sourcesContent":["import type { GraphCanvas } from \"../GraphCanvas\";\nimport { extractLinkPointIds, linkIterationExtractor, linkOptionsGetter } from \"../lib\";\n\nexport function updateLinkCache<\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 current = this.areaTransform.k;\n if (\n this.linkSettings.smartCache &&\n this._lastLinkZoomK !== undefined &&\n this.linkOptionsCache.length > 0\n ) {\n const corner = this.linkSettings.linkScaleSwitch;\n const prev = this._lastLinkZoomK;\n this._lastLinkZoomK = current;\n if (!((prev <= corner && current >= corner) || (prev >= corner && current <= corner))) {\n return;\n }\n for (let i = 0; i < this.links.length; i++) {\n const link = this.links[i];\n const linkOptions = linkIterationExtractor(\n link,\n i,\n this.links,\n this,\n this.linkSettings.options ?? {},\n linkOptionsGetter,\n );\n const cache = this.linkOptionsCache[i];\n if (cache) {\n cache.color = linkOptions.color;\n cache.arrowColor = linkOptions.arrowColor;\n cache.width = linkOptions.width;\n }\n }\n return;\n }\n\n this._lastLinkZoomK = current;\n this.linkOptionsCache.length = 0;\n\n const groupMap: Record<string, number> = {};\n const groupSelfMap: Record<string, number> = {};\n for (let i = 0; i < this.links.length; i++) {\n const link = this.links[i];\n const { sourceId, targetId } = extractLinkPointIds(link);\n\n const linkOptions = linkIterationExtractor(\n link,\n i,\n this.links,\n this,\n this.linkSettings.options ?? {},\n linkOptionsGetter,\n );\n this.linkOptionsCache[i] = linkOptions;\n\n if (this.linkSettings.curve) {\n const id = `${targetId}${sourceId}`;\n if (sourceId === targetId) {\n groupSelfMap[id] ??= 0;\n link._groupIndex = ++groupSelfMap[id];\n link._self = true;\n continue;\n }\n const reverseId = `${sourceId}${targetId}`;\n groupMap[reverseId] ??= 0;\n groupMap[reverseId]++;\n groupMap[id] ??= 0;\n link._groupIndex = indexToPosition(++groupMap[id]);\n link._self = false;\n }\n }\n if (this.linkSettings.curve) {\n for (const link of this.links) {\n const { sourceId, targetId } = extractLinkPointIds(link);\n const id = `${targetId}${sourceId}`;\n link._groupSize = link._self ? (groupSelfMap[id] ?? 1) : (groupMap[id] ?? 1);\n }\n }\n}\n\nfunction indexToPosition(n: number): number {\n if (n === 1) return 0;\n\n const index = n >> 1;\n return n & 1 ? -(index * 2) : index * 2;\n\n // return n & 1 ? -(n >> 1) : n >> 1;\n}\n"],"names":[],"mappings":";;;;;;;;;;;SAGgB,eAAe,GAAA;IAI7B,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE;AAEnB,IAAA,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;AACpC,IAAA,IACE,IAAI,CAAC,YAAY,CAAC,UAAU;QAC5B,IAAI,CAAC,cAAc,KAAK,SAAS;AACjC,QAAA,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAChC;AACA,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,eAAe;AAChD,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc;AAChC,QAAA,IAAI,CAAC,cAAc,GAAG,OAAO;QAC7B,IAAI,EAAE,CAAC,IAAI,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM,MAAM,IAAI,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM,CAAC,CAAC,EAAE;YACrF;;AAEF,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1B,MAAM,W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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,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1B,QAAA,IAAI,KAAK,KAAK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C,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,KAAK,EACN;AACA,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,cAAc;QACnD,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,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