@krainovsd/graph 0.12.0-beta.2 → 0.12.0-beta.4

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 (36) hide show
  1. package/lib/cjs/index.cjs +351 -247
  2. package/lib/cjs/index.cjs.map +1 -1
  3. package/lib/esm/constants/link-controls.js +0 -6
  4. package/lib/esm/constants/link-controls.js.map +1 -1
  5. package/lib/esm/constants/node-controls.js +71 -24
  6. package/lib/esm/constants/node-controls.js.map +1 -1
  7. package/lib/esm/lib/draw-time.js +2 -2
  8. package/lib/esm/lib/draw-time.js.map +1 -1
  9. package/lib/esm/module/GraphCanvas/GraphCanvas.js +29 -25
  10. package/lib/esm/module/GraphCanvas/GraphCanvas.js.map +1 -1
  11. package/lib/esm/module/GraphCanvas/constants/link-settings.js +0 -1
  12. package/lib/esm/module/GraphCanvas/constants/link-settings.js.map +1 -1
  13. package/lib/esm/module/GraphCanvas/constants/node-settings.js +10 -5
  14. package/lib/esm/module/GraphCanvas/constants/node-settings.js.map +1 -1
  15. package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js +20 -4
  16. package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js.map +1 -1
  17. package/lib/esm/module/GraphCanvas/slices/draw-links.js +7 -20
  18. package/lib/esm/module/GraphCanvas/slices/draw-links.js.map +1 -1
  19. package/lib/esm/module/GraphCanvas/slices/draw-nodes.js +25 -117
  20. package/lib/esm/module/GraphCanvas/slices/draw-nodes.js.map +1 -1
  21. package/lib/esm/module/GraphCanvas/slices/draw-text.js +1 -24
  22. package/lib/esm/module/GraphCanvas/slices/draw-text.js.map +1 -1
  23. package/lib/esm/module/GraphCanvas/slices/init-draw.js +25 -11
  24. package/lib/esm/module/GraphCanvas/slices/init-draw.js.map +1 -1
  25. package/lib/esm/module/GraphCanvas/slices/init-pointer.js +3 -3
  26. package/lib/esm/module/GraphCanvas/slices/init-pointer.js.map +1 -1
  27. package/lib/esm/module/GraphCanvas/slices/init-simulation.js +20 -8
  28. package/lib/esm/module/GraphCanvas/slices/init-simulation.js.map +1 -1
  29. package/lib/esm/module/GraphCanvas/slices/init-zoom.js +4 -2
  30. package/lib/esm/module/GraphCanvas/slices/init-zoom.js.map +1 -1
  31. package/lib/esm/module/GraphCanvas/slices/update-link-cache.js +19 -0
  32. package/lib/esm/module/GraphCanvas/slices/update-link-cache.js.map +1 -0
  33. package/lib/esm/module/GraphCanvas/slices/update-node-cache.js +136 -0
  34. package/lib/esm/module/GraphCanvas/slices/update-node-cache.js.map +1 -0
  35. package/lib/index.d.ts +32 -33
  36. package/package.json +8 -4
