@visactor/vrender 0.14.9-alpha.1 → 0.14.9-alpha.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 (383) hide show
  1. package/cjs/animate/animate.d.ts +1 -0
  2. package/cjs/animate/animate.js +3 -0
  3. package/cjs/animate/animate.js.map +1 -1
  4. package/cjs/animate/timeline.d.ts +1 -1
  5. package/cjs/animate/timeline.js +2 -2
  6. package/cjs/animate/timeline.js.map +1 -1
  7. package/cjs/canvas/contributions/browser/context.d.ts +1 -0
  8. package/cjs/common/contribution-provider.d.ts +1 -0
  9. package/cjs/common/contribution-provider.js +7 -2
  10. package/cjs/common/contribution-provider.js.map +1 -1
  11. package/cjs/common/enums.d.ts +4 -2
  12. package/cjs/common/enums.js +3 -2
  13. package/cjs/common/enums.js.map +1 -1
  14. package/cjs/core/contributions/env/base-contribution.d.ts +11 -1
  15. package/cjs/core/contributions/env/base-contribution.js +22 -1
  16. package/cjs/core/contributions/env/base-contribution.js.map +1 -1
  17. package/cjs/core/contributions/env/browser-contribution.d.ts +11 -2
  18. package/cjs/core/contributions/env/browser-contribution.js +66 -0
  19. package/cjs/core/contributions/env/browser-contribution.js.map +1 -1
  20. package/cjs/core/contributions/textMeasure/layout.js +1 -1
  21. package/cjs/core/contributions/textMeasure/layout.js.map +1 -1
  22. package/cjs/core/contributions/window/base-contribution.d.ts +11 -5
  23. package/cjs/core/contributions/window/base-contribution.js +10 -0
  24. package/cjs/core/contributions/window/base-contribution.js.map +1 -1
  25. package/cjs/core/contributions/window/browser-contribution.d.ts +11 -0
  26. package/cjs/core/contributions/window/browser-contribution.js +33 -2
  27. package/cjs/core/contributions/window/browser-contribution.js.map +1 -1
  28. package/cjs/core/global.d.ts +11 -1
  29. package/cjs/core/global.js +18 -0
  30. package/cjs/core/global.js.map +1 -1
  31. package/cjs/core/graphic-utils.d.ts +2 -0
  32. package/cjs/core/graphic-utils.js +13 -0
  33. package/cjs/core/graphic-utils.js.map +1 -1
  34. package/cjs/core/layer.js +6 -6
  35. package/cjs/core/layer.js.map +1 -1
  36. package/cjs/core/stage.d.ts +13 -4
  37. package/cjs/core/stage.js +54 -25
  38. package/cjs/core/stage.js.map +1 -1
  39. package/cjs/core/window.d.ts +6 -0
  40. package/cjs/core/window.js +10 -1
  41. package/cjs/core/window.js.map +1 -1
  42. package/cjs/event/event-manager.js +8 -8
  43. package/cjs/event/event-manager.js.map +1 -1
  44. package/cjs/event/event-system.js.map +1 -1
  45. package/cjs/event/federated-event/pointer-event.d.ts +1 -0
  46. package/cjs/event/federated-event/pointer-event.js.map +1 -1
  47. package/cjs/graphic/builtin-symbol/arrow2-down.d.ts +12 -0
  48. package/cjs/graphic/builtin-symbol/arrow2-down.js +30 -0
  49. package/cjs/graphic/builtin-symbol/arrow2-down.js.map +1 -0
  50. package/cjs/graphic/builtin-symbol/arrow2-left.js +1 -1
  51. package/cjs/graphic/builtin-symbol/arrow2-left.js.map +1 -1
  52. package/cjs/graphic/builtin-symbol/arrow2-right.js +1 -1
  53. package/cjs/graphic/builtin-symbol/arrow2-right.js.map +1 -1
  54. package/cjs/graphic/builtin-symbol/arrow2-up.d.ts +12 -0
  55. package/cjs/graphic/builtin-symbol/arrow2-up.js +30 -0
  56. package/cjs/graphic/builtin-symbol/arrow2-up.js.map +1 -0
  57. package/cjs/graphic/builtin-symbol/close.d.ts +13 -0
  58. package/cjs/graphic/builtin-symbol/close.js +33 -0
  59. package/cjs/graphic/builtin-symbol/close.js.map +1 -0
  60. package/cjs/graphic/builtin-symbol/index.d.ts +1 -1
  61. package/cjs/graphic/builtin-symbol/index.js +2 -2
  62. package/cjs/graphic/builtin-symbol/index.js.map +1 -1
  63. package/cjs/graphic/builtin-symbol/line-h.d.ts +13 -0
  64. package/cjs/graphic/builtin-symbol/line-h.js +32 -0
  65. package/cjs/graphic/builtin-symbol/line-h.js.map +1 -0
  66. package/cjs/graphic/builtin-symbol/line-v.d.ts +13 -0
  67. package/cjs/graphic/builtin-symbol/line-v.js +32 -0
  68. package/cjs/graphic/builtin-symbol/line-v.js.map +1 -0
  69. package/cjs/graphic/builtin-symbol/utils.d.ts +13 -5
  70. package/cjs/graphic/builtin-symbol/utils.js +23 -9
  71. package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
  72. package/cjs/graphic/config.js +10 -5
  73. package/cjs/graphic/config.js.map +1 -1
  74. package/cjs/graphic/constants.d.ts +22 -0
  75. package/cjs/graphic/constants.js +20 -2
  76. package/cjs/graphic/constants.js.map +1 -1
  77. package/cjs/graphic/graphic.d.ts +4 -1
  78. package/cjs/graphic/graphic.js +49 -21
  79. package/cjs/graphic/graphic.js.map +1 -1
  80. package/cjs/graphic/group.js +1 -1
  81. package/cjs/graphic/group.js.map +1 -1
  82. package/cjs/graphic/index.d.ts +1 -0
  83. package/cjs/graphic/index.js +13 -13
  84. package/cjs/graphic/index.js.map +1 -1
  85. package/cjs/graphic/richtext/utils.d.ts +1 -1
  86. package/cjs/graphic/richtext/utils.js +1 -1
  87. package/cjs/graphic/richtext/utils.js.map +1 -1
  88. package/cjs/graphic/symbol.d.ts +2 -1
  89. package/cjs/graphic/symbol.js +27 -4
  90. package/cjs/graphic/symbol.js.map +1 -1
  91. package/cjs/graphic/text.js +33 -23
  92. package/cjs/graphic/text.js.map +1 -1
  93. package/cjs/graphic/tools.d.ts +3 -2
  94. package/cjs/graphic/tools.js +58 -3
  95. package/cjs/graphic/tools.js.map +1 -1
  96. package/cjs/graphic/wrap-text.js +10 -8
  97. package/cjs/graphic/wrap-text.js.map +1 -1
  98. package/cjs/index.d.ts +3 -1
  99. package/cjs/index.js +3 -3
  100. package/cjs/index.js.map +1 -1
  101. package/cjs/interface/animate.d.ts +3 -1
  102. package/cjs/interface/animate.js.map +1 -1
  103. package/cjs/interface/core.d.ts +1 -0
  104. package/cjs/interface/core.js.map +1 -1
  105. package/cjs/interface/global.d.ts +25 -1
  106. package/cjs/interface/global.js.map +1 -1
  107. package/cjs/interface/graphic/area.d.ts +1 -0
  108. package/cjs/interface/graphic/area.js.map +1 -1
  109. package/cjs/interface/graphic/image.d.ts +1 -0
  110. package/cjs/interface/graphic/image.js.map +1 -1
  111. package/cjs/interface/graphic/symbol.d.ts +3 -2
  112. package/cjs/interface/graphic/symbol.js.map +1 -1
  113. package/cjs/interface/graphic/text.d.ts +1 -0
  114. package/cjs/interface/graphic/text.js.map +1 -1
  115. package/cjs/interface/graphic.d.ts +27 -3
  116. package/cjs/interface/graphic.js.map +1 -1
  117. package/cjs/interface/picker.d.ts +9 -1
  118. package/cjs/interface/picker.js.map +1 -1
  119. package/cjs/interface/render.d.ts +1 -0
  120. package/cjs/interface/render.js.map +1 -1
  121. package/cjs/interface/stage.d.ts +10 -3
  122. package/cjs/interface/stage.js.map +1 -1
  123. package/cjs/interface/window.d.ts +12 -0
  124. package/cjs/interface/window.js.map +1 -1
  125. package/cjs/jsx/graphicType.d.ts +172 -0
  126. package/cjs/jsx/graphicType.js +133 -0
  127. package/cjs/jsx/graphicType.js.map +1 -0
  128. package/cjs/jsx/index.d.ts +2 -0
  129. package/cjs/jsx/index.js +21 -0
  130. package/cjs/jsx/index.js.map +1 -0
  131. package/cjs/jsx/jsx-classic.d.ts +3 -0
  132. package/cjs/jsx/jsx-classic.js +58 -0
  133. package/cjs/jsx/jsx-classic.js.map +1 -0
  134. package/cjs/picker/canvas-picker-service.d.ts +2 -2
  135. package/cjs/picker/canvas-picker-service.js +20 -3
  136. package/cjs/picker/canvas-picker-service.js.map +1 -1
  137. package/cjs/picker/contributions/canvas-picker/glyph-picker.js +1 -1
  138. package/cjs/picker/contributions/canvas-picker/glyph-picker.js.map +1 -1
  139. package/cjs/picker/contributions/canvas-picker/group-picker.d.ts +7 -0
  140. package/cjs/picker/contributions/canvas-picker/group-picker.js +26 -0
  141. package/cjs/picker/contributions/canvas-picker/group-picker.js.map +1 -0
  142. package/cjs/picker/contributions/canvas-picker/module.js +3 -1
  143. package/cjs/picker/contributions/canvas-picker/module.js.map +1 -1
  144. package/cjs/picker/contributions/canvas-picker/symbol-picker.js +4 -2
  145. package/cjs/picker/contributions/canvas-picker/symbol-picker.js.map +1 -1
  146. package/cjs/picker/contributions/constants.d.ts +1 -0
  147. package/cjs/picker/contributions/constants.js +9 -8
  148. package/cjs/picker/contributions/constants.js.map +1 -1
  149. package/cjs/picker/contributions/math-picker/glyph-picker.js +1 -1
  150. package/cjs/picker/contributions/math-picker/glyph-picker.js.map +1 -1
  151. package/cjs/picker/global-picker-service.d.ts +1 -1
  152. package/cjs/picker/global-picker-service.js +12 -5
  153. package/cjs/picker/global-picker-service.js.map +1 -1
  154. package/cjs/picker/math-picker-service.d.ts +2 -2
  155. package/cjs/picker/math-picker-service.js +1 -1
  156. package/cjs/picker/math-picker-service.js.map +1 -1
  157. package/cjs/picker/pick-interceptor.d.ts +12 -0
  158. package/cjs/picker/pick-interceptor.js +32 -5
  159. package/cjs/picker/pick-interceptor.js.map +1 -1
  160. package/cjs/picker/pick-modules.js +2 -0
  161. package/cjs/picker/pick-modules.js.map +1 -1
  162. package/cjs/picker/picker-service.d.ts +1 -1
  163. package/cjs/picker/picker-service.js +15 -6
  164. package/cjs/picker/picker-service.js.map +1 -1
  165. package/cjs/plugins/builtin-plugin/flex-layout-plugin.d.ts +2 -0
  166. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +42 -21
  167. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  168. package/cjs/plugins/builtin-plugin/html-attribute-plugin.d.ts +13 -0
  169. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +79 -0
  170. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -0
  171. package/cjs/plugins/plugin-modules.js +1 -1
  172. package/cjs/plugins/plugin-modules.js.map +1 -1
  173. package/cjs/render/contributions/render/area-render.js +3 -2
  174. package/cjs/render/contributions/render/area-render.js.map +1 -1
  175. package/cjs/render/contributions/render/contributions/image-contribution-render.js +23 -1
  176. package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  177. package/cjs/render/contributions/render/draw-contribution.d.ts +3 -1
  178. package/cjs/render/contributions/render/draw-contribution.js +3 -1
  179. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  180. package/cjs/render/contributions/render/draw-interceptor.d.ts +2 -0
  181. package/cjs/render/contributions/render/draw-interceptor.js +8 -0
  182. package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
  183. package/cjs/render/contributions/render/image-render.js +7 -3
  184. package/cjs/render/contributions/render/image-render.js.map +1 -1
  185. package/cjs/render/contributions/render/symbol-render.js +12 -5
  186. package/cjs/render/contributions/render/symbol-render.js.map +1 -1
  187. package/cjs/render/contributions/render/utils.d.ts +2 -2
  188. package/cjs/render/contributions/render/utils.js.map +1 -1
  189. package/cjs/render/render-service.js +3 -1
  190. package/cjs/render/render-service.js.map +1 -1
  191. package/dist/index.js +3692 -430
  192. package/dist/index.min.js +1 -1
  193. package/es/animate/animate.d.ts +1 -0
  194. package/es/animate/animate.js +3 -0
  195. package/es/animate/animate.js.map +1 -1
  196. package/es/animate/timeline.d.ts +1 -1
  197. package/es/animate/timeline.js +2 -2
  198. package/es/animate/timeline.js.map +1 -1
  199. package/es/canvas/contributions/browser/context.d.ts +1 -0
  200. package/es/common/contribution-provider.d.ts +1 -0
  201. package/es/common/contribution-provider.js +4 -0
  202. package/es/common/contribution-provider.js.map +1 -1
  203. package/es/common/enums.d.ts +4 -2
  204. package/es/common/enums.js +3 -2
  205. package/es/common/enums.js.map +1 -1
  206. package/es/core/contributions/env/base-contribution.d.ts +11 -1
  207. package/es/core/contributions/env/base-contribution.js +23 -0
  208. package/es/core/contributions/env/base-contribution.js.map +1 -1
  209. package/es/core/contributions/env/browser-contribution.d.ts +11 -2
  210. package/es/core/contributions/env/browser-contribution.js +67 -1
  211. package/es/core/contributions/env/browser-contribution.js.map +1 -1
  212. package/es/core/contributions/textMeasure/layout.js +1 -1
  213. package/es/core/contributions/textMeasure/layout.js.map +1 -1
  214. package/es/core/contributions/window/base-contribution.d.ts +11 -5
  215. package/es/core/contributions/window/base-contribution.js +10 -0
  216. package/es/core/contributions/window/base-contribution.js.map +1 -1
  217. package/es/core/contributions/window/browser-contribution.d.ts +11 -0
  218. package/es/core/contributions/window/browser-contribution.js +33 -2
  219. package/es/core/contributions/window/browser-contribution.js.map +1 -1
  220. package/es/core/global.d.ts +11 -1
  221. package/es/core/global.js +18 -0
  222. package/es/core/global.js.map +1 -1
  223. package/es/core/graphic-utils.d.ts +2 -0
  224. package/es/core/graphic-utils.js +13 -0
  225. package/es/core/graphic-utils.js.map +1 -1
  226. package/es/core/layer.js +6 -6
  227. package/es/core/layer.js.map +1 -1
  228. package/es/core/stage.d.ts +13 -4
  229. package/es/core/stage.js +57 -24
  230. package/es/core/stage.js.map +1 -1
  231. package/es/core/window.d.ts +6 -0
  232. package/es/core/window.js +10 -1
  233. package/es/core/window.js.map +1 -1
  234. package/es/event/event-manager.js +8 -8
  235. package/es/event/event-manager.js.map +1 -1
  236. package/es/event/event-system.js.map +1 -1
  237. package/es/event/federated-event/pointer-event.d.ts +1 -0
  238. package/es/event/federated-event/pointer-event.js.map +1 -1
  239. package/es/graphic/builtin-symbol/arrow2-down.d.ts +12 -0
  240. package/es/graphic/builtin-symbol/arrow2-down.js +24 -0
  241. package/es/graphic/builtin-symbol/arrow2-down.js.map +1 -0
  242. package/es/graphic/builtin-symbol/arrow2-left.js +1 -1
  243. package/es/graphic/builtin-symbol/arrow2-left.js.map +1 -1
  244. package/es/graphic/builtin-symbol/arrow2-right.js +1 -1
  245. package/es/graphic/builtin-symbol/arrow2-right.js.map +1 -1
  246. package/es/graphic/builtin-symbol/arrow2-up.d.ts +12 -0
  247. package/es/graphic/builtin-symbol/arrow2-up.js +24 -0
  248. package/es/graphic/builtin-symbol/arrow2-up.js.map +1 -0
  249. package/es/graphic/builtin-symbol/close.d.ts +13 -0
  250. package/es/graphic/builtin-symbol/close.js +27 -0
  251. package/es/graphic/builtin-symbol/close.js.map +1 -0
  252. package/es/graphic/builtin-symbol/index.d.ts +1 -1
  253. package/es/graphic/builtin-symbol/index.js +11 -1
  254. package/es/graphic/builtin-symbol/index.js.map +1 -1
  255. package/es/graphic/builtin-symbol/line-h.d.ts +13 -0
  256. package/es/graphic/builtin-symbol/line-h.js +26 -0
  257. package/es/graphic/builtin-symbol/line-h.js.map +1 -0
  258. package/es/graphic/builtin-symbol/line-v.d.ts +13 -0
  259. package/es/graphic/builtin-symbol/line-v.js +26 -0
  260. package/es/graphic/builtin-symbol/line-v.js.map +1 -0
  261. package/es/graphic/builtin-symbol/utils.d.ts +13 -5
  262. package/es/graphic/builtin-symbol/utils.js +25 -7
  263. package/es/graphic/builtin-symbol/utils.js.map +1 -1
  264. package/es/graphic/config.js +10 -5
  265. package/es/graphic/config.js.map +1 -1
  266. package/es/graphic/constants.d.ts +22 -0
  267. package/es/graphic/constants.js +26 -0
  268. package/es/graphic/constants.js.map +1 -1
  269. package/es/graphic/graphic.d.ts +4 -1
  270. package/es/graphic/graphic.js +48 -21
  271. package/es/graphic/graphic.js.map +1 -1
  272. package/es/graphic/group.js +1 -1
  273. package/es/graphic/group.js.map +1 -1
  274. package/es/graphic/index.d.ts +1 -0
  275. package/es/graphic/index.js +2 -0
  276. package/es/graphic/index.js.map +1 -1
  277. package/es/graphic/richtext/utils.d.ts +1 -1
  278. package/es/graphic/richtext/utils.js +1 -1
  279. package/es/graphic/richtext/utils.js.map +1 -1
  280. package/es/graphic/symbol.d.ts +2 -1
  281. package/es/graphic/symbol.js +28 -1
  282. package/es/graphic/symbol.js.map +1 -1
  283. package/es/graphic/text.js +33 -23
  284. package/es/graphic/text.js.map +1 -1
  285. package/es/graphic/tools.d.ts +3 -2
  286. package/es/graphic/tools.js +59 -0
  287. package/es/graphic/tools.js.map +1 -1
  288. package/es/graphic/wrap-text.js +10 -8
  289. package/es/graphic/wrap-text.js.map +1 -1
  290. package/es/index.d.ts +3 -1
  291. package/es/index.js +5 -1
  292. package/es/index.js.map +1 -1
  293. package/es/interface/animate.d.ts +3 -1
  294. package/es/interface/animate.js.map +1 -1
  295. package/es/interface/core.d.ts +1 -0
  296. package/es/interface/core.js.map +1 -1
  297. package/es/interface/global.d.ts +25 -1
  298. package/es/interface/global.js.map +1 -1
  299. package/es/interface/graphic/area.d.ts +1 -0
  300. package/es/interface/graphic/area.js.map +1 -1
  301. package/es/interface/graphic/image.d.ts +1 -0
  302. package/es/interface/graphic/image.js.map +1 -1
  303. package/es/interface/graphic/symbol.d.ts +3 -2
  304. package/es/interface/graphic/symbol.js.map +1 -1
  305. package/es/interface/graphic/text.d.ts +1 -0
  306. package/es/interface/graphic/text.js.map +1 -1
  307. package/es/interface/graphic.d.ts +27 -3
  308. package/es/interface/graphic.js.map +1 -1
  309. package/es/interface/picker.d.ts +9 -1
  310. package/es/interface/picker.js.map +1 -1
  311. package/es/interface/render.d.ts +1 -0
  312. package/es/interface/render.js.map +1 -1
  313. package/es/interface/stage.d.ts +10 -3
  314. package/es/interface/stage.js.map +1 -1
  315. package/es/interface/window.d.ts +12 -0
  316. package/es/interface/window.js.map +1 -1
  317. package/es/jsx/graphicType.d.ts +172 -0
  318. package/es/jsx/graphicType.js +126 -0
  319. package/es/jsx/graphicType.js.map +1 -0
  320. package/es/jsx/index.d.ts +2 -0
  321. package/es/jsx/index.js +4 -0
  322. package/es/jsx/index.js.map +1 -0
  323. package/es/jsx/jsx-classic.d.ts +3 -0
  324. package/es/jsx/jsx-classic.js +56 -0
  325. package/es/jsx/jsx-classic.js.map +1 -0
  326. package/es/picker/canvas-picker-service.d.ts +2 -2
  327. package/es/picker/canvas-picker-service.js +20 -3
  328. package/es/picker/canvas-picker-service.js.map +1 -1
  329. package/es/picker/contributions/canvas-picker/glyph-picker.js +1 -1
  330. package/es/picker/contributions/canvas-picker/glyph-picker.js.map +1 -1
  331. package/es/picker/contributions/canvas-picker/group-picker.d.ts +7 -0
  332. package/es/picker/contributions/canvas-picker/group-picker.js +23 -0
  333. package/es/picker/contributions/canvas-picker/group-picker.js.map +1 -0
  334. package/es/picker/contributions/canvas-picker/module.js +6 -2
  335. package/es/picker/contributions/canvas-picker/module.js.map +1 -1
  336. package/es/picker/contributions/canvas-picker/symbol-picker.js +6 -1
  337. package/es/picker/contributions/canvas-picker/symbol-picker.js.map +1 -1
  338. package/es/picker/contributions/constants.d.ts +1 -0
  339. package/es/picker/contributions/constants.js +2 -0
  340. package/es/picker/contributions/constants.js.map +1 -1
  341. package/es/picker/contributions/math-picker/glyph-picker.js +1 -1
  342. package/es/picker/contributions/math-picker/glyph-picker.js.map +1 -1
  343. package/es/picker/global-picker-service.d.ts +1 -1
  344. package/es/picker/global-picker-service.js +12 -5
  345. package/es/picker/global-picker-service.js.map +1 -1
  346. package/es/picker/math-picker-service.d.ts +2 -2
  347. package/es/picker/math-picker-service.js +1 -1
  348. package/es/picker/math-picker-service.js.map +1 -1
  349. package/es/picker/pick-interceptor.d.ts +12 -0
  350. package/es/picker/pick-interceptor.js +34 -4
  351. package/es/picker/pick-interceptor.js.map +1 -1
  352. package/es/picker/pick-modules.js +4 -2
  353. package/es/picker/pick-modules.js.map +1 -1
  354. package/es/picker/picker-service.d.ts +1 -1
  355. package/es/picker/picker-service.js +15 -6
  356. package/es/picker/picker-service.js.map +1 -1
  357. package/es/plugins/builtin-plugin/flex-layout-plugin.d.ts +2 -0
  358. package/es/plugins/builtin-plugin/flex-layout-plugin.js +47 -20
  359. package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  360. package/es/plugins/builtin-plugin/html-attribute-plugin.d.ts +13 -0
  361. package/es/plugins/builtin-plugin/html-attribute-plugin.js +75 -0
  362. package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -0
  363. package/es/plugins/plugin-modules.js +2 -2
  364. package/es/plugins/plugin-modules.js.map +1 -1
  365. package/es/render/contributions/render/area-render.js +3 -2
  366. package/es/render/contributions/render/area-render.js.map +1 -1
  367. package/es/render/contributions/render/contributions/image-contribution-render.js +27 -0
  368. package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  369. package/es/render/contributions/render/draw-contribution.d.ts +3 -1
  370. package/es/render/contributions/render/draw-contribution.js +4 -0
  371. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  372. package/es/render/contributions/render/draw-interceptor.d.ts +2 -0
  373. package/es/render/contributions/render/draw-interceptor.js +8 -0
  374. package/es/render/contributions/render/draw-interceptor.js.map +1 -1
  375. package/es/render/contributions/render/image-render.js +10 -2
  376. package/es/render/contributions/render/image-render.js.map +1 -1
  377. package/es/render/contributions/render/symbol-render.js +12 -5
  378. package/es/render/contributions/render/symbol-render.js.map +1 -1
  379. package/es/render/contributions/render/utils.d.ts +2 -2
  380. package/es/render/contributions/render/utils.js.map +1 -1
  381. package/es/render/render-service.js +3 -1
  382. package/es/render/render-service.js.map +1 -1
  383. package/package.json +9 -12
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/tools.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA6C;AAK7C,SAAgB,gBAAgB,CAAC,KAAa,EAAE,OAAiB;IAC/D,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAIxC,CAAC;AALD,4CAKC;AAED,SAAsB,mBAAmB,CAAC,KAAa;;QACrD,MAAM,WAAW,GAAmB,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAc,CAAC;QAC/C,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC1B,yBAAW,CAAC,MAAM,CAAC,wBAAwB,EAAE,CAAC,GAAG,EAAE;gBACjD,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACjB,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE;gBACpB,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;oBACvB,IAA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,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1E,MAAM,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;AAChC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACxD,MAAM,gBAAgB,GAAG,CAAC,EAAE,CAAC,CAAC;AAC9B,MAAM,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;AAClC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAE5D,SAAS,UAAU,CAAC,CAAS;IAC3B,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IACD,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QAC1B,OAAO,KAAK,CAAC;KACd;IACD,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,IAAI,EAAE,GAAG,GAAG,EAAE;QACZ,MAAM,GAAG,IAAI,CAAC;KACf;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","file":"tools.js","sourcesContent":["import { application } from '../application';\nimport type { IGraphic, IGroup, ILayer, IStage } from '../interface';\nimport type { IAABBBounds } from '@visactor/vutils';\n\n// 不触发外部的render\nexport function incrementalAddTo(group: IGroup, graphic: IGraphic) {\n group.incrementalAppendChild(graphic);\n // if (group.layer && group.layer.subLayers) {\n // // const subLayer = group.layer.subLayers.get(group._uid);\n // }\n}\n\nexport async function waitForAllSubLayers(stage: IStage) {\n const promiseList: Promise<any>[] = [];\n const layers = stage.getChildren() as ILayer[];\n await new Promise(resolve => {\n application.global.getRequestAnimationFrame()(() => {\n resolve(null);\n });\n });\n layers.forEach(l => {\n if (l.subLayers.size) {\n l.subLayers.forEach(sl => {\n if (sl.drawContribution && sl.drawContribution.hooks && sl.drawContribution.rendering) {\n promiseList.push(\n new Promise(resolve => {\n sl.drawContribution!.hooks!.completeDraw.tap('outWait', () => {\n sl.drawContribution!.hooks!.completeDraw.taps = sl.drawContribution!.hooks!.completeDraw.taps.filter(\n i => {\n return i.name !== 'outWait';\n }\n );\n resolve(null);\n });\n })\n );\n }\n });\n }\n });\n await Promise.all(promiseList);\n}\n\nexport function boundStroke(bounds: IAABBBounds, halfW: number, miter: boolean, pad = 0) {\n bounds.expand(halfW + (pad / 2 + (miter ? miterAdjustment(miter, halfW) : 0)));\n return bounds;\n}\n\nfunction miterAdjustment(miter: boolean, strokeWidth: number) {\n return miter ? strokeWidth : 0;\n}\n\n// function attachShadow(graphic: Graphic) {\n// graphic.shadowRoot = createShadowRoot(graphic);\n// graphic.addUpdateBoundTag();\n// return graphic.shadowRoot;\n// }\n\n// function detachShadow(graphic: Graphic) {\n// if (graphic.shadowRoot) {\n// graphic.addUpdateBoundTag();\n// graphic.shadowRoot = null;\n// }\n// }\n\nlet NUMBER_TYPE: number = 0;\nexport function genNumberType() {\n return NUMBER_TYPE++;\n}\n\nexport enum TextDirection {\n HORIZONTAL = 0,\n VERTICAL = 1\n}\nexport function verticalLayout(text: string) {\n const nextCharacter: { text: string; direction: TextDirection }[] = [];\n let flag = 0; // 0: 竖排,1: 旋转\n let currStr = '';\n for (let i = 0; i < text.length; i++) {\n if (rotateText(text[i])) {\n if (flag) {\n currStr += text[i];\n } else {\n flag = 1;\n currStr = text[i];\n }\n } else {\n if (flag) {\n nextCharacter.push({\n text: currStr,\n direction: TextDirection.VERTICAL\n });\n currStr = '';\n flag = 0;\n }\n nextCharacter.push({\n text: text[i],\n direction: TextDirection.HORIZONTAL\n });\n }\n }\n\n if (currStr) {\n nextCharacter.push({\n text: currStr,\n direction: TextDirection.VERTICAL\n });\n }\n return nextCharacter;\n}\n\n// ——, ……, (, )\nconst rotateCharList = ['…', '(', ')', '—', '【', '】', '「', '」', '《', '》'];\nconst rotateCharMap = new Map();\nrotateCharList.forEach(c => rotateCharMap.set(c, true));\nconst noRotateCharList = [''];\nconst noRotateCharMap = new Map();\nnoRotateCharList.forEach(c => noRotateCharMap.set(c, true));\n\nfunction rotateText(c: string) {\n if (rotateCharMap.has(c)) {\n return true;\n }\n if (noRotateCharMap.has(c)) {\n return false;\n }\n const cp = c.codePointAt(0);\n let rotate = false;\n // 默认ascii码就旋转\n if (cp < 256) {\n rotate = true;\n }\n return rotate;\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/tools.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA6C;AAE7C,6CAA6D;AAC7D,qDAA0D;AAG1D,SAAgB,gBAAgB,CAAC,KAAa,EAAE,OAAiB;IAC/D,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAIxC,CAAC;AALD,4CAKC;AAED,SAAsB,mBAAmB,CAAC,KAAa;;QACrD,MAAM,WAAW,GAAmB,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAc,CAAC;QAC/C,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC1B,yBAAW,CAAC,MAAM,CAAC,wBAAwB,EAAE,CAAC,GAAG,EAAE;gBACjD,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACjB,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE;gBACpB,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;oBACvB,IAAI,EAAE,CAAC,gBAAgB,IAAI,EAAE,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,gBAAgB,CA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ent":["import { application } from '../application';\nimport type { IGraphic, IGroup, ILayer, IRichTextCharacter, IRichTextImageCharacter, IStage } from '../interface';\nimport { isArray, type IAABBBounds } from '@visactor/vutils';\nimport { XMLValidator, XMLParser } from 'fast-xml-parser';\n\n// 不触发外部的render\nexport function incrementalAddTo(group: IGroup, graphic: IGraphic) {\n group.incrementalAppendChild(graphic);\n // if (group.layer && group.layer.subLayers) {\n // // const subLayer = group.layer.subLayers.get(group._uid);\n // }\n}\n\nexport async function waitForAllSubLayers(stage: IStage) {\n const promiseList: Promise<any>[] = [];\n const layers = stage.getChildren() as ILayer[];\n await new Promise(resolve => {\n application.global.getRequestAnimationFrame()(() => {\n resolve(null);\n });\n });\n layers.forEach(l => {\n if (l.subLayers.size) {\n l.subLayers.forEach(sl => {\n if (sl.drawContribution && sl.drawContribution.hooks && sl.drawContribution.rendering) {\n promiseList.push(\n new Promise(resolve => {\n sl.drawContribution!.hooks!.completeDraw.tap('outWait', () => {\n sl.drawContribution!.hooks!.completeDraw.taps = sl.drawContribution!.hooks!.completeDraw.taps.filter(\n i => {\n return i.name !== 'outWait';\n }\n );\n resolve(null);\n });\n })\n );\n }\n });\n }\n });\n await Promise.all(promiseList);\n}\n\nexport function boundStroke(bounds: IAABBBounds, halfW: number, miter: boolean, pad = 0) {\n bounds.expand(halfW + (pad / 2 + (miter ? miterAdjustment(miter, halfW) : 0)));\n return bounds;\n}\n\nfunction miterAdjustment(miter: boolean, strokeWidth: number) {\n return miter ? strokeWidth : 0;\n}\n\n// function attachShadow(graphic: Graphic) {\n// graphic.shadowRoot = createShadowRoot(graphic);\n// graphic.addUpdateBoundTag();\n// return graphic.shadowRoot;\n// }\n\n// function detachShadow(graphic: Graphic) {\n// if (graphic.shadowRoot) {\n// graphic.addUpdateBoundTag();\n// graphic.shadowRoot = null;\n// }\n// }\n\nlet NUMBER_TYPE: number = 0;\nexport function genNumberType() {\n return NUMBER_TYPE++;\n}\n\nexport enum TextDirection {\n HORIZONTAL = 0,\n VERTICAL = 1\n}\nexport function verticalLayout(text: string) {\n const nextCharacter: { text: string; direction: TextDirection }[] = [];\n let flag = 0; // 0: 竖排,1: 旋转\n let currStr = '';\n for (let i = 0; i < text.length; i++) {\n if (rotateText(text[i])) {\n if (flag) {\n currStr += text[i];\n } else {\n flag = 1;\n currStr = text[i];\n }\n } else {\n if (flag) {\n nextCharacter.push({\n text: currStr,\n direction: TextDirection.VERTICAL\n });\n currStr = '';\n flag = 0;\n }\n nextCharacter.push({\n text: text[i],\n direction: TextDirection.HORIZONTAL\n });\n }\n }\n\n if (currStr) {\n nextCharacter.push({\n text: currStr,\n direction: TextDirection.VERTICAL\n });\n }\n return nextCharacter;\n}\n\n// ——, ……, (, )\nconst rotateCharList = ['…', '(', ')', '—', '【', '】', '「', '」', '《', '》'];\nconst rotateCharMap = new Map();\nrotateCharList.forEach(c => rotateCharMap.set(c, true));\nconst noRotateCharList = [''];\nconst noRotateCharMap = new Map();\nnoRotateCharList.forEach(c => noRotateCharMap.set(c, true));\n\nfunction rotateText(c: string) {\n if (rotateCharMap.has(c)) {\n return true;\n }\n if (noRotateCharMap.has(c)) {\n return false;\n }\n const cp = c.codePointAt(0);\n let rotate = false;\n // 默认ascii码就旋转\n if (cp < 256) {\n rotate = true;\n }\n return rotate;\n}\n\nexport function xul(str: string | string[]): IRichTextCharacter[] {\n const xmlStr = isArray(str) ? str[0] : str;\n const config: IRichTextCharacter[] = [];\n if (!xmlStr) {\n return config;\n }\n const isXML = XMLValidator.validate(xmlStr, {\n allowBooleanAttributes: true\n });\n if (isXML === true) {\n const parser = new XMLParser({ ignoreAttributes: false });\n const data = parser.parse(xmlStr);\n data.tc &&\n Object.keys(data.tc).forEach(k => {\n if (k === 'text') {\n config.push(parseRTTextXML(data.tc[k]));\n } else {\n config.push(parseRTImageXML(data.tc[k]));\n }\n });\n }\n return config;\n}\n\nfunction parseRTTextXML(str: string): IRichTextCharacter {\n const output: IRichTextCharacter = { text: '' };\n parseCommonXML(str, output);\n const inlineText = str['#text'];\n if (inlineText) {\n output.text = inlineText;\n }\n\n return output;\n}\n\nfunction parseCommonXML(str: string, output: IRichTextCharacter) {\n const attr = str['@_attribute'];\n if (attr) {\n const attrList = attr.split(';');\n attrList.forEach((attrItem: string) => {\n if (!attrItem) {\n return;\n }\n const kv = attrItem.split(':');\n\n if (kv.length === 2) {\n const val = parseFloat(kv[1]);\n output[kv[0].trim()] = isFinite(val) ? val : kv[1].trim();\n } else {\n let val = '';\n for (let i = 1; i < kv.length; i++) {\n if (i > 1) {\n val += ':';\n }\n val += kv[i].trim();\n }\n output[kv[0].trim()] = val;\n }\n });\n }\n}\n\nfunction parseRTImageXML(str: string): IRichTextCharacter {\n const output: IRichTextImageCharacter = { image: '', width: 0, height: 0 };\n parseCommonXML(str, output);\n const image = output.image as string;\n if (image) {\n output.image = (image as any).replaceAll('&quot', '\"').replaceAll('&lt', '<').replaceAll('&gt', '>');\n }\n return output;\n}\n"]}
@@ -13,14 +13,16 @@ class WrapText extends text_1.Text {
13
13
  }
