@react-fabric/graph 1.0.0-beta.63 → 1.0.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 (224) hide show
  1. package/dist/cjs/context/context.js +16 -0
  2. package/dist/cjs/graph/index.js +58 -381
  3. package/dist/cjs/index.js +25 -21
  4. package/dist/cjs/utils/edge.js +76 -0
  5. package/dist/cjs/utils/node.js +93 -0
  6. package/dist/cjs/utils/sdfFolder.js +107 -0
  7. package/dist/cjs/viewer/Graph.js +174 -0
  8. package/dist/esm/context/context.js +15 -0
  9. package/dist/esm/graph/index.js +59 -382
  10. package/dist/esm/index.js +24 -20
  11. package/dist/esm/utils/edge.js +75 -0
  12. package/dist/esm/utils/node.js +92 -0
  13. package/dist/esm/utils/sdfFolder.js +107 -0
  14. package/dist/esm/viewer/Graph.js +174 -0
  15. package/dist/types/context/context.d.ts +35 -0
  16. package/dist/types/graph/index.d.ts +47 -24
  17. package/dist/types/index.d.ts +28 -2
  18. package/dist/types/types/index.d.ts +124 -175
  19. package/dist/types/utils/edge.d.ts +28 -0
  20. package/dist/types/utils/node.d.ts +28 -0
  21. package/dist/types/utils/sdfFolder.d.ts +75 -0
  22. package/dist/types/viewer/Graph.d.ts +31 -0
  23. package/package.json +19 -25
  24. package/src/context/context.tsx +43 -0
  25. package/src/graph/index.ts +76 -399
  26. package/src/index.ts +24 -26
  27. package/src/types/index.ts +139 -185
  28. package/src/utils/edge.ts +65 -0
  29. package/src/utils/node.ts +105 -0
  30. package/src/utils/sdfFolder.ts +141 -0
  31. package/src/viewer/Graph.tsx +159 -0
  32. package/css/styles.css +0 -56
  33. package/dist/cjs/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -14
  34. package/dist/cjs/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -9
  35. package/dist/cjs/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +0 -35
  36. package/dist/cjs/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
  37. package/dist/cjs/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -20
  38. package/dist/cjs/_virtual/elk-worker.js +0 -8
  39. package/dist/cjs/components/ContextMenu.js +0 -133
  40. package/dist/cjs/components/Provider.js +0 -103
  41. package/dist/cjs/components/Tools.js +0 -205
  42. package/dist/cjs/components/Viewer.js +0 -59
  43. package/dist/cjs/components/context.js +0 -34
  44. package/dist/cjs/constants/index.js +0 -16
  45. package/dist/cjs/hooks/sigmaDragSelect.js +0 -169
  46. package/dist/cjs/hooks/sigmaHilighter.js +0 -83
  47. package/dist/cjs/hooks/sigmaMouseActions.js +0 -145
  48. package/dist/cjs/hooks/useGraphology.js +0 -41
  49. package/dist/cjs/hooks/useSigma.js +0 -112
  50. package/dist/cjs/programs/arrow-head/frag.glsl.js +0 -8
  51. package/dist/cjs/programs/arrow-head/index.js +0 -142
  52. package/dist/cjs/programs/arrow-head/vert.glsl.js +0 -8
  53. package/dist/cjs/programs/edge-curve/drawLabel.js +0 -136
  54. package/dist/cjs/programs/edge-curve/frag.glsl.js +0 -8
  55. package/dist/cjs/programs/edge-curve/index.js +0 -157
  56. package/dist/cjs/programs/edge-curve/vert.glsl.js +0 -8
  57. package/dist/cjs/programs/edge-line/drawLabel.js +0 -70
  58. package/dist/cjs/programs/edge-line/frag.glsl.js +0 -8
  59. package/dist/cjs/programs/edge-line/index.js +0 -166
  60. package/dist/cjs/programs/edge-line/vert.glsl.js +0 -8
  61. package/dist/cjs/programs/node-badge/factory.js +0 -250
  62. package/dist/cjs/programs/node-badge/frag.glsl.js +0 -8
  63. package/dist/cjs/programs/node-badge/index.js +0 -33
  64. package/dist/cjs/programs/node-badge/texture.js +0 -455
  65. package/dist/cjs/programs/node-badge/vert.glsl.js +0 -19
  66. package/dist/cjs/programs/node-circle/base/drawHover.js +0 -71
  67. package/dist/cjs/programs/node-circle/base/drawLabel.js +0 -113
  68. package/dist/cjs/programs/node-circle/base/frag.glsl.js +0 -8
  69. package/dist/cjs/programs/node-circle/base/index.js +0 -136
  70. package/dist/cjs/programs/node-circle/base/vert.glsl.js +0 -8
  71. package/dist/cjs/programs/node-circle/index.js +0 -15
  72. package/dist/cjs/programs/node-image/factory.js +0 -224
  73. package/dist/cjs/programs/node-image/frag.glsl.js +0 -8
  74. package/dist/cjs/programs/node-image/index.js +0 -14
  75. package/dist/cjs/programs/node-image/texture.js +0 -472
  76. package/dist/cjs/programs/node-image/vert.glsl.js +0 -8
  77. package/dist/cjs/programs/node-rect/base/drawHover.js +0 -68
  78. package/dist/cjs/programs/node-rect/base/drawLabel.js +0 -107
  79. package/dist/cjs/programs/node-rect/base/frag.glsl.js +0 -8
  80. package/dist/cjs/programs/node-rect/base/index.js +0 -135
  81. package/dist/cjs/programs/node-rect/base/vert.glsl.js +0 -8
  82. package/dist/cjs/programs/node-rect/index.js +0 -15
  83. package/dist/esm/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -14
  84. package/dist/esm/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -9
  85. package/dist/esm/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +0 -34
  86. package/dist/esm/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -13
  87. package/dist/esm/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -20
  88. package/dist/esm/_virtual/elk-worker.js +0 -8
  89. package/dist/esm/components/ContextMenu.js +0 -133
  90. package/dist/esm/components/Provider.js +0 -103
  91. package/dist/esm/components/Tools.js +0 -205
  92. package/dist/esm/components/Viewer.js +0 -59
  93. package/dist/esm/components/context.js +0 -33
  94. package/dist/esm/constants/index.js +0 -16
  95. package/dist/esm/hooks/sigmaDragSelect.js +0 -169
  96. package/dist/esm/hooks/sigmaHilighter.js +0 -83
  97. package/dist/esm/hooks/sigmaMouseActions.js +0 -145
  98. package/dist/esm/hooks/useGraphology.js +0 -41
  99. package/dist/esm/hooks/useSigma.js +0 -112
  100. package/dist/esm/programs/arrow-head/frag.glsl.js +0 -8
  101. package/dist/esm/programs/arrow-head/index.js +0 -141
  102. package/dist/esm/programs/arrow-head/vert.glsl.js +0 -8
  103. package/dist/esm/programs/edge-curve/drawLabel.js +0 -136
  104. package/dist/esm/programs/edge-curve/frag.glsl.js +0 -8
  105. package/dist/esm/programs/edge-curve/index.js +0 -156
  106. package/dist/esm/programs/edge-curve/vert.glsl.js +0 -8
  107. package/dist/esm/programs/edge-line/drawLabel.js +0 -70
  108. package/dist/esm/programs/edge-line/frag.glsl.js +0 -8
  109. package/dist/esm/programs/edge-line/index.js +0 -166
  110. package/dist/esm/programs/edge-line/vert.glsl.js +0 -8
  111. package/dist/esm/programs/node-badge/factory.js +0 -250
  112. package/dist/esm/programs/node-badge/frag.glsl.js +0 -8
  113. package/dist/esm/programs/node-badge/index.js +0 -32
  114. package/dist/esm/programs/node-badge/texture.js +0 -445
  115. package/dist/esm/programs/node-badge/vert.glsl.js +0 -19
  116. package/dist/esm/programs/node-circle/base/drawHover.js +0 -71
  117. package/dist/esm/programs/node-circle/base/drawLabel.js +0 -113
  118. package/dist/esm/programs/node-circle/base/frag.glsl.js +0 -8
  119. package/dist/esm/programs/node-circle/base/index.js +0 -136
  120. package/dist/esm/programs/node-circle/base/vert.glsl.js +0 -8
  121. package/dist/esm/programs/node-circle/index.js +0 -15
  122. package/dist/esm/programs/node-image/factory.js +0 -224
  123. package/dist/esm/programs/node-image/frag.glsl.js +0 -8
  124. package/dist/esm/programs/node-image/index.js +0 -13
  125. package/dist/esm/programs/node-image/texture.js +0 -462
  126. package/dist/esm/programs/node-image/vert.glsl.js +0 -8
  127. package/dist/esm/programs/node-rect/base/drawHover.js +0 -68
  128. package/dist/esm/programs/node-rect/base/drawLabel.js +0 -107
  129. package/dist/esm/programs/node-rect/base/frag.glsl.js +0 -8
  130. package/dist/esm/programs/node-rect/base/index.js +0 -135
  131. package/dist/esm/programs/node-rect/base/vert.glsl.js +0 -8
  132. package/dist/esm/programs/node-rect/index.js +0 -15
  133. package/dist/types/components/ContextMenu.d.ts +0 -1
  134. package/dist/types/components/Provider.d.ts +0 -3
  135. package/dist/types/components/Tools.d.ts +0 -1
  136. package/dist/types/components/Viewer.d.ts +0 -2
  137. package/dist/types/components/context.d.ts +0 -17
  138. package/dist/types/constants/index.d.ts +0 -12
  139. package/dist/types/graph/layout.worker.d.ts +0 -1
  140. package/dist/types/hooks/sigmaDragSelect.d.ts +0 -8
  141. package/dist/types/hooks/sigmaHilighter.d.ts +0 -3
  142. package/dist/types/hooks/sigmaMouseActions.d.ts +0 -3
  143. package/dist/types/hooks/useGraphology.d.ts +0 -6
  144. package/dist/types/hooks/useSigma.d.ts +0 -8
  145. package/dist/types/i18n/index.d.ts +0 -0
  146. package/dist/types/programs/arrow-head/frag.glsl.d.ts +0 -2
  147. package/dist/types/programs/arrow-head/index.d.ts +0 -9
  148. package/dist/types/programs/arrow-head/vert.glsl.d.ts +0 -2
  149. package/dist/types/programs/edge-curve/drawLabel.d.ts +0 -6
  150. package/dist/types/programs/edge-curve/frag.glsl.d.ts +0 -2
  151. package/dist/types/programs/edge-curve/index.d.ts +0 -43
  152. package/dist/types/programs/edge-curve/vert.glsl.d.ts +0 -2
  153. package/dist/types/programs/edge-line/drawLabel.d.ts +0 -5
  154. package/dist/types/programs/edge-line/frag.glsl.d.ts +0 -2
  155. package/dist/types/programs/edge-line/index.d.ts +0 -11
  156. package/dist/types/programs/edge-line/vert.glsl.d.ts +0 -2
  157. package/dist/types/programs/node-badge/factory.d.ts +0 -27
  158. package/dist/types/programs/node-badge/frag.glsl.d.ts +0 -2
  159. package/dist/types/programs/node-badge/index.d.ts +0 -5
  160. package/dist/types/programs/node-badge/texture.d.ts +0 -102
  161. package/dist/types/programs/node-badge/vert.glsl.d.ts +0 -2
  162. package/dist/types/programs/node-circle/base/drawHover.d.ts +0 -8
  163. package/dist/types/programs/node-circle/base/drawLabel.d.ts +0 -8
  164. package/dist/types/programs/node-circle/base/frag.glsl.d.ts +0 -2
  165. package/dist/types/programs/node-circle/base/index.d.ts +0 -37
  166. package/dist/types/programs/node-circle/base/vert.glsl.d.ts +0 -2
  167. package/dist/types/programs/node-circle/index.d.ts +0 -11
  168. package/dist/types/programs/node-image/factory.d.ts +0 -25
  169. package/dist/types/programs/node-image/frag.glsl.d.ts +0 -2
  170. package/dist/types/programs/node-image/index.d.ts +0 -5
  171. package/dist/types/programs/node-image/texture.d.ts +0 -102
  172. package/dist/types/programs/node-image/vert.glsl.d.ts +0 -2
  173. package/dist/types/programs/node-rect/base/drawHover.d.ts +0 -8
  174. package/dist/types/programs/node-rect/base/drawLabel.d.ts +0 -8
  175. package/dist/types/programs/node-rect/base/frag.glsl.d.ts +0 -2
  176. package/dist/types/programs/node-rect/base/index.d.ts +0 -34
  177. package/dist/types/programs/node-rect/base/vert.glsl.d.ts +0 -2
  178. package/dist/types/programs/node-rect/index.d.ts +0 -11
  179. package/src/components/ContextMenu.tsx +0 -138
  180. package/src/components/Provider.tsx +0 -116
  181. package/src/components/Tools.tsx +0 -68
  182. package/src/components/Viewer.tsx +0 -75
  183. package/src/components/context.ts +0 -43
  184. package/src/constants/index.ts +0 -22
  185. package/src/graph/layout.worker.ts +0 -42
  186. package/src/hooks/sigmaDragSelect.ts +0 -219
  187. package/src/hooks/sigmaHilighter.ts +0 -107
  188. package/src/hooks/sigmaMouseActions.ts +0 -153
  189. package/src/hooks/useGraphology.ts +0 -31
  190. package/src/hooks/useSigma.ts +0 -118
  191. package/src/i18n/index.ts +0 -0
  192. package/src/programs/arrow-head/frag.glsl.ts +0 -18
  193. package/src/programs/arrow-head/index.ts +0 -156
  194. package/src/programs/arrow-head/vert.glsl.ts +0 -75
  195. package/src/programs/edge-curve/drawLabel.ts +0 -166
  196. package/src/programs/edge-curve/frag.glsl.ts +0 -86
  197. package/src/programs/edge-curve/index.ts +0 -156
  198. package/src/programs/edge-curve/vert.glsl.ts +0 -110
  199. package/src/programs/edge-line/drawLabel.ts +0 -113
  200. package/src/programs/edge-line/frag.glsl.ts +0 -34
  201. package/src/programs/edge-line/index.ts +0 -163
  202. package/src/programs/edge-line/vert.glsl.ts +0 -104
  203. package/src/programs/node-badge/factory.ts +0 -325
  204. package/src/programs/node-badge/frag.glsl.ts +0 -79
  205. package/src/programs/node-badge/index.ts +0 -35
  206. package/src/programs/node-badge/texture.ts +0 -425
  207. package/src/programs/node-badge/vert.glsl.ts +0 -99
  208. package/src/programs/node-circle/base/drawHover.ts +0 -80
  209. package/src/programs/node-circle/base/drawLabel.ts +0 -145
  210. package/src/programs/node-circle/base/frag.glsl.ts +0 -72
  211. package/src/programs/node-circle/base/index.ts +0 -100
  212. package/src/programs/node-circle/base/vert.glsl.ts +0 -83
  213. package/src/programs/node-circle/index.ts +0 -19
  214. package/src/programs/node-image/factory.ts +0 -299
  215. package/src/programs/node-image/frag.glsl.ts +0 -97
  216. package/src/programs/node-image/index.ts +0 -7
  217. package/src/programs/node-image/texture.ts +0 -435
  218. package/src/programs/node-image/vert.glsl.ts +0 -60
  219. package/src/programs/node-rect/base/drawHover.ts +0 -77
  220. package/src/programs/node-rect/base/drawLabel.ts +0 -149
  221. package/src/programs/node-rect/base/frag.glsl.ts +0 -67
  222. package/src/programs/node-rect/base/index.ts +0 -107
  223. package/src/programs/node-rect/base/vert.glsl.ts +0 -87
  224. package/src/programs/node-rect/index.ts +0 -19