@@ -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\";\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 this.areaTransform = event.transform;\n this.linkOptionsCache = {};\n this.nodeOptionsCache = {};\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":";;;;AAMM,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,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,SAAS;AACpC,QAAA,IAAI,CAAC,gBAAgB,GAAG,EAAE;AAC1B,QAAA,IAAI,CAAC,gBAAgB,GAAG,EAAE;QAE1B,IAAI,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,gBAAgB;YACnD,qBAAqB,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5C,KAAC,CAAC;AAEJ,IAAA,IAAI,IAAI,CAAC,aAAa,CAAC,qBAAqB,EAAE;AAC5C,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,0BAA0B;QACjE,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC,WAAW;AACtD,cAAE;AACF,cAAE,CAAC,WAAW,EAAE,WAAW,CAAC;QAE9B,MAAM,CACJ,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,YAAY,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,EACvE,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,EACtE,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe;QAEtC,YAAY,CAAC,eAAe,CAAC;YAC3B,CAAC,IAAI,EAAE,IAAI,CAAC;YACZ,CAAC,IAAI,EAAE,IAAI,CAAC;AACb,SAAA,CAAC;;AAGJ,IAAAA,MAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,eAAe,EAAE,IAAI,CAAC;IAEhE,MAAM,WAAW,GAAG,WAAW,IAAI,IAAI,CAAC,aAAa,CAAC,WAAW;AACjE,IAAA,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CACpC,WAAW,EAAE,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 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 this.areaTransform = event.transform;\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 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,U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W,GAAG,WAAW,IAAI,IAAI,CAAC,aAAa,CAAC,WAAW;AACjE,IAAA,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CACpC,WAAW,EAAE,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;;;;"}
@@ -0,0 +1,19 @@
1
+ import { linkOptionsGetter } from '../lib/settings/link-settings-getter.js';
2
+ import '@krainovsd/js-helpers';
3
+ import { linkIterationExtractor } from '../lib/utils/link-iteration-extractor.js';
4
+ import 'd3-array';
5
+ import { extractLinkPointIds } from '../lib/utils/extract-link-point-ids.js';
6
+
7
+ function updateLinkCache() {
8
+ this.linkOptionsCache = {};
9
+ for (let i = 0; i < this.links.length; i++) {
10
+ const link = this.links[i];
11
+ const { sourceId, targetId } = extractLinkPointIds(link);
12
+ const linkOptions = linkIterationExtractor(link, i, this.links, this, this.linkSettings.options ?? {}, linkOptionsGetter);
13
+ const id = `${targetId}${sourceId}`;
14
+ this.linkOptionsCache[id] = linkOptions;
15
+ }
16
+ }
17
+
18
+ export { updateLinkCache };
19
+ //# sourceMappingURL=update-link-cache.js.map
@@ -0,0 +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 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}\n"],"names":[],"mappings":";;;;;;SAGgB,eAAe,GAAA;AAI7B,IAAA,IAAI,CAAC,gBAAgB,GAAG,EAAE;AAE1B,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,GAAG,CAAA,EAAG,QAAQ,CAAG,EAAA,QAAQ,EAAE;AACnC,QAAA,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,GAAG,WAAW;;AAE3C;;;;"}
@@ -0,0 +1,136 @@
1
+ import { nodeOptionsGetter, nodeRadiusGetter, nodeSizeGetter } from '../lib/settings/node-settings-getter.js';
2
+ import '@krainovsd/js-helpers';
3
+ import 'd3-array';
4
+ import { nodeIterationExtractor } from '../lib/utils/node-iteration-extractor.js';
5
+ import { getTextLines } from './draw-text.js';
6
+
7
+ function updateNodeCache() {
8
+ this.nodeOptionsCache = {};
9
+ if (!this.context)
10
+ return;
11
+ for (let i = 0; i < this.nodes.length; i++) {
12
+ const node = this.nodes[i];
13
+ const nodeOptions = nodeIterationExtractor(node, i, this.nodes, this, this.nodeSettings.options ?? {}, nodeOptionsGetter);
14
+ const radius = nodeOptions.shape === "circle"
15
+ ? nodeRadiusGetter({
16
+ radiusFlexible: this.nodeSettings.nodeRadiusFlexible,
17
+ radiusInitial: nodeOptions.radius,
18
+ radiusIncrementByStep: this.nodeSettings.nodeRadiusIncrementByStep,
19
+ radiusLinkCountForStep: this.nodeSettings.nodeRadiusLinkCountForStep,
20
+ radiusMaxLinearSteps: this.nodeSettings.nodeRadiusMaxLinearSteps,
21
+ radiusLogFactor: this.nodeSettings.nodeRadiusLogFactor,
22
+ radiusLinkCountDividerForLog: this.nodeSettings.nodeRadiusLinkCountDividerForLog,
23
+ linkCount: node.linkCount,
24
+ })
25
+ : nodeOptions.radius;
26
+ let width = nodeOptions.width;
27
+ let height = nodeOptions.height;
28
+ let labelSize = nodeOptions.labelSize;
29
+ if (nodeOptions.shape === "square") {
30
+ const size = nodeSizeGetter({
31
+ heightInitial: nodeOptions.height,
32
+ widthInitial: nodeOptions.width,
33
+ linkCount: node.linkCount,
34
+ sizeFlexible: this.nodeSettings.nodeSizeFlexible,
35
+ sizeIncrementByStep: this.nodeSettings.nodeSizeIncrementByStep,
36
+ sizeLinkCountForStep: this.nodeSettings.nodeSizeLinkCountForStep,
37
+ sizeMaxLinearSteps: this.nodeSettings.nodeSizeMaxLinearSteps,
38
+ sizeLogFactor: this.nodeSettings.nodeSizeLogFactor,
39
+ sizeLinkCountDividerForLog: this.nodeSettings.nodeSizeLinkCountDividerForLog,
40
+ });
41
+ width = size.width;
42
+ height = size.height;
43
+ }
44
+ if (nodeOptions.shape === "text") {
45
+ width = nodeOptions.width;
46
+ const size = nodeSizeGetter({
47
+ heightInitial: nodeOptions.height,
48
+ widthInitial: width,
49
+ linkCount: node.linkCount,
50
+ sizeFlexible: this.nodeSettings.nodeSizeFlexible,
51
+ sizeIncrementByStep: this.nodeSettings.nodeSizeIncrementByStep,
52
+ sizeLinkCountForStep: this.nodeSettings.nodeSizeLinkCountForStep,
53
+ sizeMaxLinearSteps: this.nodeSettings.nodeSizeMaxLinearSteps,
54
+ sizeLogFactor: this.nodeSettings.nodeSizeLogFactor,
55
+ sizeLinkCountDividerForLog: this.nodeSettings.nodeSizeLinkCountDividerForLog,
56
+ });
57
+ labelSize *= size.additionalSizeCoefficient;
58
+ }
59
+ /** label in not text shape */
60
+ if (nodeOptions.shape !== "text" && nodeOptions.label) {
61
+ this.context.font = `${nodeOptions.labelStyle} normal ${nodeOptions.labelWeight} ${nodeOptions.labelSize}px ${nodeOptions.labelFont}`;
62
+ this.context.fillStyle = nodeOptions.labelColor;
63
+ this.context.textAlign = nodeOptions.labelAlign;
64
+ if (nodeOptions.labelWidth == undefined ||
65
+ this.context.measureText(nodeOptions.label).width <= nodeOptions.labelWidth) {
66
+ this.cachedNodeLabel[node.id] = [nodeOptions.label];
67
+ }
68
+ const { lines } = getTextLines({
69
+ context: this.context,
70
+ maxWidth: nodeOptions.labelWidth,
71
+ text: nodeOptions.label,
72
+ textAlign: nodeOptions.labelAlign,
73
+ textColor: nodeOptions.labelColor,
74
+ textFont: nodeOptions.labelFont,
75
+ textSize: nodeOptions.labelSize,
76
+ textStyle: nodeOptions.labelStyle,
77
+ textWeight: nodeOptions.labelWeight,
78
+ });
79
+ this.cachedNodeLabel[node.id] = lines;
80
+ }
81
+ /** label in text shape */
82
+ if (nodeOptions.shape === "text" && nodeOptions.label) {
83
+ const textInfo = getTextLines({
84
+ context: this.context,
85
+ text: nodeOptions.label,
86
+ textAlign: nodeOptions.labelAlign,
87
+ textColor: nodeOptions.labelColor,
88
+ textFont: nodeOptions.labelFont,
89
+ textSize: labelSize,
90
+ maxWidth: nodeOptions.labelWidth,
91
+ textStyle: nodeOptions.labelStyle,
92
+ textWeight: nodeOptions.textWeight,
93
+ });
94
+ const textNodeParameters = [textInfo.currentMaxSize, labelSize];
95
+ const lines = textInfo.lines;
96
+ const textSizeCoefficient = labelSize / textNodeParameters[1];
97
+ const maxSize = textNodeParameters[0] * textSizeCoefficient;
98
+ height =
99
+ lines.length * labelSize +
100
+ (lines.length - 1) * nodeOptions.labelGap +
101
+ nodeOptions.labelYPadding;
102
+ width = maxSize + nodeOptions.labelXPadding;
103
+ this.cachedNodeLabel[node.id] = lines;
104
+ }
105
+ nodeOptions.width = width;
106
+ nodeOptions.height = height;
107
+ nodeOptions.radius = radius;
108
+ nodeOptions.labelSize = labelSize;
109
+ /** text */
110
+ if (nodeOptions.text) {
111
+ this.context.font = `${nodeOptions.textStyle} normal ${nodeOptions.textWeight} ${nodeOptions.textSize}px ${nodeOptions.textFont}`;
112
+ this.context.fillStyle = nodeOptions.textColor;
113
+ this.context.textAlign = nodeOptions.textAlign;
114
+ if (nodeOptions.textWidth == undefined ||
115
+ this.context.measureText(nodeOptions.text).width <= nodeOptions.textWidth) {
116
+ this.cachedNodeText[node.id] = [nodeOptions.text];
117
+ }
118
+ const { lines } = getTextLines({
119
+ context: this.context,
120
+ maxWidth: nodeOptions.textWidth,
121
+ text: nodeOptions.text,
122
+ textAlign: nodeOptions.textAlign,
123
+ textColor: nodeOptions.textColor,
124
+ textFont: nodeOptions.textFont,
125
+ textSize: nodeOptions.textSize,
126
+ textStyle: nodeOptions.textStyle,
127
+ textWeight: nodeOptions.textWeight,
128
+ });
129
+ this.cachedNodeText[node.id] = lines;
130
+ }
131
+ this.nodeOptionsCache[node.id] = nodeOptions;
132
+ }
133
+ }
134
+
135
+ export { updateNodeCache };
136
+ //# sourceMappingURL=update-node-cache.js.map
@@ -0,0 +1 @@
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 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 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 /** 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 }\n /** label in text shape */\n 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: labelSize,\n maxWidth: nodeOptions.labelWidth,\n textStyle: nodeOptions.labelStyle,\n textWeight: nodeOptions.textWeight,\n });\n const textNodeParameters = [textInfo.currentMaxSize, labelSize];\n const lines = textInfo.lines;\n const textSizeCoefficient = labelSize / textNodeParameters[1];\n const maxSize = textNodeParameters[0] * textSizeCoefficient;\n\n height =\n lines.length * labelSize +\n (lines.length - 1) * nodeOptions.labelGap +\n nodeOptions.labelYPadding;\n\n width = maxSize + nodeOptions.labelXPadding;\n this.cachedNodeLabel[node.id] = lines;\n }\n\n nodeOptions.width = width;\n nodeOptions.height = height;\n nodeOptions.radius = radius;\n nodeOptions.labelSize = labelSize;\n\n /** text */\n if (nodeOptions.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 this.nodeOptionsCache[node.id] = nodeOptions;\n }\n}\n"],"names":[],"mappings":";;;;;;SASgB,eAAe,GAAA;AAI7B,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;QAC1B,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,MAAM,GACV,WAAW,CAAC,KAAK,KAAK;cAClB,gBAAgB,CAAC;AACf,gBAAA,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB;gBACpD,aAAa,EAAE,WAAW,CAAC,MAAM;AACjC,gBAAA,qBAAqB,EAAE,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AAS,EAAE,WAAW,CAAC,SAAS;gBAChC,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,QAAQ,EAAE,WAAW,CAAC,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;;QAGtC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,WAAW;;AAEhD;;;;"}
package/lib/index.d.ts CHANGED
@@ -25,12 +25,6 @@ interface NodeInterface<NodeData extends Record<string, unknown>> extends Simula
25
25
  type NodeShape = "circle" | "square" | "text";
