@visactor/vrender-core 0.18.0-alpha.0 → 0.18.0-alpha.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 (361) hide show
  1. package/cjs/common/canvas-utils.js +2 -2
  2. package/cjs/common/canvas-utils.js.map +1 -1
  3. package/cjs/common/color-utils.d.ts +9 -0
  4. package/cjs/common/color-utils.js +231 -0
  5. package/cjs/common/color-utils.js.map +1 -0
  6. package/cjs/common/rect-utils.d.ts +7 -0
  7. package/cjs/common/rect-utils.js +27 -0
  8. package/cjs/common/rect-utils.js.map +1 -0
  9. package/cjs/common/render-area.js +3 -15
  10. package/cjs/common/render-area.js.map +1 -1
  11. package/cjs/common/render-curve.js +4 -16
  12. package/cjs/common/render-curve.js.map +1 -1
  13. package/cjs/common/render-utils.d.ts +10 -0
  14. package/cjs/common/render-utils.js +22 -0
  15. package/cjs/common/render-utils.js.map +1 -0
  16. package/cjs/common/segment/basis.js +2 -3
  17. package/cjs/common/segment/basis.js.map +1 -1
  18. package/cjs/common/segment/common.d.ts +4 -1
  19. package/cjs/common/segment/common.js +13 -3
  20. package/cjs/common/segment/common.js.map +1 -1
  21. package/cjs/common/segment/linear-closed.d.ts +2 -16
  22. package/cjs/common/segment/linear-closed.js +3 -34
  23. package/cjs/common/segment/linear-closed.js.map +1 -1
  24. package/cjs/common/segment/linear.d.ts +1 -1
  25. package/cjs/common/segment/linear.js +2 -3
  26. package/cjs/common/segment/linear.js.map +1 -1
  27. package/cjs/common/segment/monotone.d.ts +2 -2
  28. package/cjs/common/segment/monotone.js +10 -12
  29. package/cjs/common/segment/monotone.js.map +1 -1
  30. package/cjs/common/sort.js +2 -1
  31. package/cjs/common/split-path.js +2 -2
  32. package/cjs/common/split-path.js.map +1 -1
  33. package/cjs/core/application.js +1 -1
  34. package/cjs/core/camera.js +1 -1
  35. package/cjs/core/constants.js +1 -1
  36. package/cjs/core/stage.d.ts +2 -1
  37. package/cjs/core/stage.js +12 -5
  38. package/cjs/core/stage.js.map +1 -1
  39. package/cjs/env-check.js +17 -17
  40. package/cjs/env-check.js.map +1 -1
  41. package/cjs/event/event-system.js +3 -3
  42. package/cjs/event/event-system.js.map +1 -1
  43. package/cjs/graphic/arc.js +1 -1
  44. package/cjs/graphic/arc.js.map +1 -1
  45. package/cjs/graphic/arc3d.js +1 -1
  46. package/cjs/graphic/arc3d.js.map +1 -1
  47. package/cjs/graphic/area.js +1 -1
  48. package/cjs/graphic/area.js.map +1 -1
  49. package/cjs/graphic/bounds.d.ts +2 -2
  50. package/cjs/graphic/bounds.js +1 -1
  51. package/cjs/graphic/bounds.js.map +1 -1
  52. package/cjs/graphic/circle.js +1 -1
  53. package/cjs/graphic/circle.js.map +1 -1
  54. package/cjs/graphic/config.js +5 -1
  55. package/cjs/graphic/config.js.map +1 -1
  56. package/cjs/graphic/glyph.js +1 -1
  57. package/cjs/graphic/glyph.js.map +1 -1
  58. package/cjs/graphic/graphic-service/graphic-service.js +13 -11
  59. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  60. package/cjs/graphic/graphic.d.ts +1 -0
  61. package/cjs/graphic/graphic.js +8 -6
  62. package/cjs/graphic/graphic.js.map +1 -1
  63. package/cjs/graphic/group.d.ts +1 -1
  64. package/cjs/graphic/group.js +3 -3
  65. package/cjs/graphic/group.js.map +1 -1
  66. package/cjs/graphic/image.d.ts +3 -1
  67. package/cjs/graphic/image.js +7 -1
  68. package/cjs/graphic/image.js.map +1 -1
  69. package/cjs/graphic/line.js +1 -1
  70. package/cjs/graphic/line.js.map +1 -1
  71. package/cjs/graphic/node-tree.d.ts +1 -1
  72. package/cjs/graphic/node-tree.js +6 -2
  73. package/cjs/graphic/node-tree.js.map +1 -1
  74. package/cjs/graphic/path.js +1 -1
  75. package/cjs/graphic/path.js.map +1 -1
  76. package/cjs/graphic/polygon.js +1 -1
  77. package/cjs/graphic/polygon.js.map +1 -1
  78. package/cjs/graphic/pyramid3d.js +1 -1
  79. package/cjs/graphic/pyramid3d.js.map +1 -1
  80. package/cjs/graphic/rect.js +4 -7
  81. package/cjs/graphic/rect.js.map +1 -1
  82. package/cjs/graphic/richtext/frame.d.ts +2 -2
  83. package/cjs/graphic/richtext/frame.js +1 -12
  84. package/cjs/graphic/richtext/frame.js.map +1 -1
  85. package/cjs/graphic/richtext/line.js +1 -12
  86. package/cjs/graphic/richtext/line.js.map +1 -1
  87. package/cjs/graphic/richtext/paragraph.js +2 -2
  88. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  89. package/cjs/graphic/richtext.d.ts +45 -2
  90. package/cjs/graphic/richtext.js +22 -7
  91. package/cjs/graphic/richtext.js.map +1 -1
  92. package/cjs/graphic/symbol.js +1 -1
  93. package/cjs/graphic/symbol.js.map +1 -1
  94. package/cjs/graphic/text.js +4 -4
  95. package/cjs/graphic/text.js.map +1 -1
  96. package/cjs/graphic/theme.js +1 -1
  97. package/cjs/graphic/theme.js.map +1 -1
  98. package/cjs/interface/event.d.ts +2 -0
  99. package/cjs/interface/event.js.map +1 -1
  100. package/cjs/interface/graphic/richText.d.ts +2 -2
  101. package/cjs/interface/graphic/richText.js.map +1 -1
  102. package/cjs/interface/graphic/symbol.d.ts +1 -1
  103. package/cjs/interface/graphic/symbol.js.map +1 -1
  104. package/cjs/interface/graphic.d.ts +17 -3
  105. package/cjs/interface/graphic.js.map +1 -1
  106. package/cjs/interface/node-tree.d.ts +1 -1
  107. package/cjs/interface/node-tree.js.map +1 -1
  108. package/cjs/interface/picker.d.ts +1 -0
  109. package/cjs/interface/picker.js.map +1 -1
  110. package/cjs/interface/render.d.ts +1 -0
  111. package/cjs/interface/render.js.map +1 -1
  112. package/cjs/interface/stage.d.ts +7 -1
  113. package/cjs/interface/stage.js.map +1 -1
  114. package/cjs/modules.d.ts +3 -0
  115. package/cjs/modules.js +9 -10
  116. package/cjs/modules.js.map +1 -1
  117. package/cjs/picker/picker-service.js +8 -3
  118. package/cjs/picker/picker-service.js.map +1 -1
  119. package/cjs/plugins/builtin-plugin/flex-layout-plugin.d.ts +14 -3
  120. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +126 -65
  121. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  122. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +28 -25
  123. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
  124. package/cjs/render/contributions/render/area-render.js +9 -7
  125. package/cjs/render/contributions/render/area-render.js.map +1 -1
  126. package/cjs/render/contributions/render/contributions/arc-contribution-render.d.ts +1 -1
  127. package/cjs/render/contributions/render/contributions/arc-contribution-render.js +2 -2
  128. package/cjs/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
  129. package/cjs/render/contributions/render/contributions/area-contribution-render.d.ts +1 -9
  130. package/cjs/render/contributions/render/contributions/area-contribution-render.js +3 -55
  131. package/cjs/render/contributions/render/contributions/area-contribution-render.js.map +1 -1
  132. package/cjs/render/contributions/render/contributions/area-texture-contribution-render.d.ts +9 -0
  133. package/cjs/render/contributions/render/contributions/area-texture-contribution-render.js +26 -0
  134. package/cjs/render/contributions/render/contributions/area-texture-contribution-render.js.map +1 -0
  135. package/cjs/render/contributions/render/contributions/base-contribution-render.d.ts +2 -20
  136. package/cjs/render/contributions/render/contributions/base-contribution-render.js +25 -125
  137. package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  138. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.d.ts +21 -0
  139. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +128 -0
  140. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -0
  141. package/cjs/render/contributions/render/contributions/circle-contribution-render.d.ts +1 -1
  142. package/cjs/render/contributions/render/contributions/circle-contribution-render.js +2 -2
  143. package/cjs/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
  144. package/cjs/render/contributions/render/contributions/group-contribution-render.js +2 -2
  145. package/cjs/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  146. package/cjs/render/contributions/render/contributions/image-contribution-render.js +3 -2
  147. package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  148. package/cjs/render/contributions/render/contributions/index.d.ts +2 -0
  149. package/cjs/render/contributions/render/contributions/index.js +2 -1
  150. package/cjs/render/contributions/render/contributions/index.js.map +1 -1
  151. package/cjs/render/contributions/render/contributions/path-contribution-render.d.ts +1 -1
  152. package/cjs/render/contributions/render/contributions/path-contribution-render.js +2 -2
  153. package/cjs/render/contributions/render/contributions/path-contribution-render.js.map +1 -1
  154. package/cjs/render/contributions/render/contributions/polygon-contribution-render.d.ts +1 -1
  155. package/cjs/render/contributions/render/contributions/polygon-contribution-render.js +2 -2
  156. package/cjs/render/contributions/render/contributions/polygon-contribution-render.js.map +1 -1
  157. package/cjs/render/contributions/render/contributions/rect-contribution-render.d.ts +1 -1
  158. package/cjs/render/contributions/render/contributions/rect-contribution-render.js +2 -2
  159. package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  160. package/cjs/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -1
  161. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +2 -2
  162. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  163. package/cjs/render/contributions/render/contributions/text-contribution-render.js +23 -8
  164. package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  165. package/cjs/render/contributions/render/draw-contribution.js +11 -5
  166. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  167. package/cjs/render/contributions/render/image-render.js +4 -2
  168. package/cjs/render/contributions/render/image-render.js.map +1 -1
  169. package/cjs/render/contributions/render/incremental-draw-contribution.d.ts +0 -1
  170. package/cjs/render/contributions/render/incremental-draw-contribution.js +19 -15
  171. package/cjs/render/contributions/render/incremental-draw-contribution.js.map +1 -1
  172. package/cjs/render/contributions/render/index.d.ts +1 -0
  173. package/cjs/render/contributions/render/index.js +2 -1
  174. package/cjs/render/contributions/render/index.js.map +1 -1
  175. package/cjs/render/contributions/render/utils.d.ts +1 -1
  176. package/cjs/render/contributions/render/utils.js.map +1 -1
  177. package/cjs/resource-loader/loader.d.ts +5 -0
  178. package/cjs/resource-loader/loader.js +56 -15
  179. package/cjs/resource-loader/loader.js.map +1 -1
  180. package/es/common/canvas-utils.js +3 -1
  181. package/es/common/canvas-utils.js.map +1 -1
  182. package/es/common/color-utils.d.ts +9 -0
  183. package/es/common/color-utils.js +224 -0
  184. package/es/common/color-utils.js.map +1 -0
  185. package/es/common/rect-utils.d.ts +7 -0
  186. package/es/common/rect-utils.js +20 -0
  187. package/es/common/rect-utils.js.map +1 -0
  188. package/es/common/render-area.js +2 -12
  189. package/es/common/render-area.js.map +1 -1
  190. package/es/common/render-curve.js +2 -15
  191. package/es/common/render-curve.js.map +1 -1
  192. package/es/common/render-utils.d.ts +10 -0
  193. package/es/common/render-utils.js +14 -0
  194. package/es/common/render-utils.js.map +1 -0
  195. package/es/common/segment/basis.js +2 -8
  196. package/es/common/segment/basis.js.map +1 -1
  197. package/es/common/segment/common.d.ts +4 -1
  198. package/es/common/segment/common.js +11 -0
  199. package/es/common/segment/common.js.map +1 -1
  200. package/es/common/segment/linear-closed.d.ts +2 -16
  201. package/es/common/segment/linear-closed.js +4 -38
  202. package/es/common/segment/linear-closed.js.map +1 -1
  203. package/es/common/segment/linear.d.ts +1 -1
  204. package/es/common/segment/linear.js +2 -8
  205. package/es/common/segment/linear.js.map +1 -1
  206. package/es/common/segment/monotone.d.ts +2 -2
  207. package/es/common/segment/monotone.js +7 -13
  208. package/es/common/segment/monotone.js.map +1 -1
  209. package/es/common/sort.js +2 -1
  210. package/es/common/split-path.js +3 -1
  211. package/es/common/split-path.js.map +1 -1
  212. package/es/core/application.js +1 -1
  213. package/es/core/camera.js +1 -1
  214. package/es/core/constants.js +1 -1
  215. package/es/core/stage.d.ts +2 -1
  216. package/es/core/stage.js +12 -5
  217. package/es/core/stage.js.map +1 -1
  218. package/es/env-check.js +12 -13
  219. package/es/env-check.js.map +1 -1
  220. package/es/event/event-system.js +3 -3
  221. package/es/event/event-system.js.map +1 -1
  222. package/es/graphic/arc.js +1 -1
  223. package/es/graphic/arc.js.map +1 -1
  224. package/es/graphic/arc3d.js +1 -1
  225. package/es/graphic/arc3d.js.map +1 -1
  226. package/es/graphic/area.js +1 -1
  227. package/es/graphic/area.js.map +1 -1
  228. package/es/graphic/bounds.d.ts +2 -2
  229. package/es/graphic/bounds.js +1 -1
  230. package/es/graphic/bounds.js.map +1 -1
  231. package/es/graphic/circle.js +1 -1
  232. package/es/graphic/circle.js.map +1 -1
  233. package/es/graphic/config.js +5 -1
  234. package/es/graphic/config.js.map +1 -1
  235. package/es/graphic/glyph.js +1 -1
  236. package/es/graphic/glyph.js.map +1 -1
  237. package/es/graphic/graphic-service/graphic-service.js +13 -11
  238. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  239. package/es/graphic/graphic.d.ts +1 -0
  240. package/es/graphic/graphic.js +9 -7
  241. package/es/graphic/graphic.js.map +1 -1
  242. package/es/graphic/group.d.ts +1 -1
  243. package/es/graphic/group.js +3 -3
  244. package/es/graphic/group.js.map +1 -1
  245. package/es/graphic/image.d.ts +3 -1
  246. package/es/graphic/image.js +7 -1
  247. package/es/graphic/image.js.map +1 -1
  248. package/es/graphic/line.js +1 -1
  249. package/es/graphic/line.js.map +1 -1
  250. package/es/graphic/node-tree.d.ts +1 -1
  251. package/es/graphic/node-tree.js +6 -2
  252. package/es/graphic/node-tree.js.map +1 -1
  253. package/es/graphic/path.js +1 -1
  254. package/es/graphic/path.js.map +1 -1
  255. package/es/graphic/polygon.js +1 -1
  256. package/es/graphic/polygon.js.map +1 -1
  257. package/es/graphic/pyramid3d.js +1 -1
  258. package/es/graphic/pyramid3d.js.map +1 -1
  259. package/es/graphic/rect.js +4 -7
  260. package/es/graphic/rect.js.map +1 -1
  261. package/es/graphic/richtext/frame.d.ts +2 -2
  262. package/es/graphic/richtext/frame.js +1 -12
  263. package/es/graphic/richtext/frame.js.map +1 -1
  264. package/es/graphic/richtext/line.js +1 -12
  265. package/es/graphic/richtext/line.js.map +1 -1
  266. package/es/graphic/richtext/paragraph.js +2 -2
  267. package/es/graphic/richtext/paragraph.js.map +1 -1
  268. package/es/graphic/richtext.d.ts +45 -2
  269. package/es/graphic/richtext.js +23 -6
  270. package/es/graphic/richtext.js.map +1 -1
  271. package/es/graphic/symbol.js +1 -1
  272. package/es/graphic/symbol.js.map +1 -1
  273. package/es/graphic/text.js +4 -4
  274. package/es/graphic/text.js.map +1 -1
  275. package/es/graphic/theme.js +1 -1
  276. package/es/graphic/theme.js.map +1 -1
  277. package/es/interface/event.d.ts +2 -0
  278. package/es/interface/event.js.map +1 -1
  279. package/es/interface/graphic/richText.d.ts +2 -2
  280. package/es/interface/graphic/richText.js.map +1 -1
  281. package/es/interface/graphic/symbol.d.ts +1 -1
  282. package/es/interface/graphic/symbol.js.map +1 -1
  283. package/es/interface/graphic.d.ts +17 -3
  284. package/es/interface/graphic.js.map +1 -1
  285. package/es/interface/node-tree.d.ts +1 -1
  286. package/es/interface/node-tree.js.map +1 -1
  287. package/es/interface/picker.d.ts +1 -0
  288. package/es/interface/picker.js.map +1 -1
  289. package/es/interface/render.d.ts +1 -0
  290. package/es/interface/render.js.map +1 -1
  291. package/es/interface/stage.d.ts +7 -1
  292. package/es/interface/stage.js.map +1 -1
  293. package/es/modules.d.ts +3 -0
  294. package/es/modules.js +4 -6
  295. package/es/modules.js.map +1 -1
  296. package/es/picker/picker-service.js +8 -3
  297. package/es/picker/picker-service.js.map +1 -1
  298. package/es/plugins/builtin-plugin/flex-layout-plugin.d.ts +14 -3
  299. package/es/plugins/builtin-plugin/flex-layout-plugin.js +126 -69
  300. package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  301. package/es/plugins/builtin-plugin/html-attribute-plugin.js +28 -25
  302. package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
  303. package/es/render/contributions/render/area-render.js +9 -7
  304. package/es/render/contributions/render/area-render.js.map +1 -1
  305. package/es/render/contributions/render/contributions/arc-contribution-render.d.ts +1 -1
  306. package/es/render/contributions/render/contributions/arc-contribution-render.js +3 -1
  307. package/es/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
  308. package/es/render/contributions/render/contributions/area-contribution-render.d.ts +1 -9
  309. package/es/render/contributions/render/contributions/area-contribution-render.js +2 -51
  310. package/es/render/contributions/render/contributions/area-contribution-render.js.map +1 -1
  311. package/es/render/contributions/render/contributions/area-texture-contribution-render.d.ts +9 -0
  312. package/es/render/contributions/render/contributions/area-texture-contribution-render.js +18 -0
  313. package/es/render/contributions/render/contributions/area-texture-contribution-render.js.map +1 -0
  314. package/es/render/contributions/render/contributions/base-contribution-render.d.ts +2 -20
  315. package/es/render/contributions/render/contributions/base-contribution-render.js +23 -123
  316. package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  317. package/es/render/contributions/render/contributions/base-texture-contribution-render.d.ts +21 -0
  318. package/es/render/contributions/render/contributions/base-texture-contribution-render.js +124 -0
  319. package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -0
  320. package/es/render/contributions/render/contributions/circle-contribution-render.d.ts +1 -1
  321. package/es/render/contributions/render/contributions/circle-contribution-render.js +3 -1
  322. package/es/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
  323. package/es/render/contributions/render/contributions/group-contribution-render.js +2 -2
  324. package/es/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  325. package/es/render/contributions/render/contributions/image-contribution-render.js +3 -2
  326. package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  327. package/es/render/contributions/render/contributions/index.d.ts +2 -0
  328. package/es/render/contributions/render/contributions/index.js +4 -0
  329. package/es/render/contributions/render/contributions/index.js.map +1 -1
  330. package/es/render/contributions/render/contributions/path-contribution-render.d.ts +1 -1
  331. package/es/render/contributions/render/contributions/path-contribution-render.js +3 -1
  332. package/es/render/contributions/render/contributions/path-contribution-render.js.map +1 -1
  333. package/es/render/contributions/render/contributions/polygon-contribution-render.d.ts +1 -1
  334. package/es/render/contributions/render/contributions/polygon-contribution-render.js +3 -1
  335. package/es/render/contributions/render/contributions/polygon-contribution-render.js.map +1 -1
  336. package/es/render/contributions/render/contributions/rect-contribution-render.d.ts +1 -1
  337. package/es/render/contributions/render/contributions/rect-contribution-render.js +3 -1
  338. package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  339. package/es/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -1
  340. package/es/render/contributions/render/contributions/symbol-contribution-render.js +3 -1
  341. package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  342. package/es/render/contributions/render/contributions/text-contribution-render.js +28 -7
  343. package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  344. package/es/render/contributions/render/draw-contribution.js +11 -5
  345. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  346. package/es/render/contributions/render/image-render.js +6 -2
  347. package/es/render/contributions/render/image-render.js.map +1 -1
  348. package/es/render/contributions/render/incremental-draw-contribution.d.ts +0 -1
  349. package/es/render/contributions/render/incremental-draw-contribution.js +19 -15
  350. package/es/render/contributions/render/incremental-draw-contribution.js.map +1 -1
  351. package/es/render/contributions/render/index.d.ts +1 -0
  352. package/es/render/contributions/render/index.js +2 -0
  353. package/es/render/contributions/render/index.js.map +1 -1
  354. package/es/render/contributions/render/utils.d.ts +1 -1
  355. package/es/render/contributions/render/utils.js.map +1 -1
  356. package/es/resource-loader/loader.d.ts +5 -0
  357. package/es/resource-loader/loader.js +56 -14
  358. package/es/resource-loader/loader.js.map +1 -1
  359. package/package.json +6 -4
  360. package/dist/index.js +0 -27707
  361. package/dist/index.min.js +0 -1
