@antv/g6 5.0.3 → 5.0.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 (242) hide show
  1. package/README.en-US.md +118 -0
  2. package/README.md +118 -0
  3. package/dist/g6.min.js +2 -2
  4. package/dist/lib/behaviors/base-behavior.d.ts +1 -1
  5. package/dist/lib/behaviors/scroll-canvas.d.ts +1 -1
  6. package/dist/lib/behaviors/types.d.ts +0 -4
  7. package/dist/lib/behaviors/zoom-canvas.d.ts +1 -1
  8. package/dist/lib/elements/shapes/badge.d.ts +1 -1
  9. package/dist/lib/index.d.ts +1 -1
  10. package/dist/lib/layouts/index.d.ts +0 -1
  11. package/dist/lib/plugins/types.d.ts +0 -2
  12. package/dist/lib/registry/extension/index.d.ts +17 -6
  13. package/dist/lib/registry/extension/types.d.ts +15 -33
  14. package/dist/lib/runtime/data.d.ts +1 -1
  15. package/dist/lib/runtime/element.d.ts +1 -1
  16. package/dist/lib/spec/behavior.d.ts +4 -5
  17. package/dist/lib/spec/element/combo.d.ts +8 -4
  18. package/dist/lib/spec/element/edge.d.ts +8 -4
  19. package/dist/lib/spec/element/node.d.ts +8 -4
  20. package/dist/lib/spec/plugin.d.ts +4 -5
  21. package/dist/lib/spec/transform.d.ts +5 -6
  22. package/dist/lib/transforms/types.d.ts +1 -2
  23. package/dist/lib/types/index.d.ts +0 -1
  24. package/dist/lib/types/style.d.ts +2 -0
  25. package/dist/lib/utils/event/events.d.ts +4 -4
  26. package/dist/lib/utils/extension.d.ts +5 -2
  27. package/dist/lib/utils/style.d.ts +5 -2
  28. package/dist/lib/utils/transform.d.ts +1 -1
  29. package/dist/lib/version.d.ts +1 -0
  30. package/esm/behaviors/base-behavior.d.ts +1 -1
  31. package/esm/behaviors/base-behavior.js.map +1 -1
  32. package/esm/behaviors/scroll-canvas.d.ts +1 -1
  33. package/esm/behaviors/scroll-canvas.js.map +1 -1
  34. package/esm/behaviors/types.d.ts +0 -4
  35. package/esm/behaviors/zoom-canvas.d.ts +1 -1
  36. package/esm/elements/shapes/badge.d.ts +1 -1
  37. package/esm/index.d.ts +1 -1
  38. package/esm/index.js +1 -1
  39. package/esm/index.js.map +1 -1
  40. package/esm/layouts/index.d.ts +0 -1
  41. package/esm/plugins/camera-setting.js.map +1 -1
  42. package/esm/plugins/types.d.ts +0 -2
  43. package/esm/registry/extension/index.d.ts +17 -6
  44. package/esm/registry/extension/index.js +1 -1
  45. package/esm/registry/extension/index.js.map +1 -1
  46. package/esm/registry/extension/types.d.ts +15 -33
  47. package/esm/runtime/data.d.ts +1 -1
  48. package/esm/runtime/element.d.ts +1 -1
  49. package/esm/runtime/element.js +7 -4
  50. package/esm/runtime/element.js.map +1 -1
  51. package/esm/runtime/graph.js +3 -3
  52. package/esm/runtime/graph.js.map +1 -1
  53. package/esm/spec/behavior.d.ts +4 -5
  54. package/esm/spec/element/combo.d.ts +8 -4
  55. package/esm/spec/element/edge.d.ts +8 -4
  56. package/esm/spec/element/node.d.ts +8 -4
  57. package/esm/spec/plugin.d.ts +4 -5
  58. package/esm/spec/transform.d.ts +5 -6
  59. package/esm/transforms/types.d.ts +1 -2
  60. package/esm/types/index.d.ts +0 -1
  61. package/esm/types/style.d.ts +2 -0
  62. package/esm/utils/event/events.d.ts +4 -4
  63. package/esm/utils/extension.d.ts +5 -2
  64. package/esm/utils/extension.js +5 -1
  65. package/esm/utils/extension.js.map +1 -1
  66. package/esm/utils/style.d.ts +5 -2
  67. package/esm/utils/style.js +5 -6
  68. package/esm/utils/style.js.map +1 -1
  69. package/esm/utils/transform.d.ts +1 -1
  70. package/esm/version.d.ts +1 -0
  71. package/esm/version.js +2 -0
  72. package/esm/version.js.map +1 -0
  73. package/lib/behaviors/base-behavior.d.ts +1 -1
  74. package/lib/behaviors/base-behavior.js.map +1 -1
  75. package/lib/behaviors/scroll-canvas.d.ts +1 -1
  76. package/lib/behaviors/scroll-canvas.js.map +1 -1
  77. package/lib/behaviors/types.d.ts +0 -4
  78. package/lib/behaviors/zoom-canvas.d.ts +1 -1
  79. package/lib/elements/effect.js +1 -2
  80. package/lib/elements/effect.js.map +1 -1
  81. package/lib/elements/shapes/badge.d.ts +1 -1
  82. package/lib/index.d.ts +1 -1
  83. package/lib/index.js +2 -1
  84. package/lib/index.js.map +1 -1
  85. package/lib/layouts/index.d.ts +0 -1
  86. package/lib/plugins/camera-setting.js.map +1 -1
  87. package/lib/plugins/contextmenu/util.js +2 -2
  88. package/lib/plugins/contextmenu/util.js.map +1 -1
  89. package/lib/plugins/history/util.js +2 -3
  90. package/lib/plugins/history/util.js.map +1 -1
  91. package/lib/plugins/hull/util.js +1 -2
  92. package/lib/plugins/hull/util.js.map +1 -1
  93. package/lib/plugins/toolbar/util.js +2 -2
  94. package/lib/plugins/toolbar/util.js.map +1 -1
  95. package/lib/plugins/types.d.ts +0 -2
  96. package/lib/plugins/watermark/util.js +2 -3
  97. package/lib/plugins/watermark/util.js.map +1 -1
  98. package/lib/registry/extension/index.d.ts +17 -6
  99. package/lib/registry/extension/index.js +1 -1
  100. package/lib/registry/extension/index.js.map +1 -1
  101. package/lib/registry/extension/types.d.ts +15 -33
  102. package/lib/registry/index.js +4 -5
  103. package/lib/registry/index.js.map +1 -1
  104. package/lib/runtime/data.d.ts +1 -1
  105. package/lib/runtime/element.d.ts +1 -1
  106. package/lib/runtime/element.js +7 -4
  107. package/lib/runtime/element.js.map +1 -1
  108. package/lib/runtime/graph.js +3 -3
  109. package/lib/runtime/graph.js.map +1 -1
  110. package/lib/spec/behavior.d.ts +4 -5
  111. package/lib/spec/element/combo.d.ts +8 -4
  112. package/lib/spec/element/edge.d.ts +8 -4
  113. package/lib/spec/element/node.d.ts +8 -4
  114. package/lib/spec/plugin.d.ts +4 -5
  115. package/lib/spec/transform.d.ts +5 -6
  116. package/lib/themes/base.js +1 -2
  117. package/lib/themes/base.js.map +1 -1
  118. package/lib/transforms/types.d.ts +1 -2
  119. package/lib/transforms/utils.js +1 -2
  120. package/lib/transforms/utils.js.map +1 -1
  121. package/lib/types/index.d.ts +0 -1
  122. package/lib/types/style.d.ts +2 -0
  123. package/lib/utils/anchor.js +1 -2
  124. package/lib/utils/anchor.js.map +1 -1
  125. package/lib/utils/animation.js +5 -6
  126. package/lib/utils/animation.js.map +1 -1
  127. package/lib/utils/array.js +1 -2
  128. package/lib/utils/array.js.map +1 -1
  129. package/lib/utils/bbox.js +13 -14
  130. package/lib/utils/bbox.js.map +1 -1
  131. package/lib/utils/cache.js +4 -5
  132. package/lib/utils/cache.js.map +1 -1
  133. package/lib/utils/change.js +2 -3
  134. package/lib/utils/change.js.map +1 -1
  135. package/lib/utils/collapsibility.js +1 -2
  136. package/lib/utils/collapsibility.js.map +1 -1
  137. package/lib/utils/data.js +3 -4
  138. package/lib/utils/data.js.map +1 -1
  139. package/lib/utils/diff.js +1 -2
  140. package/lib/utils/diff.js.map +1 -1
  141. package/lib/utils/dom.js +4 -5
  142. package/lib/utils/dom.js.map +1 -1
  143. package/lib/utils/edge.js +18 -18
  144. package/lib/utils/edge.js.map +1 -1
  145. package/lib/utils/element.js +26 -27
  146. package/lib/utils/element.js.map +1 -1
  147. package/lib/utils/event/events.d.ts +4 -4
  148. package/lib/utils/event/index.js +2 -3
  149. package/lib/utils/event/index.js.map +1 -1
  150. package/lib/utils/extension.d.ts +5 -2
  151. package/lib/utils/extension.js +6 -3
  152. package/lib/utils/extension.js.map +1 -1
  153. package/lib/utils/graphlib.js +3 -4
  154. package/lib/utils/graphlib.js.map +1 -1
  155. package/lib/utils/id.js +3 -4
  156. package/lib/utils/id.js.map +1 -1
  157. package/lib/utils/is.js +4 -5
  158. package/lib/utils/is.js.map +1 -1
  159. package/lib/utils/layout.js +7 -8
  160. package/lib/utils/layout.js.map +1 -1
  161. package/lib/utils/line.js +2 -3
  162. package/lib/utils/line.js.map +1 -1
  163. package/lib/utils/math.js +1 -2
  164. package/lib/utils/math.js.map +1 -1
  165. package/lib/utils/node.js +1 -2
  166. package/lib/utils/node.js.map +1 -1
  167. package/lib/utils/padding.js +1 -2
  168. package/lib/utils/padding.js.map +1 -1
  169. package/lib/utils/palette.js +3 -4
  170. package/lib/utils/palette.js.map +1 -1
  171. package/lib/utils/path.js +4 -4
  172. package/lib/utils/path.js.map +1 -1
  173. package/lib/utils/placement.js +1 -2
  174. package/lib/utils/placement.js.map +1 -1
  175. package/lib/utils/point.js +21 -22
  176. package/lib/utils/point.js.map +1 -1
  177. package/lib/utils/polygon.js +1 -2
  178. package/lib/utils/polygon.js.map +1 -1
  179. package/lib/utils/position.js +5 -5
  180. package/lib/utils/position.js.map +1 -1
  181. package/lib/utils/prefix.js +7 -8
  182. package/lib/utils/prefix.js.map +1 -1
  183. package/lib/utils/relation.js +2 -3
  184. package/lib/utils/relation.js.map +1 -1
  185. package/lib/utils/router/orth.js +9 -10
  186. package/lib/utils/router/orth.js.map +1 -1
  187. package/lib/utils/shape.js +1 -2
  188. package/lib/utils/shape.js.map +1 -1
  189. package/lib/utils/size.js +1 -2
  190. package/lib/utils/size.js.map +1 -1
  191. package/lib/utils/style.d.ts +5 -2
  192. package/lib/utils/style.js +8 -10
  193. package/lib/utils/style.js.map +1 -1
  194. package/lib/utils/text.js +3 -4
  195. package/lib/utils/text.js.map +1 -1
  196. package/lib/utils/theme.js +1 -2
  197. package/lib/utils/theme.js.map +1 -1
  198. package/lib/utils/transform.d.ts +1 -1
  199. package/lib/utils/transform.js +2 -2
  200. package/lib/utils/transform.js.map +1 -1
  201. package/lib/utils/traverse.js +2 -3
  202. package/lib/utils/traverse.js.map +1 -1
  203. package/lib/utils/tree.js +1 -2
  204. package/lib/utils/tree.js.map +1 -1
  205. package/lib/utils/vector.js +16 -17
  206. package/lib/utils/vector.js.map +1 -1
  207. package/lib/utils/visibility.js +1 -2
  208. package/lib/utils/visibility.js.map +1 -1
  209. package/lib/version.d.ts +1 -0
  210. package/lib/version.js +5 -0
  211. package/lib/version.js.map +1 -0
  212. package/package.json +6 -3
  213. package/src/behaviors/base-behavior.ts +1 -1
  214. package/src/behaviors/scroll-canvas.ts +1 -1
  215. package/src/behaviors/types.ts +0 -4
  216. package/src/index.ts +1 -1
  217. package/src/plugins/camera-setting.ts +2 -2
  218. package/src/plugins/types.ts +0 -2
  219. package/src/registry/extension/index.ts +15 -8
  220. package/src/registry/extension/types.ts +15 -40
  221. package/src/runtime/element.ts +7 -4
  222. package/src/runtime/graph.ts +3 -3
  223. package/src/spec/behavior.ts +4 -5
  224. package/src/spec/element/combo.ts +16 -4
  225. package/src/spec/element/edge.ts +16 -4
  226. package/src/spec/element/node.ts +16 -4
  227. package/src/spec/plugin.ts +4 -5
  228. package/src/spec/transform.ts +5 -6
  229. package/src/transforms/types.ts +1 -2
  230. package/src/types/index.ts +0 -1
  231. package/src/types/style.ts +2 -0
  232. package/src/utils/extension.ts +10 -3
  233. package/src/utils/style.ts +11 -6
  234. package/src/version.ts +1 -0
  235. package/dist/lib/types/callable.d.ts +0 -19
  236. package/esm/types/callable.d.ts +0 -19
  237. package/esm/types/callable.js +0 -2
  238. package/esm/types/callable.js.map +0 -1
  239. package/lib/types/callable.d.ts +0 -19
  240. package/lib/types/callable.js +0 -3
  241. package/lib/types/callable.js.map +0 -1
  242. package/src/types/callable.ts +0 -21