26
26
  type TextStyleEnum = "normal" | "italic" | "oblique";
27
27
  type CachedNodeTextInterface = Record<string | number, string[] | undefined>;
28
- type CachedTextNodeParametersMap = Record<string | number, [number, number] | undefined>;
29
- /**
30
- * 1. Initial max size of text
31
- * 2. Initial size of text
32
- */
33
- type CachedTextNodeParametersInterface = [number, number];
34
28
 
35
29
  interface LinkInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> extends SimulationLinkDatum<NodeInterface<NodeData>> {
36
30
  data?: LinkData;
@@ -177,7 +171,6 @@ type HighlightByLinkForArrowSettingsInterface = {
177
171
  };
178
172
 
179
173
  type LinkSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
180
- cacheOptions?: boolean;
181
174
  prettyDraw?: boolean;
182
175
  arrow?: boolean;
183
176
  arrowByHighlight?: boolean;
@@ -236,13 +229,18 @@ type ListenersInterface<NodeData extends Record<string, unknown>, LinkData exten
236
229
  };
237
230
 
238
231
  type NodeSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
239
- cacheOptions?: boolean;
240
232
  nodeRadiusFlexible?: boolean;
241
- nodeRadiusCoefficient?: number;
242
- nodeRadiusFactor?: number;
233
+ nodeRadiusLinkCountForStep?: number;
234
+ nodeRadiusIncrementByStep?: number;
235
+ nodeRadiusMaxLinearSteps?: number;
236
+ nodeRadiusLogFactor?: number;
237
+ nodeRadiusLinkCountDividerForLog?: number;
243
238
  nodeSizeFlexible?: boolean;