14
14
  updateMultilineAABBBounds(text) {
15
15
  var _a, _b, _c;
16
- const textTheme = (0, theme_1.getTheme)(this).text, {fontFamily: fontFamily = textTheme.fontFamily, textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline, fontSize: fontSize = textTheme.fontSize, lineHeight: lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize, ellipsis: ellipsis = textTheme.ellipsis, maxLineWidth: maxLineWidth, stroke: stroke = textTheme.stroke, lineWidth: lineWidth = textTheme.lineWidth, heightLimit: heightLimit = 0, lineClamp: lineClamp} = this.attribute;
16
+ const textTheme = (0, theme_1.getTheme)(this).text, {fontFamily: fontFamily = textTheme.fontFamily, textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline, fontSize: fontSize = textTheme.fontSize, lineHeight: lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize, ellipsis: ellipsis = textTheme.ellipsis, maxLineWidth: maxLineWidth, stroke: stroke = textTheme.stroke, lineWidth: lineWidth = textTheme.lineWidth, wordBreak: wordBreak = textTheme.wordBreak, fontWeight: fontWeight = textTheme.fontWeight, ignoreBuf: ignoreBuf = textTheme.ignoreBuf, heightLimit: heightLimit = 0, lineClamp: lineClamp} = this.attribute, buf = ignoreBuf ? 0 : 2;
17
17
  if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
18
18
  const bbox = this.cache.layoutData.bbox;
19
19
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height),
20
20
  stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