@@ -2,11 +2,7 @@ import { getTheme } from "../../graphic";
2
2
 
3
3
  import { Generator } from "../../common/generator";
4
4
 
5
- import { isNumber } from "../../canvas/util";
6
-
7
- import { parsePadding } from "../../common/utils";
8
-
9
- import { AABBBounds, isArray } from "@visactor/vutils";
5
+ import { AABBBounds } from "@visactor/vutils";
10
6
 
11
7
  import { application } from "../../application";
12
8
 
@@ -17,25 +13,33 @@ export class FlexLayoutPlugin {
17
13
  this.name = "FlexLayoutPlugin", this.activeEvent = "onRegister", this.id = Generator.GenAutoIncrementId(),
18
14
  this.key = this.name + this.id, this.tempBounds = new AABBBounds;
19
15
  }
20
- tryLayout(graphic) {
21
- if (this.layouting) return;
22
- this.layouting = !0;
16
+ pauseLayout(p) {
17
+ this.pause = p;
18
+ }
19
+ tryLayoutChildren(graphic) {
20
+ graphic.firstChild && this.tryLayout(graphic.firstChild);
21
+ }
22
+ tryLayout(graphic, force = !0) {
23
+ if (this.pause) return;
23
24
  const p = graphic.parent;
24
- if (!p || !graphic.needUpdateLayout()) return;
25
+ if (!(force || p && graphic.needUpdateLayout())) return;
25
26
  const theme = getTheme(p).group, {display: display = theme.display} = p.attribute;
26
27
  if ("flex" !== display) return;
27
- const {flexDirection: flexDirection = theme.flexDirection, flexWrap: flexWrap = theme.flexWrap, justifyContent: justifyContent = theme.justifyContent, alignItems: alignItems = theme.alignItems, alignContent: alignContent = theme.alignContent, clip: clip = theme.clip} = p.attribute;
28
- let childrenWidth = 0, childrenHeight = 0, boundsLegal = 0;
29
- if (p.forEachChildren((child => {
30
- const bounds = child.AABBBounds;
31
- "column" === flexDirection || "column-reverse" === flexDirection ? (childrenHeight += bounds.height(),
32
- childrenWidth = Math.max(childrenWidth, bounds.width())) : (childrenWidth += bounds.width(),
33
- childrenHeight = Math.max(childrenHeight, bounds.height())), boundsLegal += bounds.x1,
34
- boundsLegal += bounds.y1, boundsLegal += bounds.x2, boundsLegal += bounds.y2;
35
- })), !isFinite(boundsLegal)) return;
36
- const width = p.attribute.width || childrenWidth, height = p.attribute.height || childrenHeight;
37
- p.attribute.width || (p.attribute.width = 0), p.attribute.height || (p.attribute.height = 0),
38
- this.tempBounds.copy(p._AABBBounds);
28
+ const {flexDirection: flexDirection = theme.flexDirection, flexWrap: flexWrap = theme.flexWrap, alignItems: alignItems = theme.alignItems, clip: clip = theme.clip} = p.attribute, {alignContent: alignContent = (null != alignItems ? alignItems : theme.alignContent)} = p.attribute;
29
+ let {width: width, height: height, justifyContent: justifyContent = theme.justifyContent} = p.attribute;
30
+ const children = p.getChildren();
31
+ if (null == width || null == height) {
32
+ let childrenWidth = 0, childrenHeight = 0, boundsLegal = 0;
33
+ if (children.forEach((child => {
34
+ const bounds = this.getAABBBounds(child);
35
+ bounds.empty() || ("column" === flexDirection || "column-reverse" === flexDirection ? (childrenHeight += bounds.height(),
36
+ childrenWidth = Math.max(childrenWidth, bounds.width())) : (childrenWidth += bounds.width(),
37
+ childrenHeight = Math.max(childrenHeight, bounds.height())), boundsLegal += bounds.x1,
38
+ boundsLegal += bounds.y1, boundsLegal += bounds.x2, boundsLegal += bounds.y2);
39
+ })), !isFinite(boundsLegal)) return;
40
+ width = childrenWidth, height = childrenHeight;
41
+ }
42
+ p.attribute.width = width, p.attribute.height = height, this.tempBounds.copy(p._AABBBounds);
39
43
  const result = {
40
44
  main: {
41
45
  len: width,
@@ -44,16 +48,16 @@ export class FlexLayoutPlugin {
44
48
  cross: {
45
49
  len: height,
46
50
  field: "y"
47
- },
48
- dir: 1
51
+ }
49
52
  }, main = result.main, cross = result.cross;
50
- "row-reverse" === flexDirection ? result.dir = -1 : "column" === flexDirection ? (main.len = height,
51
- cross.len = width, main.field = "y", cross.field = "x") : "column-reverse" === flexDirection && (main.len = height,
52
- cross.len = width, main.field = "y", cross.field = "x", result.dir = -1);
53
+ "column" !== flexDirection && "column-reverse" !== flexDirection || (main.len = height,
54
+ cross.len = width, main.field = "y", cross.field = "x"), "row-reverse" !== flexDirection && "column-reverse" !== flexDirection || ("flex-start" === justifyContent ? justifyContent = "flex-end" : "flex-end" === justifyContent ? justifyContent = "flex-start" : children.reverse());
53
55
  let mainLen = 0, crossLen = 0;
54
56
  const mianLenArray = [];
55
- p.forEachChildren((c => {
56
- const b = c.AABBBounds, ml = "x" === main.field ? b.width() : b.height(), cl = "x" === cross.field ? b.width() : b.height();
57
+ children.forEach((c => {
58
+ const b = this.getAABBBounds(c);
59
+ if (b.empty()) return;
60
+ const ml = "x" === main.field ? b.width() : b.height(), cl = "x" === cross.field ? b.width() : b.height();
57
61
  mianLenArray.push({
58
62
  mainLen: ml,
59
63
  crossLen: cl
@@ -82,30 +86,38 @@ export class FlexLayoutPlugin {
82
86
  mainLen: mainLen,
83
87
  crossLen: crossLen
84
88
  });
85
- const children = p.getChildren();
86
89
  let lastIdx = 0;
87
90
  if (mainList.forEach((s => {
88
91
  this.layoutMain(p, children, justifyContent, main, mianLenArray, lastIdx, s), lastIdx = s.idx + 1;
89
- })), crossLen = mainList.reduce(((a, b) => a + b.crossLen), 0), 1 === mainList.length) if ("flex-end" === alignItems) {
90
- const anchorPos = cross.len;
91
- this.layoutCross(children, alignItems, cross, anchorPos, mianLenArray, mainList[0], 0);
92
- } else if ("center" === alignItems) {
93
- const anchorPos = cross.len / 2;
94
- this.layoutCross(children, alignItems, cross, anchorPos, mianLenArray, mainList[0], 0);
95
- } else children.forEach((child => {
96
- child.attribute[cross.field] = getPadding(child, cross.field);
97
- })); else if ("flex-start" === alignContent) {
92
+ })), crossLen = mainList.reduce(((a, b) => a + b.crossLen), 0), 1 === mainList.length) {
93
+ const anchorPosMap = {
94
+ "flex-start": 0,
95
+ "flex-end": cross.len,
96
+ center: cross.len / 2
97
+ };
98
+ this.layoutCross(children, alignItems, cross, anchorPosMap, mianLenArray, mainList[0], 0);
99
+ } else if ("flex-start" === alignContent) {
98
100
  lastIdx = 0;
99
101
  let anchorPos = 0;
100
102
  mainList.forEach(((s, i) => {
101
- this.layoutCross(children, "flex-start", cross, anchorPos, mianLenArray, mainList[i], lastIdx),
103
+ const anchorPosMap = {
104
+ "flex-start": anchorPos,
105
+ "flex-end": anchorPos + s.crossLen,
106
+ center: anchorPos + s.crossLen / 2
107
+ };
108
+ this.layoutCross(children, "flex-start", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
102
109
  lastIdx = s.idx + 1, anchorPos += s.crossLen;
103
110
  }));
104
111
  } else if ("center" === alignContent) {
105
112
  lastIdx = 0;
106
113
  let anchorPos = Math.max(0, (cross.len - crossLen) / 2);
107
114
  mainList.forEach(((s, i) => {
108
- this.layoutCross(children, "center", cross, anchorPos + s.crossLen / 2, mianLenArray, mainList[i], lastIdx),
115
+ const anchorPosMap = {
116
+ "flex-start": anchorPos,
117
+ "flex-end": anchorPos + s.crossLen,
118
+ center: anchorPos + s.crossLen / 2
119
+ };
120
+ this.layoutCross(children, "center", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
109
121
  lastIdx = s.idx + 1, anchorPos += s.crossLen;
110
122
  }));
111
123
  } else if ("space-around" === alignContent) {
@@ -113,7 +125,12 @@ export class FlexLayoutPlugin {
113
125
  const padding = Math.max(0, (cross.len - crossLen) / mainList.length / 2);
114
126
  let anchorPos = padding;
115
127
  mainList.forEach(((s, i) => {
116
- this.layoutCross(children, "flex-start", cross, anchorPos, mianLenArray, mainList[i], lastIdx),
128
+ const anchorPosMap = {
129
+ "flex-start": anchorPos,
130
+ "flex-end": anchorPos + s.crossLen,
131
+ center: anchorPos + s.crossLen / 2
132
+ };
133
+ this.layoutCross(children, "flex-start", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
117
134
  lastIdx = s.idx + 1, anchorPos += s.crossLen + 2 * padding;
118
135
  }));
119
136
  } else if ("space-between" === alignContent) {
@@ -121,73 +138,113 @@ export class FlexLayoutPlugin {
121
138
  const padding = Math.max(0, (cross.len - crossLen) / (2 * mainList.length - 2));
122
139
  let anchorPos = 0;
123
140
  mainList.forEach(((s, i) => {
124
- this.layoutCross(children, "flex-start", cross, anchorPos, mianLenArray, mainList[i], lastIdx),
141
+ const anchorPosMap = {
142
+ "flex-start": anchorPos,
143
+ "flex-end": anchorPos + s.crossLen,
144
+ center: anchorPos + s.crossLen / 2
145
+ };
146
+ this.layoutCross(children, "flex-start", cross, anchorPosMap, mianLenArray, mainList[i], lastIdx),
125
147
  lastIdx = s.idx + 1, anchorPos += s.crossLen + 2 * padding;
126
148
  }));
127
149
  }
128
150
  children.forEach(((child, idx) => {
129
151
  child.addUpdateBoundTag(), child.addUpdatePositionTag(), child.clearUpdateLayoutTag();
130
- })), p.addUpdateLayoutTag(), clip || this.tempBounds.equals(p.AABBBounds) || (this.tryLayout(p),
131
- this.layouting = !1);
152
+ })), p.addUpdateLayoutTag();
153
+ const b = this.getAABBBounds(p);
154
+ clip || this.tempBounds.equals(b) || this.tryLayout(p, !1);
155
+ }
156
+ getAABBBounds(graphic) {
157
+ this.skipBoundsTrigger = !0;
158
+ const b = graphic.AABBBounds;
159
+ return this.skipBoundsTrigger = !1, b;
160
+ }
161
+ updateChildPos(posBaseLeftTop, lastP, lastBP) {
162
+ return posBaseLeftTop + (null != lastP ? lastP : 0) - lastBP;
132
163
  }
133
164
  layoutMain(p, children, justifyContent, main, mianLenArray, lastIdx, currSeg) {
134
165
  if ("flex-start" === justifyContent) {
135
166
  let pos = 0;
136
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
137
- pos += mianLenArray[i].mainLen;
167
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
168
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
169
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
170
+ pos += mianLenArray[i].mainLen;
171
+ }
138
172
  } else if ("flex-end" === justifyContent) {
139
173
  let pos = main.len;
140
- for (let i = lastIdx; i <= currSeg.idx; i++) pos -= mianLenArray[i].mainLen, children[i].attribute[main.field] = pos + getPadding(children[i], main.field);
174
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
175
+ pos -= mianLenArray[i].mainLen;
176
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
177
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`]));
178
+ }
141
179
  } else if ("space-around" === justifyContent) if (currSeg.mainLen >= main.len) {
142
180
  let pos = 0;
143
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
144
- pos += mianLenArray[i].mainLen;
181
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
182
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
183
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
184
+ pos += mianLenArray[i].mainLen;
185
+ }
145
186
  } else {
146
187
  const size = currSeg.idx - lastIdx + 1, padding = (main.len - currSeg.mainLen) / size / 2;
147
188
  let pos = padding;
148
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
149
- pos += mianLenArray[i].mainLen + 2 * padding;
189
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
190
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
191
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
192
+ pos += mianLenArray[i].mainLen + 2 * padding;
193
+ }
150
194
  } else if ("space-between" === justifyContent) if (currSeg.mainLen >= main.len) {
151
195
  let pos = 0;
152
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
153
- pos += mianLenArray[i].mainLen;
196
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
197
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
198
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
199
+ pos += mianLenArray[i].mainLen;
200
+ }
154
201
  } else {
155
202
  const size = currSeg.idx - lastIdx + 1, padding = (main.len - currSeg.mainLen) / (2 * size - 2);
156
203
  let pos = 0;
157
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
158
- pos += mianLenArray[i].mainLen + 2 * padding;
204
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
205
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
206
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
207
+ pos += mianLenArray[i].mainLen + 2 * padding;
208
+ }
159
209
  } else if ("center" === justifyContent) {
160
210
  let pos = (main.len - currSeg.mainLen) / 2;
161
- for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[main.field] = pos + getPadding(children[i], main.field),
162
- pos += mianLenArray[i].mainLen;
211
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
212
+ const posBaseLeftTop = pos + getPadding(children[i], main.field), b = this.getAABBBounds(children[i]);
213
+ !b.empty() && (children[i].attribute[main.field] = this.updateChildPos(posBaseLeftTop, children[i].attribute[main.field], b[`${main.field}1`])),
214
+ pos += mianLenArray[i].mainLen;
215
+ }
163
216
  }
164
217
  }
165
- layoutCross(children, alignItem, cross, anchorPos, lenArray, currSeg, lastIdx) {
166
- if ("flex-end" === alignItem) for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[cross.field] = anchorPos - lenArray[i].crossLen + getPadding(children[i], cross.field); else if ("center" === alignItem) for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[cross.field] = anchorPos - lenArray[i].crossLen / 2 + getPadding(children[i], cross.field); else for (let i = lastIdx; i <= currSeg.idx; i++) children[i].attribute[cross.field] = anchorPos + getPadding(children[i], cross.field);
218
+ layoutCross(children, alignItem, cross, anchorPosMap, lenArray, currSeg, lastIdx) {
219
+ var _a;
220
+ for (let i = lastIdx; i <= currSeg.idx; i++) {
221
+ const child = children[i];
222
+ let {alignSelf: alignSelf} = child.attribute;
223
+ alignSelf && "auto" !== alignSelf || (alignSelf = alignItem);
224
+ const b = this.getAABBBounds(child), anchorPos = null !== (_a = anchorPosMap[alignSelf]) && void 0 !== _a ? _a : anchorPosMap["flex-start"];
225
+ "flex-end" === alignSelf ? !b.empty() && (child.attribute[cross.field] = this.updateChildPos(anchorPos - lenArray[i].crossLen + getPadding(child, cross.field), child.attribute[cross.field], b[`${cross.field}1`])) : "center" === alignSelf ? !b.empty() && (child.attribute[cross.field] = this.updateChildPos(anchorPos - lenArray[i].crossLen / 2 + getPadding(child, cross.field), child.attribute[cross.field], b[`${cross.field}1`])) : !b.empty() && (child.attribute[cross.field] = this.updateChildPos(anchorPos + getPadding(child, cross.field), child.attribute[cross.field], b[`${cross.field}1`]));
226
+ }
167
227
  }
168
228
  activate(context) {
169
229
  this.pluginService = context, application.graphicService.hooks.onAttributeUpdate.tap(this.key, (graphic => {
170
- graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic), this.layouting = !1;
230
+ graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage && graphic.stage === this.pluginService.stage && this.tryLayout(graphic, !1);
171
231
  })), application.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, ((graphic, stage, willUpdate, bounds) => {
172
- graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && graphic.isContainer && _tempBounds.copy(bounds);
232
+ graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && graphic.isContainer && !this.skipBoundsTrigger && _tempBounds.copy(bounds);
173
233
  })), application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, ((graphic, stage, bounds, params, selfChange) => {
174
- stage && stage === this.pluginService.stage && graphic.isContainer && (_tempBounds.equals(bounds) || (this.tryLayout(graphic),
175
- this.layouting = !1));
234
+ stage && stage === this.pluginService.stage && graphic.isContainer && !this.skipBoundsTrigger && (_tempBounds.equals(bounds) || this.tryLayout(graphic, !1));
176
235
  })), application.graphicService.hooks.onSetStage.tap(this.key, (graphic => {
177
- graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic), this.layouting = !1;
236
+ graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic, !1);
178
237
  }));
179
238
  }
180
239
  deactivate(context) {
181
240
  application.graphicService.hooks.onAttributeUpdate.taps = application.graphicService.hooks.onAttributeUpdate.taps.filter((item => item.name !== this.key)),
241
+ application.graphicService.hooks.beforeUpdateAABBBounds.taps = application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
242
+ application.graphicService.hooks.afterUpdateAABBBounds.taps = application.graphicService.hooks.afterUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
182
243
  application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter((item => item.name !== this.key));
183
244
  }
184
245
  }
185
246
 
186
247
  function getPadding(graphic, field) {
187
- if (!graphic.attribute.boundsPadding) return 0;
188
- if (isNumber(graphic.attribute.boundsPadding)) return graphic.attribute.boundsPadding;
189
- if (isArray(graphic.attribute.boundsPadding) && 1 === graphic.attribute.boundsPadding.length) return graphic.attribute.boundsPadding[0];
190
- const paddingArray = parsePadding(graphic.attribute.boundsPadding);
191
- return "x" === field ? paddingArray[3] : "y" === field ? paddingArray[0] : 0;
248
+ return 0;
192
249
  }
193
250
  //# sourceMappingURL=flex-layout-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugins/builtin-plugin/flex-layout-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC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AAM,CAAC,IAAI,CAAC,EAAE;YAChH,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,UAAU,CAAC,OAAiB,EAAE,KAAa;IAClD,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,EAAE;QACpC,OAAO,CAAC,CAAC;KACV;SAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE;QACpD,OAAO,OAAO,CAAC,SAAS,CAAC,aAAuB,CAAC;KAClD;SAAM,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;QACnG,OAAO,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;KAC3C;IACD,MAAM,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACnE,IAAI,KAAK,KAAK,GAAG,EAAE;QACjB,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;KACxB;SAAM,IAAI,KAAK,KAAK,GAAG,EAAE;QACxB,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;KACxB;IACD,OAAO,CAAC,CAAC;AACX,CAAC","file":"flex-layout-plugin.js","sourcesContent":["import type { IGraphic, IGroup, IGroupAttribute, IStage } from '../../interface';\nimport { getTheme } from '../../graphic';\nimport type { IPlugin, IPluginService } from '../../interface';\nimport { Generator } from '../../common/generator';\nimport { isNumber } from '../../canvas/util';\nimport { parsePadding } from '../../common/utils';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, isArray } from '@visactor/vutils';\nimport { application } from '../../application';\n\nconst _tempBounds = new AABBBounds();\n\nexport class FlexLayoutPlugin implements IPlugin {\n name: 'FlexLayoutPlugin' = 'FlexLayoutPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n id: number = Generator.GenAutoIncrementId();\n key: string = this.name + this.id;\n tempBounds: AABBBounds = new AABBBounds();\n layouting: boolean;\n\n tryLayout(graphic: IGraphic) {\n if (this.layouting) {\n return;\n }\n this.layouting = true;\n const p = graphic.parent;\n if (!p || !graphic.needUpdateLayout()) {\n return;\n }\n const theme = getTheme(p).group;\n const { display = theme.display } = p.attribute;\n if (display !== 'flex') {\n return;\n }\n const {\n // width,\n // height,\n flexDirection = theme.flexDirection,\n flexWrap = theme.flexWrap,\n justifyContent = theme.justifyContent,\n alignItems = theme.alignItems,\n alignContent = theme.alignContent,\n clip = theme.clip\n } = p.attribute;\n // if (!(width && height)) {\n // return;\n // }\n\n let childrenWidth = 0;\n let childrenHeight = 0;\n let boundsLegal = 0;\n p.forEachChildren((child: IGraphic) => {\n const bounds = child.AABBBounds;\n if (flexDirection === 'column' || flexDirection === 'column-reverse') {\n childrenHeight += bounds.height();\n childrenWidth = Math.max(childrenWidth, bounds.width());\n } else {\n childrenWidth += bounds.width();\n childrenHeight = Math.max(childrenHeight, bounds.height());\n }\n boundsLegal += bounds.x1;\n boundsLegal += bounds.y1;\n boundsLegal += bounds.x2;\n boundsLegal += bounds.y2;\n });\n // judgement children bounds legal\n if (!isFinite(boundsLegal)) {\n return;\n }\n const width = p.attribute.width || childrenWidth;\n const height = p.attribute.height || childrenHeight;\n if (!p.attribute.width) {\n p.attribute.width = 0;\n }\n if (!p.attribute.height) {\n p.attribute.height = 0;\n }\n\n // 这里使用p._AABBBounds可能会将非布局造成的bounds更新也会触发重新布局\n // TODO: 增加layout前预处理,在非递归布局前将子节点及其全部父节点_AABBBounds更新\n this.tempBounds.copy(p._AABBBounds);\n const result = {\n main: { len: width, field: 'x' },\n cross: { len: height, field: 'y' },\n dir: 1\n };\n const main = result.main;\n const cross = result.cross;\n if (flexDirection === 'row-reverse') {\n result.dir = -1;\n } else if (flexDirection === 'column') {\n main.len = height;\n cross.len = width;\n main.field = 'y';\n cross.field = 'x';\n } else if (flexDirection === 'column-reverse') {\n main.len = height;\n cross.len = width;\n main.field = 'y';\n cross.field = 'x';\n result.dir = -1;\n }\n\n // 计算宽度\n let mainLen = 0;\n let crossLen = 0;\n const mianLenArray: { mainLen: number; crossLen: number }[] = [];\n p.forEachChildren((c: IGraphic) => {\n const b = c.AABBBounds;\n const ml = main.field === 'x' ? b.width() : b.height();\n const cl = cross.field === 'x' ? b.width() : b.height();\n mianLenArray.push({ mainLen: ml, crossLen: cl });\n mainLen += ml;\n crossLen = Math.max(crossLen, cl);\n });\n // 解析main\n const mainList: { idx: number; mainLen: number; crossLen: number }[] = [];\n if (mainLen > main.len && flexWrap === 'wrap') {\n let tempMainL = 0;\n let tempCrossL = 0;\n mianLenArray.forEach(({ mainLen, crossLen }, i) => {\n if (tempMainL + mainLen > main.len) {\n if (tempMainL === 0) {\n mainList.push({ idx: i, mainLen: tempMainL + mainLen, crossLen });\n tempMainL = 0;\n tempCrossL = 0;\n } else {\n mainList.push({ idx: i - 1, mainLen: tempMainL, crossLen });\n tempMainL = mainLen;\n tempCrossL = crossLen;\n }\n } else {\n tempMainL += mainLen;\n tempCrossL = Math.max(tempCrossL, crossLen);\n }\n });\n mainList.push({ idx: mianLenArray.length - 1, mainLen: tempMainL, crossLen: tempCrossL });\n } else {\n mainList.push({ idx: mianLenArray.length - 1, mainLen: mainLen, crossLen });\n }\n\n const children = p.getChildren() as IGraphic[];\n\n // 布局main\n let lastIdx: number = 0;\n mainList.forEach(s => {\n this.layoutMain(p, children, justifyContent, main, mianLenArray, lastIdx, s);\n lastIdx = s.idx + 1;\n });\n\n crossLen = mainList.reduce((a, b) => a + b.crossLen, 0);\n\n // 布局cross\n if (mainList.length === 1) {\n if (alignItems === 'flex-end') {\n const anchorPos = cross.len;\n this.layoutCross(children, alignItems, cross, anchorPos, mianLenArray, mainList[0], 0);\n } else if (alignItems === 'center') {\n const anchorPos = cross.len / 2;\n this.layoutCross(children, alignItems, cross, anchorPos, mianLenArray, mainList[0], 0);\n } else {\n children.forEach(child => {\n child.attribute[cross.field] = getPadding(child, cross.field);\n });\n }\n } else {\n if (alignContent === 'flex-start') {\n lastIdx = 0;\n let anchorPos = 0;\n mainList.forEach((s, i) => {\n this.layoutCross(children, 'flex-start', cross, anchorPos, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen;\n });\n } else if (alignContent === 'center') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / 2);\n let anchorPos = padding;\n mainList.forEach((s, i) => {\n this.layoutCross(children, 'center', cross, anchorPos + s.crossLen / 2, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen;\n });\n } else if (alignContent === 'space-around') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / mainList.length / 2);\n let anchorPos = padding;\n mainList.forEach((s, i) => {\n this.layoutCross(children, 'flex-start', cross, anchorPos, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen + padding * 2;\n });\n } else if (alignContent === 'space-between') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / (mainList.length * 2 - 2));\n let anchorPos = 0;\n mainList.forEach((s, i) => {\n this.layoutCross(children, 'flex-start', cross, anchorPos, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen + padding * 2;\n });\n }\n }\n\n // update children\n children.forEach((child, idx) => {\n child.addUpdateBoundTag();\n child.addUpdatePositionTag();\n child.clearUpdateLayoutTag();\n });\n\n p.addUpdateLayoutTag();\n // 更新父级元素的layout,直到存在clip\n if (!clip && !this.tempBounds.equals(p.AABBBounds)) {\n // 判断父元素包围盒是否发生变化\n this.tryLayout(p);\n this.layouting = false;\n }\n }\n\n layoutMain(\n p: IGroup,\n children: IGraphic[],\n justifyContent: IGroupAttribute['justifyContent'],\n main: { len: number; field: string },\n mianLenArray: { mainLen: number; crossLen: number }[],\n lastIdx: number,\n currSeg: { idx: number; mainLen: number; crossLen: number }\n ) {\n if (justifyContent === 'flex-start') {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen;\n }\n } else if (justifyContent === 'flex-end') {\n let pos = main.len;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n pos -= mianLenArray[i].mainLen;\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n }\n } else if (justifyContent === 'space-around') {\n if (currSeg.mainLen >= main.len) {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen;\n }\n } else {\n const size = currSeg.idx - lastIdx + 1;\n const padding = (main.len - currSeg.mainLen) / size / 2;\n let pos = padding;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen + padding * 2;\n }\n }\n } else if (justifyContent === 'space-between') {\n if (currSeg.mainLen >= main.len) {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen;\n }\n } else {\n const size = currSeg.idx - lastIdx + 1;\n const padding = (main.len - currSeg.mainLen) / (size * 2 - 2);\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen + padding * 2;\n }\n }\n } else if (justifyContent === 'center') {\n let pos = (main.len - currSeg.mainLen) / 2;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[main.field] = pos + getPadding(children[i], main.field);\n pos += mianLenArray[i].mainLen;\n }\n }\n }\n\n layoutCross(\n children: IGraphic[],\n alignItem: IGroupAttribute['alignItems'],\n cross: { len: number; field: string },\n anchorPos: number,\n lenArray: { mainLen: number; crossLen: number }[],\n currSeg: { idx: number; mainLen: number; crossLen: number },\n lastIdx: number\n ) {\n if (alignItem === 'flex-end') {\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[cross.field] = anchorPos - lenArray[i].crossLen + getPadding(children[i], cross.field);\n }\n } else if (alignItem === 'center') {\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[cross.field] =\n anchorPos - lenArray[i].crossLen / 2 + getPadding(children[i], cross.field);\n }\n } else {\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n children[i].attribute[cross.field] = anchorPos + getPadding(children[i], cross.field);\n }\n }\n }\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n application.graphicService.hooks.onAttributeUpdate.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n this.tryLayout(graphic);\n this.layouting = false;\n });\n application.graphicService.hooks.beforeUpdateAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n if (!graphic.isContainer) {\n return;\n }\n _tempBounds.copy(bounds);\n }\n );\n application.graphicService.hooks.afterUpdateAABBBounds.tap(\n this.key,\n (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n if (!graphic.isContainer) {\n return;\n }\n if (!_tempBounds.equals(bounds)) {\n this.tryLayout(graphic);\n this.layouting = false;\n }\n }\n );\n application.graphicService.hooks.onSetStage.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n this.tryLayout(graphic);\n this.layouting = false;\n });\n }\n deactivate(context: IPluginService): void {\n application.graphicService.hooks.onAttributeUpdate.taps =\n application.graphicService.hooks.onAttributeUpdate.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n\nfunction getPadding(graphic: IGraphic, field: string): number {\n if (!graphic.attribute.boundsPadding) {\n return 0;\n } else if (isNumber(graphic.attribute.boundsPadding)) {\n return graphic.attribute.boundsPadding as number;\n } else if (isArray(graphic.attribute.boundsPadding) && graphic.attribute.boundsPadding.length === 1) {\n return graphic.attribute.boundsPadding[0];\n }\n const paddingArray = parsePadding(graphic.attribute.boundsPadding);\n if (field === 'x') {\n return paddingArray[3];\n } else if (field === 'y') {\n return paddingArray[0];\n }\n return 0;\n}\n"]}
1
+ {"version":3,"sources":["../src/plugins/builtin-plugin/flex-layout-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInD,OAAO,EAAE,UAAU,EAAW,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,WAAW,GAAG,IAAI,UAAU,EAAE,CAAC;AAQrC,MAAM,OAAO,gBAAgB;IAA7B;QACE,SAAI,GAAuB,kBAAkB,CAAC;QAC9C,gBAAW,GAAiB,YAAY,CAAC;QAEzC,OAAE,GAAW,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC5C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;QAClC,eAAU,GAAe,IAAI,UAAU,EAAE,CAAC;IAkf5C,CAAC;IA9eC,WAAW,CAAC,CAAU;QACpB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAED,iBAAiB,CAAC,OAAiB;QACjC,IAAI,OAAO,CAAC,UAAU,EAAE;YACtB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAs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AAC,EAAE;gBACxE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAChH,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,UAAU,CAAC,OAAiB,EAAE,KAAa;IAclD,OAAO,CAAC,CAAC;AACX,CAAC","file":"flex-layout-plugin.js","sourcesContent":["import type { IGraphic, IGroup, IGroupAttribute, IStage } from '../../interface';\nimport { getTheme } from '../../graphic';\nimport type { IPlugin, IPluginService } from '../../interface';\nimport { Generator } from '../../common/generator';\nimport { isNumber } from '../../canvas/util';\nimport { parsePadding } from '../../common/utils';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, isArray } from '@visactor/vutils';\nimport { application } from '../../application';\n\nconst _tempBounds = new AABBBounds();\n\ntype IAnchorPosMap = {\n 'flex-start': number;\n 'flex-end': number;\n center: number;\n};\n\nexport class FlexLayoutPlugin implements IPlugin {\n name: 'FlexLayoutPlugin' = 'FlexLayoutPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n id: number = Generator.GenAutoIncrementId();\n key: string = this.name + this.id;\n tempBounds: AABBBounds = new AABBBounds();\n pause: boolean;\n skipBoundsTrigger: boolean;\n\n pauseLayout(p: boolean) {\n this.pause = p;\n }\n\n tryLayoutChildren(graphic: IGraphic) {\n if (graphic.firstChild) {\n this.tryLayout(graphic.firstChild as IGraphic);\n }\n }\n\n tryLayout(graphic: IGraphic, force: boolean = true) {\n if (this.pause) {\n return;\n }\n const p = graphic.parent;\n if (!(force || (p && graphic.needUpdateLayout()))) {\n return;\n }\n const theme = getTheme(p).group;\n const { display = theme.display } = p.attribute;\n if (display !== 'flex') {\n return;\n }\n const {\n // width,\n // height,\n flexDirection = theme.flexDirection,\n flexWrap = theme.flexWrap,\n alignItems = theme.alignItems,\n clip = theme.clip\n } = p.attribute;\n const { alignContent = alignItems ?? theme.alignContent } = p.attribute;\n // if (!(width && height)) {\n // return;\n // }\n\n let { width, height, justifyContent = theme.justifyContent } = p.attribute;\n const children = p.getChildren() as IGraphic[];\n if (width == null || height == null) {\n // 计算子节点flex排列后的宽高\n let childrenWidth = 0;\n let childrenHeight = 0;\n let boundsLegal = 0;\n children.forEach((child: IGraphic) => {\n const bounds = this.getAABBBounds(child);\n if (bounds.empty()) {\n return;\n }\n if (flexDirection === 'column' || flexDirection === 'column-reverse') {\n childrenHeight += bounds.height();\n childrenWidth = Math.max(childrenWidth, bounds.width());\n } else {\n childrenWidth += bounds.width();\n childrenHeight = Math.max(childrenHeight, bounds.height());\n }\n boundsLegal += bounds.x1;\n boundsLegal += bounds.y1;\n boundsLegal += bounds.x2;\n boundsLegal += bounds.y2;\n });\n // judgement children bounds legal\n if (!isFinite(boundsLegal)) {\n return;\n }\n width = childrenWidth;\n height = childrenHeight;\n }\n\n p.attribute.width = width;\n p.attribute.height = height;\n\n // 这里使用p._AABBBounds可能会将非布局造成的bounds更新也会触发重新布局\n // TODO: 增加layout前预处理,在非递归布局前将子节点及其全部父节点_AABBBounds更新\n this.tempBounds.copy(p._AABBBounds);\n const result = {\n main: { len: width, field: 'x' },\n cross: { len: height, field: 'y' }\n };\n const main = result.main;\n const cross = result.cross;\n if (flexDirection === 'column' || flexDirection === 'column-reverse') {\n main.len = height;\n cross.len = width;\n main.field = 'y';\n cross.field = 'x';\n }\n if (flexDirection === 'row-reverse' || flexDirection === 'column-reverse') {\n if (justifyContent === 'flex-start') {\n justifyContent = 'flex-end';\n } else if (justifyContent === 'flex-end') {\n justifyContent = 'flex-start';\n } else {\n children.reverse();\n }\n }\n\n // 计算宽度\n let mainLen = 0;\n let crossLen = 0;\n const mianLenArray: { mainLen: number; crossLen: number }[] = [];\n children.forEach((c: IGraphic) => {\n const b = this.getAABBBounds(c);\n if (b.empty()) {\n return;\n }\n const ml = main.field === 'x' ? b.width() : b.height();\n const cl = cross.field === 'x' ? b.width() : b.height();\n mianLenArray.push({ mainLen: ml, crossLen: cl });\n mainLen += ml;\n crossLen = Math.max(crossLen, cl);\n });\n // 解析main\n const mainList: { idx: number; mainLen: number; crossLen: number }[] = [];\n if (mainLen > main.len && flexWrap === 'wrap') {\n let tempMainL = 0;\n let tempCrossL = 0;\n mianLenArray.forEach(({ mainLen, crossLen }, i) => {\n if (tempMainL + mainLen > main.len) {\n if (tempMainL === 0) {\n mainList.push({ idx: i, mainLen: tempMainL + mainLen, crossLen });\n tempMainL = 0;\n tempCrossL = 0;\n } else {\n mainList.push({ idx: i - 1, mainLen: tempMainL, crossLen });\n tempMainL = mainLen;\n tempCrossL = crossLen;\n }\n } else {\n tempMainL += mainLen;\n tempCrossL = Math.max(tempCrossL, crossLen);\n }\n });\n mainList.push({ idx: mianLenArray.length - 1, mainLen: tempMainL, crossLen: tempCrossL });\n } else {\n mainList.push({ idx: mianLenArray.length - 1, mainLen: mainLen, crossLen });\n }\n\n // 布局main\n let lastIdx: number = 0;\n mainList.forEach(s => {\n this.layoutMain(p, children, justifyContent, main, mianLenArray, lastIdx, s);\n lastIdx = s.idx + 1;\n });\n\n crossLen = mainList.reduce((a, b) => a + b.crossLen, 0);\n\n // 布局cross\n\n if (mainList.length === 1) {\n const anchorPosMap: IAnchorPosMap = {\n 'flex-start': 0,\n 'flex-end': cross.len,\n center: cross.len / 2\n };\n this.layoutCross(children, alignItems, cross, anchorPosMap, mianLenArray, mainList[0], 0);\n } else {\n if (alignContent === 'flex-start') {\n lastIdx = 0;\n let anchorPos = 0;\n mainList.forEach((s, i) => {\n const anchorPosMap: IAnchorPosMap = {\n 'flex-start': anchorPos,\n 'flex-end': anchorPos + s.crossLen,\n center: anchorPos + s.crossLen / 2\n };\n this.layoutCross(children, 'flex-start', cross, anchorPosMap, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen;\n });\n } else if (alignContent === 'center') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / 2);\n let anchorPos = padding;\n mainList.forEach((s, i) => {\n const anchorPosMap: IAnchorPosMap = {\n 'flex-start': anchorPos,\n 'flex-end': anchorPos + s.crossLen,\n center: anchorPos + s.crossLen / 2\n };\n this.layoutCross(children, 'center', cross, anchorPosMap, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen;\n });\n } else if (alignContent === 'space-around') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / mainList.length / 2);\n let anchorPos = padding;\n mainList.forEach((s, i) => {\n const anchorPosMap: IAnchorPosMap = {\n 'flex-start': anchorPos,\n 'flex-end': anchorPos + s.crossLen,\n center: anchorPos + s.crossLen / 2\n };\n this.layoutCross(children, 'flex-start', cross, anchorPosMap, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen + padding * 2;\n });\n } else if (alignContent === 'space-between') {\n lastIdx = 0;\n const padding = Math.max(0, (cross.len - crossLen) / (mainList.length * 2 - 2));\n let anchorPos = 0;\n mainList.forEach((s, i) => {\n const anchorPosMap: IAnchorPosMap = {\n 'flex-start': anchorPos,\n 'flex-end': anchorPos + s.crossLen,\n center: anchorPos + s.crossLen / 2\n };\n this.layoutCross(children, 'flex-start', cross, anchorPosMap, mianLenArray, mainList[i], lastIdx);\n lastIdx = s.idx + 1;\n anchorPos += s.crossLen + padding * 2;\n });\n }\n }\n\n // update children\n children.forEach((child, idx) => {\n child.addUpdateBoundTag();\n child.addUpdatePositionTag();\n child.clearUpdateLayoutTag();\n });\n\n p.addUpdateLayoutTag();\n // 更新父级元素的layout,直到存在clip\n const b = this.getAABBBounds(p);\n if (!clip && !this.tempBounds.equals(b)) {\n // 判断父元素包围盒是否发生变化\n this.tryLayout(p, false);\n }\n }\n\n // 避免获取bounds的时候递归进行布局\n getAABBBounds(graphic: IGraphic) {\n this.skipBoundsTrigger = true;\n const b = graphic.AABBBounds;\n this.skipBoundsTrigger = false;\n return b;\n }\n\n // 锚点并不一定总在左上角,根据位置和bounds的偏移进行定位\n private updateChildPos(posBaseLeftTop: number, lastP: number | undefined, lastBP: number): number {\n return posBaseLeftTop + (lastP ?? 0) - lastBP;\n }\n\n layoutMain(\n p: IGroup,\n children: IGraphic[],\n justifyContent: IGroupAttribute['justifyContent'],\n main: { len: number; field: string },\n mianLenArray: { mainLen: number; crossLen: number }[],\n lastIdx: number,\n currSeg: { idx: number; mainLen: number; crossLen: number }\n ) {\n if (justifyContent === 'flex-start') {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen;\n }\n } else if (justifyContent === 'flex-end') {\n let pos = main.len;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n pos -= mianLenArray[i].mainLen;\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n }\n } else if (justifyContent === 'space-around') {\n if (currSeg.mainLen >= main.len) {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen;\n }\n } else {\n const size = currSeg.idx - lastIdx + 1;\n const padding = (main.len - currSeg.mainLen) / size / 2;\n let pos = padding;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen + padding * 2;\n }\n }\n } else if (justifyContent === 'space-between') {\n if (currSeg.mainLen >= main.len) {\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen;\n }\n } else {\n const size = currSeg.idx - lastIdx + 1;\n const padding = (main.len - currSeg.mainLen) / (size * 2 - 2);\n let pos = 0;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen + padding * 2;\n }\n }\n } else if (justifyContent === 'center') {\n let pos = (main.len - currSeg.mainLen) / 2;\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const posBaseLeftTop = pos + getPadding(children[i], main.field);\n const b = this.getAABBBounds(children[i]);\n !b.empty() &&\n (children[i].attribute[main.field] = this.updateChildPos(\n posBaseLeftTop,\n children[i].attribute[main.field],\n b[`${main.field}1`]\n ));\n pos += mianLenArray[i].mainLen;\n }\n }\n }\n\n layoutCross(\n children: IGraphic[],\n alignItem: IGroupAttribute['alignItems'],\n cross: { len: number; field: string },\n anchorPosMap: IAnchorPosMap,\n lenArray: { mainLen: number; crossLen: number }[],\n currSeg: { idx: number; mainLen: number; crossLen: number },\n lastIdx: number\n ) {\n for (let i = lastIdx; i <= currSeg.idx; i++) {\n const child = children[i];\n let { alignSelf } = child.attribute;\n if (!alignSelf || alignSelf === 'auto') {\n alignSelf = alignItem;\n }\n const b = this.getAABBBounds(child);\n const anchorPos = anchorPosMap[alignSelf] ?? anchorPosMap['flex-start'];\n if (alignSelf === 'flex-end') {\n !b.empty() &&\n (child.attribute[cross.field] = this.updateChildPos(\n anchorPos - lenArray[i].crossLen + getPadding(child, cross.field),\n child.attribute[cross.field],\n b[`${cross.field}1`]\n ));\n } else if (alignSelf === 'center') {\n !b.empty() &&\n (child.attribute[cross.field] = this.updateChildPos(\n anchorPos - lenArray[i].crossLen / 2 + getPadding(child, cross.field),\n child.attribute[cross.field],\n b[`${cross.field}1`]\n ));\n } else {\n !b.empty() &&\n (child.attribute[cross.field] = this.updateChildPos(\n anchorPos + getPadding(child, cross.field),\n child.attribute[cross.field],\n b[`${cross.field}1`]\n ));\n }\n }\n // if (alignItem === 'flex-end') {\n // for (let i = lastIdx; i <= currSeg.idx; i++) {\n // children[i].attribute[cross.field] = this.updateChildPos(\n // anchorPos - lenArray[i].crossLen + getPadding(children[i], cross.field),\n // children[i].attribute[cross.field],\n // children[i].AABBBounds[`${cross.field}1`]\n // );\n // }\n // } else if (alignItem === 'center') {\n // for (let i = lastIdx; i <= currSeg.idx; i++) {\n // children[i].attribute[cross.field] = this.updateChildPos(\n // anchorPos - lenArray[i].crossLen / 2 + getPadding(children[i], cross.field),\n // children[i].attribute[cross.field],\n // children[i].AABBBounds[`${cross.field}1`]\n // );\n // }\n // } else {\n // for (let i = lastIdx; i <= currSeg.idx; i++) {\n // children[i].attribute[cross.field] = this.updateChildPos(\n // anchorPos + getPadding(children[i], cross.field),\n // children[i].attribute[cross.field],\n // children[i].AABBBounds[`${cross.field}1`]\n // );\n // }\n // }\n }\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n // 属性更新\n application.graphicService.hooks.onAttributeUpdate.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(graphic.stage && graphic.stage === this.pluginService.stage)) {\n return;\n }\n this.tryLayout(graphic, false);\n });\n // 包围盒更新(如果包围盒发生变化,就重新布局\n application.graphicService.hooks.beforeUpdateAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n if (!graphic.isContainer || this.skipBoundsTrigger) {\n return;\n }\n _tempBounds.copy(bounds);\n }\n );\n application.graphicService.hooks.afterUpdateAABBBounds.tap(\n this.key,\n (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n if (!graphic.isContainer || this.skipBoundsTrigger) {\n return;\n }\n if (!_tempBounds.equals(bounds)) {\n this.tryLayout(graphic, false);\n }\n }\n );\n // 添加到场景树\n application.graphicService.hooks.onSetStage.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n this.tryLayout(graphic, false);\n });\n }\n deactivate(context: IPluginService): void {\n application.graphicService.hooks.onAttributeUpdate.taps =\n application.graphicService.hooks.onAttributeUpdate.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.beforeUpdateAABBBounds.taps =\n application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.afterUpdateAABBBounds.taps =\n application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n\nfunction getPadding(graphic: IGraphic, field: string): number {\n // if (!graphic.attribute.boundsPadding) {\n // return 0;\n // } else if (isNumber(graphic.attribute.boundsPadding)) {\n // return graphic.attribute.boundsPadding as number;\n // } else if (isArray(graphic.attribute.boundsPadding) && graphic.attribute.boundsPadding.length === 1) {\n // return graphic.attribute.boundsPadding[0];\n // }\n // const paddingArray = parsePadding(graphic.attribute.boundsPadding);\n // if (field === 'x') {\n // return paddingArray[3];\n // } else if (field === 'y') {\n // return paddingArray[0];\n // }\n return 0;\n}\n"]}
@@ -12,6 +12,8 @@ export class HtmlAttributePlugin {
12
12
  activate(context) {
13
13
  this.pluginService = context, context.stage.hooks.afterRender.tap(this.key, (stage => {
14
14
  stage && stage === this.pluginService.stage && this.drawHTML(context.stage.renderService);
15
+ })), application.graphicService.hooks.onRemove.tap(this.key, (graphic => {
16
+ this.removeDom(graphic);
15
17
  })), application.graphicService.hooks.onRelease.tap(this.key, (graphic => {
16
18
  this.removeDom(graphic);
17
19
  }));
@@ -47,34 +49,35 @@ export class HtmlAttributePlugin {
47
49
  const {dom: dom, container: container, width: width, height: height, style: style, anchorType: anchorType = "boundsLeftTop"} = html;
48
50
  graphic.bindDom || (graphic.bindDom = new Map);
49
51
  const lastDom = graphic.bindDom.get(dom);
50
- if (lastDom && (!container || container === lastDom.container)) return;
51
- let nativeDom, nativeContainer;
52
- graphic.bindDom.forEach((({wrapGroup: wrapGroup}) => {
53
- application.global.removeDom(wrapGroup);
54
- })), nativeDom = "string" == typeof dom ? (new DOMParser).parseFromString(dom, "text/html").firstChild : dom;
55
- const _container = container || (!0 === stage.params.enableHtmlAttribute ? null : stage.params.enableHtmlAttribute);
56
- nativeContainer = _container ? "string" == typeof _container ? application.global.getElementById(_container) : _container : graphic.stage.window.getContainer();
57
- const wrapGroup = application.global.createDom({
58
- tagName: "div",
59
- width: width,
60
- height: height,
61
- style: style,
62
- parent: nativeContainer
63
- });
64
- wrapGroup && (wrapGroup.appendChild(nativeDom), graphic.bindDom.set(dom, {
65
- dom: nativeDom,
66
- container: container,
67
- wrapGroup: wrapGroup
68
- })), wrapGroup.style.pointerEvents = "none", wrapGroup.style.position || (wrapGroup.style.position = "absolute",
52
+ let wrapGroup, nativeContainer;
53
+ if (!lastDom || container && container !== lastDom.container) {
54
+ let nativeDom;
55
+ graphic.bindDom.forEach((({wrapGroup: wrapGroup}) => {
56
+ application.global.removeDom(wrapGroup);
57
+ })), "string" == typeof dom ? (nativeDom = (new DOMParser).parseFromString(dom, "text/html").firstChild,
58
+ nativeDom.lastChild && (nativeDom = nativeDom.lastChild.firstChild)) : nativeDom = dom;
59
+ const _container = container || (!0 === stage.params.enableHtmlAttribute ? null : stage.params.enableHtmlAttribute);
60
+ nativeContainer = _container ? "string" == typeof _container ? application.global.getElementById(_container) : _container : graphic.stage.window.getContainer(),
61
+ wrapGroup = application.global.createDom({
62
+ tagName: "div",
63
+ width: width,
64
+ height: height,
65
+ style: style,
66
+ parent: nativeContainer
67
+ }), wrapGroup && (wrapGroup.appendChild(nativeDom), graphic.bindDom.set(dom, {
68
+ dom: nativeDom,
69
+ container: container,
70
+ wrapGroup: wrapGroup
71
+ }));
72
+ } else wrapGroup = lastDom.wrapGroup, nativeContainer = wrapGroup.parentNode;
73
+ wrapGroup.style.pointerEvents = "none", wrapGroup.style.position || (wrapGroup.style.position = "absolute",
69
74
  nativeContainer.style.position = "relative");
70
75
  let left = 0, top = 0;
71
- if ("position" === anchorType) {
72
- const matrix = graphic.transMatrix;
76
+ const b = graphic.globalAABBBounds;
77
+ if ("position" === anchorType || b.empty()) {
78
+ const matrix = graphic.globalTransMatrix;
73
79
  left = matrix.e, top = matrix.f;
74
- } else {
75
- const b = graphic.AABBBounds;
76
- left = b.x1, top = b.y1;
77
- }
80
+ } else left = b.x1, top = b.y1;
78
81
  const containerTL = application.global.getElementTopLeft(nativeContainer, !1), windowTL = stage.window.getTopLeft(!1), offsetX = left + windowTL.left - containerTL.left, offsetTop = top + windowTL.top - containerTL.top;
79
82
  wrapGroup.style.left = `${offsetX}px`,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7C;QACD,IAAI,IAAI,GAAW,CAAC,CAAC;QACrB,IAAI,GAAG,GAAW,CAAC,CAAC;QACpB,IAAI,UAAU,KAAK,UAAU,EAAE;YAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;YACnC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;YAChB,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC;SAChB;aAAM;YACL,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;YAC7B,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC;YACZ,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;SACZ;QAGD,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QACjF,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,IAAI,GAAG,QAAQ,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;QACxD,MAAM,SAAS,GAAG,GAAG,GAAG,QAAQ,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC;QAEvD,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,OAAO,IAAI,CAAC;QACtC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,SAAS,IAAI,CAAC;IACzC,CAAC;CACF","file":"html-attribute-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport type { IGraphic, IPlugin, IPluginService, IRenderService, IDrawContext, IGroup } from '../../interface';\nimport { application } from '../../application';\nimport { DefaultAttribute } from '../../graphic';\n\nexport class HtmlAttributePlugin implements IPlugin {\n name: 'HtmlAttributePlugin' = 'HtmlAttributePlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n\n this.drawHTML(context.stage.renderService);\n });\n application.graphicService.hooks.onRelease.tap(this.key, graphic => {\n this.removeDom(graphic);\n });\n }\n deactivate(context: IPluginService): void {\n context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n\n protected drawHTML(renderService: IRenderService) {\n if (application.global.env === 'browser') {\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroupHTML(group as IGroup);\n });\n }\n }\n\n renderGroupHTML(group: IGroup) {\n this.renderGraphicHTML(group);\n group.forEachChildren((g: IGraphic) => {\n if (g.isContainer) {\n this.renderGroupHTML(g as IGroup);\n } else {\n this.renderGraphicHTML(g);\n }\n });\n }\n\n removeDom(graphic: IGraphic) {\n if (graphic.bindDom && graphic.bindDom.size) {\n // 删除dom\n graphic.bindDom.forEach(item => {\n item.dom && item.dom.parentElement.removeChild(item.dom);\n });\n graphic.bindDom.clear();\n }\n }\n\n renderGraphicHTML(graphic: IGraphic) {\n const { html } = graphic.attribute;\n if (!html) {\n if (graphic.bindDom && graphic.bindDom.size) {\n // 删除dom\n graphic.bindDom.forEach(item => {\n item.dom && item.dom.parentElement.removeChild(item.dom);\n });\n graphic.bindDom.clear();\n }\n return;\n }\n const stage = graphic.stage;\n if (!stage) {\n return;\n }\n const { dom, container, width, height, style, anchorType = 'boundsLeftTop' } = html;\n if (!graphic.bindDom) {\n graphic.bindDom = new Map();\n }\n const lastDom = graphic.bindDom.get(dom);\n // 如果存在了(dom存在,且container没有变化),就跳过\n if (lastDom && !(container && container !== lastDom.container)) {\n return;\n }\n // 清除上一次的dom\n graphic.bindDom.forEach(({ wrapGroup }) => {\n application.global.removeDom(wrapGroup);\n });\n // 转化这个dom为nativeDOM\n let nativeDom: HTMLElement;\n if (typeof dom === 'string') {\n nativeDom = new DOMParser().parseFromString(dom, 'text/html').firstChild as any;\n } else {\n nativeDom = dom;\n }\n // 获取container的dom,默认为window的container\n let nativeContainer;\n const _container =\n container || (stage.params.enableHtmlAttribute === true ? null : stage.params.enableHtmlAttribute);\n if (_container) {\n if (typeof _container === 'string') {\n nativeContainer = application.global.getElementById(_container);\n } else {\n nativeContainer = _container;\n }\n } else {\n // nativeContainer = application.global.getRootElement();\n nativeContainer = graphic.stage.window.getContainer();\n }\n // 创建wrapGroup\n const wrapGroup = application.global.createDom({ tagName: 'div', width, height, style, parent: nativeContainer });\n if (wrapGroup) {\n wrapGroup.appendChild(nativeDom);\n graphic.bindDom.set(dom, { dom: nativeDom, container, wrapGroup: wrapGroup as any });\n }\n // 事件穿透\n wrapGroup.style.pointerEvents = 'none';\n // 定位wrapGroup\n if (!wrapGroup.style.position) {\n wrapGroup.style.position = 'absolute';\n nativeContainer.style.position = 'relative';\n }\n let left: number = 0;\n let top: number = 0;\n if (anchorType === 'position') {\n const matrix = graphic.transMatrix;\n left = matrix.e;\n top = matrix.f;\n } else {\n const b = graphic.AABBBounds;\n left = b.x1;\n top = b.y1;\n }\n // 查看wrapGroup的位置\n // const wrapGroupTL = application.global.getElementTopLeft(wrapGroup, false);\n const containerTL = application.global.getElementTopLeft(nativeContainer, false);\n const windowTL = stage.window.getTopLeft(false);\n const offsetX = left + windowTL.left - containerTL.left;\n const offsetTop = top + windowTL.top - containerTL.top;\n // wrapGroup.style.transform = `translate(${offsetX}px, ${offsetTop}px)`;\n wrapGroup.style.left = `${offsetX}px`;\n wrapGroup.style.top = `${offsetTop}px`;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/plugins/builtin-plugin/html-attribute-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,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C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC7B,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;YACtC,eAAe,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;SAC7C;QACD,IAAI,IAAI,GAAW,CAAC,CAAC;QACrB,IAAI,GAAG,GAAW,CAAC,CAAC;QACpB,MAAM,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACnC,IAAI,UAAU,KAAK,UAAU,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;YACzC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;YAChB,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC;SAChB;aAAM;YACL,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC;YACZ,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;SACZ;QAGD,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QACjF,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,IAAI,GAAG,QAAQ,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;QACxD,MAAM,SAAS,GAAG,GAAG,GAAG,QAAQ,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC;QAEvD,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,OAAO,IAAI,CAAC;QACtC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,SAAS,IAAI,CAAC;IACzC,CAAC;CACF","file":"html-attribute-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport type { IGraphic, IPlugin, IPluginService, IRenderService, IDrawContext, IGroup } from '../../interface';\nimport { application } from '../../application';\nimport { DefaultAttribute } from '../../graphic';\n\nexport class HtmlAttributePlugin implements IPlugin {\n name: 'HtmlAttributePlugin' = 'HtmlAttributePlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n\n this.drawHTML(context.stage.renderService);\n });\n application.graphicService.hooks.onRemove.tap(this.key, graphic => {\n this.removeDom(graphic);\n });\n application.graphicService.hooks.onRelease.tap(this.key, graphic => {\n this.removeDom(graphic);\n });\n }\n deactivate(context: IPluginService): void {\n context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n\n protected drawHTML(renderService: IRenderService) {\n if (application.global.env === 'browser') {\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroupHTML(group as IGroup);\n });\n }\n }\n\n renderGroupHTML(group: IGroup) {\n this.renderGraphicHTML(group);\n group.forEachChildren((g: IGraphic) => {\n if (g.isContainer) {\n this.renderGroupHTML(g as IGroup);\n } else {\n this.renderGraphicHTML(g);\n }\n });\n }\n\n removeDom(graphic: IGraphic) {\n if (graphic.bindDom && graphic.bindDom.size) {\n // 删除dom\n graphic.bindDom.forEach(item => {\n item.dom && item.dom.parentElement.removeChild(item.dom);\n });\n graphic.bindDom.clear();\n }\n }\n\n renderGraphicHTML(graphic: IGraphic) {\n const { html } = graphic.attribute;\n if (!html) {\n if (graphic.bindDom && graphic.bindDom.size) {\n // 删除dom\n graphic.bindDom.forEach(item => {\n item.dom && item.dom.parentElement.removeChild(item.dom);\n });\n graphic.bindDom.clear();\n }\n return;\n }\n const stage = graphic.stage;\n if (!stage) {\n return;\n }\n const { dom, container, width, height, style, anchorType = 'boundsLeftTop' } = html;\n if (!graphic.bindDom) {\n graphic.bindDom = new Map();\n }\n const lastDom = graphic.bindDom.get(dom);\n\n let wrapGroup;\n // 获取container的dom,默认为window的container\n let nativeContainer;\n // 如果存在了(dom存在,且container没有变化),就不做事情\n if (lastDom && !(container && container !== lastDom.container)) {\n wrapGroup = lastDom.wrapGroup;\n nativeContainer = wrapGroup.parentNode;\n } else {\n // 清除上一次的dom\n graphic.bindDom.forEach(({ wrapGroup }) => {\n application.global.removeDom(wrapGroup);\n });\n // 转化这个dom为nativeDOM\n let nativeDom: HTMLElement;\n if (typeof dom === 'string') {\n nativeDom = new DOMParser().parseFromString(dom, 'text/html').firstChild as any;\n if ((nativeDom as any).lastChild) {\n nativeDom = (nativeDom as any).lastChild.firstChild;\n }\n } else {\n nativeDom = dom;\n }\n\n const _container =\n container || (stage.params.enableHtmlAttribute === true ? null : stage.params.enableHtmlAttribute);\n if (_container) {\n if (typeof _container === 'string') {\n nativeContainer = application.global.getElementById(_container);\n } else {\n nativeContainer = _container;\n }\n } else {\n // nativeContainer = application.global.getRootElement();\n nativeContainer = graphic.stage.window.getContainer();\n }\n // 创建wrapGroup\n wrapGroup = application.global.createDom({ tagName: 'div', width, height, style, parent: nativeContainer });\n if (wrapGroup) {\n wrapGroup.appendChild(nativeDom);\n graphic.bindDom.set(dom, { dom: nativeDom, container, wrapGroup: wrapGroup as any });\n }\n }\n\n // 事件穿透\n wrapGroup.style.pointerEvents = 'none';\n // 定位wrapGroup\n if (!wrapGroup.style.position) {\n wrapGroup.style.position = 'absolute';\n nativeContainer.style.position = 'relative';\n }\n let left: number = 0;\n let top: number = 0;\n const b = graphic.globalAABBBounds;\n if (anchorType === 'position' || b.empty()) {\n const matrix = graphic.globalTransMatrix;\n left = matrix.e;\n top = matrix.f;\n } else {\n left = b.x1;\n top = b.y1;\n }\n // 查看wrapGroup的位置\n // const wrapGroupTL = application.global.getElementTopLeft(wrapGroup, false);\n const containerTL = application.global.getElementTopLeft(nativeContainer, false);\n const windowTL = stage.window.getTopLeft(false);\n const offsetX = left + windowTL.left - containerTL.left;\n const offsetTop = top + windowTL.top - containerTL.top;\n // wrapGroup.style.transform = `translate(${offsetX}px, ${offsetTop}px)`;\n wrapGroup.style.left = `${offsetX}px`;\n wrapGroup.style.top = `${offsetTop}px`;\n }\n}\n"]}