244
- nodeSizeCoefficient?: number;
245
- nodeSizeFactor?: number;
239
+ nodeSizeLinkCountForStep?: number;
240
+ nodeSizeIncrementByStep?: number;
241
+ nodeSizeMaxLinearSteps?: number;
242
+ nodeSizeLogFactor?: number;
243
+ nodeSizeLinkCountDividerForLog?: number;
246
244
  textNodeDebug?: boolean;
247
245
  textScaleMin?: number;
248
246
  textScaleMax?: number;
@@ -335,11 +333,10 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
335
333
  protected simulation: GraphCanvasSimulation<NodeData, LinkData> | undefined;
336
334
  protected areaTransform: ZoomTransform;
337
335
  protected areaRect: DOMRect | undefined;
338
- protected draw: (this: GraphCanvas<NodeData, LinkData>) => void;
336
+ protected draw: (this: GraphCanvas<NodeData, LinkData>, recursive?: boolean) => void;
339
337
  protected eventAbortController: AbortController;
340
338
  protected cachedNodeText: CachedNodeTextInterface;
341
339
  protected cachedNodeLabel: CachedNodeTextInterface;
342
- protected cachedTextNodeParameters: CachedTextNodeParametersMap;
343
340
  protected linkOptionsCache: Record<string, Required<LinkOptionsInterface<NodeData, LinkData>>>;