@@ -1,135 +0,0 @@
1
- 'use client';
2
-
3
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
- import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
5
- import _createClass from '@babel/runtime/helpers/createClass';
6
- import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
7
- import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
8
- import _inherits from '@babel/runtime/helpers/inherits';
9
- import { NodeProgram } from 'sigma/rendering';
10
- import { floatColor } from 'sigma/utils';
11
- import SHADER_SOURCE$1 from './frag.glsl.js';
12
- import SHADER_SOURCE from './vert.glsl.js';
13
-
14
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
15
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
16
-
17
- /* istanbul ignore file */
18
-
19
- var _WebGLRenderingContex = WebGLRenderingContext,
20
- UNSIGNED_BYTE = _WebGLRenderingContex.UNSIGNED_BYTE,
21
- FLOAT = _WebGLRenderingContex.FLOAT;
22
- var UNIFORMS = ["u_sizeRatio", "u_correctionRatio", "u_cameraAngle", "u_matrix"];
23
- var PI = Math.PI;
24
- var NodeRectBase = /*#__PURE__*/function (_NodeProgram) {
25
- function NodeRectBase() {
26
- _classCallCheck(this, NodeRectBase);
27
- return _callSuper(this, NodeRectBase, arguments);
28
- }
29
- _inherits(NodeRectBase, _NodeProgram);
30
- return _createClass(NodeRectBase, [{
31
- key: "getDefinition",
32
- value: function getDefinition() {
33
- return {
34
- VERTICES: 6,
35
- VERTEX_SHADER_SOURCE: SHADER_SOURCE,
36
- FRAGMENT_SHADER_SOURCE: SHADER_SOURCE$1,
37
- METHOD: WebGLRenderingContext.TRIANGLES,
38
- UNIFORMS: UNIFORMS,
39
- ATTRIBUTES: [{
40
- name: "a_position",
41
- size: 2,
42
- type: FLOAT
43
- }, {
44
- name: "a_size",
45
- size: 1,
46
- type: FLOAT
47
- }, {
48
- name: "a_border",
49
- size: 1,
50
- type: FLOAT
51
- }, {
52
- name: "a_opacity",
53
- size: 1,
54
- type: FLOAT
55
- }, {
56
- name: "a_base",
57
- size: 4,
58
- type: UNSIGNED_BYTE,
59
- normalized: true
60
- }, {
61
- name: "a_color",
62
- size: 4,
63
- type: UNSIGNED_BYTE,
64
- normalized: true
65
- }, {
66
- name: "a_stroke",
67
- size: 4,
68
- type: UNSIGNED_BYTE,
69
- normalized: true
70
- }, {
71
- name: "a_segments",
72
- size: 1,
73
- type: FLOAT
74
- }].concat(_toConsumableArray(Array(7).fill(0).map(function (_, idx) {
75
- return {
76
- name: "a_colors_" + idx,
77
- size: 4,
78
- type: UNSIGNED_BYTE,
79
- normalized: true
80
- };
81
- })), [{
82
- name: "a_id",
83
- size: 4,
84
- type: UNSIGNED_BYTE,
85
- normalized: true
86
- }]),
87
- CONSTANT_ATTRIBUTES: [{
88
- name: "a_angle",
89
- size: 1,
90
- type: FLOAT
91
- }],
92
- CONSTANT_DATA: [[PI / 4], [3 * PI / 4], [-PI / 4], [3 * PI / 4], [-PI / 4], [-3 * PI / 4]]
93
- };
94
- }
95
- }, {
96
- key: "processVisibleItem",
97
- value: function processVisibleItem(nodeIndex, startIndex, data) {
98
- var _data$color, _data$borderColor, _data$border, _data$opacity, _data$pie$length, _data$pie;
99
- var array = this.array;
100
- var base = floatColor(this.renderer.getSetting("defaultNodeColor"));
101
- var color = floatColor((_data$color = data.color) !== null && _data$color !== void 0 ? _data$color : this.renderer.getSetting("defaultNodeColor"));
102
- var stroke = floatColor((_data$borderColor = data.borderColor) !== null && _data$borderColor !== void 0 ? _data$borderColor : this.renderer.getSetting("defaultEdgeColor"));
103
- array[startIndex++] = data.x;
104
- array[startIndex++] = data.y;
105
- array[startIndex++] = data.size;
106
- array[startIndex++] = Math.min((_data$border = data.border) !== null && _data$border !== void 0 ? _data$border : 0, 4);
107
- array[startIndex++] = (_data$opacity = data.opacity) !== null && _data$opacity !== void 0 ? _data$opacity : 1;
108
- array[startIndex++] = base;
109
- array[startIndex++] = color;
110
- array[startIndex++] = stroke;
111
- array[startIndex++] = Math.min(7, (_data$pie$length = (_data$pie = data.pie) === null || _data$pie === void 0 ? void 0 : _data$pie.length) !== null && _data$pie$length !== void 0 ? _data$pie$length : 0);
112
- Array(7).fill(0).forEach(function (_, idx) {
113
- var _data$pie$idx, _data$pie2;
114
- array[startIndex++] = floatColor((_data$pie$idx = (_data$pie2 = data.pie) === null || _data$pie2 === void 0 ? void 0 : _data$pie2[idx]) !== null && _data$pie$idx !== void 0 ? _data$pie$idx : "#0000");
115
- });
116
- array[startIndex++] = nodeIndex;
117
- }
118
- }, {
119
- key: "setUniforms",
120
- value: function setUniforms(params, _ref) {
121
- var gl = _ref.gl,
122
- uniformLocations = _ref.uniformLocations;
123
- var u_sizeRatio = uniformLocations.u_sizeRatio,
124
- u_correctionRatio = uniformLocations.u_correctionRatio,
125
- u_cameraAngle = uniformLocations.u_cameraAngle,
126
- u_matrix = uniformLocations.u_matrix;
127
- gl.uniform1f(u_sizeRatio, params.sizeRatio);
128
- gl.uniform1f(u_cameraAngle, params.cameraAngle);
129
- gl.uniform1f(u_correctionRatio, params.correctionRatio);
130
- gl.uniformMatrix3fv(u_matrix, false, params.matrix);
131
- }
132
- }]);
133
- }(NodeProgram);
134
-
135
- export { NodeRectBase };
@@ -1,8 +0,0 @@
1
- 'use client';
2
-
3
- /* istanbul ignore file */
4
-
5
- // language=GLSL
6
- var SHADER_SOURCE = /* glsl */"\nattribute vec4 a_id;\nattribute vec4 a_base;\nattribute vec4 a_color;\nattribute vec4 a_stroke;\nattribute vec2 a_position;\nattribute float a_size;\nattribute float a_border;\nattribute float a_angle;\nattribute float a_opacity;\nattribute float a_segments;\nattribute vec4 a_colors_0;\nattribute vec4 a_colors_1;\nattribute vec4 a_colors_2;\nattribute vec4 a_colors_3;\nattribute vec4 a_colors_4;\nattribute vec4 a_colors_5;\nattribute vec4 a_colors_6;\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_cameraAngle;\nuniform float u_correctionRatio;\n\nvarying vec4 v_color;\nvarying vec4 v_stroke;\nvarying float v_border;\nvarying vec2 v_diffVector;\nvarying float v_segmentAngle;\nvarying vec4 v_colors_0;\nvarying vec4 v_colors_1;\nvarying vec4 v_colors_2;\nvarying vec4 v_colors_3;\nvarying vec4 v_colors_4;\nvarying vec4 v_colors_5;\nvarying vec4 v_colors_6;\n\nconst float bias = 255.0 / 254.0;\nconst float sqrt_8 = sqrt(8.0);\n\nvoid main() {\n float angle = a_angle + u_cameraAngle; \n\n float size = a_size * u_correctionRatio / u_sizeRatio * sqrt_8;\n vec2 diffVector = size * vec2(cos(angle), sin(angle));\n vec2 position = a_position + diffVector;\n\n float borderLessSize = (a_size - a_border) * u_correctionRatio / u_sizeRatio * sqrt_8;\n\n gl_Position = vec4(\n (u_matrix * vec3(position, 1)).xy,\n 0,\n 1\n );\n\n v_diffVector = diffVector;\n v_border = a_border * u_correctionRatio / u_sizeRatio * sqrt_8;\n v_border = borderLessSize / ".concat(Math.PI / 2.2, ";\n\n #ifdef PICKING_MODE\n v_color = a_id;\n #else\n v_color = mix(a_base, a_color, a_opacity * bias);\n v_stroke = mix(a_base, a_stroke, a_opacity * bias);\n\n // pie colors\n v_segmentAngle = 0.0;\n if(a_segments > 0.0) {\n v_segmentAngle = ").concat(Math.PI * 2, " / a_segments;\n v_colors_0 = mix(a_base, a_colors_0, a_opacity * bias);\n v_colors_1 = mix(a_base, a_colors_1, a_opacity * bias);\n v_colors_2 = mix(a_base, a_colors_2, a_opacity * bias);\n v_colors_3 = mix(a_base, a_colors_3, a_opacity * bias);\n v_colors_4 = mix(a_base, a_colors_4, a_opacity * bias);\n v_colors_5 = mix(a_base, a_colors_5, a_opacity * bias);\n v_colors_6 = mix(a_base, a_colors_6, a_opacity * bias);\n }\n #endif\n\n v_color.a *= bias;\n}\n");
7
-
8
- export { SHADER_SOURCE as default };
@@ -1,15 +0,0 @@
1
- 'use client';
2
-
3
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
- import { createNodeCompoundProgram } from 'sigma/rendering';
5
- import { NodeBadgeProgram } from '../node-badge/index.js';
6
- import { NodeImageProgram } from '../node-image/index.js';
7
- import { NodeRectBase } from './base/index.js';
8
- import { drawNodeHover } from './base/drawHover.js';
9
- import { drawNodeLabel } from './base/drawLabel.js';
10
-
11
- /* istanbul ignore file */
12
-
13
- var NodeRectProgram = createNodeCompoundProgram([NodeRectBase, NodeImageProgram(false)].concat(_toConsumableArray(NodeBadgeProgram(false))), drawNodeLabel, drawNodeHover);
14
-
15
- export { NodeRectProgram };
@@ -1 +0,0 @@
1
- export declare const GraphContextMenu: () => false | import("react/jsx-runtime").JSX.Element;
@@ -1,3 +0,0 @@
1
- import { type PropsWithChildren } from "react";
2
- import { type GraphProps } from "../types";
3
- export declare const GraphProvider: <N = KeyValue, E = KeyValue>({ ref, data, children, nodeReducer, edgeReducer, onSelectChange, onNodeDoubleClick, onContextMenu, }: PropsWithChildren<GraphProps<N, E>>) => import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const Tools: () => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +0,0 @@
1
- import { type GraphProps } from "../types";
2
- export declare const SigmaGraph: <N = KeyValue, E = KeyValue>(props: GraphProps<N, E>) => import("react/jsx-runtime").JSX.Element;
@@ -1,17 +0,0 @@
1
- import { Graph } from "../graph";
2
- import { useDragSelection } from "../hooks/sigmaDragSelect";
3
- import { useSigma } from "../hooks/useSigma";
4
- import { EdgeAttributes, NodeAttributes } from "../types";
5
- interface Context<N = KeyValue, E = KeyValue> {
6
- sigma: ReturnType<typeof useSigma>;
7
- graph: Graph<NodeAttributes<N>, EdgeAttributes<E>>;
8
- selected: string[];
9
- layoutRunning: boolean;
10
- dragSelector: ReturnType<typeof useDragSelection>;
11
- resetViewport: () => void;
12
- zoomIn: () => void;
13
- zoomOut: () => void;
14
- }
15
- export declare const GraphContext: import("react").Context<Context<KeyValue<any>, KeyValue<any>>>;
16
- export declare const useGraph: <N = KeyValue, E = KeyValue>() => Context<N, E>;
17
- export {};
@@ -1,12 +0,0 @@
1
- export declare const ICONS: {
2
- focus: string;
3
- zoomIn: string;
4
- zoomOut: string;
5
- lasso: string;
6
- select: string;
7
- cancel: string;
8
- delete: string;
9
- clear: string;
10
- expand: string;
11
- collapse: string;
12
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import type Sigma from "sigma";
2
- import { type EdgeAttributes, type NodeAttributes } from "../types";
3
- export declare const useDragSelection: (renderer?: Sigma<NodeAttributes<any>, EdgeAttributes<any>>) => {
4
- selectionMode: false | "rectangle" | "lasso";
5
- startRectangleSelection: () => void;
6
- startLassoSelection: () => void;
7
- cancelSelection: () => void;
8
- };
@@ -1,3 +0,0 @@
1
- import type Sigma from "sigma";
2
- import { type EdgeAttributes, type NodeAttributes } from "../types";
3
- export declare const attachHighlighter: (renderer: Sigma<NodeAttributes<any>, EdgeAttributes<any>>) => void;
@@ -1,3 +0,0 @@
1
- import type Sigma from "sigma";
2
- import { type EdgeAttributes, type NodeAttributes } from "../types";
3
- export declare const attachMouseActions: (renderer: Sigma<NodeAttributes<any>, EdgeAttributes<any>>) => void;
@@ -1,6 +0,0 @@
1
- import { Graph } from "../graph";
2
- import { type GraphProps } from "../types";
3
- export declare const useGraphology: <N, E>(data: GraphProps<N, E>["data"]) => {
4
- graph: Graph<N, E>;
5
- selected: string[];
6
- };
@@ -1,8 +0,0 @@
1
- import Sigma from "sigma";
2
- import { type Graph } from "../graph";
3
- import { type EdgeAttributes, type NodeAttributes } from "../types";
4
- export declare const useSigma: <N, E>(graph: Graph<N, E>, nodeReducer?: (node: NodeAttributes<N>) => NodeAttributes<N>, edgeReducer?: (edge: EdgeAttributes<E>) => EdgeAttributes<E>) => {
5
- instance: Sigma<NodeAttributes<N>, EdgeAttributes<E>, import("graphology-types").Attributes> | undefined;
6
- containerRef: import("react").Dispatch<import("react").SetStateAction<HTMLDivElement | null>>;
7
- componentsRef: import("react").Dispatch<import("react").SetStateAction<HTMLDivElement | null>>;
8
- };
File without changes
@@ -1,2 +0,0 @@
1
- declare const SHADER_SOURCE = "\nprecision mediump float;\n\nvarying vec4 v_color;\nvarying float v_opacity;\n\nconst vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);\n\nvoid main(void) {\n gl_FragColor = v_color;\n gl_FragColor = mix(transparent, gl_FragColor, v_opacity);\n}\n";
2
- export default SHADER_SOURCE;
@@ -1,9 +0,0 @@
1
- import { type Attributes } from "graphology-types";
2
- import { type EdgeProgramType } from "sigma/rendering";
3
- export interface CreateEdgeArrowHeadProgramOptions {
4
- extremity: "source" | "target";
5
- lengthToThicknessRatio: number;
6
- widenessToThicknessRatio: number;
7
- }
8
- export declare const DEFAULT_EDGE_ARROW_HEAD_PROGRAM_OPTIONS: CreateEdgeArrowHeadProgramOptions;
9
- export declare function createEdgeArrowHeadProgram<N extends Attributes = Attributes, E extends Attributes = Attributes, G extends Attributes = Attributes>(inputOptions?: Partial<CreateEdgeArrowHeadProgramOptions>): EdgeProgramType<N, E, G>;
@@ -1,2 +0,0 @@
1
- declare const SHADER_SOURCE = "\nattribute vec2 a_position;\nattribute vec2 a_normal;\nattribute float a_radius;\nattribute vec3 a_barycentric;\nattribute float a_opacity;\n\n#ifdef PICKING_MODE\nattribute vec4 a_id;\n#else\nattribute vec4 a_color;\n#endif\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_correctionRatio;\nuniform float u_minEdgeThickness;\nuniform float u_lengthToThicknessRatio;\nuniform float u_widenessToThicknessRatio;\n\nvarying vec4 v_color;\nvarying float v_opacity;\n\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n float minThickness = u_minEdgeThickness;\n\n float normalLength = length(a_normal);\n vec2 unitNormal = a_normal / normalLength;\n\n // These first computations are taken from edge.vert.glsl and\n // edge.clamped.vert.glsl. Please read it to get better comments on what's\n // happening:\n float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);\n float webGLThickness = pixelsThickness * u_correctionRatio;\n float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;\n float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;\n float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;\n\n float da = a_barycentric.x;\n float db = a_barycentric.y;\n float dc = a_barycentric.z;\n\n vec2 delta = vec2(\n da * (webGLNodeRadius * unitNormal.y)\n + db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)\n + dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),\n\n da * (-webGLNodeRadius * unitNormal.x)\n + db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)\n + dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)\n );\n\n vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;\n\n gl_Position = vec4(position, 0, 1);\n\n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_color = a_color;\n v_opacity = a_opacity;\n #endif\n\n v_color.a *= bias;\n}\n";
2
- export default SHADER_SOURCE;
@@ -1,6 +0,0 @@
1
- import { type CreateEdgeCurveProgramOptions } from "@sigma/edge-curve";
2
- import { type Attributes } from "graphology-types";
3
- import { type EdgeLabelDrawingFunction } from "sigma/rendering";
4
- export declare function createDrawCurvedEdgeLabel<N extends Attributes = Attributes, E extends Attributes = Attributes, G extends Attributes = Attributes>({ curvatureAttribute, defaultCurvature, keepLabelUpright, }: CreateEdgeCurveProgramOptions & {
5
- keepLabelUpright?: boolean;
6
- }): EdgeLabelDrawingFunction<N, E, G>;
@@ -1,2 +0,0 @@
1
- declare const SHADER = "\nprecision highp float;\n\nvarying vec4 v_color;\nvarying float v_opacity;\nvarying float v_thickness;\nvarying float v_feather;\nvarying vec2 v_cpA;\nvarying vec2 v_cpB;\nvarying vec2 v_cpC;\nvarying float v_sourceSize;\nvarying vec2 v_sourcePoint;\nvarying float v_targetSize;\nvarying vec2 v_targetPoint;\n\nuniform float u_lengthToThicknessRatio;\nuniform float u_widenessToThicknessRatio;\n\nfloat det(vec2 a, vec2 b) {\n return a.x * b.y - b.x * a.y;\n}\n\nvec2 getDistanceVector(vec2 b0, vec2 b1, vec2 b2) {\n float a = det(b0, b2), b = 2.0 * det(b1, b0), d = 2.0 * det(b2, b1);\n float f = b * d - a * a;\n vec2 d21 = b2 - b1, d10 = b1 - b0, d20 = b2 - b0;\n vec2 gf = 2.0 * (b * d21 + d * d10 + a * d20);\n gf = vec2(gf.y, -gf.x);\n vec2 pp = -f * gf / dot(gf, gf);\n vec2 d0p = b0 - pp;\n float ap = det(d0p, d20), bp = 2.0 * det(d10, d0p);\n float t = clamp((ap + bp) / (2.0 * a + b + d), 0.0, 1.0);\n return mix(mix(b0, b1, t), mix(b1, b2, t), t);\n}\n\nfloat distToQuadraticBezierCurve(vec2 p, vec2 b0, vec2 b1, vec2 b2) {\n return length(getDistanceVector(b0 - p, b1 - p, b2 - p));\n}\n\nconst float epsilon = 0.7;\nconst vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);\n\nvoid main(void) {\n float dist = distToQuadraticBezierCurve(gl_FragCoord.xy, v_cpA, v_cpB, v_cpC);\n float thickness = v_thickness;\n\n if(v_sourceSize > 0.0) {\n float distToSource = length(gl_FragCoord.xy - v_sourcePoint);\n float sourceArrowLength = v_sourceSize + (thickness) * u_lengthToThicknessRatio;\n if (distToSource < sourceArrowLength) {\n thickness = (distToSource - v_sourceSize) / (sourceArrowLength - v_sourceSize) * u_widenessToThicknessRatio * thickness;\n }\n }\n\n if(v_targetSize > 0.0) {\n float distToTarget = length(gl_FragCoord.xy - v_targetPoint);\n float targetArrowLength = v_targetSize + (thickness) * u_lengthToThicknessRatio;\n if (distToTarget < targetArrowLength) {\n thickness = (distToTarget - v_targetSize) / (targetArrowLength - v_targetSize) * u_widenessToThicknessRatio * thickness;\n }\n }\n\n float halfThickness = thickness / 2.0;\n if (dist < halfThickness) {\n #ifdef PICKING_MODE\n gl_FragColor = v_color;\n #else\n float t = smoothstep(\n halfThickness - v_feather,\n halfThickness,\n dist\n );\n\n gl_FragColor = mix(v_color, transparent, t);\n gl_FragColor = mix(transparent, gl_FragColor, v_opacity);\n #endif\n } else {\n gl_FragColor = transparent;\n }\n}\n";
2
- export default SHADER;
@@ -1,43 +0,0 @@
1
- import { type Attributes } from "graphology-types";
2
- import { EdgeProgram, type ProgramInfo } from "sigma/rendering";
3
- import { type EdgeDisplayData, type NodeDisplayData, type RenderParams } from "sigma/types";
4
- import { type InternalEdgeAttributes } from "../../types";
5
- declare const UNIFORMS: readonly ["u_matrix", "u_sizeRatio", "u_dimensions", "u_pixelRatio", "u_feather", "u_minEdgeThickness", "u_lengthToThicknessRatio", "u_widenessToThicknessRatio"];
6
- export declare class EdgeCurveProgramBase<N extends Attributes = Attributes, E extends Attributes = Attributes, G extends Attributes = Attributes> extends EdgeProgram<(typeof UNIFORMS)[number], N, E, G> {
7
- getDefinition(): {
8
- VERTICES: number;
9
- VERTEX_SHADER_SOURCE: string;
10
- FRAGMENT_SHADER_SOURCE: string;
11
- METHOD: 4;
12
- UNIFORMS: readonly ["u_matrix", "u_sizeRatio", "u_dimensions", "u_pixelRatio", "u_feather", "u_minEdgeThickness", "u_lengthToThicknessRatio", "u_widenessToThicknessRatio"];
13
- ATTRIBUTES: ({
14
- name: string;
15
- size: number;
16
- type: 5126;
17
- normalized?: undefined;
18
- } | {
19
- name: string;
20
- size: number;
21
- type: 5121;
22
- normalized: boolean;
23
- })[];
24
- CONSTANT_ATTRIBUTES: {
25
- name: string;
26
- size: number;
27
- type: 5126;
28
- }[];
29
- CONSTANT_DATA: number[][];
30
- };
31
- processVisibleItem(edgeIndex: number, startIndex: number, sourceData: NodeDisplayData, targetData: NodeDisplayData, data: EdgeDisplayData & InternalEdgeAttributes): void;
32
- setUniforms(params: RenderParams, { gl, uniformLocations }: ProgramInfo): void;
33
- }
34
- export declare const EdgeCurveProgram: {
35
- new (_gl: WebGLRenderingContext, _pickingBuffer: WebGLFramebuffer | null, _renderer: import("sigma").default<Attributes, Attributes, Attributes>): {
36
- drawLabel: import("sigma/rendering").EdgeLabelDrawingFunction<Attributes, Attributes, Attributes> | undefined;
37
- kill(): void;
38
- reallocate(_capacity: number): void;
39
- process(_edgeIndex: number, _offset: number, _sourceData: NodeDisplayData, _targetData: NodeDisplayData, _data: EdgeDisplayData): void;
40
- render(_params: RenderParams): void;
41
- };
42
- };
43
- export {};
@@ -1,2 +0,0 @@
1
- declare const SHADER = "\nattribute vec4 a_id;\nattribute vec4 a_color;\nattribute float a_direction;\nattribute float a_thickness;\nattribute float a_opacity;\nattribute vec2 a_source;\nattribute vec2 a_target;\nattribute float a_current;\nattribute float a_curvature;\nattribute float a_sourceSize;\nattribute float a_targetSize;\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_pixelRatio;\nuniform vec2 u_dimensions;\nuniform float u_minEdgeThickness;\nuniform float u_feather;\nuniform float u_widenessToThicknessRatio;\n\nvarying vec4 v_color;\nvarying float v_opacity;\nvarying float v_thickness;\nvarying float v_feather;\nvarying vec2 v_cpA;\nvarying vec2 v_cpB;\nvarying vec2 v_cpC;\nvarying float v_sourceSize;\nvarying vec2 v_sourcePoint;\nvarying float v_targetSize;\nvarying vec2 v_targetPoint;\n\nconst float bias = 255.0 / 254.0;\nconst float epsilon = 0.7;\n\nvec2 clipspaceToViewport(vec2 pos, vec2 dimensions) {\n return vec2(\n (pos.x + 1.0) * dimensions.x / 2.0,\n (pos.y + 1.0) * dimensions.y / 2.0\n );\n}\n\nvec2 viewportToClipspace(vec2 pos, vec2 dimensions) {\n return vec2(\n pos.x / dimensions.x * 2.0 - 1.0,\n pos.y / dimensions.y * 2.0 - 1.0\n );\n}\n\nvoid main() {\n float minThickness = u_minEdgeThickness;\n // Selecting the correct position\n // Branchless \"position = a_source if a_current == 1.0 else a_target\"\n vec2 position = a_source * max(0.0, a_current) + a_target * max(0.0, 1.0 - a_current);\n position = (u_matrix * vec3(position, 1)).xy;\n\n vec2 source = (u_matrix * vec3(a_source, 1)).xy;\n vec2 target = (u_matrix * vec3(a_target, 1)).xy;\n\n vec2 viewportPosition = clipspaceToViewport(position, u_dimensions);\n vec2 viewportSource = clipspaceToViewport(source, u_dimensions);\n vec2 viewportTarget = clipspaceToViewport(target, u_dimensions);\n\n vec2 delta = viewportTarget.xy - viewportSource.xy;\n float len = length(delta);\n vec2 normal = vec2(-delta.y, delta.x) * a_direction;\n vec2 unitNormal = normal / len;\n float boundingBoxThickness = len * a_curvature;\n float curveThickness = max(minThickness, a_thickness / 2.0 / u_sizeRatio * u_pixelRatio);\n\n v_thickness = curveThickness;\n v_feather = u_feather;\n\n v_cpA = viewportSource;\n v_cpB = 0.5 * (viewportSource + viewportTarget) + unitNormal * a_direction * boundingBoxThickness;\n v_cpC = viewportTarget;\n\n vec2 viewportOffsetPosition = (\n viewportPosition +\n unitNormal * (boundingBoxThickness / 2.0 + sign(boundingBoxThickness) * (curveThickness + epsilon)) *\n max(0.0, a_direction) // NOTE: cutting the bounding box in half to avoid overdraw\n );\n\n position = viewportToClipspace(viewportOffsetPosition, u_dimensions);\n gl_Position = vec4(position, 0, 1);\n\n v_sourceSize = a_sourceSize * u_pixelRatio / u_sizeRatio;\n v_sourcePoint = viewportSource;\n \n v_targetSize = a_targetSize * u_pixelRatio / u_sizeRatio;\n v_targetPoint = viewportTarget;\n \n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_color = a_color;\n v_opacity = a_opacity;\n #endif\n\n v_color.a *= bias;\n}\n";
2
- export default SHADER;
@@ -1,5 +0,0 @@
1
- import { type Attributes } from "graphology-types";
2
- import { type Settings } from "sigma/settings";
3
- import { type EdgeDisplayData, type NodeDisplayData, type PartialButFor } from "sigma/types";
4
- export type EdgeLabelDrawingFunction<N extends Attributes = Attributes, E extends Attributes = Attributes, G extends Attributes = Attributes> = (context: CanvasRenderingContext2D, edgeData: PartialButFor<EdgeDisplayData, "label" | "color" | "size">, sourceData: PartialButFor<NodeDisplayData, "x" | "y" | "size">, targetData: PartialButFor<NodeDisplayData, "x" | "y" | "size">, settings: Settings<N, E, G>) => void;
5
- export declare function drawLineLabel<N extends Attributes = Attributes, E extends Attributes = Attributes, G extends Attributes = Attributes>(context: CanvasRenderingContext2D, edgeData: PartialButFor<EdgeDisplayData, "label" | "color" | "size">, sourceData: PartialButFor<NodeDisplayData, "x" | "y" | "size">, targetData: PartialButFor<NodeDisplayData, "x" | "y" | "size">, settings: Settings<N, E, G>): void;
@@ -1,2 +0,0 @@
1
- declare const SHADER_SOURCE = "\nprecision mediump float;\n\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_opacity;\nvarying float v_thickness;\nvarying float v_feather;\n\nconst vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);\n\nvoid main(void) {\n // We only handle antialiasing for normal mode:\n #ifdef PICKING_MODE\n gl_FragColor = v_color;\n #else\n float dist = length(v_normal) * v_thickness;\n\n float t = smoothstep(\n v_thickness - v_feather,\n v_thickness,\n dist\n );\n\n gl_FragColor = mix(v_color, transparent, t);\n gl_FragColor = mix(transparent, gl_FragColor, v_opacity);\n #endif\n}\n";
2
- export default SHADER_SOURCE;
@@ -1,11 +0,0 @@
1
- import { type Attributes } from "graphology-types";
2
- import { type EdgeDisplayData, type NodeDisplayData, type RenderParams } from "sigma/types";
3
- export declare const EdgeLineProgram: {
4
- new (_gl: WebGLRenderingContext, _pickingBuffer: WebGLFramebuffer | null, _renderer: import("sigma").default<Attributes, Attributes, Attributes>): {
5
- drawLabel: import("sigma/rendering").EdgeLabelDrawingFunction<Attributes, Attributes, Attributes> | undefined;
6
- kill(): void;
7
- reallocate(_capacity: number): void;
8
- process(_edgeIndex: number, _offset: number, _sourceData: NodeDisplayData, _targetData: NodeDisplayData, _data: EdgeDisplayData): void;
9
- render(_params: RenderParams): void;
10
- };
11
- };
@@ -1,2 +0,0 @@
1
- declare const SHADER_SOURCE = "\nattribute vec4 a_id;\nattribute vec4 a_color;\nattribute vec2 a_normal;\nattribute float a_opacity;\nattribute float a_normalCoef;\nattribute vec2 a_positionStart;\nattribute vec2 a_positionEnd;\nattribute float a_positionCoef;\nattribute float a_sourceRadius;\nattribute float a_targetRadius;\nattribute float a_sourceRadiusCoef;\nattribute float a_targetRadiusCoef;\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_zoomRatio;\nuniform float u_pixelRatio;\nuniform float u_correctionRatio;\nuniform float u_minEdgeThickness;\nuniform float u_lengthToThicknessRatio;\nuniform float u_feather;\n\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_opacity;\nvarying float v_thickness;\nvarying float v_feather;\n\nconst float minThickness = 1.7;\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n vec2 normal = a_normal * a_normalCoef;\n vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;\n\n float normalLength = length(normal);\n vec2 unitNormal = normal / normalLength;\n\n // We require edges to be at least \"minThickness\" pixels thick *on screen*\n // (so we need to compensate the size ratio):\n float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);\n\n // Then, we need to retrieve the normalized thickness of the edge in the WebGL\n // referential (in a ([0, 1], [0, 1]) space), using our \"magic\" correction\n // ratio:\n float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;\n\n // Here, we move the point to leave space for the arrow heads:\n // Source arrow head\n float sourceRadius = a_sourceRadius * a_sourceRadiusCoef;\n float sourceDirection = sign(sourceRadius);\n float webGLSourceRadius = sourceDirection * sourceRadius * 2.0 * u_correctionRatio / u_sizeRatio;\n float webGLSourceArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;\n vec2 sourceCompensationVector =\n vec2(-sourceDirection * unitNormal.y, sourceDirection * unitNormal.x)\n * (webGLSourceRadius + webGLSourceArrowHeadLength);\n \n // Target arrow head\n float targetRadius = a_targetRadius * a_targetRadiusCoef;\n float targetDirection = sign(targetRadius);\n float webGLTargetRadius = targetDirection * targetRadius * 2.0 * u_correctionRatio / u_sizeRatio;\n float webGLTargetArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;\n vec2 targetCompensationVector =\n vec2(-targetDirection * unitNormal.y, targetDirection * unitNormal.x)\n * (webGLTargetRadius + webGLTargetArrowHeadLength);\n\n if(a_sourceRadius == 0.0) {\n sourceCompensationVector = vec2(0.0, 0.0);\n }\n if(a_targetRadius == 0.0) {\n targetCompensationVector = vec2(0.0, 0.0);\n }\n\n // Here is the proper position of the vertex\n gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + sourceCompensationVector + targetCompensationVector, 1)).xy, 0, 1);\n\n // For the fragment shader though, we need a thickness that takes the \"magic\"\n // correction ratio into account (as in webGLThickness), but so that the\n // antialiasing effect does not depend on the zoom level. So here's yet\n // another thickness version:\n v_thickness = webGLThickness / u_zoomRatio;\n\n v_normal = unitNormal;\n\n v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;\n\n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_color = a_color;\n v_opacity = a_opacity;\n #endif\n\n v_color.a *= bias;\n}\n";
2
- export default SHADER_SOURCE;
@@ -1,27 +0,0 @@
1
- import { type Attributes } from "graphology-types";
2
- import { type NodeHoverDrawingFunction, type NodeLabelDrawingFunction, type NodeProgramType } from "sigma/rendering";
3
- import { type EdgeAttributes, type NodeAttributes } from "../../types";
4
- import { type TextureManagerOptions } from "./texture";
5
- interface CreateNodeImageProgramOptions<N extends Attributes, E extends Attributes, G extends Attributes> extends TextureManagerOptions {
6
- drawingMode: "background" | "color";
7
- keepWithinCircle: boolean;
8
- drawLabel: NodeLabelDrawingFunction<N, E, G> | undefined;
9
- drawHover: NodeHoverDrawingFunction<N, E, G> | undefined;
10
- padding: number;
11
- colorAttribute: string;
12
- }
13
- /**
14
- * To share the texture between the program instances of the graph and the
15
- * hovered nodes (to prevent some flickering, mostly), this program must be
16
- * "built" for each sigma instance:
17
- */
18
- export default function getNodeImageProgram(options?: Partial<CreateNodeImageProgramOptions<NodeAttributes & {
19
- bg: string;
20
- opacity: number;
21
- }, EdgeAttributes, Attributes>> & {
22
- badgePosition: string;
23
- }): NodeProgramType<NodeAttributes & {
24
- bg: string;
25
- opacity: number;
26
- }, EdgeAttributes>;
27
- export {};
@@ -1,2 +0,0 @@
1
- declare const SHADER_SOURCE = "\nprecision highp float;\n\nvarying vec4 v_fill;\nvarying vec4 v_color;\nvarying vec4 v_texture;\nvarying vec2 v_diffVector;\nvarying float v_opacity;\nvarying float v_radius;\n\nuniform sampler2D u_atlas;\nuniform float u_correctionRatio;\nuniform float u_cameraAngle;\nuniform float u_percentagePadding;\nuniform bool u_keepWithinCircle;\nuniform bool u_shape;\n\nconst vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);\n\nconst float radius = 0.5;\n\nvoid main(void) {\n float border = 2.0 * u_correctionRatio;\n float dist = length(v_diffVector);\n vec4 color = v_fill;\n\n float c = cos(-u_cameraAngle);\n float s = sin(-u_cameraAngle);\n vec2 diffVector = mat2(c, s, -s, c) * (v_diffVector);\n\n // No antialiasing for picking mode:\n #ifdef PICKING_MODE\n border = 0.0;\n gl_FragColor = v_color;\n\n #else\n // First case: No image to display\n if (v_texture.w <= 0.0) {\n color = v_fill;\n }\n\n // Second case: Image loaded into the texture\n else {\n float paddingRatio = 1.0 + 2.0 * u_percentagePadding;\n float coef = 1.0;\n vec2 coordinateInTexture = diffVector * vec2(paddingRatio, -paddingRatio) / v_radius / 2.0 * coef + vec2(0.5, 0.5);\n vec4 texel = texture2D(u_atlas, (v_texture.xy + coordinateInTexture * v_texture.zw), -1.0);\n\n // Colorize all visible image pixels:\n color = mix(v_fill, v_color, texel.a);\n \n // Erase pixels \"in the padding\":\n if (abs(diffVector.x) > v_radius / paddingRatio || abs(diffVector.y) > v_radius / paddingRatio) {\n color = v_fill;\n }\n }\n\n // Crop in a circle when u_keepWithinCircle is truthy:\n if(v_opacity == 0.0) {\n gl_FragColor = transparent;\n }\n else if (dist - v_radius + border > border)\n gl_FragColor = transparent;\n else if (dist - v_radius + border > 0.0) {\n gl_FragColor = mix(v_fill, transparent, (dist - v_radius + border) / border);\n }\n else {\n gl_FragColor = mix(v_fill, color, v_opacity);\n }\n #endif\n \n\n}\n";
2
- export default SHADER_SOURCE;
@@ -1,5 +0,0 @@
1
- export { default as createNodeImageProgram } from "./factory";
2
- export declare const NodeBadgeProgram: (isCircle: boolean) => import("sigma/rendering").NodeProgramType<import("../..").NodeAttributes<KeyValue<any>> & {
3
- bg: string;
4
- opacity: number;
5
- }, import("../..").EdgeAttributes<KeyValue<any>>>[];
@@ -1,102 +0,0 @@
1
- import { EventEmitter } from "events";
2
- import { type Coordinates } from "sigma/types";
3
- /**
4
- * Useful types:
5
- * *************
6
- */
7
- export interface ImageLoading {
8
- status: "loading";
9
- }
10
- export interface ImageError {
11
- status: "error";
12
- }
13
- export interface ImageReady {
14
- status: "ready";
15
- image: HTMLImageElement;
16
- sourceX: number;
17
- sourceY: number;
18
- sourceSize: number;
19
- destinationSize: number;
20
- }
21
- export type ImageType = ImageLoading | ImageError | ImageReady;
22
- export type Atlas = Record<string, Coordinates & {
23
- size: number;
24
- }>;
25
- export interface TextureManagerOptions {
26
- size: {
27
- mode: "auto";
28
- } | {
29
- mode: "max";
30
- value: number;
31
- } | {
32
- mode: "force";
33
- value: number;
34
- };
35
- objectFit: "contain" | "cover" | "fill";
36
- correctCentering: boolean;
37
- }
38
- export declare const DEFAULT_TEXTURE_MANAGER_OPTIONS: TextureManagerOptions;
39
- export declare const DEBOUNCE_TIMEOUT = 100;
40
- export declare const MARGIN_IN_TEXTURE = 1;
41
- /**
42
- * Helpers:
43
- * ********
44
- */
45
- /**
46
- * This helper loads an image at a given URL, and returns an HTMLImageElement
47
- * with it displayed once it's properly loaded, within a promise.
48
- */
49
- export declare function loadRasterImage(imageSource: string): Promise<HTMLImageElement>;
50
- export declare const makeSvg: (path?: string) => string;
51
- /**
52
- * This helper loads an SVG image at a given URL, adjusts its size to a given
53
- * size, and returns an HTMLImageElement with it displayed once it's properly
54
- * loaded, within a promise.
55
- */
56
- export declare function loadSVGImage(imageSource: string, { size }?: {
57
- size?: number;
58
- }): Promise<HTMLImageElement>;
59
- /**
60
- * This helper loads an image using the proper function.
61
- */
62
- export declare function loadImage(imageSource: string, { size }?: {
63
- size?: number;
64
- }): Promise<HTMLImageElement>;
65
- /**
66
- * This helper computes exact coordinates to draw an image onto a texture.
67
- */
68
- export declare function refineImage(image: HTMLImageElement, corrector: PictogramCenteringCorrector, { objectFit, size, correctCentering }: TextureManagerOptions): Omit<ImageReady, "status" | "image">;
69
- /**
70
- * This helper takes a collection of image states and a context, draw all the
71
- * images in the context, and returns an atlas to get where each image is drawn
72
- * on the texture.
73
- */
74
- export declare function drawTexture(ctx: CanvasRenderingContext2D, images: Record<string, ImageType>): Atlas;
75
- /**
76
- * This class helps to "correct" the centering of an SVG pictogram by finding
77
- * the "true" visually correct center through the barycenter of the pictogram's
78
- * alpha layer in x and y dimension.
79
- */
80
- export declare class PictogramCenteringCorrector {
81
- canvas: HTMLCanvasElement;
82
- context: CanvasRenderingContext2D;
83
- constructor();
84
- getCorrectionOffset(image: HTMLImageElement, size: number): Coordinates;
85
- }
86
- export declare class TextureManager extends EventEmitter {
87
- static NEW_TEXTURE_EVENT: string;
88
- private readonly options;
89
- private readonly canvas;
90
- private readonly ctx;
91
- private frameId?;
92
- private readonly corrector;
93
- private imageStates;
94
- private texture;
95
- private atlas;
96
- constructor(options?: Partial<TextureManagerOptions>);
97
- private scheduleGenerateTexture;
98
- private generateTexture;
99
- registerImage(source: string): Promise<void>;
100
- getAtlas(): Atlas;
101
- getTexture(): ImageData;
102
- }
@@ -1,2 +0,0 @@
1
- declare const VERTEX_SHADER_SOURCE: string;
2
- export default VERTEX_SHADER_SOURCE;
@@ -1,8 +0,0 @@
1
- import { type Settings } from "sigma/settings";
2
- import { type EdgeAttributes, type NodeAttributes } from "../../../types";
3
- export declare function drawNodeHover(context: CanvasRenderingContext2D, data: NodeAttributes & {
4
- opacity: number;
5
- x: number;
6
- y: number;
7
- size: number;
8
- }, settings: Settings<NodeAttributes, EdgeAttributes>): void;
@@ -1,8 +0,0 @@
1
- import { type Settings } from "sigma/settings";
2
- import { type EdgeAttributes, type InternalNodeAttributes, type NodeAttributes } from "../../../types";
3
- export declare function drawNodeLabel(context: CanvasRenderingContext2D, data: InternalNodeAttributes & {
4
- opacity: number;
5
- x: number;
6
- y: number;
7
- size: number;
8
- }, settings: Settings<NodeAttributes, EdgeAttributes>): void;
@@ -1,2 +0,0 @@
1
- declare const SHADER_SOURCE: string;
2
- export default SHADER_SOURCE;
@@ -1,37 +0,0 @@
1
- import { NodeProgram, type ProgramInfo } from "sigma/rendering";
2
- import { type NodeDisplayData, type RenderParams } from "sigma/types";
3
- import { type EdgeAttributes, type NodeAttributes } from "../../../types";
4
- declare const UNIFORMS: readonly ["u_sizeRatio", "u_correctionRatio", "u_matrix"];
5
- export declare class NodeCircleBase extends NodeProgram<(typeof UNIFORMS)[number], NodeAttributes, EdgeAttributes> {
6
- static readonly ANGLE_1 = 0;
7
- static readonly ANGLE_2: number;
8
- static readonly ANGLE_3: number;
9
- getDefinition(): {
10
- VERTICES: number;
11
- VERTEX_SHADER_SOURCE: string;
12
- FRAGMENT_SHADER_SOURCE: string;
13
- METHOD: 4;
14
- UNIFORMS: readonly ["u_sizeRatio", "u_correctionRatio", "u_matrix"];
15
- ATTRIBUTES: ({
16
- name: string;
17
- size: number;
18
- type: 5121;
19
- normalized: boolean;
20
- } | {
21
- name: string;
22
- size: number;
23
- type: 5126;
24
- })[];
25
- CONSTANT_ATTRIBUTES: {
26
- name: string;
27
- size: number;
28
- type: 5126;
29
- }[];
30
- CONSTANT_DATA: number[][];
31
- };
32
- processVisibleItem(nodeIndex: number, startIndex: number, data: NodeDisplayData & NodeAttributes & {
33
- opacity: number;
34
- }): void;
35
- setUniforms(params: RenderParams, { gl, uniformLocations }: ProgramInfo): void;
36
- }
37
- export {};
@@ -1,2 +0,0 @@
1
- declare const SHADER_SOURCE: string;
2
- export default SHADER_SOURCE;
@@ -1,11 +0,0 @@
1
- import { type NodeAttributes } from "../../types";
2
- export declare const NodeCircleProgram: {
3
- new (_gl: WebGLRenderingContext, _pickingBuffer: WebGLFramebuffer | null, _renderer: import("sigma").default<NodeAttributes<any>, import("graphology-types").Attributes, import("graphology-types").Attributes>): {
4
- drawLabel: import("sigma/rendering").NodeLabelDrawingFunction<NodeAttributes<any>, import("graphology-types").Attributes, import("graphology-types").Attributes> | undefined;
5
- drawHover: import("sigma/rendering").NodeHoverDrawingFunction<NodeAttributes<any>, import("graphology-types").Attributes, import("graphology-types").Attributes> | undefined;
6
- kill(): void;
7
- reallocate(_capacity: number): void;
8
- process(_nodeIndex: number, _offset: number, _data: import("sigma/types").NodeDisplayData): void;
9
- render(_params: import("sigma/types").RenderParams): void;
10
- };
11
- };