@@ -1 +1 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"src/","sources":["utils/tree.ts"],"names":[],"mappings":";;;AAEA,yCAAiC;AAQjC;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,QAAkB,EAAE,MAAuB;IACzE,MAAM,EACJ,WAAW,GAAG,CAAC,KAAe,EAAE,EAAE;QAChC,IAAI,CAAC,KAAK,CAAC,QAAQ;YAAE,OAAO,KAAiB,CAAC;QAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;QACzC,OAAO,EAAE,GAAG,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CA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GAAG,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAAc,CAAC;IACnF,CAAC,EACD,WAAW,GAAG,CAAC,MAAgB,EAAE,MAAgB,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,EAChG,WAAW,GAAG,CAAC,KAAe,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,GACxD,GAAG,MAAM,IAAI,EAAE,CAAC;IAEjB,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAe,EAAE,CAAC;IAE7B,IAAA,cAAG,EACD,QAAQ,EACR,CAAC,IAAI,EAAE,EAAE;QACP,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9B,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QACnC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAC3B,IAAI,CACL,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC"}
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toVector3 = exports.toVector2 = exports.mod = exports.perpendicular = exports.exactEquals = exports.angle = exports.normalize = exports.manhattanDistance = exports.distance = exports.scale = exports.cross = exports.dot = exports.divide = exports.multiply = exports.subtract = exports.add = void 0;
3
+ exports.add = add;
4
+ exports.subtract = subtract;
5
+ exports.multiply = multiply;
6
+ exports.divide = divide;
7
+ exports.dot = dot;
8
+ exports.cross = cross;
9
+ exports.scale = scale;
10
+ exports.distance = distance;
11
+ exports.manhattanDistance = manhattanDistance;
12
+ exports.normalize = normalize;
13
+ exports.angle = angle;
14
+ exports.exactEquals = exactEquals;
15
+ exports.perpendicular = perpendicular;
16
+ exports.mod = mod;
17
+ exports.toVector2 = toVector2;
18
+ exports.toVector3 = toVector3;
4
19
  const is_1 = require("./is");