344
341
  protected nodeOptionsCache: Record<string, Required<NodeOptionsInterface<NodeData, LinkData>>>;
345
342
  protected isDragging: boolean;
@@ -348,16 +345,15 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
348
345
  protected highlightedNeighbors: Set<string | number> | null;
349
346
  protected highlightProgress: number;
350
347
  protected highlightWorking: boolean;
351
- protected highlightDrawing: boolean;
352
348
  protected get simulationWorking(): boolean;
353
349
  constructor({ links, nodes, root, forceSettings, linkSettings, listeners, nodeSettings, graphSettings, highlightSettings, }: GraphCanvasInterface<NodeData, LinkData>);
354
350
  get dpi(): number;
355
351
  getData(): Pick<GraphCanvasInterface<NodeData, LinkData>, "nodes" | "links">;
356
- changeData(options: Pick<Partial<GraphCanvasInterface<NodeData, LinkData>>, "links" | "nodes">, alpha?: number): void;
357
- changeSettings(options: Omit<Partial<GraphCanvasInterface<NodeData, LinkData>>, "links" | "nodes" | "listeners">): undefined;
352
+ changeData(options: Pick<Partial<GraphCanvasInterface<NodeData, LinkData>>, "links" | "nodes">, alpha?: number, clearCache?: boolean): void;
353
+ changeSettings(options: Omit<Partial<GraphCanvasInterface<NodeData, LinkData>>, "links" | "nodes" | "listeners">, clearCache?: boolean): undefined;
358
354
  updateRect(): void;