21
21
  }
22
22
  const textMeasure = application_1.application.graphicUtil.textMeasure, layoutObj = new layout_1.CanvasTextLayout(fontFamily, {
23
- fontSize: fontSize
23
+ fontSize: fontSize,
24
+ fontWeight: fontWeight,
25
+ fontFamily: fontFamily
24
26
  }, textMeasure), lines = text.map((l => l.toString())), linesLayout = [], bboxWH = [ 0, 0 ];
25
27
  let lineCountLimit = 1 / 0;
26
28
  if (heightLimit > 0 && (lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1)),
@@ -29,17 +31,17 @@ class WrapText extends text_1.Text {
29
31
  const str = lines[i];
30
32
  let needCut = !0;
31
33
  if (i === lineCountLimit - 1) {
32
- const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis);
34
+ const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1);
33
35
  linesLayout.push({
34
36
  str: clip.str,
35
37
  width: clip.width
36
38
  });
37
39
  break;
38
40
  }
39
- const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth);
41
+ const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-word" === wordBreak);
40
42
  if ("" !== str && "" === clip.str) {
41
43
  if (ellipsis) {
42
- const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis);
44
+ const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1);
43
45
  clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
44
46
  } else clip.str = "", clip.width = 0;
45
47
  needCut = !1;
@@ -60,14 +62,14 @@ class WrapText extends text_1.Text {
60
62
  let width, text, lineWidth = 0;
61
63
  for (let i = 0, len = lines.length; i < len; i++) {
62
64
  if (i === lineCountLimit - 1) {
63
- const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis);
65
+ const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1);
64
66
  linesLayout.push({
65
67
  str: clip.str,
66
68
  width: clip.width
67
69
  }), lineWidth = Math.max(lineWidth, clip.width);
68
70
  break;
69
71
  }