5
20
  const VECTOR_ZERO = [0, 0, 0];
6
21
  /**
@@ -14,7 +29,6 @@ const VECTOR_ZERO = [0, 0, 0];
14
29
  function add(a, b) {
15
30
  return a.map((v, i) => v + b[i]);
16
31
  }
17
- exports.add = add;
18
32
  /**
19
33
  * <zh/> 两个向量求差
20
34
  *
@@ -26,7 +40,6 @@ exports.add = add;
26
40
  function subtract(a, b) {
27
41
  return a.map((v, i) => v - b[i]);
28
42
  }
29
- exports.subtract = subtract;
30
43
  /**
31
44
  * <zh/> 两个向量求积或者向量和标量求积
32
45
  *
@@ -40,7 +53,6 @@ function multiply(a, b) {
40
53
  return a.map((v) => v * b);
41
54
  return a.map((v, i) => v * b[i]);
42
55
  }
43
- exports.multiply = multiply;
44
56
  /**
45
57
  * <zh/> 两个向量求商或者向量和标量求商
46
58
  *
@@ -54,7 +66,6 @@ function divide(a, b) {
54
66
  return a.map((v) => v / b);
55
67
  return a.map((v, i) => v / b[i]);
56
68
  }
57
- exports.divide = divide;
58
69
  /**
59
70
  * <zh/> 两个向量求点积
60
71
  *
@@ -66,7 +77,6 @@ exports.divide = divide;
66
77
  function dot(a, b) {
67
78
  return a.reduce((sum, v, i) => sum + v * b[i], 0);
68
79
  }
69
- exports.dot = dot;
70
80
  /**
71
81
  * <zh/> 两个二维向量求叉积
72
82
  *
@@ -80,7 +90,6 @@ function cross(a, b) {
80
90
  const b2 = toVector3(b);
81
91
  return [a2[1] * b2[2] - a2[2] * b2[1], a2[2] * b2[0] - a2[0] * b2[2], a2[0] * b2[1] - a2[1] * b2[0]];
82
92
  }
83
- exports.cross = cross;
84
93
  /**
85
94
  * <zh/> 向量缩放
86
95
  *
@@ -92,7 +101,6 @@ exports.cross = cross;
92
101
  function scale(a, s) {
93
102
  return a.map((v) => v * s);
94
103
  }
95
- exports.scale = scale;
96
104
  /**
97
105
  * <zh/> 计算两个向量间的欧几里得距离
98
106
  *
@@ -104,7 +112,6 @@ exports.scale = scale;
104
112
  function distance(a, b) {
105
113
  return Math.sqrt(a.reduce((sum, v, i) => sum + (v - b[i] || 0) ** 2, 0));
106
114
  }
107
- exports.distance = distance;
108
115
  /**
109
116
  * <zh/> 计算两个向量间的曼哈顿距离
110
117
  *
@@ -116,7 +123,6 @@ exports.distance = distance;
116
123
  function manhattanDistance(a, b) {
117
124
  return a.reduce((sum, v, i) => sum + Math.abs(v - b[i]), 0);
118
125
  }
119
- exports.manhattanDistance = manhattanDistance;
120
126
  /**
121
127
  * <zh/> 标准化向量(使长度为 1)
122
128
  *
@@ -128,7 +134,6 @@ function normalize(a) {
128
134
  const length = a.reduce((sum, v) => sum + v ** 2, 0);
129
135
  return a.map((v) => v / Math.sqrt(length));
130
136
  }
131
- exports.normalize = normalize;
132
137
  /**
133
138
  * <zh/> 计算两个向量间的夹角,输出为锐角余弦值
134
139
  *
@@ -148,7 +153,6 @@ function angle(a, b, clockwise = false) {
148
153
  }
149
154
  return angle;
150
155
  }
151
- exports.angle = angle;
152
156
  /**
153
157
  * <zh/> 判断两个向量是否完全相等(使用 === 比较)
154
158
  *
@@ -160,7 +164,6 @@ exports.angle = angle;
160
164
  function exactEquals(a, b) {
161
165
  return a.every((v, i) => v === b[i]);
162
166
  }
163
- exports.exactEquals = exactEquals;
164
167
  /**
165
168
  * <zh/> 计算向量的垂直向量
166
169
  *
@@ -172,7 +175,6 @@ exports.exactEquals = exactEquals;
172
175
  function perpendicular(a, clockwise = true) {
173
176
  return clockwise ? [-a[1], a[0]] : [a[1], -a[0]];
174
177
  }
175
- exports.perpendicular = perpendicular;
176
178
  /**
177
179
  * <zh/> 计算向量的模
178
180
  *
@@ -184,7 +186,6 @@ exports.perpendicular = perpendicular;
184
186
  function mod(a, b) {
185
187
  return a.map((v) => v % b);
186
188
  }
187
- exports.mod = mod;
188
189
  /**
189
190
  * <zh/> 向量强制转换为二维向量
190
191
  *
@@ -195,7 +196,6 @@ exports.mod = mod;
195
196
  function toVector2(a) {
196
197
  return [a[0], a[1]];
197
198
  }
198
- exports.toVector2 = toVector2;
199
199
  /**
200
200
  * <zh/> 向量强制转换为三维向量
201
201
  *
@@ -206,5 +206,4 @@ exports.toVector2 = toVector2;
206
206
  function toVector3(a) {
207
207
  return (0, is_1.isVector2)(a) ? [a[0], a[1], 0] : a;
208
208
  }
209
- exports.toVector3 = toVector3;
210
209
  //# sourceMappingURL=vector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vector.js","sourceRoot":"src/","sources":["utils/vector.ts"],"names":[],"mappings":";;;AACA,6BAAiC;AAEjC,MAAM,WAAW,GAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEvC;;;;;;;GAOG;AACH,SAAgB,GAAG,CAAC,CAAoB,EAAE,CAAoB;IAC5D,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAsB,CAAC;AACxD,CAAC;AAFD,kBAEC;AAED;;;;;;;GAOG;AACH,SAAgB,QAAQ,CAAC,CAAoB,EAAE,CAAoB;IACjE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAsB,CAAC;AACxD,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAgB,QAAQ,CAAC,CAAoB,EAAE,CAA6B;IAC1E,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,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;AACH,SAAgB,aAAa,CAAC,CAAU,EAAE,SAAS,GAAG,IAAI;IACxD,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,GAAG,CAAC,CAAoB,EAAE,CAAS;IACjD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAsB,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,CAAoB;IAC5C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,CAAoB;IAC5C,OAAO,IAAA,cAAS,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setVisibility = void 0;
3
+ exports.setVisibility = setVisibility;
4
4
  const cache_1 = require("./cache");
5
5
  const shape_1 = require("./shape");
6
6
  const PropertyKey = 'visibility';
@@ -28,5 +28,4 @@ function setVisibility(shape, visibility) {
28
28
  sp.style.visibility = visibility;
29
29
  });
30
30
  }
31
- exports.setVisibility = setVisibility;
32
31
  //# sourceMappingURL=visibility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"visibility.js","sourceRoot":"src/","sources":["utils/visibility.ts"],"names":[],"mappings":";;;AACA,mCAAqE;A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EzD,sBAAsB;QACtB,+CAA+C;QAC/C,IAAI,KAAK,KAAK,EAAE,IAAI,gBAAgB,KAAK,QAAQ;YAAE,OAAO;QAE1D,EAAE,CAAC,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const version = "5.0.4";
package/lib/version.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = void 0;
4
+ exports.version = '5.0.4';
5
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"src/","sources":["version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g6",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "A Graph Visualization Framework in JavaScript",
5
5
  "keywords": [
6
6
  "antv",
@@ -28,7 +28,8 @@
28
28
  "src",
29
29
  "esm",
30
30
  "lib",
31
- "dist"
31
+ "dist",
32
+ "README"
32
33
  ],
33
34
  "dependencies": {
34
35
  "@antv/component": "^2.0.1",
@@ -82,12 +83,14 @@
82
83
  "fix": "eslint ./src ./__tests__ --fix && prettier ./src __tests__ --write ",
83
84
  "jest": "node --expose-gc --max-old-space-size=1024 --unhandled-rejections=strict ../../node_modules/jest/bin/jest --coverage --logHeapUsage --detectOpenHandles",
84
85
  "lint": "eslint ./src __tests__ --quiet && prettier ./src __tests__ --check",
86
+ "readme": "cp ../../README.* ./",
85
87
  "size": "limit-size",
86
88
  "start": "rimraf ./lib && tsc --module commonjs --outDir lib --watch",
87
89
  "tag": "node ./scripts/tag.mjs",
88
90
  "test": "jest",
89
91
  "test:integration": "npm run jest __tests__/integration",
90
92
  "test:unit": "npm run jest __tests__/unit",
91
- "type-check": "tsc --noEmit"
93
+ "type-check": "tsc --noEmit",
94
+ "version": "node ./scripts/version.mjs"
92
95
  }
93
96
  }
@@ -3,4 +3,4 @@ import type { CustomBehaviorOption } from '../spec/behavior';
3
3
 
4
4
  export interface BaseBehaviorOptions extends CustomBehaviorOption {}
5
5
 
6
- export abstract class BaseBehavior<T extends BaseBehaviorOptions> extends BaseExtension<T> {}
6
+ export abstract class BaseBehavior<T extends BaseBehaviorOptions = BaseBehaviorOptions> extends BaseExtension<T> {}
@@ -63,7 +63,7 @@ export interface ScrollCanvasOptions extends BaseBehaviorOptions {
63
63
  * <en/> Scroll canvas behavior
64
64
  */