359
355
  updateSize(): void;
360
- clearCache(keys?: ("nodeOptionsCache" | "linkOptionsCache" | "cachedNodeText" | "cachedNodeLabel" | "cachedTextNodeParameters")[]): void;
356
+ clearCache(keys?: ("nodeOptionsCache" | "linkOptionsCache")[]): void;
361
357
  tick(): void;
362
358
  restart(alpha?: number): void;
363
359
  start(): void;
@@ -367,7 +363,7 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
367
363
  protected clearHTMLElements(): void;
368
364
  protected updateSimulation(): void;
369
365
  protected clearState(): void;
370
- protected updateData(alpha?: number): void;
366
+ protected updateData(alpha?: number, clearCache?: boolean): void;
371
367
  protected init(): void;
372
368
  }
373
369
 
@@ -389,20 +385,26 @@ declare function nodeTextSizeGetter<NodeData extends Record<string, unknown>, Li
389
385
  type NodeRadiusGetterOptions = {
390
386
  linkCount: number | undefined;
391
387
  radiusFlexible: boolean;
392
- radiusCoefficient: number;
393
- radiusFactor: number;
394
388
  radiusInitial: number;
389
+ radiusLinkCountForStep: number;
390
+ radiusIncrementByStep: number;
391
+ radiusMaxLinearSteps: number;
392
+ radiusLogFactor: number;
393
+ radiusLinkCountDividerForLog: number;
395
394
  };
396
- declare function nodeRadiusGetter({ radiusFlexible, radiusInitial, linkCount, radiusCoefficient, radiusFactor, }: NodeRadiusGetterOptions): number;
395
+ declare function nodeRadiusGetter({ radiusFlexible, linkCount, radiusInitial, radiusIncrementByStep, radiusLinkCountDividerForLog, radiusLinkCountForStep, radiusLogFactor, radiusMaxLinearSteps, }: NodeRadiusGetterOptions): number;
397
396
  type NodeSizeGetterOptions = {
398
397
  linkCount: number | undefined;
399
398
  sizeFlexible: boolean;
400
- sizeCoefficient: number;
401
- sizeFactor: number;
402
399
  widthInitial: number;
403
400
  heightInitial: number;
401
+ sizeLinkCountForStep: number;
402
+ sizeIncrementByStep: number;
403
+ sizeMaxLinearSteps: number;
404
+ sizeLogFactor: number;
405
+ sizeLinkCountDividerForLog: number;
404
406
  };