70
- text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions),
72
+ text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak),
71
73
  lineWidth = Math.max(lineWidth, width), linesLayout.push({
72
74
  str: text,
73
75
  width: width
@@ -75,7 +77,7 @@ class WrapText extends text_1.Text {
75
77
  }
76
78
  bboxWH[0] = lineWidth;
77
79
  }
78
- bboxWH[1] = linesLayout.length * (lineHeight + 2);
80
+ bboxWH[1] = linesLayout.length * (lineHeight + buf);
79
81
  const bbox = {
80
82
  xOffset: 0,
81
83
  yOffset: 0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/wrap-text.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,qEAA4E;AAE5E,gDAA6C;AAC7C,iCAA8B;AAC9B,mCAAmC;AAEnC,MAAM,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AAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE;gBAChC,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,aAAa,CAAC,GAAW;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,wBAAwB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxD,MAAM,OAAO,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,OAAO,EAAE;gBACnB,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;CACF;AA1MD,4BA0MC","file":"wrap-text.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { CanvasTextLayout } from '../core/contributions/textMeasure/layout';\nimport type { IWrapTextGraphicAttribute, LayoutItemType } from '../interface';\nimport { application } from '../application';\nimport { Text } from './text';\nimport { getTheme } from './theme';\n\nconst WRAP_TEXT_UPDATE_TAG_KEY = ['heightLimit', 'lineClamp'];\n\n/* WrapText功能\n * 1. 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 2. 高度限制控制显示内容及省略号(heightLimit)\n * 3. 按照行数限制显示内容及省略号(lineClamp)\n */\nexport class WrapText extends Text {\n declare attribute: IWrapTextGraphicAttribute;\n\n protected _isValid(): boolean {\n const { text } = this.attribute;\n if (isArray(text)) {\n return !(text as any[]).every((t: any) => t == null || t === '');\n }\n return text != null && text !== '';\n }\n\n /**\n * 计算多行文字的bounds,缓存每行文字的布局位置\n * 自动折行params.text是数组,因此只重新updateMultilineAABBBounds\n * @param text\n */\n updateMultilineAABBBounds(text: (number | string)[]) {\n const textTheme = getTheme(this).text;\n const {\n fontFamily = textTheme.fontFamily,\n textAlign = textTheme.textAlign,\n textBaseline = textTheme.textBaseline,\n fontSize = textTheme.fontSize,\n lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize,\n ellipsis = textTheme.ellipsis,\n maxLineWidth,\n stroke = textTheme.stroke,\n lineWidth = textTheme.lineWidth,\n // widthLimit,\n heightLimit = 0,\n lineClamp\n } = this.attribute;\n const buf = 2;\n if (!this.shouldUpdateShape() && this.cache?.layoutData) {\n const bbox = this.cache.layoutData.bbox;\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n\n const textMeasure = application.graphicUtil.textMeasure;\n const layoutObj = new CanvasTextLayout(fontFamily, { fontSize }, textMeasure as any) as any;\n\n // layoutObj内逻辑\n const lines = text.map(l => l.toString()) as string[];\n const linesLayout: LayoutItemType[] = [];\n const bboxWH: [number, number] = [0, 0];\n\n let lineCountLimit = Infinity;\n if (heightLimit > 0) {\n lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);\n }\n if (lineClamp) {\n // 处理行数限制\n lineCountLimit = Math.min(lineCountLimit, lineClamp);\n }\n\n if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {\n // widthLimit > 0\n if (maxLineWidth > 0) {\n for (let i = 0; i < lines.length; i++) {\n const str = lines[i] as string;\n let needCut = true;\n // // 测量当前行宽度\n // width = Math.min(\n // layoutObj.textMeasure.measureTextWidth(str, layoutObj.textOptions),\n // maxLineWidth\n // );\n\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis);\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n break; // 不处理后续行\n }\n\n // 测量截断位置\n const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth);\n if (str !== '' && clip.str === '') {\n if (ellipsis) {\n const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis\n );\n clip.str = clipEllipsis.str ?? '';\n clip.width = clipEllipsis.width ?? 0;\n } else {\n // 宽度限制不足一个字符,不显示\n clip.str = '';\n clip.width = 0;\n }\n needCut = false;\n }\n\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else if (needCut) {\n const newStr = str.substring(clip.str.length);\n lines.splice(i + 1, 0, newStr);\n }\n }\n }\n // bboxWH[0] = maxLineWidth;\n let maxWidth = 0;\n linesLayout.forEach(layout => {\n maxWidth = Math.max(maxWidth, layout.width);\n });\n bboxWH[0] = maxWidth;\n } else {\n // 使用所有行中最长的作为lineWidth\n let lineWidth = 0;\n let width: number;\n let text: string;\n for (let i = 0, len = lines.length; i < len; i++) {\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n lines[i],\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n lineWidth = Math.max(lineWidth, clip.width);\n break; // 不处理后续行\n }\n\n text = lines[i] as string;\n width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions);\n lineWidth = Math.max(lineWidth, width);\n linesLayout.push({ str: text, width });\n }\n bboxWH[0] = lineWidth;\n }\n bboxWH[1] = linesLayout.length * (lineHeight + buf);\n\n const bbox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n layoutObj.LayoutBBox(bbox, textAlign, textBaseline as any);\n\n const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline as any, lineHeight);\n\n // const layoutData = layoutObj.GetLayoutByLines(\n // text,\n // textAlign,\n // textBaseline as any,\n // lineHeight,\n // ellipsis === true ? (DefaultTextAttribute.ellipsis as string) : ellipsis || undefined,\n // maxLineWidth\n // );\n // const { bbox } = layoutData;\n this.cache.layoutData = layoutData;\n this.clearUpdateShapeTag();\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n needUpdateTags(keys: string[]): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (keys.indexOf(attrKey) !== -1) {\n return true;\n }\n }\n return super.needUpdateTags(keys);\n }\n\n needUpdateTag(key: string): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (key === attrKey) {\n return true;\n }\n }\n return super.needUpdateTag(key);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/wrap-text.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,qEAA4E;AAE5E,gDAA6C;AAC7C,iCAA8B;AAC9B,mCAAmC;AAEnC,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAO9D,MAAa,QAAS,SAAQ,WAAI;IAGtB,QAAQ;QAChB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,IAAA,gBAAO,EAAC,IAAI,CAAC,EAAE;YACjB,OAAO,CAAE,IAAc,CAAC,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;SAClE;QACD,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;IACrC,CAAC;IAOD,yBAAyB,CAAC,IAAyB;;QACjD,MAAM,SAAS,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAA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KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,wBAAwB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxD,MAAM,OAAO,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,OAAO,EAAE;gBACnB,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;CACF;AA1ND,4BA0NC","file":"wrap-text.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { CanvasTextLayout } from '../core/contributions/textMeasure/layout';\nimport type { IWrapTextGraphicAttribute, LayoutItemType } from '../interface';\nimport { application } from '../application';\nimport { Text } from './text';\nimport { getTheme } from './theme';\n\nconst WRAP_TEXT_UPDATE_TAG_KEY = ['heightLimit', 'lineClamp'];\n\n/* WrapText功能\n * 1. 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 2. 高度限制控制显示内容及省略号(heightLimit)\n * 3. 按照行数限制显示内容及省略号(lineClamp)\n */\nexport class WrapText extends Text {\n declare attribute: IWrapTextGraphicAttribute;\n\n protected _isValid(): boolean {\n const { text } = this.attribute;\n if (isArray(text)) {\n return !(text as any[]).every((t: any) => t == null || t === '');\n }\n return text != null && text !== '';\n }\n\n /**\n * 计算多行文字的bounds,缓存每行文字的布局位置\n * 自动折行params.text是数组,因此只重新updateMultilineAABBBounds\n * @param text\n */\n updateMultilineAABBBounds(text: (number | string)[]) {\n const textTheme = getTheme(this).text;\n const {\n fontFamily = textTheme.fontFamily,\n textAlign = textTheme.textAlign,\n textBaseline = textTheme.textBaseline,\n fontSize = textTheme.fontSize,\n lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize,\n ellipsis = textTheme.ellipsis,\n maxLineWidth,\n stroke = textTheme.stroke,\n lineWidth = textTheme.lineWidth,\n wordBreak = textTheme.wordBreak,\n fontWeight = textTheme.fontWeight,\n // widthLimit,\n ignoreBuf = textTheme.ignoreBuf,\n heightLimit = 0,\n lineClamp\n } = this.attribute;\n const buf = ignoreBuf ? 0 : 2;\n if (!this.shouldUpdateShape() && this.cache?.layoutData) {\n const bbox = this.cache.layoutData.bbox;\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n\n const textMeasure = application.graphicUtil.textMeasure;\n const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure as any) as any;\n\n // layoutObj内逻辑\n const lines = text.map(l => l.toString()) as string[];\n const linesLayout: LayoutItemType[] = [];\n const bboxWH: [number, number] = [0, 0];\n\n let lineCountLimit = Infinity;\n if (heightLimit > 0) {\n lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);\n }\n if (lineClamp) {\n // 处理行数限制\n lineCountLimit = Math.min(lineCountLimit, lineClamp);\n }\n\n if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {\n // widthLimit > 0\n if (maxLineWidth > 0) {\n for (let i = 0; i < lines.length; i++) {\n const str = lines[i] as string;\n let needCut = true;\n // // 测量当前行宽度\n // width = Math.min(\n // layoutObj.textMeasure.measureTextWidth(str, layoutObj.textOptions),\n // maxLineWidth\n // );\n\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n break; // 不处理后续行\n }\n\n // 测量截断位置\n const clip = layoutObj.textMeasure.clipText(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n wordBreak === 'break-word'\n );\n if (str !== '' && clip.str === '') {\n if (ellipsis) {\n const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n clip.str = clipEllipsis.str ?? '';\n clip.width = clipEllipsis.width ?? 0;\n } else {\n // 宽度限制不足一个字符,不显示\n clip.str = '';\n clip.width = 0;\n }\n needCut = false;\n }\n\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else if (needCut) {\n const newStr = str.substring(clip.str.length);\n lines.splice(i + 1, 0, newStr);\n }\n }\n }\n // bboxWH[0] = maxLineWidth;\n let maxWidth = 0;\n linesLayout.forEach(layout => {\n maxWidth = Math.max(maxWidth, layout.width);\n });\n bboxWH[0] = maxWidth;\n } else {\n // 使用所有行中最长的作为lineWidth\n let lineWidth = 0;\n let width: number;\n let text: string;\n for (let i = 0, len = lines.length; i < len; i++) {\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n lines[i],\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n lineWidth = Math.max(lineWidth, clip.width);\n break; // 不处理后续行\n }\n\n text = lines[i] as string;\n width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');\n lineWidth = Math.max(lineWidth, width);\n linesLayout.push({ str: text, width });\n }\n bboxWH[0] = lineWidth;\n }\n bboxWH[1] = linesLayout.length * (lineHeight + buf);\n\n const bbox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n layoutObj.LayoutBBox(bbox, textAlign, textBaseline as any);\n\n const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline as any, lineHeight);\n\n // const layoutData = layoutObj.GetLayoutByLines(\n // text,\n // textAlign,\n // textBaseline as any,\n // lineHeight,\n // ellipsis === true ? (DefaultTextAttribute.ellipsis as string) : ellipsis || undefined,\n // maxLineWidth\n // );\n // const { bbox } = layoutData;\n this.cache.layoutData = layoutData;\n this.clearUpdateShapeTag();\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n needUpdateTags(keys: string[]): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (keys.indexOf(attrKey) !== -1) {\n return true;\n }\n }\n return super.needUpdateTags(keys);\n }\n\n needUpdateTag(key: string): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (key === attrKey) {\n return true;\n }\n }\n return super.needUpdateTag(key);\n }\n}\n"]}
package/cjs/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'core-js/proposals/reflect-metadata';
2
2
  import './modules';
3
- export declare const version = "0.14.9-alpha.1";
3
+ export declare const version = "0.14.9-alpha.4";
4
4
  export * from './container';
5
5
  export * from './core/global';
6
6
  export * from './graphic';
@@ -38,5 +38,7 @@ export * from './common/split-path';
38
38
  export * from './common/enums';
39
39
  export * from './common/generator';
40
40
  export * from './plugins/constants';
41
+ export * from './allocator/matrix-allocate';
41
42
  export * from './animate/default-ticker';
42
43
  export { wrapCanvas, wrapContext } from './canvas/util';
44
+ export * from './jsx';
package/cjs/index.js CHANGED
@@ -18,7 +18,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
20
  }), exports.wrapContext = exports.wrapCanvas = exports.version = void 0, require("core-js/proposals/reflect-metadata"),
21
- require("./modules"), exports.version = "0.14.9-alpha.1", __exportStar(require("./container"), exports),
21
+ require("./modules"), exports.version = "0.14.9-alpha.4", __exportStar(require("./container"), exports),
22
22
  __exportStar(require("./core/global"), exports), __exportStar(require("./graphic"), exports),
23
23
  __exportStar(require("./modules"), exports), __exportStar(require("./create"), exports),
24
24
  __exportStar(require("./event"), exports), __exportStar(require("./interface"), exports),
@@ -37,7 +37,7 @@ __exportStar(require("./common/render-area"), exports), __exportStar(require("./
37
37
  __exportStar(require("./common/sort"), exports), __exportStar(require("./common/morphing-utils"), exports),
38
38
  __exportStar(require("./common/split-path"), exports), __exportStar(require("./common/enums"), exports),
39
39
  __exportStar(require("./common/generator"), exports), __exportStar(require("./plugins/constants"), exports),
40
- __exportStar(require("./animate/default-ticker"), exports);
40
+ __exportStar(require("./allocator/matrix-allocate"), exports), __exportStar(require("./animate/default-ticker"), exports);
41
41
 
42
42
  var util_1 = require("./canvas/util");
43
43
 
@@ -51,5 +51,5 @@ Object.defineProperty(exports, "wrapCanvas", {
51
51
  get: function() {
52
52
  return util_1.wrapContext;
53
53
  }
54
- });
54
+ }), __exportStar(require("./jsx"), exports);
55
55
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA4C;AAC5C,qBAAmB;AAGN,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAExC,8CAA4B;AAC5B,gDAA8B;AAC9B,4CAA0B;AAC1B,4CAA0B;AAC1B,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,4EAA0D;AAC1D,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,yCAAuB;AACvB,4CAA0B;AAC1B,2DAAyC;AAGzC,gDAA8B;AAC9B,wDAAsC;AACtC,0DAAwC;AACxC,uDAAqC;AACrC,yDAAuC;AACvC,mDAAiC;AACjC,wDAAsC;AACtC,iEAA+C;AAC/C,qDAAmC;AACnC,iDAA+B;AAC/B,qDAAmC;AACnC,sDAAoC;AAEpC,oDAAkC;AAClC,wDAAsC;AACtC,uDAAqC;AACrC,+DAA6C;AAC7C,gDAA8B;AAC9B,0DAAwC;AACxC,sDAAoC;AACpC,iDAA+B;AAC/B,qDAAmC;AACnC,sDAAoC;AAEpC,2DAAyC;AACzC,sCAAwD;AAA/C,kGAAA,UAAU,OAAA;AAAE,mGAAA,WAAW,OAAA","file":"index.js","sourcesContent":["import 'core-js/proposals/reflect-metadata';\nimport './modules';\n\n// 导出版本号\nexport const version = \"0.14.9-alpha.1\";\n\nexport * from './container';\nexport * from './core/global';\nexport * from './graphic';\nexport * from './modules';\nexport * from './create';\nexport * from './event';\nexport * from './interface';\nexport * from './render';\nexport * from './render/contributions/render/base-render';\nexport * from './canvas';\nexport * from './core';\nexport * from './picker';\nexport * from './kits';\nexport * from './animate';\nexport * from './resource-loader/loader';\n\n/* export common */\nexport * from './common/text';\nexport * from './common/bezier-utils';\nexport * from './common/bounds-context';\nexport * from './common/seg-context';\nexport * from './common/custom-path2d';\nexport * from './common/segment';\nexport * from './common/canvas-utils';\nexport * from './common/contribution-provider';\nexport * from './common/generator';\nexport * from './common/utils';\nexport * from './common/shape/arc';\nexport * from './common/shape/rect';\n\nexport * from './common/path-svg';\nexport * from './common/render-curve';\nexport * from './common/render-area';\nexport * from './common/render-command-list';\nexport * from './common/sort';\nexport * from './common/morphing-utils';\nexport * from './common/split-path';\nexport * from './common/enums';\nexport * from './common/generator';\nexport * from './plugins/constants';\n\nexport * from './animate/default-ticker';\nexport { wrapCanvas, wrapContext } from './canvas/util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA4C;AAC5C,qBAAmB;AAGN,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAExC,8CAA4B;AAC5B,gDAA8B;AAC9B,4CAA0B;AAC1B,4CAA0B;AAC1B,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,4EAA0D;AAC1D,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,yCAAuB;AACvB,4CAA0B;AAC1B,2DAAyC;AAGzC,gDAA8B;AAC9B,wDAAsC;AACtC,0DAAwC;AACxC,uDAAqC;AACrC,yDAAuC;AACvC,mDAAiC;AACjC,wDAAsC;AACtC,iEAA+C;AAC/C,qDAAmC;AACnC,iDAA+B;AAC/B,qDAAmC;AACnC,sDAAoC;AAEpC,oDAAkC;AAClC,wDAAsC;AACtC,uDAAqC;AACrC,+DAA6C;AAC7C,gDAA8B;AAC9B,0DAAwC;AACxC,sDAAoC;AACpC,iDAA+B;AAC/B,qDAAmC;AACnC,sDAAoC;AACpC,8DAA4C;AAE5C,2DAAyC;AACzC,sCAAwD;AAA/C,kGAAA,UAAU,OAAA;AAAE,mGAAA,WAAW,OAAA;AAChC,wCAAsB","file":"index.js","sourcesContent":["import 'core-js/proposals/reflect-metadata';\nimport './modules';\n\n// 导出版本号\nexport const version = \"0.14.9-alpha.4\";\n\nexport * from './container';\nexport * from './core/global';\nexport * from './graphic';\nexport * from './modules';\nexport * from './create';\nexport * from './event';\nexport * from './interface';\nexport * from './render';\nexport * from './render/contributions/render/base-render';\nexport * from './canvas';\nexport * from './core';\nexport * from './picker';\nexport * from './kits';\nexport * from './animate';\nexport * from './resource-loader/loader';\n\n/* export common */\nexport * from './common/text';\nexport * from './common/bezier-utils';\nexport * from './common/bounds-context';\nexport * from './common/seg-context';\nexport * from './common/custom-path2d';\nexport * from './common/segment';\nexport * from './common/canvas-utils';\nexport * from './common/contribution-provider';\nexport * from './common/generator';\nexport * from './common/utils';\nexport * from './common/shape/arc';\nexport * from './common/shape/rect';\n\nexport * from './common/path-svg';\nexport * from './common/render-curve';\nexport * from './common/render-area';\nexport * from './common/render-command-list';\nexport * from './common/sort';\nexport * from './common/morphing-utils';\nexport * from './common/split-path';\nexport * from './common/enums';\nexport * from './common/generator';\nexport * from './plugins/constants';\nexport * from './allocator/matrix-allocate';\n\nexport * from './animate/default-ticker';\nexport { wrapCanvas, wrapContext } from './canvas/util';\nexport * from './jsx';\n"]}
@@ -101,6 +101,7 @@ export interface IAnimate {
101
101
  _onRemove?: (() => void)[];
102
102
  getStartProps: () => Record<string, any>;
103
103
  getEndProps: () => Record<string, any>;
104
+ setTimeline: (timeline: ITimeline) => void;
104
105
  bind: (target: IAnimateTarget) => this;
105
106
  to: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;
106
107
  from: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;
@@ -157,7 +158,7 @@ export interface ITimeline {
157
158
  id: number;
158
159
  animateCount: number;
159
160
  addAnimate: (animate: IAnimate) => void;
160
- removeAnimate: (animate: IAnimate) => void;
161
+ removeAnimate: (animate: IAnimate, release?: boolean) => void;
161
162
  tick: (delta: number) => void;
162
163
  clear: () => void;
163
164
  pause: () => void;
@@ -186,4 +187,5 @@ export interface ITicker {
186
187
  resume: () => boolean;
187
188
  start: (force?: boolean) => boolean;
188
189
  stop: () => void;
190
+ addTimeline: (timeline: ITimeline) => void;
189
191
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { AnimateMode, AnimateStatus, AnimateStepType } from '../common/enums';\nimport type { Releaseable } from './common';\nimport type { IGraphic } from './graphic';\n\n// export type EasingType = (...args: any) => any;\n\nexport declare class Easing {\n static linear(t: number): number;\n static none(): typeof Easing.linear;\n /**\n * 获取缓动函数,amount指示这个缓动函数的插值方式\n * @param amount\n * @returns\n */\n static get(amount: number): (t: number) => number;\n static getPowIn(pow: number): (t: number) => number;\n static getPowOut(pow: number): (t: number) => number;\n static getPowInOut(pow: number): (t: number) => number;\n static quadIn: (t: number) => number;\n static quadOut: (t: number) => number;\n static quadInOut: (t: number) => number;\n static cubicIn: (t: number) => number;\n static cubicOut: (t: number) => number;\n static cubicInOut: (t: number) => number;\n static quartIn: (t: number) => number;\n static quartOut: (t: number) => number;\n static quartInOut: (t: number) => number;\n static quintIn: (t: number) => number;\n static quintOut: (t: number) => number;\n static quintInOut: (t: number) => number;\n static getBackIn(amount: number): (t: number) => number;\n static getBackOut(amount: number): (t: number) => number;\n static getBackInOut(amount: number): (t: number) => number;\n static backIn: (t: number) => number;\n static backOut: (t: number) => number;\n static backInOut: (t: number) => number;\n static circIn(t: number): number;\n static circOut(t: number): number;\n static circInOut(t: number): number;\n static bounceOut(t: number): number;\n static bounceIn(t: number): number;\n static bounceInOut(t: number): number;\n static getElasticIn(amplitude: number, period: number): (t: number) => number;\n static getElasticOut(amplitude: number, period: number): (t: number) => number;\n static getElasticInOut(amplitude: number, period: number): (t: number) => number;\n static elasticIn: (t: number) => number;\n static elasticOut: (t: number) => number;\n static elasticInOut: (t: number) => number;\n}\n\n// timeline管理一堆的animate,多个timeline互不影响\n// timeline主要作用是基于layer层面的整体管理\n// 每个layer默认带有一个timeline\nexport interface Timeline {\n AnimateList: IAnimate[];\n}\n\ntype IStopType = 'end' | 'start' | 'current';\n\n// TODO: 提供options配置可序列化\ninterface AnimateSpecItem {\n type: 'to' | 'delay' | 'stop' | 'any';\n params: any[];\n}\n\nexport type EasingTypeStr =\n | 'linear'\n | 'quadIn'\n | 'quadOut'\n | 'quadInOut'\n | 'quadInOut'\n | 'cubicIn'\n | 'cubicOut'\n | 'cubicInOut'\n | 'quartIn'\n | 'quartOut'\n | 'quartInOut'\n | 'quintIn'\n | 'quintOut'\n | 'quintInOut'\n | 'backIn'\n | 'backOut'\n | 'backInOut'\n | 'circIn'\n | 'circOut'\n | 'circInOut'\n | 'bounceOut'\n | 'bounceIn'\n | 'bounceInOut'\n | 'elasticIn'\n | 'elasticOut'\n | 'elasticInOut'\n | 'sineIn'\n | 'sineOut'\n | 'sineInOut'\n | 'expoIn'\n | 'expoOut'\n | 'expoInOut'\n | '';\nexport type EasingTypeFunc = (t: number) => number;\n\nexport type EasingType = EasingTypeStr | EasingTypeFunc;\n\nexport type IAnimateStepType = keyof typeof AnimateStepType;\n\nexport interface IStep {\n type: IAnimateStepType;\n prev?: IStep;\n // 持续时间\n duration: number;\n // 在animate中的位置\n position: number;\n next?: IStep;\n props?: any;\n parsedProps?: any;\n propKeys?: string[];\n easing?: EasingTypeFunc;\n customAnimate?: ICustomAnimate;\n\n append: (step: IStep) => void;\n getLastProps: () => any;\n}\n\nexport interface IStepConfig {\n tempProps?: boolean; // props为临时props,可以直接使用不用拷贝\n noPreventAttrs?: boolean;\n}\n\nexport interface IAnimateTarget {\n onAnimateBind?: (animte: IAnimate | ISubAnimate) => void;\n // 添加动画step的时候调用\n onAddStep?: (step: IStep) => void;\n // step时调用\n onStep: (subAnimate: ISubAnimate, animate: IAnimate, step: IStep, ratio: number, end: boolean) => void;\n // 插值函数\n stepInterpolate: (\n subAnimate: ISubAnimate,\n animate: IAnimate,\n nextAttributes: Record<string, any>,\n step: IStep,\n ratio: number,\n end: boolean,\n nextProps: Record<string, any>,\n lastProps?: Record<string, any>,\n nextParsedProps?: any,\n propKeys?: string[]\n ) => void;\n // 获取属性\n getComputedAttribute: (name: string) => any;\n // 获取默认属性\n getDefaultAttribute: (name: string) => any;\n onStop: (props?: Record<string, any>) => void;\n animates: Map<string | number, IAnimate>;\n [key: string]: any;\n}\n\nexport interface ICustomAnimate {\n duration: number;\n easing: EasingType;\n step?: IStep;\n mode?: AnimateMode;\n\n bind: (target: IAnimateTarget, subAni: ISubAnimate) => void;\n // 在第一次调用的时候触发\n onBind: () => void;\n // 第一次执行的时候调用\n onFirstRun: () => void;\n // 开始执行的时候调用(如果有循环,那每个周期都会调用)\n onStart: () => void;\n // 结束执行的时候调用(如果有循环,那每个周期都会调用)\n onEnd: () => void;\n onUpdate: (end: boolean, ratio: number, out: Record<string, any>) => void;\n update: (end: boolean, ratio: number, out: Record<string, any>) => void;\n getEndProps: () => Record<string, any> | void;\n getFromProps: () => Record<string, any> | void;\n getMergedEndProps: () => Record<string, any> | void;\n}\n\n// 每一个animate绑定一个graphic,用于描述这个graphic的动画内容\n// 在timeline层面,animate相当于是一段timeslice\nexport interface IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n\n interpolateFunc: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n getStartProps: () => Record<string, any>;\n getEndProps: () => Record<string, any>;\n\n bind: (target: IAnimateTarget) => this;\n to: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;\n from: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;\n pause: () => void;\n resume: () => void;\n onStart: (cb: () => void) => void;\n onEnd: (cb: () => void) => void;\n onFrame: (cb: (step: IStep, ratio: number) => void) => void;\n // 屏蔽属性\n preventAttr: (key: string) => void;\n // 屏蔽属性\n preventAttrs: (key: string[]) => void;\n // 属性是否合法\n validAttr: (key: string) => boolean;\n\n runCb: (cb: (a: IAnimate, step: IStep) => void) => IAnimate;\n\n // 自定义插值,返回false表示没有匹配上\n customInterpolate: (\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IAnimateTarget,\n ret: Record<string, any>\n ) => boolean;\n //\n play: (customAnimate: ICustomAnimate) => this;\n\n // 获取该属性的上一个值\n // getLastPropByName: (name: string, step: IStep) => any;\n // delay: (duration: number) => IAnimate;\n stop: (type?: 'start' | 'end' | Record<string, any>) => void;\n /** 打上END标志,下一帧被删除 */\n release: () => void;\n // 获取持续的时长\n getDuration: () => number;\n // 获取动画开始时间(注意并不是子动画的startAt)\n getStartTime: () => number;\n // done: (cb: (_: any) => any) => IAnimate;\n // pause: () => IAnimate;\n // spec: (spec: AnimateSpecItem[]) => IAnimate;\n // start: () => void; // 有start方法,避免动画提前开始(VGrammar需要时间处理数据)\n wait: (delay: number) => this;\n\n // // 编排\n afterAll: (list: IAnimate[]) => this;\n after: (animate: IAnimate) => this;\n parallel: (animate: IAnimate) => this;\n\n // // timislice (getter)\n // startTime: number;\n // endTime: number;\n // startTimes: number[];\n // endTimes: number[];\n\n // // 高级参数,frame到frameEnd之间可以进行reverse,loop,bounce效果\n // frame: () => IAnimate;\n // frameEnd: () => IAnimate;\n reversed: (r: boolean) => IAnimate;\n loop: (n: number) => IAnimate;\n bounce: (b: boolean) => IAnimate;\n\n nextAnimate?: IAnimate;\n prevAnimate?: IAnimate;\n\n advance: (delta: number) => void;\n\n startAt: (t: number) => IAnimate;\n\n // // 语法糖\n // create: (duration: number) => IAnimate;\n // fadeIn: (duration: number) => IAnimate;\n}\n\nexport interface ISubAnimate {\n getLastStep: () => IStep;\n animate: IAnimate;\n // 获取该属性的上一个值\n getLastPropByName: (name: string, step: IStep) => any;\n}\n\n// rect.animate().abc().to({}, 1000).delay(1000).frame().to().delay().to().frameEnd().loop().bounce()\n\nexport interface BaseAnimateConfig {\n id?: number | string;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n}\n\n// VGrammar和 vrender命名不一致,好尴尬\nexport interface MorphingAnimateConfig extends Omit<BaseAnimateConfig, 'interpolate'> {\n duration?: number;\n easing?: EasingType; // 统一到easing\n delay?: number;\n}\n\nexport interface MultiMorphingAnimateConfig extends MorphingAnimateConfig {\n splitPath?: 'clone' | ((graphic: IGraphic, count: number, needAppend?: boolean) => IGraphic[]);\n individualDelay?: (index: number, count: number, fromGraphic: IGraphic, toGraphic: IGraphic) => number;\n}\n\nexport interface ITimeline {\n id: number;\n animateCount: number;\n addAnimate: (animate: IAnimate) => void;\n removeAnimate: (animate: IAnimate) => void;\n tick: (delta: number) => void;\n clear: () => void;\n pause: () => void;\n resume: () => void;\n}\n\nexport interface ITickHandler extends Releaseable {\n avaliable: () => boolean;\n /**\n * 开始执行tick\n * @param interval 延时 ms\n * @param cb 执行的回调\n */\n tick: (interval: number, cb: (handler: ITickHandler) => void) => void; // 开始\n tickTo?: (t: number, cb: (handler: ITickHandler, params?: { once: boolean }) => void) => void;\n getTime: () => number; // 获取时间\n}\n\nexport interface ITickerHandlerStatic {\n Avaliable: () => boolean;\n new (): ITickHandler;\n}\n\nexport interface ITicker {\n setFPS?: (fps: number) => void;\n setInterval?: (interval: number) => void;\n getFPS?: () => number;\n getInterval?: () => number;\n tick: (interval: number) => void;\n tickAt?: (time: number) => void;\n pause: () => boolean;\n resume: () => boolean;\n /**\n * 开启tick,force为true强制开启,否则如果timeline为空则不开启\n */\n start: (force?: boolean) => boolean;\n stop: () => void;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { AnimateMode, AnimateStatus, AnimateStepType } from '../common/enums';\nimport type { Releaseable } from './common';\nimport type { IGraphic } from './graphic';\n\n// export type EasingType = (...args: any) => any;\n\nexport declare class Easing {\n static linear(t: number): number;\n static none(): typeof Easing.linear;\n /**\n * 获取缓动函数,amount指示这个缓动函数的插值方式\n * @param amount\n * @returns\n */\n static get(amount: number): (t: number) => number;\n static getPowIn(pow: number): (t: number) => number;\n static getPowOut(pow: number): (t: number) => number;\n static getPowInOut(pow: number): (t: number) => number;\n static quadIn: (t: number) => number;\n static quadOut: (t: number) => number;\n static quadInOut: (t: number) => number;\n static cubicIn: (t: number) => number;\n static cubicOut: (t: number) => number;\n static cubicInOut: (t: number) => number;\n static quartIn: (t: number) => number;\n static quartOut: (t: number) => number;\n static quartInOut: (t: number) => number;\n static quintIn: (t: number) => number;\n static quintOut: (t: number) => number;\n static quintInOut: (t: number) => number;\n static getBackIn(amount: number): (t: number) => number;\n static getBackOut(amount: number): (t: number) => number;\n static getBackInOut(amount: number): (t: number) => number;\n static backIn: (t: number) => number;\n static backOut: (t: number) => number;\n static backInOut: (t: number) => number;\n static circIn(t: number): number;\n static circOut(t: number): number;\n static circInOut(t: number): number;\n static bounceOut(t: number): number;\n static bounceIn(t: number): number;\n static bounceInOut(t: number): number;\n static getElasticIn(amplitude: number, period: number): (t: number) => number;\n static getElasticOut(amplitude: number, period: number): (t: number) => number;\n static getElasticInOut(amplitude: number, period: number): (t: number) => number;\n static elasticIn: (t: number) => number;\n static elasticOut: (t: number) => number;\n static elasticInOut: (t: number) => number;\n}\n\n// timeline管理一堆的animate,多个timeline互不影响\n// timeline主要作用是基于layer层面的整体管理\n// 每个layer默认带有一个timeline\nexport interface Timeline {\n AnimateList: IAnimate[];\n}\n\ntype IStopType = 'end' | 'start' | 'current';\n\n// TODO: 提供options配置可序列化\ninterface AnimateSpecItem {\n type: 'to' | 'delay' | 'stop' | 'any';\n params: any[];\n}\n\nexport type EasingTypeStr =\n | 'linear'\n | 'quadIn'\n | 'quadOut'\n | 'quadInOut'\n | 'quadInOut'\n | 'cubicIn'\n | 'cubicOut'\n | 'cubicInOut'\n | 'quartIn'\n | 'quartOut'\n | 'quartInOut'\n | 'quintIn'\n | 'quintOut'\n | 'quintInOut'\n | 'backIn'\n | 'backOut'\n | 'backInOut'\n | 'circIn'\n | 'circOut'\n | 'circInOut'\n | 'bounceOut'\n | 'bounceIn'\n | 'bounceInOut'\n | 'elasticIn'\n | 'elasticOut'\n | 'elasticInOut'\n | 'sineIn'\n | 'sineOut'\n | 'sineInOut'\n | 'expoIn'\n | 'expoOut'\n | 'expoInOut'\n | '';\nexport type EasingTypeFunc = (t: number) => number;\n\nexport type EasingType = EasingTypeStr | EasingTypeFunc;\n\nexport type IAnimateStepType = keyof typeof AnimateStepType;\n\nexport interface IStep {\n type: IAnimateStepType;\n prev?: IStep;\n // 持续时间\n duration: number;\n // 在animate中的位置\n position: number;\n next?: IStep;\n props?: any;\n parsedProps?: any;\n propKeys?: string[];\n easing?: EasingTypeFunc;\n customAnimate?: ICustomAnimate;\n\n append: (step: IStep) => void;\n getLastProps: () => any;\n}\n\nexport interface IStepConfig {\n tempProps?: boolean; // props为临时props,可以直接使用不用拷贝\n noPreventAttrs?: boolean;\n}\n\nexport interface IAnimateTarget {\n onAnimateBind?: (animte: IAnimate | ISubAnimate) => void;\n // 添加动画step的时候调用\n onAddStep?: (step: IStep) => void;\n // step时调用\n onStep: (subAnimate: ISubAnimate, animate: IAnimate, step: IStep, ratio: number, end: boolean) => void;\n // 插值函数\n stepInterpolate: (\n subAnimate: ISubAnimate,\n animate: IAnimate,\n nextAttributes: Record<string, any>,\n step: IStep,\n ratio: number,\n end: boolean,\n nextProps: Record<string, any>,\n lastProps?: Record<string, any>,\n nextParsedProps?: any,\n propKeys?: string[]\n ) => void;\n // 获取属性\n getComputedAttribute: (name: string) => any;\n // 获取默认属性\n getDefaultAttribute: (name: string) => any;\n onStop: (props?: Record<string, any>) => void;\n animates: Map<string | number, IAnimate>;\n [key: string]: any;\n}\n\nexport interface ICustomAnimate {\n duration: number;\n easing: EasingType;\n step?: IStep;\n mode?: AnimateMode;\n\n bind: (target: IAnimateTarget, subAni: ISubAnimate) => void;\n // 在第一次调用的时候触发\n onBind: () => void;\n // 第一次执行的时候调用\n onFirstRun: () => void;\n // 开始执行的时候调用(如果有循环,那每个周期都会调用)\n onStart: () => void;\n // 结束执行的时候调用(如果有循环,那每个周期都会调用)\n onEnd: () => void;\n onUpdate: (end: boolean, ratio: number, out: Record<string, any>) => void;\n update: (end: boolean, ratio: number, out: Record<string, any>) => void;\n getEndProps: () => Record<string, any> | void;\n getFromProps: () => Record<string, any> | void;\n getMergedEndProps: () => Record<string, any> | void;\n}\n\n// 每一个animate绑定一个graphic,用于描述这个graphic的动画内容\n// 在timeline层面,animate相当于是一段timeslice\nexport interface IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n\n interpolateFunc: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n getStartProps: () => Record<string, any>;\n getEndProps: () => Record<string, any>;\n\n setTimeline: (timeline: ITimeline) => void;\n\n bind: (target: IAnimateTarget) => this;\n to: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;\n from: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;\n pause: () => void;\n resume: () => void;\n onStart: (cb: () => void) => void;\n onEnd: (cb: () => void) => void;\n onFrame: (cb: (step: IStep, ratio: number) => void) => void;\n // 屏蔽属性\n preventAttr: (key: string) => void;\n // 屏蔽属性\n preventAttrs: (key: string[]) => void;\n // 属性是否合法\n validAttr: (key: string) => boolean;\n\n runCb: (cb: (a: IAnimate, step: IStep) => void) => IAnimate;\n\n // 自定义插值,返回false表示没有匹配上\n customInterpolate: (\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IAnimateTarget,\n ret: Record<string, any>\n ) => boolean;\n //\n play: (customAnimate: ICustomAnimate) => this;\n\n // 获取该属性的上一个值\n // getLastPropByName: (name: string, step: IStep) => any;\n // delay: (duration: number) => IAnimate;\n stop: (type?: 'start' | 'end' | Record<string, any>) => void;\n /** 打上END标志,下一帧被删除 */\n release: () => void;\n // 获取持续的时长\n getDuration: () => number;\n // 获取动画开始时间(注意并不是子动画的startAt)\n getStartTime: () => number;\n // done: (cb: (_: any) => any) => IAnimate;\n // pause: () => IAnimate;\n // spec: (spec: AnimateSpecItem[]) => IAnimate;\n // start: () => void; // 有start方法,避免动画提前开始(VGrammar需要时间处理数据)\n wait: (delay: number) => this;\n\n // // 编排\n afterAll: (list: IAnimate[]) => this;\n after: (animate: IAnimate) => this;\n parallel: (animate: IAnimate) => this;\n\n // // timislice (getter)\n // startTime: number;\n // endTime: number;\n // startTimes: number[];\n // endTimes: number[];\n\n // // 高级参数,frame到frameEnd之间可以进行reverse,loop,bounce效果\n // frame: () => IAnimate;\n // frameEnd: () => IAnimate;\n reversed: (r: boolean) => IAnimate;\n loop: (n: number) => IAnimate;\n bounce: (b: boolean) => IAnimate;\n\n nextAnimate?: IAnimate;\n prevAnimate?: IAnimate;\n\n advance: (delta: number) => void;\n\n startAt: (t: number) => IAnimate;\n\n // // 语法糖\n // create: (duration: number) => IAnimate;\n // fadeIn: (duration: number) => IAnimate;\n}\n\nexport interface ISubAnimate {\n getLastStep: () => IStep;\n animate: IAnimate;\n // 获取该属性的上一个值\n getLastPropByName: (name: string, step: IStep) => any;\n}\n\n// rect.animate().abc().to({}, 1000).delay(1000).frame().to().delay().to().frameEnd().loop().bounce()\n\nexport interface BaseAnimateConfig {\n id?: number | string;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n}\n\n// VGrammar和 vrender命名不一致,好尴尬\nexport interface MorphingAnimateConfig extends Omit<BaseAnimateConfig, 'interpolate'> {\n duration?: number;\n easing?: EasingType; // 统一到easing\n delay?: number;\n}\n\nexport interface MultiMorphingAnimateConfig extends MorphingAnimateConfig {\n splitPath?: 'clone' | ((graphic: IGraphic, count: number, needAppend?: boolean) => IGraphic[]);\n individualDelay?: (index: number, count: number, fromGraphic: IGraphic, toGraphic: IGraphic) => number;\n}\n\nexport interface ITimeline {\n id: number;\n animateCount: number;\n addAnimate: (animate: IAnimate) => void;\n removeAnimate: (animate: IAnimate, release?: boolean) => void;\n tick: (delta: number) => void;\n clear: () => void;\n pause: () => void;\n resume: () => void;\n}\n\nexport interface ITickHandler extends Releaseable {\n avaliable: () => boolean;\n /**\n * 开始执行tick\n * @param interval 延时 ms\n * @param cb 执行的回调\n */\n tick: (interval: number, cb: (handler: ITickHandler) => void) => void; // 开始\n tickTo?: (t: number, cb: (handler: ITickHandler, params?: { once: boolean }) => void) => void;\n getTime: () => number; // 获取时间\n}\n\nexport interface ITickerHandlerStatic {\n Avaliable: () => boolean;\n new (): ITickHandler;\n}\n\nexport interface ITicker {\n setFPS?: (fps: number) => void;\n setInterval?: (interval: number) => void;\n getFPS?: () => number;\n getInterval?: () => number;\n tick: (interval: number) => void;\n tickAt?: (time: number) => void;\n pause: () => boolean;\n resume: () => boolean;\n /**\n * 开启tick,force为true强制开启,否则如果timeline为空则不开启\n */\n start: (force?: boolean) => boolean;\n stop: () => void;\n addTimeline: (timeline: ITimeline) => void;\n}\n"]}
@@ -24,6 +24,7 @@ export interface ITransformUtil {
24
24
  init: (origin: TransformType) => ITransformUtil;
25
25
  fromMatrix: (source: IMatrix, target: IMatrix) => ITransformUtil;
26
26
  scale: (sx: number, sy: number, center?: IPointLike) => ITransformUtil;
27
+ rotate: (angle: number, center?: IPointLike) => ITransformUtil;
27
28
  translate: (dx: number, dy: number) => ITransformUtil;
28
29
  }
29
30
  export interface ILayerService {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/core.ts"],"names":[],"mappings":"","file":"core.js","sourcesContent":["import type { ICanvas } from './canvas';\nimport type { IContext2d } from './context';\nimport type { IGraphicAttribute } from './graphic';\nimport type { ITextAttribute } from './graphic/text';\nimport type { ILayer, ILayerParams } from './layer';\nimport type { IStage } from './stage';\nimport type { ITextMeasure, TextOptionsType } from './text';\nimport type { IMatrix, IPointLike, ITextMeasureOption, TextMeasure } from '@visactor/vutils';\n\nexport interface IGraphicUtil {\n canvas?: ICanvas;\n context?: IContext2d | null;\n textMeasure: ITextMeasure;\n measureText: (text: string, tc: TextOptionsType) => { width: number; height: number };\n bindTextMeasure: (tm: ITextMeasure) => void;\n createTextMeasureInstance: (\n textSpec?: Partial<ITextAttribute>,\n option?: Partial<ITextMeasureOption>,\n getCanvasForMeasure?: () => any\n ) => TextMeasure<ITextAttribute>;\n}\n\nexport type TransformType = Pick<IGraphicAttribute, 'x' | 'y' | 'scaleX' | 'scaleY' | 'angle' | 'dx' | 'dy'> & {\n anchor?: IGraphicAttribute['anchor'];\n};\nexport interface ITransformUtil {\n init: (origin: TransformType) => ITransformUtil;\n fromMatrix: (source: IMatrix, target: IMatrix) => ITransformUtil;\n scale: (sx: number, sy: number, center?: IPointLike) => ITransformUtil;\n translate: (dx: number, dy: number) => ITransformUtil;\n}\n\nexport interface ILayerService {\n createLayer: (stage: IStage, options?: ILayerParams) => ILayer;\n releaseLayer: (stage: IStage, layer: ILayer) => void;\n restLayerCount: (stage: IStage) => number;\n getStageLayer: (stage: IStage) => ILayer[];\n layerCount: (stage: IStage) => number;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/core.ts"],"names":[],"mappings":"","file":"core.js","sourcesContent":["import type { ICanvas } from './canvas';\nimport type { IContext2d } from './context';\nimport type { IGraphicAttribute } from './graphic';\nimport type { ITextAttribute } from './graphic/text';\nimport type { ILayer, ILayerParams } from './layer';\nimport type { IStage } from './stage';\nimport type { ITextMeasure, TextOptionsType } from './text';\nimport type { IMatrix, IPointLike, ITextMeasureOption, TextMeasure } from '@visactor/vutils';\n\nexport interface IGraphicUtil {\n canvas?: ICanvas;\n context?: IContext2d | null;\n textMeasure: ITextMeasure;\n measureText: (text: string, tc: TextOptionsType) => { width: number; height: number };\n bindTextMeasure: (tm: ITextMeasure) => void;\n createTextMeasureInstance: (\n textSpec?: Partial<ITextAttribute>,\n option?: Partial<ITextMeasureOption>,\n getCanvasForMeasure?: () => any\n ) => TextMeasure<ITextAttribute>;\n}\n\nexport type TransformType = Pick<IGraphicAttribute, 'x' | 'y' | 'scaleX' | 'scaleY' | 'angle' | 'dx' | 'dy'> & {\n anchor?: IGraphicAttribute['anchor'];\n};\nexport interface ITransformUtil {\n init: (origin: TransformType) => ITransformUtil;\n fromMatrix: (source: IMatrix, target: IMatrix) => ITransformUtil;\n scale: (sx: number, sy: number, center?: IPointLike) => ITransformUtil;\n rotate: (angle: number, center?: IPointLike) => ITransformUtil;\n translate: (dx: number, dy: number) => ITransformUtil;\n}\n\nexport interface ILayerService {\n createLayer: (stage: IStage, options?: ILayerParams) => ILayer;\n releaseLayer: (stage: IStage, layer: ILayer) => void;\n restLayerCount: (stage: IStage) => number;\n getStageLayer: (stage: IStage) => ILayer[];\n layerCount: (stage: IStage) => number;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Dict, IPointLike } from '@visactor/vutils';
1
+ import type { Dict, IAABBBoundsLike, IPointLike } from '@visactor/vutils';
2
2
  import type { ICanvasLike } from './canvas';
3
3
  import type { IEventElement } from './common';
4
4
  import type { IContribution } from './contribution';
@@ -25,6 +25,15 @@ export interface IEnvContribution extends IContribution<IGlobal>, Omit<IEventEle
25
25
  createCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;
26
26
  createOffscreenCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;
27
27
  releaseCanvas: (canvas: ICanvasLike | string | any) => void;
28
+ getNativeAABBBounds: (dom: string | HTMLElement | any) => IAABBBoundsLike;
29
+ removeDom: (dom: HTMLElement) => boolean;
30
+ createDom: (params: CreateDOMParamsType) => HTMLElement | null;
31
+ getElementTop: (dom: any, baseWindow?: boolean) => number;
32
+ getElementLeft: (dom: any, baseWindow?: boolean) => number;
33
+ getElementTopLeft: (dom: any, baseWindow?: boolean) => {
34
+ top: number;
35
+ left: number;
36
+ };
28
37
  getDynamicCanvasCount: () => number;
29
38
  getStaticCanvasCount: () => number;
30
39
  getDevicePixelRatio: () => number;
@@ -78,6 +87,13 @@ export interface IEnvParamsMap {
78
87
  readonly lynx: any;
79
88
  readonly wx: any;
80
89
  }
90
+ export type CreateDOMParamsType = {
91
+ tagName?: string;
92
+ width?: number;
93
+ height?: number;
94
+ style?: string | Record<string, any>;
95
+ parent?: string | HTMLElement;
96
+ };
81
97
  export interface IGlobal extends Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {
82
98
  env: EnvType;
83
99
  devicePixelRatio: number;
@@ -126,4 +142,12 @@ export interface IGlobal extends Omit<IEventElement, 'on' | 'off' | 'once' | 'em
126
142
  loadState: 'success' | 'fail';
127
143
  data: Blob | null;
128
144
  }>;
145
+ removeDom: (dom: HTMLElement) => boolean;
146
+ createDom: (params: CreateDOMParamsType) => HTMLElement | null;
147
+ getElementTop: (dom: any, baseWindow?: boolean) => number;
148
+ getElementLeft: (dom: any, baseWindow?: boolean) => number;
149
+ getElementTopLeft: (dom: any, baseWindow?: boolean) => {
150
+ top: number;
151
+ left: number;
152
+ };
129
153
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/global.ts"],"names":[],"mappings":"","file":"global.js","sourcesContent":["import type { Dict, IPointLike } from '@visactor/vutils';\nimport type { ICanvasLike } from './canvas';\nimport type { IEventElement } from './common';\nimport type { IContribution } from './contribution';\nimport type { ISyncHook } from './sync-hook';\n\nexport interface ILoader {\n loadImage: (url: string) => HTMLImageElement | ImageData;\n loadJson: (url: string) => JSON;\n}\n\n// 环境定义\nexport type EnvType = 'browser' | 'feishu' | 'tt' | 'taro' | 'node' | 'native' | 'lynx' | 'wx';\n\n// 创建canvas需要的参数\nexport interface ICreateCanvasParams {\n id?: string;\n // 像素宽\n width?: number;\n // 像素高\n height?: number;\n dpr?: number;\n}\n\nexport interface ILoader {\n loadImage: (url: string) => HTMLImageElement | ImageData;\n loadJson: (url: string) => JSON;\n}\n\nexport interface IEnvContribution\n extends IContribution<IGlobal>,\n Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {\n // 当前代码所运行的环境\n type: EnvType;\n\n // 是否支持事件\n // node环境不需要事件\n supportEvent: boolean;\n\n // 开始配置环境,相当于init\n configure: (global: IGlobal, ...p: any) => void;\n\n // 创建销毁\n createCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;\n createOffscreenCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;\n releaseCanvas: (canvas: ICanvasLike | string | any) => void;\n\n /**\n * 获取动态canvas的数量,offscreenCanvas或者framebuffer\n */\n getDynamicCanvasCount: () => number;\n\n /**\n * 获取静态canvas的数量,纯粹canvas\n */\n getStaticCanvasCount: () => number;\n\n // 设备信息\n getDevicePixelRatio: () => number;\n\n // 通用接口\n getRequestAnimationFrame: () => (callback: FrameRequestCallback) => number;\n getCancelAnimationFrame: () => (h: number) => void;\n\n // DOM接口\n getElementById?: (str: string) => HTMLElement | null;\n getRootElement?: () => HTMLElement | null;\n /**\n * get document instance\n */\n getDocument?: () => Document | null;\n /**\n * whether supports TouchEvent.\n */\n supportsTouchEvents: boolean;\n /**\n * whether supports PointerEvent.\n */\n supportsPointerEvents: boolean;\n /**\n * whether supports MouseEvent.\n */\n supportsMouseEvents: boolean;\n /**\n * Whether to allow setting the cursor style\n */\n applyStyles?: boolean;\n\n /**\n * 将窗口坐标转换为画布坐标,小程序/小组件环境需要兼容\n */\n mapToCanvasPoint?: (event: any, domElement?: any) => IPointLike | null;\n\n loadImage: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadSvg: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadJson: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Record<string, unknown> | null;\n }>;\n loadArrayBuffer: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: ArrayBuffer | null;\n }>;\n loadBlob: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Blob | null;\n }>;\n}\n\nexport type IMiniAppEnvParams = {\n /** dom 容器对象 */\n domref?: Dict<any>;\n /**\n * 强行设置env,如果env重复设置也设置\n */\n force?: boolean;\n /**\n * 可用的canvas列表\n */\n canvasIdLists?: (string | number)[];\n /**\n * 表示可以自由使用的canvas索引\n */\n freeCanvasIdx?: string | number;\n /** taro 环境使用 */\n taro?: any;\n pixelRatio?: number;\n [key: string]: any;\n};\n\nexport interface IEnvParamsMap {\n readonly taro: IMiniAppEnvParams;\n readonly feishu: IMiniAppEnvParams;\n readonly tt: IMiniAppEnvParams;\n readonly browser: any;\n readonly node: any;\n readonly native: any;\n readonly lynx: any;\n readonly wx: any;\n}\nexport interface IGlobal extends Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {\n // 当前代码所运行的环境\n env: EnvType;\n\n // 设备的dpr\n devicePixelRatio: number;\n\n // 当设置env的时候被调用\n hooks: {\n onSetEnv: ISyncHook<[EnvType | undefined, EnvType, IGlobal]>;\n };\n\n // 设置env的时候传入的参数\n // node环境需要传入整个node-canvas包\n // 小程序环境需要传入小程序要用到的参数\n envParams?: any;\n\n // 是否支持事件\n // node环境不需要事件\n supportEvent: boolean;\n\n setEnv: (env: EnvType, params?: IEnvParamsMap[EnvType]) => void;\n setActiveEnvContribution: (contribution: IEnvContribution) => void;\n createCanvas: (params: ICreateCanvasParams) => HTMLCanvasElement | any;\n createOffscreenCanvas: (params: ICreateCanvasParams) => HTMLCanvasElement | any;\n releaseCanvas: (canvas: HTMLCanvasElement | string | any) => void;\n\n /**\n * 获取环境中最大动态canvas的数量,offscreenCanvas或者framebuffer\n */\n getDynamicCanvasCount: () => number;\n\n isChrome: () => boolean;\n isSafari: () => boolean;\n\n /**\n * 获取环境中最大静态canvas的数量,纯粹canvas\n */\n getStaticCanvasCount: () => number;\n\n /* 浏览器环境 - dom tree */\n getElementById: (str: string) => HTMLElement | null;\n getRootElement: () => HTMLElement | null;\n /**\n * get document instance\n */\n getDocument: () => Document | null;\n /**\n * whether supports TouchEvent.\n */\n supportsTouchEvents: boolean;\n /**\n * whether supports PointerEvent.\n */\n supportsPointerEvents: boolean;\n /**\n * whether supports MouseEvent.\n */\n supportsMouseEvents: boolean;\n /**\n * Whether to allow setting the cursor style\n */\n applyStyles?: boolean;\n /**\n * 测量文字的方法\n */\n measureTextMethod: 'native' | 'simple' | 'quick';\n\n getRequestAnimationFrame: () => null | ((callback: FrameRequestCallback) => number);\n getCancelAnimationFrame: () => null | ((h: number) => void);\n\n /**\n * 将窗口坐标转换为画布坐标,小程序/小组件环境需要兼容\n */\n mapToCanvasPoint: (nativeEvent: any, domElement?: any) => IPointLike | null;\n\n loadImage: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadSvg: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadJson: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Record<string, unknown> | null;\n }>;\n loadArrayBuffer: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: ArrayBuffer | null;\n }>;\n loadBlob: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Blob | null;\n }>;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/global.ts"],"names":[],"mappings":"","file":"global.js","sourcesContent":["import type { Dict, IAABBBoundsLike, IPointLike } from '@visactor/vutils';\nimport type { ICanvasLike } from './canvas';\nimport type { IEventElement } from './common';\nimport type { IContribution } from './contribution';\nimport type { ISyncHook } from './sync-hook';\n\nexport interface ILoader {\n loadImage: (url: string) => HTMLImageElement | ImageData;\n loadJson: (url: string) => JSON;\n}\n\n// 环境定义\nexport type EnvType = 'browser' | 'feishu' | 'tt' | 'taro' | 'node' | 'native' | 'lynx' | 'wx';\n\n// 创建canvas需要的参数\nexport interface ICreateCanvasParams {\n id?: string;\n // 像素宽\n width?: number;\n // 像素高\n height?: number;\n dpr?: number;\n}\n\nexport interface ILoader {\n loadImage: (url: string) => HTMLImageElement | ImageData;\n loadJson: (url: string) => JSON;\n}\n\nexport interface IEnvContribution\n extends IContribution<IGlobal>,\n Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {\n // 当前代码所运行的环境\n type: EnvType;\n\n // 是否支持事件\n // node环境不需要事件\n supportEvent: boolean;\n\n // 开始配置环境,相当于init\n configure: (global: IGlobal, ...p: any) => void;\n\n // 创建销毁\n createCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;\n createOffscreenCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;\n releaseCanvas: (canvas: ICanvasLike | string | any) => void;\n\n getNativeAABBBounds: (dom: string | HTMLElement | any) => IAABBBoundsLike;\n removeDom: (dom: HTMLElement) => boolean;\n createDom: (params: CreateDOMParamsType) => HTMLElement | null;\n getElementTop: (dom: any, baseWindow?: boolean) => number;\n getElementLeft: (dom: any, baseWindow?: boolean) => number;\n getElementTopLeft: (dom: any, baseWindow?: boolean) => { top: number; left: number };\n\n /**\n * 获取动态canvas的数量,offscreenCanvas或者framebuffer\n */\n getDynamicCanvasCount: () => number;\n\n /**\n * 获取静态canvas的数量,纯粹canvas\n */\n getStaticCanvasCount: () => number;\n\n // 设备信息\n getDevicePixelRatio: () => number;\n\n // 通用接口\n getRequestAnimationFrame: () => (callback: FrameRequestCallback) => number;\n getCancelAnimationFrame: () => (h: number) => void;\n\n // DOM接口\n getElementById?: (str: string) => HTMLElement | null;\n getRootElement?: () => HTMLElement | null;\n /**\n * get document instance\n */\n getDocument?: () => Document | null;\n /**\n * whether supports TouchEvent.\n */\n supportsTouchEvents: boolean;\n /**\n * whether supports PointerEvent.\n */\n supportsPointerEvents: boolean;\n /**\n * whether supports MouseEvent.\n */\n supportsMouseEvents: boolean;\n /**\n * Whether to allow setting the cursor style\n */\n applyStyles?: boolean;\n\n /**\n * 将窗口坐标转换为画布坐标,小程序/小组件环境需要兼容\n */\n mapToCanvasPoint?: (event: any, domElement?: any) => IPointLike | null;\n\n loadImage: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadSvg: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadJson: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Record<string, unknown> | null;\n }>;\n loadArrayBuffer: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: ArrayBuffer | null;\n }>;\n loadBlob: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Blob | null;\n }>;\n}\n\nexport type IMiniAppEnvParams = {\n /** dom 容器对象 */\n domref?: Dict<any>;\n /**\n * 强行设置env,如果env重复设置也设置\n */\n force?: boolean;\n /**\n * 可用的canvas列表\n */\n canvasIdLists?: (string | number)[];\n /**\n * 表示可以自由使用的canvas索引\n */\n freeCanvasIdx?: string | number;\n /** taro 环境使用 */\n taro?: any;\n pixelRatio?: number;\n [key: string]: any;\n};\n\nexport interface IEnvParamsMap {\n readonly taro: IMiniAppEnvParams;\n readonly feishu: IMiniAppEnvParams;\n readonly tt: IMiniAppEnvParams;\n readonly browser: any;\n readonly node: any;\n readonly native: any;\n readonly lynx: any;\n readonly wx: any;\n}\n\nexport type CreateDOMParamsType = {\n tagName?: string;\n width?: number;\n height?: number;\n style?: string | Record<string, any>;\n parent?: string | HTMLElement;\n};\nexport interface IGlobal extends Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {\n // 当前代码所运行的环境\n env: EnvType;\n\n // 设备的dpr\n devicePixelRatio: number;\n\n // 当设置env的时候被调用\n hooks: {\n onSetEnv: ISyncHook<[EnvType | undefined, EnvType, IGlobal]>;\n };\n\n // 设置env的时候传入的参数\n // node环境需要传入整个node-canvas包\n // 小程序环境需要传入小程序要用到的参数\n envParams?: any;\n\n // 是否支持事件\n // node环境不需要事件\n supportEvent: boolean;\n\n setEnv: (env: EnvType, params?: IEnvParamsMap[EnvType]) => void;\n setActiveEnvContribution: (contribution: IEnvContribution) => void;\n createCanvas: (params: ICreateCanvasParams) => HTMLCanvasElement | any;\n createOffscreenCanvas: (params: ICreateCanvasParams) => HTMLCanvasElement | any;\n releaseCanvas: (canvas: HTMLCanvasElement | string | any) => void;\n\n /**\n * 获取环境中最大动态canvas的数量,offscreenCanvas或者framebuffer\n */\n getDynamicCanvasCount: () => number;\n\n isChrome: () => boolean;\n isSafari: () => boolean;\n\n /**\n * 获取环境中最大静态canvas的数量,纯粹canvas\n */\n getStaticCanvasCount: () => number;\n\n /* 浏览器环境 - dom tree */\n getElementById: (str: string) => HTMLElement | null;\n getRootElement: () => HTMLElement | null;\n /**\n * get document instance\n */\n getDocument: () => Document | null;\n /**\n * whether supports TouchEvent.\n */\n supportsTouchEvents: boolean;\n /**\n * whether supports PointerEvent.\n */\n supportsPointerEvents: boolean;\n /**\n * whether supports MouseEvent.\n */\n supportsMouseEvents: boolean;\n /**\n * Whether to allow setting the cursor style\n */\n applyStyles?: boolean;\n /**\n * 测量文字的方法\n */\n measureTextMethod: 'native' | 'simple' | 'quick';\n\n getRequestAnimationFrame: () => null | ((callback: FrameRequestCallback) => number);\n getCancelAnimationFrame: () => null | ((h: number) => void);\n\n /**\n * 将窗口坐标转换为画布坐标,小程序/小组件环境需要兼容\n */\n mapToCanvasPoint: (nativeEvent: any, domElement?: any) => IPointLike | null;\n\n loadImage: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadSvg: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadJson: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Record<string, unknown> | null;\n }>;\n loadArrayBuffer: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: ArrayBuffer | null;\n }>;\n loadBlob: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Blob | null;\n }>;\n\n removeDom: (dom: HTMLElement) => boolean;\n createDom: (params: CreateDOMParamsType) => HTMLElement | null;\n\n getElementTop: (dom: any, baseWindow?: boolean) => number;\n getElementLeft: (dom: any, baseWindow?: boolean) => number;\n getElementTopLeft: (dom: any, baseWindow?: boolean) => { top: number; left: number };\n}\n"]}
@@ -7,6 +7,7 @@ export type IAreaAttribute = {
7
7
  points: IPointLike[];
8
8
  curveType: ICurveType;
9
9
  clipRange: number;
10
+ closePath: boolean;
10
11
  };
11
12
  export type IAreaCacheItem = {
12
13
  top: ISegPath2D;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/area.ts"],"names":[],"mappings":"","file":"area.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type { ISegPath2D } from '../curve';\nimport type { IConnectedStyle, IGraphic, IGraphicAttribute } from '../graphic';\nimport type { ICurveType } from '../common';\n\nexport type IAreaAttribute = {\n segments: IAreaSegment[]; // 分段设置point和样式\n points: IPointLike[];\n curveType: ICurveType;\n clipRange: number;\n};\n\nexport type IAreaCacheItem = {\n top: ISegPath2D;\n bottom: ISegPath2D;\n};\n\nexport type IAreaGraphicAttribute = Partial<IGraphicAttribute> & Partial<IAreaAttribute> & Partial<IConnectedStyle>;\n\nexport interface IArea extends IGraphic<IAreaGraphicAttribute> {\n cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n}\n\ntype ISegmentStyle = Pick<\n IGraphicAttribute,\n 'fill' | 'fillOpacity' | 'background' | 'texture' | 'textureColor' | 'textureSize' | 'texturePadding'\n>;\n\nexport interface IAreaSegment extends Partial<ISegmentStyle>, Partial<IConnectedStyle> {\n points: IPointLike[];\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/area.ts"],"names":[],"mappings":"","file":"area.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type { ISegPath2D } from '../curve';\nimport type { IConnectedStyle, IGraphic, IGraphicAttribute } from '../graphic';\nimport type { ICurveType } from '../common';\n\nexport type IAreaAttribute = {\n segments: IAreaSegment[]; // 分段设置point和样式\n points: IPointLike[];\n curveType: ICurveType;\n clipRange: number;\n closePath: boolean;\n};\n\nexport type IAreaCacheItem = {\n top: ISegPath2D;\n bottom: ISegPath2D;\n};\n\nexport type IAreaGraphicAttribute = Partial<IGraphicAttribute> & Partial<IAreaAttribute> & Partial<IConnectedStyle>;\n\nexport interface IArea extends IGraphic<IAreaGraphicAttribute> {\n cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n}\n\ntype ISegmentStyle = Pick<\n IGraphicAttribute,\n 'fill' | 'fillOpacity' | 'background' | 'texture' | 'textureColor' | 'textureSize' | 'texturePadding'\n>;\n\nexport interface IAreaSegment extends Partial<ISegmentStyle>, Partial<IConnectedStyle> {\n points: IPointLike[];\n}\n"]}
@@ -6,6 +6,7 @@ export type IImageAttribute = {
6
6
  repeatX: IRepeatType;
7
7
  repeatY: IRepeatType;
8
8
  image: string | HTMLImageElement | HTMLCanvasElement;
9
+ cornerRadius: number | number[];
9
10
  };
10
11
  export type IImageGraphicAttribute = Partial<IGraphicAttribute> & Partial<IImageAttribute>;
11
12
  export interface IImage extends IGraphic<IImageGraphicAttribute> {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/image.ts"],"names":[],"mappings":"","file":"image.js","sourcesContent":["import type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport type IRepeatType = 'no-repeat' | 'repeat';\n\nexport type IImageAttribute = {\n width: number;\n height: number;\n repeatX: IRepeatType;\n repeatY: IRepeatType;\n image: string | HTMLImageElement | HTMLCanvasElement;\n};\n\nexport type IImageGraphicAttribute = Partial<IGraphicAttribute> & Partial<IImageAttribute>;\n\nexport interface IImage extends IGraphic<IImageGraphicAttribute> {\n successCallback?: () => void;\n failCallback?: () => void;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/image.ts"],"names":[],"mappings":"","file":"image.js","sourcesContent":["import type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport type IRepeatType = 'no-repeat' | 'repeat';\n\nexport type IImageAttribute = {\n width: number;\n height: number;\n repeatX: IRepeatType;\n repeatY: IRepeatType;\n image: string | HTMLImageElement | HTMLCanvasElement;\n cornerRadius: number | number[];\n};\n\nexport type IImageGraphicAttribute = Partial<IGraphicAttribute> & Partial<IImageAttribute>;\n\nexport interface IImage extends IGraphic<IImageGraphicAttribute> {\n successCallback?: () => void;\n failCallback?: () => void;\n}\n"]}
@@ -14,8 +14,9 @@ export interface ISymbolClass {
14
14
  type: SymbolType | string;
15
15
  path?: ICustomPath2D;
16
16
  pathStr: string;
17
- draw: (ctx: IPath2D, size: number | [number, number], x: number, y: number, z?: number) => boolean;
18
- drawOffset: (ctx: IPath2D, size: number | [number, number], x: number, y: number, offset: number, z?: number) => boolean;
17
+ isSvg?: boolean;
18
+ draw: (ctx: IPath2D, size: number | [number, number], x: number, y: number, z?: number, cb?: (p: ICustomPath2D, a: any) => void) => boolean;
19
+ drawOffset: (ctx: IPath2D, size: number | [number, number], x: number, y: number, offset: number, z?: number, cb?: (p: ICustomPath2D, a: any) => void) => boolean;
19
20
  drawToSvgPath?: (size: number | [number, number], x: number, y: number, z?: number) => string;
20
21
  bounds: (size: number | [number, number], bounds: IBounds) => void;
21
22
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/symbol.ts"],"names":[],"mappings":"","file":"symbol.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { ICustomPath2D, IPath2D } from '../path';\n\nexport type ISymbolAttribute = {\n symbolType: SymbolType;\n size: number | [number, number];\n};\n\nexport type ISymbolGraphicAttribute = Partial<IGraphicAttribute> & Partial<ISymbolAttribute>;\n\nexport interface ISymbol extends IGraphic<ISymbolGraphicAttribute> {\n getParsedPath: () => ISymbolClass;\n}\n\nexport type SymbolType =\n | 'circle'\n | 'cross'\n | 'diamond'\n | 'square'\n | 'arrow'\n | 'arrow2Left'\n | 'arrow2Right'\n | 'wedge'\n | 'thinTriangle'\n | 'triangle'\n | 'triangleUp'\n | 'triangleDown'\n | 'triangleRight'\n | 'triangleLeft'\n | 'stroke'\n | 'star'\n | 'wye'\n | 'rect'\n | string;\n\nexport interface ISymbolClass {\n type: SymbolType | string;\n path?: ICustomPath2D;\n pathStr: string;\n\n // 返回true表示内部已经调用closePath,返回false表示没有调用closePath,外部需要调用closePath\n draw: (ctx: IPath2D, size: number | [number, number], x: number, y: number, z?: number) => boolean;\n drawOffset: (\n ctx: IPath2D,\n size: number | [number, number],\n x: number,\n y: number,\n offset: number,\n z?: number\n ) => boolean;\n\n drawToSvgPath?: (size: number | [number, number], x: number, y: number, z?: number) => string;\n\n bounds: (size: number | [number, number], bounds: IBounds) => void;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/symbol.ts"],"names":[],"mappings":"","file":"symbol.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { ICustomPath2D, IPath2D } from '../path';\n\nexport type ISymbolAttribute = {\n symbolType: SymbolType;\n size: number | [number, number];\n};\n\nexport type ISymbolGraphicAttribute = Partial<IGraphicAttribute> & Partial<ISymbolAttribute>;\n\nexport interface ISymbol extends IGraphic<ISymbolGraphicAttribute> {\n getParsedPath: () => ISymbolClass;\n}\n\nexport type SymbolType =\n | 'circle'\n | 'cross'\n | 'diamond'\n | 'square'\n | 'arrow'\n | 'arrow2Left'\n | 'arrow2Right'\n | 'wedge'\n | 'thinTriangle'\n | 'triangle'\n | 'triangleUp'\n | 'triangleDown'\n | 'triangleRight'\n | 'triangleLeft'\n | 'stroke'\n | 'star'\n | 'wye'\n | 'rect'\n | string;\n\nexport interface ISymbolClass {\n type: SymbolType | string;\n path?: ICustomPath2D;\n pathStr: string;\n isSvg?: boolean;\n\n // 返回true表示内部已经调用closePath,返回false表示没有调用closePath,外部需要调用closePath\n draw: (\n ctx: IPath2D,\n size: number | [number, number],\n x: number,\n y: number,\n z?: number,\n cb?: (p: ICustomPath2D, a: any) => void\n ) => boolean;\n drawOffset: (\n ctx: IPath2D,\n size: number | [number, number],\n x: number,\n y: number,\n offset: number,\n z?: number,\n cb?: (p: ICustomPath2D, a: any) => void\n ) => boolean;\n\n drawToSvgPath?: (size: number | [number, number], x: number, y: number, z?: number) => string;\n\n bounds: (size: number | [number, number], bounds: IBounds) => void;\n}\n"]}
@@ -42,6 +42,7 @@ export type ITextAttribute = {
42
42
  scaleIn3d: boolean;
43
43
  direction: 'horizontal' | 'vertical';
44
44
  wordBreak: 'break-word' | 'break-all';
45
+ ignoreBuf: boolean;
45
46
  };
46
47
  export type ITextCache = {
47
48
  clipedText?: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n wordBreak: 'break-word' | 'break-all';\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n};\nexport type ITextCache = {\n // 单行文本的时候缓存用\n clipedText?: string;\n clipedWidth?: number;\n // 多行文本的布局缓存\n layoutData?: LayoutType;\n verticalList?: { text: string; width?: number; direction: number }[][];\n};\n\nexport type ITextGraphicAttribute = Partial<IGraphicAttribute> & Partial<ITextAttribute>;\n\nexport type IWrapTextGraphicAttribute = ITextGraphicAttribute & {\n heightLimit?: number;\n lineClamp?: number;\n};\n\nexport interface IText extends IGraphic<ITextGraphicAttribute> {\n // 判断是否被ellipisised\n clipedText?: string;\n clipedWidth?: number;\n cliped?: boolean;\n multilineLayout?: LayoutType;\n font?: string;\n cache?: ITextCache;\n\n updateMultilineAABBBounds: (text: (number | string)[]) => IAABBBounds;\n updateSingallineAABBBounds: (text: number | string) => IAABBBounds;\n}\n\nexport type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';\nexport type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n wordBreak: 'break-word' | 'break-all';\n ignoreBuf: boolean;\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n};\nexport type ITextCache = {\n // 单行文本的时候缓存用\n clipedText?: string;\n clipedWidth?: number;\n // 多行文本的布局缓存\n layoutData?: LayoutType;\n verticalList?: { text: string; width?: number; direction: number }[][];\n};\n\nexport type ITextGraphicAttribute = Partial<IGraphicAttribute> & Partial<ITextAttribute>;\n\nexport type IWrapTextGraphicAttribute = ITextGraphicAttribute & {\n heightLimit?: number;\n lineClamp?: number;\n};\n\nexport interface IText extends IGraphic<ITextGraphicAttribute> {\n // 判断是否被ellipisised\n clipedText?: string;\n clipedWidth?: number;\n cliped?: boolean;\n multilineLayout?: LayoutType;\n font?: string;\n cache?: ITextCache;\n\n updateMultilineAABBBounds: (text: (number | string)[]) => IAABBBounds;\n updateSingallineAABBBounds: (text: number | string) => IAABBBounds;\n}\n\nexport type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';\nexport type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';\n"]}
@@ -84,16 +84,33 @@ export type IConnectedStyle = {
84
84
  connectedX: number;
85
85
  connectedY: number;
86
86
  };
87
+ export type IBackgroundConfig = {
88
+ stroke?: string | boolean;
89
+ fill?: string | boolean;
90
+ lineWidth?: number;
91
+ cornerRadius?: number;
92
+ expandX?: number;
93
+ expandY?: number;
94
+ };
87
95
  export type IGraphicStyle = IFillStyle & IStrokeStyle & {
88
96
  opacity: number;
89
97
  backgroundMode: number;
90
- background: string | HTMLImageElement | HTMLCanvasElement | null;
98
+ background: string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig | null;
91
99
  texture: TextureType | string;
92
100
  textureColor: string;
93
101
  textureSize: number;
94
102
  texturePadding: number;
95
103
  blur: number;
96
104
  cursor: Cursor | null;
105
+ html: {
106
+ dom: string | HTMLElement;
107
+ container: string | HTMLElement | null;
108
+ width: number;
109
+ height: number;
110
+ style: string | Record<string, any>;
111
+ visible?: boolean;
112
+ anchorType?: 'position' | 'boundsLeftTop';
113
+ } | null;
97
114
  };
98
115
  export type IGraphicAttribute = IGraphicStyle & ITransform & {
99
116
  strokeSeg: IStrokeSeg | null;
@@ -107,6 +124,7 @@ export type IGraphicAttribute = IGraphicStyle & ITransform & {
107
124
  zIndex: number;
108
125
  layout: any;
109
126
  keepDirIn3d?: boolean;
127
+ shadowRootIdx: number;
110
128
  };
111
129
  export interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {
112
130
  attribute: Partial<T>;
@@ -140,6 +158,11 @@ export interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphi
140
158
  shadowRoot?: IShadowRoot;
141
159
  glyphHost?: IGraphic<IGlyphGraphicAttribute>;
142
160
  backgroundImg?: boolean;
161
+ bindDom?: Map<string | HTMLElement, {
162
+ container: HTMLElement | string;
163
+ dom: HTMLElement;
164
+ wrapGroup: HTMLDivElement;
165
+ }>;
143
166
  valid: boolean;
144
167
  parent: IGroup | null;
145
168
  isContainer?: boolean;
@@ -180,11 +203,12 @@ export interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphi
180
203
  translateTo: (x: number, y: number) => this;
181
204
  scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;
182
205
  scaleTo: (scaleX: number, scaleY: number) => this;
183
- rotate: (angle: number) => this;
206
+ rotate: (angle: number, rotateCenter?: IPointLike) => this;
184
207
  rotateTo: (angle: number) => this;
185
208
  skewTo: (b: number, c: number) => this;
186
209
  addUpdateBoundTag: () => void;
187
210
  addUpdateShapeAndBoundsTag: () => void;
211
+ addUpdateLayoutTag: () => void;
188
212
  update: (d?: {
189
213
  bounds: boolean;
190
214
  trans: boolean;
@@ -208,7 +232,7 @@ export interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphi
208
232
  toJson: () => IGraphicJson;
209
233
  createPathProxy: (path?: string) => void;
210
234
  toCustomPath?: () => ICustomPath2D;
211
- resources?: Map<string | HTMLImageElement | HTMLCanvasElement, {
235
+ resources?: Map<string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig, {
212
236
  state: 'init' | 'loading' | 'success' | 'fail';
213
237
  data?: HTMLImageElement | HTMLCanvasElement;
214
238
  }>;