65
65
  export class ScrollCanvas extends BaseBehavior<ScrollCanvasOptions> {
66
- static defaultOptions: ScrollCanvasOptions = {
66
+ static defaultOptions: Partial<ScrollCanvasOptions> = {
67
67
  enable: true,
68
68
  sensitivity: 1,
69
69
  };
@@ -1,7 +1,3 @@
1
1
  import type { BaseBehavior } from './base-behavior';
2
- import type { DragCanvasOptions } from './drag-canvas';
3
- import type { ScrollCanvasOptions } from './scroll-canvas';
4
- import type { ZoomCanvasOptions } from './zoom-canvas';
5
2
 
6
- export type BuiltInBehaviorOptions = DragCanvasOptions | ZoomCanvasOptions | ScrollCanvasOptions;
7
3
  export type Behavior = BaseBehavior<any>;
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ import './preset';
2
2
 
3
3
  export * from './exports';
4
4
 
5
- export const version = '5.0.3';
5
+ export { version } from './version';
6
6
  export const iconfont = {
7
7
  css: '//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.css',
8
8
  js: '//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.js',
@@ -137,12 +137,12 @@ export class CameraSetting extends BasePlugin<CameraSettingOptions> {
137
137
  azimuth: 'setAzimuth',
138
138
  } as const;
139
139
 
140
- const valueMapper = <T extends keyof CameraSettingOptions>(key: T, value: CameraSettingOptions[T]) => {
140
+ const valueMapper = (key: string, value: string) => {
141
141
  switch (key) {
142
142
  case 'projectionMode':
143
143
  return value === 'perspective' ? 1 : 0;
144
144
  case 'cameraType':
145
- return { orbiting: 0, exploring: 1, tracking: 2 }[value];
145
+ return { orbiting: 0, exploring: 1, tracking: 2 }[value]!;
146
146
  case 'aspect':
147
147
  if (typeof value === 'number') return value;
148
148
  return this.getCanvasAspect();
@@ -1,5 +1,3 @@
1
1
  import type { BasePlugin } from './base-plugin';
2
- import type { GridLineOptions } from './grid-line';
3
2
 
4
- export type BuiltInPluginOptions = GridLineOptions;
5
3
  export type Plugin = BasePlugin<any>;
@@ -1,17 +1,18 @@
1
1
  import type EventEmitter from '@antv/event-emitter';
2
2
  import { getExtension } from '..';
3
+ import type { Graph } from '../../runtime/graph';
3
4
  import type { RuntimeContext } from '../../runtime/types';
4
5
  import type { IEvent } from '../../types';
5
6
  import { arrayDiff } from '../../utils/diff';
6
7
  import { parseExtensions } from '../../utils/extension';
7
- import type { ExtensionOptions, LooselyExtensionOption, STDExtensionOption } from './types';
8
+ import type { STDExtensionOption } from './types';
8
9
 
9
- export abstract class ExtensionController<Extension extends BaseExtension<LooselyExtensionOption>> {
10
+ export abstract class ExtensionController<E extends BaseExtension<any>> {
10
11
  protected context: RuntimeContext;
11
12
 
12
13
  protected extensions: STDExtensionOption[] = [];
13
14
 
14
- protected extensionMap: Record<string, Extension> = {};
15
+ protected extensionMap: Record<string, E> = {};
15
16
 
16
17
  public abstract category: 'plugin' | 'behavior' | 'transform';
17
18
 
@@ -19,8 +20,14 @@ export abstract class ExtensionController<Extension extends BaseExtension<Loosel
19
20
  this.context = context;
20
21
  }
21
22
 
22
- public setExtensions(extensions: ExtensionOptions) {
23
- const stdExtensions = parseExtensions(this.category, extensions) as STDExtensionOption[];
23
+ public setExtensions(
24
+ extensions: (
25
+ | string
26
+ | { type: string; [keys: string]: unknown }
27
+ | ((this: Graph) => { type: string; [keys: string]: unknown })
28
+ )[],
29
+ ) {
30
+ const stdExtensions = parseExtensions(this.context.graph, this.category, extensions) as STDExtensionOption[];
24
31
  const { enter, update, exit, keep } = arrayDiff(this.extensions, stdExtensions, (extension) => extension.key);
25
32
 
26
33
  this.createExtensions(enter);
@@ -38,7 +45,7 @@ export abstract class ExtensionController<Extension extends BaseExtension<Loosel
38
45
  if (!Ctor) return;
39
46
 
40
47
  const instance = new Ctor(this.context, extension);
41
- this.extensionMap[key] = instance as Extension;
48
+ this.extensionMap[key] = instance as E;
42
49
  }
43
50
 
44
51
  protected createExtensions(extensions: STDExtensionOption[]) {
@@ -83,7 +90,7 @@ export abstract class ExtensionController<Extension extends BaseExtension<Loosel
83
90
  *
84
91
  * <en/> Base class for extension instance
85
92
  */
86
- export class BaseExtension<T extends LooselyExtensionOption> {
93
+ export class BaseExtension<T extends { type: string; key?: string; [key: string]: unknown }> {
87
94
  protected context: RuntimeContext;
88
95
 
89
96
  protected options: Required<T>;
@@ -92,7 +99,7 @@ export class BaseExtension<T extends LooselyExtensionOption> {
92
99
 
93
100
  public destroyed = false;
94
101
 
95
- constructor(context: RuntimeContext, options: T) {
102
+ constructor(context: RuntimeContext, options: Partial<T>) {
96
103
  this.context = context;
97
104
  this.options = options as Required<T>;
98
105
  }
@@ -1,45 +1,20 @@
1
- interface ExtensionMetaOptions {
2
- type: string;
3
- key: string;
4
- }
5
-
6
- interface CustomExtensionOptions {
7
- [key: string]: any;
8
- }
9
-
10
- /**
11
- * <zh/> 扩展配置项
12
- *
13
- * <en/> Extension options
14
- */
15
- export type ExtensionOptions<Registry extends CustomExtensionOptions = CustomExtensionOptions> = ExtensionOption<
16
- Registry | LooselyExtensionOption
17
- >[];
18
-
19
- /**
20
- * <zh/> 扩展配置项
21
- *
22
- * <en/> Extension option
23
- */
24
- type ExtensionOption<Registry extends CustomExtensionOptions> = AbbrExtensionOption<Registry>;
25
-
26
1
  /**
27
2
  * <zh/> 标准扩展配置项
28
3
  *
29
4
  * <en/> Standard extension options
30
5
  */
31
- export type STDExtensionOption = ExtensionMetaOptions & CustomExtensionOptions;
32
-
33
- /**
34
- * <zh/> 宽松的扩展配置项,可以不传入 key
35
- *
36
- * <en/> Loosely extension option, key can be omitted
37
- */
38
- export type LooselyExtensionOption = Partial<ExtensionMetaOptions> & CustomExtensionOptions;
39
-
40
- /**
41
- * <zh/> 扩展配置项简写,支持直接传入 type 字符串
42
- *
43
- * <en/> Extension option abbreviation, support directly passing in type string
44
- */
45
- type AbbrExtensionOption<S extends LooselyExtensionOption> = S | S['type'];
6
+ export interface STDExtensionOption {
7
+ /**
8
+ * <zh/> 扩展类型
9
+ *
10
+ * <en/> Extension type
11
+ */
12
+ type: string;
13
+ /**
14
+ * <zh/> 扩展 key,即唯一标识
15
+ *
16
+ * <en/> Extension key, that is, the unique identifier
17
+ */
18
+ key: string;
19
+ [key: string]: unknown;
20
+ }
@@ -68,7 +68,7 @@ export class ElementController {
68
68
  }
69
69
 
70
70
  public getElementType(elementType: ElementType, datum: ElementDatum) {
71
- const { options } = this.context;
71
+ const { options, graph } = this.context;
72
72
  const userDefinedType = options[elementType]?.type || datum.type;
73
73
 
74
74
  if (!userDefinedType) {
@@ -77,7 +77,8 @@ export class ElementController {
77
77
  else return 'circle';
78
78
  }
79
79
  if (typeof userDefinedType === 'string') return userDefinedType;
80
- return userDefinedType(datum as any);
80
+ // @ts-expect-error skip type check
81
+ return userDefinedType.call(graph, datum);
81
82
  }
82
83
 
83
84
  private getTheme(elementType: ElementType) {
@@ -134,12 +135,13 @@ export class ElementController {
134
135
  }
135
136
 
136
137
  private computeElementsDefaultStyle(ids?: ID[]) {
138
+ const { graph } = this.context;
137
139
  this.forEachElementData((elementType, elementData) => {
138
140
  const length = elementData.length;
139
141
  for (let i = 0; i < length; i++) {
140
142
  const datum = elementData[i];
141
143
  if (ids === undefined || ids.includes(idOf(datum))) {
142
- this.computeElementDefaultStyle(elementType, { datum });
144
+ this.computeElementDefaultStyle(elementType, { datum, graph });
143
145
  }
144
146
  }
145
147
  });
@@ -190,13 +192,14 @@ export class ElementController {
190
192
  * @param ids - <zh/> 计算指定元素的状态样式 | <en/> compute state style of specified elements
191
193
  */
192
194
  private computeElementsStatesStyle(ids?: ID[]) {
195
+ const { graph } = this.context;
193
196
  this.forEachElementData((elementType, elementData) => {
194
197
  const length = elementData.length;
195
198
  for (let i = 0; i < length; i++) {
196
199
  const datum = elementData[i];
197
200
  if (ids === undefined || ids.includes(idOf(datum))) {
198
201
  const states = this.getElementState(idOf(datum));
199
- this.computeElementStatesStyle(elementType, states, { datum });
202
+ this.computeElementStatesStyle(elementType, states, { datum, graph });
200
203
  }
201
204
  }
202
205
  });
@@ -355,7 +355,7 @@ export class Graph extends EventEmitter {
355
355
  public updateBehavior(behavior: UpdateBehaviorOption): void {
356
356
  this.setBehaviors((behaviors) =>
357
357
  behaviors.map((_behavior) => {
358
- if (isObject(_behavior) && _behavior.key === behavior.key) {
358
+ if (typeof _behavior === 'object' && _behavior.key === behavior.key) {
359
359
  return { ..._behavior, ...behavior };
360
360
  }
361
361
  return _behavior;
@@ -414,7 +414,7 @@ export class Graph extends EventEmitter {
414
414
  public updatePlugin(plugin: UpdatePluginOption): void {
415
415
  this.setPlugins((plugins) =>
416
416
  plugins.map((_plugin) => {
417
- if (isObject(_plugin) && _plugin.key === plugin.key) {
417
+ if (typeof _plugin === 'object' && _plugin.key === plugin.key) {
418
418
  return { ..._plugin, ...plugin };
419
419
  }
420
420
  return _plugin;
@@ -482,7 +482,7 @@ export class Graph extends EventEmitter {
482
482
  public updateTransform(transform: UpdateTransformOption): void {
483
483
  this.setTransforms((transforms) =>
484
484
  transforms.map((_transform) => {
485
- if (isObject(_transform) && _transform.key === transform.key) {
485
+ if (typeof _transform === 'object' && _transform.key === transform.key) {
486
486
  return { ..._transform, ...transform };
487
487
  }
488
488
  return _transform;
@@ -1,11 +1,10 @@
1
- import type { BuiltInBehaviorOptions } from '../behaviors/types';
2
- import type { ExtensionOptions } from '../registry/extension/types';
1
+ import type { Graph } from '../runtime/graph';
3
2
 
4
- export type BehaviorOptions = ExtensionOptions<BuiltInBehaviorOptions>;
3
+ export type BehaviorOptions = (string | CustomBehaviorOption | ((this: Graph) => CustomBehaviorOption))[];
5
4
 
6
5
  export interface UpdateBehaviorOption {
7
6
  key: string;
8
- [key: string]: any;
7
+ [key: string]: unknown;
9
8
  }
10
9
 
11
10
  export interface CustomBehaviorOption extends Record<string, any> {
@@ -14,7 +13,7 @@ export interface CustomBehaviorOption extends Record<string, any> {
14
13
  *
15
14
  * <en/> Behavior type
16
15
  */
17
- type?: string;
16
+ type: string;
18
17
  /**
19
18
  * <zh/> 交互 key,即唯一标识
20
19
  *
@@ -1,6 +1,6 @@
1
1
  import type { AnimationOptions } from '../../animations/types';
2
2
  import type { BaseComboStyleProps } from '../../elements/combos';
3
- import type { CallableObject } from '../../types';
3
+ import type { Graph } from '../../runtime/graph';
4
4
  import type { ComboData } from '../data';
5
5
  import type { AnimationStage } from './animation';
6
6
  import type { PaletteOptions } from './palette';
@@ -16,19 +16,31 @@ export interface ComboOptions {
16
16
  *
17
17
  * <en/> Combo type
18
18
  */
19
- type?: string | ((datum: ComboData) => string);
19
+ type?: string | ((this: Graph, datum: ComboData) => string);
20
20
  /**
21
21
  * <zh/> 组合样式
22
22
  *
23
23
  * <en/> Combo style
24
24
  */
25
- style?: CallableObject<ComboStyle, ComboData>;
25
+ style?:
26
+ | ComboStyle
27
+ | ((this: Graph, data: ComboData) => ComboStyle)
28
+ | {
29
+ [K in keyof ComboStyle]: ComboStyle[K] | ((this: Graph, data: ComboData) => ComboStyle[K]);
30
+ };
26
31
  /**
27
32
  * <zh/> 组合状态样式
28
33
  *
29
34
  * <en/> Combo state style
30
35
  */
31
- state?: Record<string, CallableObject<ComboStyle, ComboData>>;
36
+ state?: Record<
37
+ string,
38
+ | ComboStyle
39
+ | ((this: Graph, data: ComboData) => ComboStyle)
40
+ | {
41
+ [K in keyof ComboStyle]: ComboStyle[K] | ((this: Graph, data: ComboData) => ComboStyle[K]);
42
+ }
43
+ >;
32
44
  /**
33
45
  * <zh/> 组合动画
34
46
  *
@@ -1,6 +1,6 @@
1
1
  import type { AnimationOptions } from '../../animations/types';
2
2
  import type { BaseEdgeStyleProps } from '../../elements/edges';
3
- import type { CallableObject } from '../../types';
3
+ import type { Graph } from '../../runtime/graph';
4
4
  import type { EdgeData } from '../data';
5
5
  import type { AnimationStage } from './animation';
6
6
  import type { PaletteOptions } from './palette';
@@ -16,19 +16,31 @@ export interface EdgeOptions {
16
16
  *
17
17
  * <en/> Edge type
18
18
  */
19
- type?: string | ((datum: EdgeData) => string);
19
+ type?: string | ((this: Graph, datum: EdgeData) => string);
20
20
  /**
21
21
  * <zh/> 边样式
22
22
  *
23
23
  * <en/> Edge style
24
24
  */
25
- style?: CallableObject<EdgeStyle, EdgeData>;
25
+ style?:
26
+ | EdgeStyle
27
+ | ((this: Graph, data: EdgeData) => EdgeStyle)
28
+ | {
29
+ [K in keyof EdgeStyle]: EdgeStyle[K] | ((this: Graph, data: EdgeData) => EdgeStyle[K]);
30
+ };
26
31
  /**
27
32
  * <zh/> 边状态样式
28
33
  *
29
34
  * <en/> Edge state style
30
35
  */
31
- state?: Record<string, CallableObject<EdgeStyle, EdgeData>>;
36
+ state?: Record<
37
+ string,
38
+ | EdgeStyle
39
+ | ((this: Graph, data: EdgeData) => EdgeStyle)
40
+ | {
41
+ [K in keyof EdgeStyle]: EdgeStyle[K] | ((this: Graph, data: EdgeData) => EdgeStyle[K]);
42
+ }
43
+ >;
32
44
  /**
33
45
  * <zh/> 边动画
34
46
  *
@@ -1,6 +1,6 @@
1
1
  import type { AnimationOptions } from '../../animations/types';
2
2
  import type { BaseNodeStyleProps } from '../../elements/nodes';
3
- import type { CallableObject } from '../../types';
3
+ import type { Graph } from '../../runtime/graph';
4
4
  import type { NodeData } from '../data';
5
5
  import type { AnimationStage } from './animation';
6
6
  import type { PaletteOptions } from './palette';
@@ -16,19 +16,31 @@ export interface NodeOptions {
16
16
  *
17
17
  * <en/> Node type
18
18
  */
19
- type?: string | ((datum: NodeData) => string);
19
+ type?: string | ((this: Graph, datum: NodeData) => string);
20
20
  /**
21
21
  * <zh/> 节点样式
22
22
  *
23
23
  * <en/> Node style
24
24
  */
25
- style?: CallableObject<NodeStyle, NodeData>;
25
+ style?:
26
+ | NodeStyle
27
+ | ((this: Graph, data: NodeData) => NodeStyle)
28
+ | {
29
+ [K in keyof NodeStyle]: NodeStyle[K] | ((this: Graph, data: NodeData) => NodeStyle[K]);
30
+ };
26
31
  /**
27
32
  * <zh/> 节点状态样式
28
33
  *
29
34
  * <en/> Node state style
30
35
  */
31
- state?: Record<string, CallableObject<NodeStyle, NodeData>>;
36
+ state?: Record<
37
+ string,
38
+ | NodeStyle
39
+ | ((this: Graph, data: NodeData) => NodeStyle)
40
+ | {
41
+ [K in keyof NodeStyle]: NodeStyle[K] | ((this: Graph, data: NodeData) => NodeStyle[K]);
42
+ }
43
+ >;
32
44
  /**
33
45
  * <zh/> 节点动画
34
46
  *