405
- declare function nodeSizeGetter({ heightInitial, linkCount, sizeCoefficient, sizeFactor, sizeFlexible, widthInitial, }: NodeSizeGetterOptions): {
407
+ declare function nodeSizeGetter({ heightInitial, linkCount, sizeFlexible, widthInitial, sizeIncrementByStep, sizeLinkCountDividerForLog, sizeLinkCountForStep, sizeLogFactor, sizeMaxLinearSteps, }: NodeSizeGetterOptions): {
406
408
  width: number;
407
409
  height: number;
408
410
  additionalSizeCoefficient: number;
@@ -554,15 +556,14 @@ declare function extractLinkPointIds<NodeData extends Record<string, unknown>, L
554
556
  targetId: string | number;
555
557
  };
556
558
 
557
- declare function getDrawLink<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(): (this: GraphCanvas<NodeData, LinkData>, link: LinkInterface<NodeData, LinkData>, index: number) => void;
559
+ declare function getDrawLink<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(): (this: GraphCanvas<NodeData, LinkData>, link: LinkInterface<NodeData, LinkData>) => void;
558
560
 
559
- 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;
561
+ 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;
560
562
 
561
563
  type DrawTextOptions = {
562
- id: string | number;
564
+ lines: string[];
563
565
  x: number;
564
566
  y: number;
565
- text: string;
566
567
  textSize: number;
567
568
  textStyle: TextStyleEnum;
568
569
  textWeight: number;
@@ -571,10 +572,8 @@ type DrawTextOptions = {
571
572
  textGap: number;
572
573
  textAlign: CanvasTextAlign;
573
574
  context: CanvasRenderingContext2D;
574
- cachedNodeText: CachedNodeTextInterface;
575
- maxWidth?: number;
576
575
  };
577
- declare function drawText({ context, id, textAlign, textColor, textFont, textStyle, textGap, textWeight, textSize, text, x, y, cachedNodeText, maxWidth, }: DrawTextOptions): void;
576
+ declare function drawText({ context, textAlign, textColor, textFont, textStyle, textGap, textWeight, textSize, x, y, lines, }: DrawTextOptions): void;
578
577
 
579
578
  declare const COMMON_SETTINGS: {
580
579
  nodeRadius: number;
@@ -675,4 +674,4 @@ declare const NODE_OPTIONS_TEXT_CONTROLS: GraphSettingsInputInterface<keyof Node
675
674
  declare const NODE_OPTIONS_LABEL_CONTROLS: GraphSettingsInputInterface<keyof NodeOptionsLabelInterface>[];
676
675
 
677
676
  export { COMMON_SETTINGS, FORCE_CONTROLS, FORCE_SETTINGS, 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 };
678
- export type { CachedNodeTextInterface, CachedTextNodeParametersInterface, CachedTextNodeParametersMap, DragEventInterface, ForceSettingsInterface, 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 };
677
+ export type { CachedNodeTextInterface, DragEventInterface, ForceSettingsInterface, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krainovsd/graph",
3
- "version": "0.12.0-beta.2",
3
+ "version": "0.12.0-beta.4",
4
4
  "description": "Krainov graph",
5
5
  "type": "module",
6
6
  "author": "KrainovSD <denislosev48@gmail.com>",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "scripts": {
30
30
  "publish-package": "npm run lint && npm run build && npm publish",
31
- "dev": "vite --host",
31
+ "dev": "vite --host --force",
32
32
  "clear": "rm -rf ./lib",
33
33
  "build-dev": "vite build",
34
34
  "build": "npm run clear && npm run build:types && npm run build:js",
@@ -56,8 +56,12 @@
56
56
  "@types/d3-array": "3.2.1",
57
57
  "vite": "6.2.1",
58
58
  "@types/lodash": "4.17.14",
59
- "@sveltejs/vite-plugin-svelte": "5.0.3",
60
- "svelte": "5.23.2"
59
+ "vue-tsc": "3.1.0",
60
+ "vue": "3.5.14",
61
+ "@vitejs/plugin-vue": "5.2.4",
62
+ "@krainovsd/vue-ui": "0.4.0-beta.23",
63
+ "@krainovsd/vue-icons": "0.1.4",
64
+ "sass-embedded": "1.81.0"
61
65
  },
62
66
  "dependencies": {
63
67
  "@krainovsd/js-helpers": "^0.16.5",