@visactor/vrender 0.14.0-alpha.0 → 0.14.0-alpha.2

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 (312) hide show
  1. package/cjs/canvas/contributions/browser/canvas.d.ts +3 -1
  2. package/cjs/canvas/contributions/browser/canvas.js +6 -0
  3. package/cjs/canvas/contributions/browser/canvas.js.map +1 -1
  4. package/cjs/canvas/contributions/browser/context.d.ts +1 -0
  5. package/cjs/canvas/contributions/feishu/canvas.d.ts +3 -1
  6. package/cjs/canvas/contributions/feishu/canvas.js +6 -0
  7. package/cjs/canvas/contributions/feishu/canvas.js.map +1 -1
  8. package/cjs/canvas/contributions/lynx/canvas.d.ts +3 -1
  9. package/cjs/canvas/contributions/lynx/canvas.js +6 -0
  10. package/cjs/canvas/contributions/lynx/canvas.js.map +1 -1
  11. package/cjs/canvas/contributions/node/canvas.d.ts +2 -0
  12. package/cjs/canvas/contributions/node/canvas.js +2 -0
  13. package/cjs/canvas/contributions/node/canvas.js.map +1 -1
  14. package/cjs/canvas/contributions/taro/canvas.d.ts +3 -1
  15. package/cjs/canvas/contributions/taro/canvas.js +6 -0
  16. package/cjs/canvas/contributions/taro/canvas.js.map +1 -1
  17. package/cjs/canvas/contributions/tt/canvas.d.ts +3 -1
  18. package/cjs/canvas/contributions/tt/canvas.js +6 -0
  19. package/cjs/canvas/contributions/tt/canvas.js.map +1 -1
  20. package/cjs/canvas/contributions/wx/canvas.d.ts +2 -0
  21. package/cjs/canvas/contributions/wx/canvas.js +6 -0
  22. package/cjs/canvas/contributions/wx/canvas.js.map +1 -1
  23. package/cjs/common/render-area.d.ts +4 -0
  24. package/cjs/common/render-area.js +31 -6
  25. package/cjs/common/render-area.js.map +1 -1
  26. package/cjs/common/render-curve.d.ts +4 -0
  27. package/cjs/common/render-curve.js +19 -5
  28. package/cjs/common/render-curve.js.map +1 -1
  29. package/cjs/constants.d.ts +1 -1
  30. package/cjs/constants.js +2 -2
  31. package/cjs/constants.js.map +1 -1
  32. package/cjs/core/contributions/layerHandler/canvas2d-contribution.d.ts +2 -0
  33. package/cjs/core/contributions/layerHandler/canvas2d-contribution.js +9 -3
  34. package/cjs/core/contributions/layerHandler/canvas2d-contribution.js.map +1 -1
  35. package/cjs/core/contributions/layerHandler/offscreen2d-contribution.js +1 -1
  36. package/cjs/core/contributions/layerHandler/offscreen2d-contribution.js.map +1 -1
  37. package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +24 -0
  38. package/cjs/core/contributions/textMeasure/AtextMeasure.js +42 -0
  39. package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  40. package/cjs/core/contributions/window/browser-contribution.js +1 -1
  41. package/cjs/core/contributions/window/browser-contribution.js.map +1 -1
  42. package/cjs/core/contributions/window/feishu-contribution.js +1 -1
  43. package/cjs/core/contributions/window/feishu-contribution.js.map +1 -1
  44. package/cjs/core/contributions/window/lynx-contribution.js +1 -1
  45. package/cjs/core/contributions/window/lynx-contribution.js.map +1 -1
  46. package/cjs/core/contributions/window/native-contribution.js.map +1 -1
  47. package/cjs/core/contributions/window/node-contribution.js +1 -1
  48. package/cjs/core/contributions/window/node-contribution.js.map +1 -1
  49. package/cjs/core/contributions/window/taro-contribution.js +1 -1
  50. package/cjs/core/contributions/window/taro-contribution.js.map +1 -1
  51. package/cjs/core/contributions/window/wx-contribution.js +1 -1
  52. package/cjs/core/contributions/window/wx-contribution.js.map +1 -1
  53. package/cjs/core/core-modules.js +2 -2
  54. package/cjs/core/core-modules.js.map +1 -1
  55. package/cjs/core/global-module.d.ts +5 -1
  56. package/cjs/core/global-module.js +20 -1
  57. package/cjs/core/global-module.js.map +1 -1
  58. package/cjs/core/graphic-utils.js +1 -1
  59. package/cjs/core/graphic-utils.js.map +1 -1
  60. package/cjs/core/layer-service.js +1 -1
  61. package/cjs/core/layer-service.js.map +1 -1
  62. package/cjs/core/stage.d.ts +5 -1
  63. package/cjs/core/stage.js +18 -8
  64. package/cjs/core/stage.js.map +1 -1
  65. package/cjs/core/window.d.ts +1 -1
  66. package/cjs/core/window.js +3 -3
  67. package/cjs/core/window.js.map +1 -1
  68. package/cjs/graphic/config.d.ts +3 -1
  69. package/cjs/graphic/config.js +23 -8
  70. package/cjs/graphic/config.js.map +1 -1
  71. package/cjs/graphic/graphic-service/graphic-service.js +12 -3
  72. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  73. package/cjs/graphic/node-tree.d.ts +2 -2
  74. package/cjs/graphic/node-tree.js +2 -0
  75. package/cjs/graphic/node-tree.js.map +1 -1
  76. package/cjs/graphic/text.d.ts +5 -1
  77. package/cjs/graphic/text.js +94 -2
  78. package/cjs/graphic/text.js.map +1 -1
  79. package/cjs/graphic/tools.d.ts +8 -0
  80. package/cjs/graphic/tools.js +38 -2
  81. package/cjs/graphic/tools.js.map +1 -1
  82. package/cjs/graphic/wrap-text.js +5 -1
  83. package/cjs/graphic/wrap-text.js.map +1 -1
  84. package/cjs/index.d.ts +2 -1
  85. package/cjs/index.js +16 -2
  86. package/cjs/index.js.map +1 -1
  87. package/cjs/interface/graphic/area.d.ts +3 -3
  88. package/cjs/interface/graphic/area.js.map +1 -1
  89. package/cjs/interface/graphic/group.d.ts +6 -0
  90. package/cjs/interface/graphic/group.js.map +1 -1
  91. package/cjs/interface/graphic/line.d.ts +3 -3
  92. package/cjs/interface/graphic/line.js.map +1 -1
  93. package/cjs/interface/graphic/text.d.ts +6 -0
  94. package/cjs/interface/graphic/text.js.map +1 -1
  95. package/cjs/interface/graphic.d.ts +19 -0
  96. package/cjs/interface/graphic.js.map +1 -1
  97. package/cjs/interface/stage.d.ts +2 -0
  98. package/cjs/interface/stage.js.map +1 -1
  99. package/cjs/interface/text.d.ts +24 -0
  100. package/cjs/interface/text.js.map +1 -1
  101. package/cjs/modules.d.ts +1 -1
  102. package/cjs/modules.js +3 -3
  103. package/cjs/modules.js.map +1 -1
  104. package/cjs/picker/canvas-picker-service.js +1 -1
  105. package/cjs/picker/canvas-picker-service.js.map +1 -1
  106. package/cjs/picker/global-picker-service.js +1 -1
  107. package/cjs/picker/global-picker-service.js.map +1 -1
  108. package/cjs/picker/math-picker-service.js +1 -1
  109. package/cjs/picker/math-picker-service.js.map +1 -1
  110. package/cjs/picker/picker-service.js +1 -1
  111. package/cjs/picker/picker-service.js.map +1 -1
  112. package/cjs/plugins/builtin-plugin/flex-layout-plugin.d.ts +34 -0
  113. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +156 -0
  114. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -0
  115. package/cjs/render/contributions/render/arc-render.js +4 -4
  116. package/cjs/render/contributions/render/arc-render.js.map +1 -1
  117. package/cjs/render/contributions/render/arc3d-render.js +3 -3
  118. package/cjs/render/contributions/render/arc3d-render.js.map +1 -1
  119. package/cjs/render/contributions/render/area-render.d.ts +1 -0
  120. package/cjs/render/contributions/render/area-render.js +43 -16
  121. package/cjs/render/contributions/render/area-render.js.map +1 -1
  122. package/cjs/render/contributions/render/circle-render.js +3 -3
  123. package/cjs/render/contributions/render/circle-render.js.map +1 -1
  124. package/cjs/render/contributions/render/group-render.js +4 -3
  125. package/cjs/render/contributions/render/group-render.js.map +1 -1
  126. package/cjs/render/contributions/render/image-render.js +1 -1
  127. package/cjs/render/contributions/render/image-render.js.map +1 -1
  128. package/cjs/render/contributions/render/incremental-area-render.js +1 -1
  129. package/cjs/render/contributions/render/incremental-area-render.js.map +1 -1
  130. package/cjs/render/contributions/render/incremental-draw-contribution.js +1 -1
  131. package/cjs/render/contributions/render/incremental-draw-contribution.js.map +1 -1
  132. package/cjs/render/contributions/render/incremental-line-render.js +1 -1
  133. package/cjs/render/contributions/render/incremental-line-render.js.map +1 -1
  134. package/cjs/render/contributions/render/line-render.js +30 -4
  135. package/cjs/render/contributions/render/line-render.js.map +1 -1
  136. package/cjs/render/contributions/render/path-render.js +3 -3
  137. package/cjs/render/contributions/render/path-render.js.map +1 -1
  138. package/cjs/render/contributions/render/polygon-render.js +3 -3
  139. package/cjs/render/contributions/render/polygon-render.js.map +1 -1
  140. package/cjs/render/contributions/render/pyramid3d-render.js +1 -1
  141. package/cjs/render/contributions/render/pyramid3d-render.js.map +1 -1
  142. package/cjs/render/contributions/render/rect-render.js +4 -3
  143. package/cjs/render/contributions/render/rect-render.js.map +1 -1
  144. package/cjs/render/contributions/render/rect3d-render.js +2 -1
  145. package/cjs/render/contributions/render/rect3d-render.js.map +1 -1
  146. package/cjs/render/contributions/render/richtext-render.js +1 -1
  147. package/cjs/render/contributions/render/richtext-render.js.map +1 -1
  148. package/cjs/render/contributions/render/symbol-render.js +3 -3
  149. package/cjs/render/contributions/render/symbol-render.js.map +1 -1
  150. package/cjs/render/contributions/render/text-render.js +63 -14
  151. package/cjs/render/contributions/render/text-render.js.map +1 -1
  152. package/cjs/render/contributions/render/utils.d.ts +3 -3
  153. package/cjs/render/contributions/render/utils.js +7 -7
  154. package/cjs/render/contributions/render/utils.js.map +1 -1
  155. package/dist/index.js +1107 -201
  156. package/dist/index.min.js +1 -1
  157. package/es/canvas/contributions/browser/canvas.d.ts +3 -1
  158. package/es/canvas/contributions/browser/canvas.js +6 -0
  159. package/es/canvas/contributions/browser/canvas.js.map +1 -1
  160. package/es/canvas/contributions/browser/context.d.ts +1 -0
  161. package/es/canvas/contributions/feishu/canvas.d.ts +3 -1
  162. package/es/canvas/contributions/feishu/canvas.js +6 -0
  163. package/es/canvas/contributions/feishu/canvas.js.map +1 -1
  164. package/es/canvas/contributions/lynx/canvas.d.ts +3 -1
  165. package/es/canvas/contributions/lynx/canvas.js +6 -0
  166. package/es/canvas/contributions/lynx/canvas.js.map +1 -1
  167. package/es/canvas/contributions/node/canvas.d.ts +2 -0
  168. package/es/canvas/contributions/node/canvas.js +2 -0
  169. package/es/canvas/contributions/node/canvas.js.map +1 -1
  170. package/es/canvas/contributions/taro/canvas.d.ts +3 -1
  171. package/es/canvas/contributions/taro/canvas.js +6 -0
  172. package/es/canvas/contributions/taro/canvas.js.map +1 -1
  173. package/es/canvas/contributions/tt/canvas.d.ts +3 -1
  174. package/es/canvas/contributions/tt/canvas.js +6 -0
  175. package/es/canvas/contributions/tt/canvas.js.map +1 -1
  176. package/es/canvas/contributions/wx/canvas.d.ts +2 -0
  177. package/es/canvas/contributions/wx/canvas.js +6 -0
  178. package/es/canvas/contributions/wx/canvas.js.map +1 -1
  179. package/es/common/render-area.d.ts +4 -0
  180. package/es/common/render-area.js +31 -6
  181. package/es/common/render-area.js.map +1 -1
  182. package/es/common/render-curve.d.ts +4 -0
  183. package/es/common/render-curve.js +19 -5
  184. package/es/common/render-curve.js.map +1 -1
  185. package/es/constants.d.ts +1 -1
  186. package/es/constants.js +1 -1
  187. package/es/constants.js.map +1 -1
  188. package/es/core/contributions/layerHandler/canvas2d-contribution.d.ts +2 -0
  189. package/es/core/contributions/layerHandler/canvas2d-contribution.js +10 -4
  190. package/es/core/contributions/layerHandler/canvas2d-contribution.js.map +1 -1
  191. package/es/core/contributions/layerHandler/offscreen2d-contribution.js +2 -2
  192. package/es/core/contributions/layerHandler/offscreen2d-contribution.js.map +1 -1
  193. package/es/core/contributions/textMeasure/AtextMeasure.d.ts +24 -0
  194. package/es/core/contributions/textMeasure/AtextMeasure.js +42 -0
  195. package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  196. package/es/core/contributions/window/browser-contribution.js +2 -2
  197. package/es/core/contributions/window/browser-contribution.js.map +1 -1
  198. package/es/core/contributions/window/feishu-contribution.js +2 -2
  199. package/es/core/contributions/window/feishu-contribution.js.map +1 -1
  200. package/es/core/contributions/window/lynx-contribution.js +2 -2
  201. package/es/core/contributions/window/lynx-contribution.js.map +1 -1
  202. package/es/core/contributions/window/native-contribution.js.map +1 -1
  203. package/es/core/contributions/window/node-contribution.js +2 -2
  204. package/es/core/contributions/window/node-contribution.js.map +1 -1
  205. package/es/core/contributions/window/taro-contribution.js +2 -2
  206. package/es/core/contributions/window/taro-contribution.js.map +1 -1
  207. package/es/core/contributions/window/wx-contribution.js +2 -2
  208. package/es/core/contributions/window/wx-contribution.js.map +1 -1
  209. package/es/core/core-modules.js +4 -4
  210. package/es/core/core-modules.js.map +1 -1
  211. package/es/core/global-module.d.ts +5 -1
  212. package/es/core/global-module.js +20 -1
  213. package/es/core/global-module.js.map +1 -1
  214. package/es/core/graphic-utils.js +2 -2
  215. package/es/core/graphic-utils.js.map +1 -1
  216. package/es/core/layer-service.js +2 -2
  217. package/es/core/layer-service.js.map +1 -1
  218. package/es/core/stage.d.ts +5 -1
  219. package/es/core/stage.js +21 -9
  220. package/es/core/stage.js.map +1 -1
  221. package/es/core/window.d.ts +1 -1
  222. package/es/core/window.js +3 -3
  223. package/es/core/window.js.map +1 -1
  224. package/es/graphic/config.d.ts +3 -1
  225. package/es/graphic/config.js +24 -6
  226. package/es/graphic/config.js.map +1 -1
  227. package/es/graphic/graphic-service/graphic-service.js +12 -3
  228. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  229. package/es/graphic/node-tree.d.ts +2 -2
  230. package/es/graphic/node-tree.js +2 -0
  231. package/es/graphic/node-tree.js.map +1 -1
  232. package/es/graphic/text.d.ts +5 -1
  233. package/es/graphic/text.js +95 -1
  234. package/es/graphic/text.js.map +1 -1
  235. package/es/graphic/tools.d.ts +8 -0
  236. package/es/graphic/tools.js +38 -0
  237. package/es/graphic/tools.js.map +1 -1
  238. package/es/graphic/wrap-text.js +5 -1
  239. package/es/graphic/wrap-text.js.map +1 -1
  240. package/es/index.d.ts +2 -1
  241. package/es/index.js +3 -1
  242. package/es/index.js.map +1 -1
  243. package/es/interface/graphic/area.d.ts +3 -3
  244. package/es/interface/graphic/area.js.map +1 -1
  245. package/es/interface/graphic/group.d.ts +6 -0
  246. package/es/interface/graphic/group.js.map +1 -1
  247. package/es/interface/graphic/line.d.ts +3 -3
  248. package/es/interface/graphic/line.js.map +1 -1
  249. package/es/interface/graphic/text.d.ts +6 -0
  250. package/es/interface/graphic/text.js.map +1 -1
  251. package/es/interface/graphic.d.ts +19 -0
  252. package/es/interface/graphic.js.map +1 -1
  253. package/es/interface/stage.d.ts +2 -0
  254. package/es/interface/stage.js.map +1 -1
  255. package/es/interface/text.d.ts +24 -0
  256. package/es/interface/text.js.map +1 -1
  257. package/es/modules.d.ts +1 -1
  258. package/es/modules.js +3 -3
  259. package/es/modules.js.map +1 -1
  260. package/es/picker/canvas-picker-service.js +2 -2
  261. package/es/picker/canvas-picker-service.js.map +1 -1
  262. package/es/picker/global-picker-service.js +2 -2
  263. package/es/picker/global-picker-service.js.map +1 -1
  264. package/es/picker/math-picker-service.js +2 -2
  265. package/es/picker/math-picker-service.js.map +1 -1
  266. package/es/picker/picker-service.js +2 -2
  267. package/es/picker/picker-service.js.map +1 -1
  268. package/es/plugins/builtin-plugin/flex-layout-plugin.d.ts +34 -0
  269. package/es/plugins/builtin-plugin/flex-layout-plugin.js +152 -0
  270. package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -0
  271. package/es/render/contributions/render/arc-render.js +3 -3
  272. package/es/render/contributions/render/arc-render.js.map +1 -1
  273. package/es/render/contributions/render/arc3d-render.js +2 -2
  274. package/es/render/contributions/render/arc3d-render.js.map +1 -1
  275. package/es/render/contributions/render/area-render.d.ts +1 -0
  276. package/es/render/contributions/render/area-render.js +42 -14
  277. package/es/render/contributions/render/area-render.js.map +1 -1
  278. package/es/render/contributions/render/circle-render.js +2 -2
  279. package/es/render/contributions/render/circle-render.js.map +1 -1
  280. package/es/render/contributions/render/group-render.js +2 -2
  281. package/es/render/contributions/render/group-render.js.map +1 -1
  282. package/es/render/contributions/render/image-render.js +1 -1
  283. package/es/render/contributions/render/image-render.js.map +1 -1
  284. package/es/render/contributions/render/incremental-area-render.js +1 -1
  285. package/es/render/contributions/render/incremental-area-render.js.map +1 -1
  286. package/es/render/contributions/render/incremental-draw-contribution.js +2 -2
  287. package/es/render/contributions/render/incremental-draw-contribution.js.map +1 -1
  288. package/es/render/contributions/render/incremental-line-render.js +1 -1
  289. package/es/render/contributions/render/incremental-line-render.js.map +1 -1
  290. package/es/render/contributions/render/line-render.js +30 -4
  291. package/es/render/contributions/render/line-render.js.map +1 -1
  292. package/es/render/contributions/render/path-render.js +2 -2
  293. package/es/render/contributions/render/path-render.js.map +1 -1
  294. package/es/render/contributions/render/polygon-render.js +2 -2
  295. package/es/render/contributions/render/polygon-render.js.map +1 -1
  296. package/es/render/contributions/render/pyramid3d-render.js +1 -1
  297. package/es/render/contributions/render/pyramid3d-render.js.map +1 -1
  298. package/es/render/contributions/render/rect-render.js +2 -2
  299. package/es/render/contributions/render/rect-render.js.map +1 -1
  300. package/es/render/contributions/render/rect3d-render.js +1 -1
  301. package/es/render/contributions/render/rect3d-render.js.map +1 -1
  302. package/es/render/contributions/render/richtext-render.js +1 -1
  303. package/es/render/contributions/render/richtext-render.js.map +1 -1
  304. package/es/render/contributions/render/symbol-render.js +2 -2
  305. package/es/render/contributions/render/symbol-render.js.map +1 -1
  306. package/es/render/contributions/render/text-render.js +65 -12
  307. package/es/render/contributions/render/text-render.js.map +1 -1
  308. package/es/render/contributions/render/utils.d.ts +3 -3
  309. package/es/render/contributions/render/utils.js +7 -7
  310. package/es/render/contributions/render/utils.js.map +1 -1
  311. package/es/tsconfig.tsbuildinfo +1 -1
  312. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/graphic/wrap-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAO9D,MAAM,OAAO,QAAS,SAAQ,IAAI;IAGtB,QAAQ;QAChB,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UAAU,CAAC;QACnC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QAExG,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;SACxC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,cAAc,CAAC,IAAc;QAC3B,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,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","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 // // 测量当前行宽度\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 linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else {\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,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAO9D,MAA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AK,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","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 // // 测量当前行宽度\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 }\n\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else {\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"]}
package/es/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.0-alpha.0";
3
+ export declare const version = "0.14.0-alpha.2";
4
4
  export * from './container';
5
5
  export * from './core/global';
6
6
  export * from './graphic';
@@ -39,3 +39,4 @@ export * from './common/enums';
39
39
  export * from './common/generator';
40
40
  export * from './plugins/constants';
41
41
  export * from './animate/default-ticker';
42
+ export { wrapCanvas, wrapContext } from './canvas/util';
package/es/index.js CHANGED
@@ -2,7 +2,7 @@ import "core-js/proposals/reflect-metadata";
2
2
 
3
3
  import "./modules";
4
4
 
5
- export const version = "0.14.0-alpha.0";
5
+ export const version = "0.14.0-alpha.2";
6
6
 
7
7
  export * from "./container";
8
8
 
@@ -79,4 +79,6 @@ export * from "./common/generator";
79
79
  export * from "./plugins/constants";
80
80
 
81
81
  export * from "./animate/default-ticker";
82
+
83
+ export { wrapCanvas, wrapContext } from "./canvas/util";
82
84
  //# sourceMappingURL=index.js.map
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC;AAC5C,OAAO,WAAW,CAAC;AAGnB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,2CAA2C,CAAC;AAC1D,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AAGzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,0BAA0B,CAAC","file":"index.js","sourcesContent":["import 'core-js/proposals/reflect-metadata';\nimport './modules';\n\n// 导出版本号\nexport const version = \"0.14.0-alpha.0\";\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';\n"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC;AAC5C,OAAO,WAAW,CAAC;AAGnB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,2CAA2C,CAAC;AAC1D,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AAGzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","file":"index.js","sourcesContent":["import 'core-js/proposals/reflect-metadata';\nimport './modules';\n\n// 导出版本号\nexport const version = \"0.14.0-alpha.2\";\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,6 +1,6 @@
1
1
  import type { IPointLike } from '@visactor/vutils';
2
2
  import type { ISegPath2D } from '../curve';
3
- import type { IGraphic, IGraphicAttribute } from '../graphic';
3
+ import type { IConnectedStyle, IGraphic, IGraphicAttribute } from '../graphic';
4
4
  import type { ICurveType } from '../common';
5
5
  export type IAreaAttribute = {
6
6
  segments: IAreaSegment[];
@@ -12,12 +12,12 @@ export type IAreaCacheItem = {
12
12
  top: ISegPath2D;
13
13
  bottom: ISegPath2D;
14
14
  };
15
- export type IAreaGraphicAttribute = Partial<IGraphicAttribute> & Partial<IAreaAttribute>;
15
+ export type IAreaGraphicAttribute = Partial<IGraphicAttribute> & Partial<IAreaAttribute> & Partial<IConnectedStyle>;
16
16
  export interface IArea extends IGraphic<IAreaGraphicAttribute> {
17
17
  cacheArea?: IAreaCacheItem | IAreaCacheItem[];
18
18
  }
19
19
  type ISegmentStyle = Pick<IGraphicAttribute, 'fill' | 'fillOpacity' | 'background' | 'texture' | 'textureColor' | 'textureSize' | 'texturePadding'>;
20
- export interface IAreaSegment extends Partial<ISegmentStyle> {
20
+ export interface IAreaSegment extends Partial<ISegmentStyle>, Partial<IConnectedStyle> {
21
21
  points: IPointLike[];
22
22
  }
23
23
  export {};
@@ -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 { 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>;\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> {\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};\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"]}
@@ -9,6 +9,12 @@ export type IGroupAttribute = {
9
9
  cornerRadius: number | number[];
10
10
  clip: boolean;
11
11
  visibleAll: boolean;
12
+ display?: 'relative' | 'flex';
13
+ flexDirection?: 'row' | 'row-reverse' | 'column' | 'column-reverse';
14
+ flexWrap?: 'nowrap' | 'wrap';
15
+ justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';
16
+ alignItems?: 'flex-start' | 'flex-end' | 'center';
17
+ alignContent?: 'flex-start' | 'center' | 'space-between' | 'space-around';
12
18
  };
13
19
  export type IGroupGraphicAttribute = Partial<IGraphicAttribute> & Partial<IGroupAttribute>;
14
20
  export interface IGroup extends IGraphic<IGroupGraphicAttribute> {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/interface/graphic/group.ts"],"names":[],"mappings":"","file":"group.js","sourcesContent":["import type { ITheme, IThemeSpec } from './theme';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { INode } from '../node-tree';\nimport type { GraphicAttributeMap } from './creator';\n\nexport type IGroupAttribute = {\n path: IGraphic[];\n width: number;\n height: number;\n cornerRadius: number | number[];\n clip: boolean;\n visibleAll: boolean;\n};\n\nexport type IGroupGraphicAttribute = Partial<IGraphicAttribute> & Partial<IGroupAttribute>;\n\nexport interface IGroup extends IGraphic<IGroupGraphicAttribute> {\n childrenPickable?: boolean; // 子元素是否可以被pick\n\n theme?: ITheme;\n\n createTheme: () => void;\n hideAll: () => void;\n showAll: () => void;\n\n setTheme: (t: IThemeSpec) => void;\n\n incrementalAppendChild: (node: INode, highPerformance?: boolean) => INode | null;\n incrementalClearChild: () => void;\n\n createOrUpdateChild: <T extends keyof GraphicAttributeMap>(\n graphicName: string,\n attributes: GraphicAttributeMap[T],\n graphicType: T\n ) => INode;\n}\n"]}
1
+ {"version":3,"sources":["../../src/interface/graphic/group.ts"],"names":[],"mappings":"","file":"group.js","sourcesContent":["import type { ITheme, IThemeSpec } from './theme';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { INode } from '../node-tree';\nimport type { GraphicAttributeMap } from './creator';\n\nexport type IGroupAttribute = {\n path: IGraphic[];\n width: number;\n height: number;\n cornerRadius: number | number[];\n clip: boolean;\n visibleAll: boolean;\n display?: 'relative' | 'flex';\n flexDirection?: 'row' | 'row-reverse' | 'column' | 'column-reverse';\n flexWrap?: 'nowrap' | 'wrap';\n justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';\n alignItems?: 'flex-start' | 'flex-end' | 'center';\n alignContent?: 'flex-start' | 'center' | 'space-between' | 'space-around';\n};\n\nexport type IGroupGraphicAttribute = Partial<IGraphicAttribute> & Partial<IGroupAttribute>;\n\nexport interface IGroup extends IGraphic<IGroupGraphicAttribute> {\n childrenPickable?: boolean; // 子元素是否可以被pick\n\n theme?: ITheme;\n\n createTheme: () => void;\n hideAll: () => void;\n showAll: () => void;\n\n setTheme: (t: IThemeSpec) => void;\n\n incrementalAppendChild: (node: INode, highPerformance?: boolean) => INode | null;\n incrementalClearChild: () => void;\n\n createOrUpdateChild: <T extends keyof GraphicAttributeMap>(\n graphicName: string,\n attributes: GraphicAttributeMap[T],\n graphicType: T\n ) => INode;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { IPointLike } from '@visactor/vutils';
2
- import type { IGraphicAttribute, IGraphic } from '../graphic';
2
+ import type { IGraphicAttribute, IGraphic, IConnectedStyle } from '../graphic';
3
3
  import type { ICurveType } from '../common';
4
4
  import type { ISegPath2D } from '../curve';
5
5
  export type IClipRangeByDimensionType = 'x' | 'y' | 'auto' | 'default';
@@ -10,12 +10,12 @@ export type ILineAttribute = {
10
10
  clipRange: number;
11
11
  clipRangeByDimension: IClipRangeByDimensionType;
12
12
  };
13
- export type ILineGraphicAttribute = Partial<IGraphicAttribute> & Partial<ILineAttribute>;
13
+ export type ILineGraphicAttribute = Partial<IGraphicAttribute> & Partial<ILineAttribute> & Partial<IConnectedStyle>;
14
14
  export interface ILine extends IGraphic<ILineGraphicAttribute> {
15
15
  cache?: ISegPath2D | ISegPath2D[];
16
16
  }
17
17
  type ISegmentStyle = Pick<IGraphicAttribute, 'stroke' | 'strokeOpacity' | 'lineDash' | 'lineDashOffset' | 'lineCap' | 'lineJoin' | 'lineWidth' | 'miterLimit'>;
18
- export interface ISegment extends Partial<ISegmentStyle> {
18
+ export interface ISegment extends Partial<ISegmentStyle>, Partial<IConnectedStyle> {
19
19
  points: IPointLike[];
20
20
  simplify?: boolean;
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/interface/graphic/line.ts"],"names":[],"mappings":"","file":"line.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { ICurveType } from '../common';\nimport type { ISegPath2D } from '../curve';\n\n// 依据x纬度做clipRange\n// 依据y纬度做clipRange\n// 依据线段自动匹配纬度做clipRange\n// 依据线长纬度做clipRange\nexport type IClipRangeByDimensionType = 'x' | 'y' | 'auto' | 'default';\n\nexport type ILineAttribute = {\n segments: ISegment[]; // 分段设置point和样式\n points: IPointLike[]; // segments points 二选一\n curveType: ICurveType;\n clipRange: number;\n clipRangeByDimension: IClipRangeByDimensionType;\n};\n\nexport type ILineGraphicAttribute = Partial<IGraphicAttribute> & Partial<ILineAttribute>;\n\nexport interface ILine extends IGraphic<ILineGraphicAttribute> {\n cache?: ISegPath2D | ISegPath2D[];\n}\n\ntype ISegmentStyle = Pick<\n IGraphicAttribute,\n 'stroke' | 'strokeOpacity' | 'lineDash' | 'lineDashOffset' | 'lineCap' | 'lineJoin' | 'lineWidth' | 'miterLimit'\n>;\n\nexport interface ISegment extends Partial<ISegmentStyle> {\n points: IPointLike[];\n simplify?: boolean;\n}\n"]}
1
+ {"version":3,"sources":["../../src/interface/graphic/line.ts"],"names":[],"mappings":"","file":"line.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic, IConnectedStyle } from '../graphic';\nimport type { ICurveType } from '../common';\nimport type { ISegPath2D } from '../curve';\n\n// 依据x纬度做clipRange\n// 依据y纬度做clipRange\n// 依据线段自动匹配纬度做clipRange\n// 依据线长纬度做clipRange\nexport type IClipRangeByDimensionType = 'x' | 'y' | 'auto' | 'default';\n\nexport type ILineAttribute = {\n segments: ISegment[]; // 分段设置point和样式\n points: IPointLike[]; // segments points 二选一\n curveType: ICurveType;\n clipRange: number;\n clipRangeByDimension: IClipRangeByDimensionType;\n};\n\nexport type ILineGraphicAttribute = Partial<IGraphicAttribute> & Partial<ILineAttribute> & Partial<IConnectedStyle>;\n\nexport interface ILine extends IGraphic<ILineGraphicAttribute> {\n cache?: ISegPath2D | ISegPath2D[];\n}\n\ntype ISegmentStyle = Pick<\n IGraphicAttribute,\n 'stroke' | 'strokeOpacity' | 'lineDash' | 'lineDashOffset' | 'lineCap' | 'lineJoin' | 'lineWidth' | 'miterLimit'\n>;\n\nexport interface ISegment extends Partial<ISegmentStyle>, Partial<IConnectedStyle> {\n points: IPointLike[];\n simplify?: boolean;\n}\n"]}
@@ -40,11 +40,17 @@ export type ITextAttribute = {
40
40
  underline: number;
41
41
  lineThrough: number;
42
42
  scaleIn3d: boolean;
43
+ direction: 'horizontal' | 'vertical';
43
44
  };
44
45
  export type ITextCache = {
45
46
  clipedText?: string;
46
47
  clipedWidth?: number;
47
48
  layoutData?: LayoutType;
49
+ verticalList?: {
50
+ text: string;
51
+ width?: number;
52
+ direction: number;
53
+ }[][];
48
54
  };
49
55
  export type ITextGraphicAttribute = Partial<IGraphicAttribute> & Partial<ITextAttribute>;
50
56
  export type IWrapTextGraphicAttribute = ITextGraphicAttribute & {
@@ -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 // 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};\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 // 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"]}
@@ -45,6 +45,9 @@ export type IFillStyle = {
45
45
  shadowOffsetY: number;
46
46
  fill: IFillType;
47
47
  };
48
+ export type ILayout = {
49
+ alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch';
50
+ };
48
51
  export type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {
49
52
  distance: number | string;
50
53
  };
@@ -63,6 +66,22 @@ export type IStrokeStyle = {
63
66
  stroke: IStrokeType[] | IStrokeType;
64
67
  };
65
68
  type TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';
69
+ export type IConnectedStyle = {
70
+ connectedType: 'connect' | 'zero' | 'none';
71
+ connectedStyle: {
72
+ stroke: IStrokeStyle['stroke'];
73
+ strokeOpacity: IStrokeStyle['strokeOpacity'];
74
+ lineDash: IStrokeStyle['lineDash'];
75
+ lineDashOffset: IStrokeStyle['lineDashOffset'];
76
+ lineCap: IStrokeStyle['lineCap'];
77
+ lineJoin: IStrokeStyle['lineJoin'];
78
+ lineWidth: IStrokeStyle['lineWidth'];
79
+ fill: IFillStyle['fill'];
80
+ fillOpacity: IFillStyle['fillOpacity'];
81
+ };
82
+ connectedX: number;
83
+ connectedY: number;
84
+ };
66
85
  export type IGraphicStyle = IFillStyle & IStrokeStyle & {
67
86
  opacity: number;
68
87
  backgroundMode: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IOBBBounds, IMatrix, IPointLike, IPoint } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget } from './animate';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\n\ntype IStrokeSeg = {\n start: number; // 百分比\n // end和length二选一\n end: number; // 百分比\n length: number; // 像素长度\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph';\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n x: number;\n y: number;\n z: number;\n dx: number;\n dy: number;\n dz: number;\n scrollX: number;\n scrollY: number;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n angle: number;\n alpha: number;\n beta: number;\n anchor: [number | string, number | string]; // 基于AABB的锚点位置,用于简单的定位某些path\n anchor3d: [number | string, number | string, number] | [number | string, number | string]; // 3d的锚点位置\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n fillOpacity: number;\n shadowBlur: number;\n shadowColor: string;\n shadowOffsetX: number;\n shadowOffsetY: number;\n fill: IFillType;\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n distance: number | string;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n outerBorder: Partial<IBorderStyle>;\n innerBorder: Partial<IBorderStyle>;\n strokeOpacity: number;\n lineDash: number[];\n lineDashOffset: number;\n lineWidth: number;\n lineCap: CanvasLineCap;\n lineJoin: CanvasLineJoin;\n miterLimit: number;\n // 描边的boundsBuffer,用于控制bounds的buffer\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IGraphicStyle = IFillStyle &\n IStrokeStyle & {\n opacity: number;\n backgroundMode: number; // 填充模式(与具体图元有关)\n background: string | HTMLImageElement | HTMLCanvasElement | null; // 背景,可以与fill同时存在\n texture: TextureType | string; // 纹理\n textureColor: string; // 纹理颜色\n textureSize: number; // 纹理大小\n texturePadding: number; // 纹理间隙\n blur: number;\n cursor: Cursor | null; // 鼠标样式\n };\n\nexport type IGraphicAttribute = IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n // 包围盒的padding\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n zIndex: number;\n layout: any;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n};\n\nexport type IGraphicAnimateParams = {\n id?: number | string;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
1
+ {"version":3,"sources":["../../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IOBBBounds, IMatrix, IPointLike, IPoint } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget } from './animate';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\n\ntype IStrokeSeg = {\n start: number; // 百分比\n // end和length二选一\n end: number; // 百分比\n length: number; // 像素长度\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph';\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n x: number;\n y: number;\n z: number;\n dx: number;\n dy: number;\n dz: number;\n scrollX: number;\n scrollY: number;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n angle: number;\n alpha: number;\n beta: number;\n anchor: [number | string, number | string]; // 基于AABB的锚点位置,用于简单的定位某些path\n anchor3d: [number | string, number | string, number] | [number | string, number | string]; // 3d的锚点位置\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n fillOpacity: number;\n shadowBlur: number;\n shadowColor: string;\n shadowOffsetX: number;\n shadowOffsetY: number;\n fill: IFillType;\n};\n\nexport type ILayout = {\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n distance: number | string;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n outerBorder: Partial<IBorderStyle>;\n innerBorder: Partial<IBorderStyle>;\n strokeOpacity: number;\n lineDash: number[];\n lineDashOffset: number;\n lineWidth: number;\n lineCap: CanvasLineCap;\n lineJoin: CanvasLineJoin;\n miterLimit: number;\n // 描边的boundsBuffer,用于控制bounds的buffer\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n // 连接,取零或者断开\n connectedType: 'connect' | 'zero' | 'none';\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IGraphicStyle = IFillStyle &\n IStrokeStyle & {\n opacity: number;\n backgroundMode: number; // 填充模式(与具体图元有关)\n background: string | HTMLImageElement | HTMLCanvasElement | null; // 背景,可以与fill同时存在\n texture: TextureType | string; // 纹理\n textureColor: string; // 纹理颜色\n textureSize: number; // 纹理大小\n texturePadding: number; // 纹理间隙\n blur: number;\n cursor: Cursor | null; // 鼠标样式\n };\n\nexport type IGraphicAttribute = IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n // 包围盒的padding\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n zIndex: number;\n layout: any;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n};\n\nexport type IGraphicAnimateParams = {\n id?: number | string;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
@@ -26,6 +26,7 @@ export interface IStageParams {
26
26
  canvasControled: boolean;
27
27
  title: string;
28
28
  autoRender: boolean;
29
+ enableLayout: boolean;
29
30
  disableDirtyBounds: boolean;
30
31
  interactiveLayer: boolean;
31
32
  poptip: boolean;
@@ -94,6 +95,7 @@ export interface IStage extends INode {
94
95
  removeLayer: (layerId: number) => ILayer | false;
95
96
  render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;
96
97
  renderNextFrame: (layers?: ILayer[]) => void;
98
+ tryInitInteractiveLayer: () => void;
97
99
  resize: (w: number, h: number, rerender?: boolean) => void;
98
100
  resizeWindow: (w: number, h: number, rerender?: boolean) => void;
99
101
  resizeView: (w: number, h: number, rerender?: boolean) => void;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer } from './layer';\nimport type { IGraphic } from './graphic';\nimport type { IGroup } from './graphic/group';\nimport type { IColor } from './color';\nimport type { IBounds, IBoundsLike, IMatrix, IPointLike } from '@visactor/vutils';\nimport type { ICamera } from './camera';\nimport type { vec3 } from './matrix';\nimport type { IDirectionLight } from './light';\nimport type { ISyncHook } from './sync-hook';\nimport type { IDrawContext, IRenderService } from './render';\nimport type { ITicker } from './animate';\nimport type { IPickerService } from './picker';\nimport type { IPluginService } from './plugin';\nimport type { IWindow } from './window';\nimport type { ILayerService } from './core';\n\nexport type IExportType = 'canvas' | 'imageData';\n\nexport interface IStageParams {\n // x: number;\n // y: number;\n // // 视口的宽高\n // viewWidth: number;\n // viewHeight: number;\n\n // 视口的宽高\n viewBox: IBoundsLike;\n // 总的宽高\n width: number;\n height: number;\n dpr: number;\n // stage的背景\n background: string | IColor;\n // 外部的canvas\n canvas: string | HTMLCanvasElement;\n // canvas的container容器,如果不传入canvas,那就会在容器中创建canvas\n container: string | HTMLElement;\n // 是否是受控制的canvas,如果不是的话,不会进行resize等操作,也不会修改canvas的样式\n canvasControled: boolean;\n title: string;\n autoRender: boolean;\n disableDirtyBounds: boolean;\n // 是否支持interactiveLayer,默认为true\n interactiveLayer: boolean;\n poptip: boolean;\n // 绘制之前的钩子函数\n beforeRender: (stage: IStage) => void;\n // 绘制之后的钩子函数\n afterRender: (stage: IStage) => void;\n renderStyle?: string;\n ticker?: ITicker;\n pluginList?: string[];\n}\n\nexport interface IOption3D {\n enableView3dTransform?: boolean; // 是否开启view3d自动旋转\n alpha?: number; // x轴的转角\n beta?: number; // y轴的转角\n gama?: number; // z轴的转角\n center?: { x?: number; y?: number; z?: number; dx?: number; dy?: number; dz?: number }; // 中心位置\n fieldRatio?: number; // 透视的视域缩放比例\n fieldDepth?: number;\n light?: {\n dir?: vec3;\n color?: string;\n ambient?: number;\n };\n // 配置相机后,alpha、beta、gamma配置会失效\n camera?: any; // 相机配置\n}\n\n// TODO 命名方式\nexport interface IStage extends INode {\n stage?: IStage;\n parent: IStage | null;\n // rootNode: IStage;\n x: number;\n y: number;\n\n window: IWindow;\n\n width: number;\n height: number;\n viewWidth: number;\n viewHeight: number;\n defaultLayer: ILayer;\n dirtyBounds: IBounds | null;\n\n autoRender: boolean;\n renderCount: number;\n\n hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n option3d?: IOption3D;\n\n set3dOptions: (options: IOption3D) => void;\n light?: IDirectionLight;\n camera?: ICamera;\n\n dpr: number;\n\n viewBox: IBoundsLike;\n background: string | IColor;\n ticker: ITicker;\n increaseAutoRender: boolean;\n readonly renderService: IRenderService;\n readonly pickerService: IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer: (canvasId?: string) => ILayer;\n getLayer: (name: string) => ILayer;\n sortLayer: (cb: (layer1: ILayer, layer2: ILayer) => number) => void;\n removeLayer: (layerId: number) => ILayer | false;\n\n render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;\n renderNextFrame: (layers?: ILayer[]) => void;\n\n // 画布操作\n resize: (w: number, h: number, rerender?: boolean) => void;\n resizeWindow: (w: number, h: number, rerender?: boolean) => void;\n resizeView: (w: number, h: number, rerender?: boolean) => void;\n setViewBox:\n | ((viewBox: IBoundsLike, rerender: boolean) => void)\n | ((x: number, y: number, w: number, h: number, rerender: boolean) => void)\n | ((x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean) => void);\n setDpr: (dpr: number) => void;\n setOrigin: (x: number, y: number) => void;\n export: (type: IExportType) => HTMLCanvasElement | ImageData;\n pick: (x: number, y: number) => { graphic: IGraphic | null; group: IGroup | null } | false;\n\n // 动画相关\n startAnimate: (t: number) => void;\n setToFrame: (t: number) => void;\n dirty: (b: IBounds, matrix?: IMatrix) => void;\n // 考虑操作回放\n\n renderTo: (window: IWindow, params: { x: number; y: number; width: number; height: number }) => void;\n\n renderToNewWindow: (fullImage?: boolean) => IWindow;\n\n toCanvas: (fullImage?: boolean) => HTMLCanvasElement | null;\n\n setBeforeRender: (cb: (stage: IStage) => void) => void;\n\n setAfterRender: (cb: (stage: IStage) => void) => void;\n\n afterNextRender: (cb: (stage: IStage) => void) => void;\n enableAutoRender: () => void;\n disableAutoRender: () => void;\n enableIncrementalAutoRender: () => void;\n disableIncrementalAutoRender: () => void;\n enableDirtyBounds: () => void;\n disableDirtyBounds: () => void;\n enableView3dTransform: () => void;\n disableView3dTranform: () => void;\n clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => void;\n\n setCursor: (mode?: string) => void;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
1
+ {"version":3,"sources":["../../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer } from './layer';\nimport type { IGraphic } from './graphic';\nimport type { IGroup } from './graphic/group';\nimport type { IColor } from './color';\nimport type { IBounds, IBoundsLike, IMatrix, IPointLike } from '@visactor/vutils';\nimport type { ICamera } from './camera';\nimport type { vec3 } from './matrix';\nimport type { IDirectionLight } from './light';\nimport type { ISyncHook } from './sync-hook';\nimport type { IDrawContext, IRenderService } from './render';\nimport type { ITicker } from './animate';\nimport type { IPickerService } from './picker';\nimport type { IPluginService } from './plugin';\nimport type { IWindow } from './window';\nimport type { ILayerService } from './core';\n\nexport type IExportType = 'canvas' | 'imageData';\n\nexport interface IStageParams {\n // x: number;\n // y: number;\n // // 视口的宽高\n // viewWidth: number;\n // viewHeight: number;\n\n // 视口的宽高\n viewBox: IBoundsLike;\n // 总的宽高\n width: number;\n height: number;\n dpr: number;\n // stage的背景\n background: string | IColor;\n // 外部的canvas\n canvas: string | HTMLCanvasElement;\n // canvas的container容器,如果不传入canvas,那就会在容器中创建canvas\n container: string | HTMLElement;\n // 是否是受控制的canvas,如果不是的话,不会进行resize等操作,也不会修改canvas的样式\n canvasControled: boolean;\n title: string;\n // 是否开启自动渲染\n autoRender: boolean;\n // 是否开启布局支持\n enableLayout: boolean;\n // 是否关闭脏矩形检测\n disableDirtyBounds: boolean;\n // 是否支持interactiveLayer,默认为true\n interactiveLayer: boolean;\n poptip: boolean;\n // 绘制之前的钩子函数\n beforeRender: (stage: IStage) => void;\n // 绘制之后的钩子函数\n afterRender: (stage: IStage) => void;\n renderStyle?: string;\n ticker?: ITicker;\n pluginList?: string[];\n}\n\nexport interface IOption3D {\n enableView3dTransform?: boolean; // 是否开启view3d自动旋转\n alpha?: number; // x轴的转角\n beta?: number; // y轴的转角\n gama?: number; // z轴的转角\n center?: { x?: number; y?: number; z?: number; dx?: number; dy?: number; dz?: number }; // 中心位置\n fieldRatio?: number; // 透视的视域缩放比例\n fieldDepth?: number;\n light?: {\n dir?: vec3;\n color?: string;\n ambient?: number;\n };\n // 配置相机后,alpha、beta、gamma配置会失效\n camera?: any; // 相机配置\n}\n\n// TODO 命名方式\nexport interface IStage extends INode {\n stage?: IStage;\n parent: IStage | null;\n // rootNode: IStage;\n x: number;\n y: number;\n\n window: IWindow;\n\n width: number;\n height: number;\n viewWidth: number;\n viewHeight: number;\n defaultLayer: ILayer;\n dirtyBounds: IBounds | null;\n\n autoRender: boolean;\n renderCount: number;\n\n hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n option3d?: IOption3D;\n\n set3dOptions: (options: IOption3D) => void;\n light?: IDirectionLight;\n camera?: ICamera;\n\n dpr: number;\n\n viewBox: IBoundsLike;\n background: string | IColor;\n ticker: ITicker;\n increaseAutoRender: boolean;\n readonly renderService: IRenderService;\n readonly pickerService: IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer: (canvasId?: string) => ILayer;\n getLayer: (name: string) => ILayer;\n sortLayer: (cb: (layer1: ILayer, layer2: ILayer) => number) => void;\n removeLayer: (layerId: number) => ILayer | false;\n\n render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;\n renderNextFrame: (layers?: ILayer[]) => void;\n tryInitInteractiveLayer: () => void;\n\n // 画布操作\n resize: (w: number, h: number, rerender?: boolean) => void;\n resizeWindow: (w: number, h: number, rerender?: boolean) => void;\n resizeView: (w: number, h: number, rerender?: boolean) => void;\n setViewBox:\n | ((viewBox: IBoundsLike, rerender: boolean) => void)\n | ((x: number, y: number, w: number, h: number, rerender: boolean) => void)\n | ((x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean) => void);\n setDpr: (dpr: number) => void;\n setOrigin: (x: number, y: number) => void;\n export: (type: IExportType) => HTMLCanvasElement | ImageData;\n pick: (x: number, y: number) => { graphic: IGraphic | null; group: IGroup | null } | false;\n\n // 动画相关\n startAnimate: (t: number) => void;\n setToFrame: (t: number) => void;\n dirty: (b: IBounds, matrix?: IMatrix) => void;\n // 考虑操作回放\n\n renderTo: (window: IWindow, params: { x: number; y: number; width: number; height: number }) => void;\n\n renderToNewWindow: (fullImage?: boolean) => IWindow;\n\n toCanvas: (fullImage?: boolean) => HTMLCanvasElement | null;\n\n setBeforeRender: (cb: (stage: IStage) => void) => void;\n\n setAfterRender: (cb: (stage: IStage) => void) => void;\n\n afterNextRender: (cb: (stage: IStage) => void) => void;\n enableAutoRender: () => void;\n disableAutoRender: () => void;\n enableIncrementalAutoRender: () => void;\n disableIncrementalAutoRender: () => void;\n enableDirtyBounds: () => void;\n disableDirtyBounds: () => void;\n enableView3dTransform: () => void;\n disableView3dTranform: () => void;\n clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => void;\n\n setCursor: (mode?: string) => void;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
@@ -15,10 +15,34 @@ export interface ITextMeasure extends IContribution<IGraphicUtil> {
15
15
  str: string;
16
16
  width: number;
17
17
  };
18
+ clipTextVertical: (verticalList: {
19
+ text: string;
20
+ width?: number;
21
+ direction: number;
22
+ }[], options: TextOptionsType, width: number) => {
23
+ verticalList: {
24
+ text: string;
25
+ width?: number;
26
+ direction: number;
27
+ }[];
28
+ width: number;
29
+ };
18
30
  clipTextWithSuffix: (text: string, options: TextOptionsType, width: number, suffix: string) => {
19
31
  str: string;
20
32
  width: number;
21
33
  };
34
+ clipTextWithSuffixVertical: (verticalList: {
35
+ text: string;
36
+ width?: number;
37
+ direction: number;
38
+ }[], options: TextOptionsType, width: number, suffix: string) => {
39
+ verticalList: {
40
+ text: string;
41
+ width?: number;
42
+ direction: number;
43
+ }[];
44
+ width: number;
45
+ };
22
46
  measureText: (text: string, options: TextOptionsType) => {
23
47
  width: number;
24
48
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/interface/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IContribution } from './contribution';\nimport type { IGraphicUtil } from './core';\n\nexport interface TextOptionsType {\n fontSize?: number;\n fontWeight?: string | number;\n fontFamily?: string;\n fontStyle?: string;\n fontVariant?: string;\n}\n\nexport interface ITextMeasure extends IContribution<IGraphicUtil> {\n measureTextWidth: (text: string, options: TextOptionsType) => number;\n measureTextPixelHeight: (text: string, options: TextOptionsType) => number;\n measureTextBoundHieght: (text: string, options: TextOptionsType) => number;\n clipText: (text: string, options: TextOptionsType, width: number) => { str: string; width: number };\n clipTextWithSuffix: (\n text: string,\n options: TextOptionsType,\n width: number,\n suffix: string\n ) => { str: string; width: number };\n measureText: (text: string, options: TextOptionsType) => { width: number };\n}\n"]}
1
+ {"version":3,"sources":["../../src/interface/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IContribution } from './contribution';\nimport type { IGraphicUtil } from './core';\n\nexport interface TextOptionsType {\n fontSize?: number;\n fontWeight?: string | number;\n fontFamily?: string;\n fontStyle?: string;\n fontVariant?: string;\n}\n\nexport interface ITextMeasure extends IContribution<IGraphicUtil> {\n measureTextWidth: (text: string, options: TextOptionsType) => number;\n measureTextPixelHeight: (text: string, options: TextOptionsType) => number;\n measureTextBoundHieght: (text: string, options: TextOptionsType) => number;\n clipText: (text: string, options: TextOptionsType, width: number) => { str: string; width: number };\n clipTextVertical: (\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number\n ) => { verticalList: { text: string; width?: number; direction: number }[]; width: number };\n clipTextWithSuffix: (\n text: string,\n options: TextOptionsType,\n width: number,\n suffix: string\n ) => { str: string; width: number };\n clipTextWithSuffixVertical: (\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n suffix: string\n ) => { verticalList: { text: string; width?: number; direction: number }[]; width: number };\n measureText: (text: string, options: TextOptionsType) => { width: number };\n}\n"]}
package/es/modules.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { IGlobal, IGraphicService, IPickerService } from './interface';
2
2
  import type { IGraphicUtil, ILayerService, ITransformUtil } from './interface/core';
3
- export declare const vglobal: IGlobal;
3
+ export declare const global: IGlobal;
4
4
  export declare const graphicUtil: IGraphicUtil;
5
5
  export declare const transformUtil: ITransformUtil;
6
6
  export declare const graphicService: IGraphicService;
package/es/modules.js CHANGED
@@ -28,15 +28,15 @@ import { GraphicUtil, TransformUtil } from "./core/constants";
28
28
 
29
29
  import { container } from "./container";
30
30
 
31
- import { VGlobal } from "./constants";
31
+ import { Global } from "./constants";
32
32
 
33
33
  container.load(coreModule), container.load(graphicModule), container.load(renderModule),
34
34
  container.load(pickModule), container.load(pluginModule), loadBuiltinContributions(container),
35
35
  loadRenderContributions(container), loadPickContributions(container), loadCanvasContributions(container);
36
36
 
37
- export const vglobal = container.get(VGlobal);
37
+ export const global = container.get(Global);
38
38
 
39
- application.global = vglobal;
39
+ application.global = global;
40
40
 
41
41
  export const graphicUtil = container.get(GraphicUtil);
42
42
 
package/es/modules.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/modules.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,YAAY,MAAM,yBAAyB,CAAC;AACnD,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAE/C,OAAO,aAAa,MAAM,0CAA0C,CAAC;AACrE,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,wBAAwB,MAAM,8BAA8B,CAAC;AACpE,OAAO,uBAAuB,MAAM,gCAAgC,CAAC;AACrE,OAAO,qBAAqB,MAAM,gCAAgC,CAAC;AACnE,OAAO,uBAAuB,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAA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CAAC,GAAG,CAAiB,mBAAmB,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAgB,YAAY,CAAC,CAAC;AACvE,WAAW,CAAC,YAAY,GAAG,YAAY,CAAC","file":"modules.js","sourcesContent":["import { Container } from 'inversify';\nimport coreModule from './core/core-modules';\nimport renderModule from './render/render-modules';\nimport pickModule from './picker/pick-modules';\n// import allocatorModule from './allocator/allocator-modules';\nimport graphicModule from './graphic/graphic-service/graphic-module';\nimport pluginModule from './plugins/plugin-modules';\nimport loadBuiltinContributions from './core/contributions/modules';\nimport loadRenderContributions from './render/contributions/modules';\nimport loadPickContributions from './picker/contributions/modules';\nimport loadCanvasContributions from './canvas/contributions/modules';\nimport { LayerService } from './core/constants';\n// import { IMat4Allocate, IMatrixAllocate, Mat4Allocate, MatrixAllocate } from './allocator/matrix-allocate';\nimport { GlobalPickerService } from './picker/global-picker-service';\nimport type { IGlobal, IGraphicService, IPickerService } from './interface';\nimport { application } from './application';\nimport type { IGraphicUtil, ILayerService, ITransformUtil } from './interface/core';\nimport { GraphicService } from './graphic/constants';\nimport { GraphicUtil, TransformUtil } from './core/constants';\nimport { container } from './container';\nimport { VGlobal } from './constants';\n\ncontainer.load(coreModule);\ncontainer.load(graphicModule);\ncontainer.load(renderModule);\ncontainer.load(pickModule);\n// container.load(allocatorModule);\ncontainer.load(pluginModule);\nloadBuiltinContributions(container);\nloadRenderContributions(container);\nloadPickContributions(container);\nloadCanvasContributions(container);\n\n// 全局变量\nexport const vglobal = container.get<IGlobal>(VGlobal);\napplication.global = vglobal;\nexport const graphicUtil = container.get<IGraphicUtil>(GraphicUtil);\napplication.graphicUtil = graphicUtil;\nexport const transformUtil = container.get<ITransformUtil>(TransformUtil);\napplication.transformUtil = transformUtil;\nexport const graphicService = container.get<IGraphicService>(GraphicService);\napplication.graphicService = graphicService;\n// export const matrixAllocate = container.get<IMatrixAllocate>(MatrixAllocate);\n// export const mat4Allocate = container.get<IMat4Allocate>(Mat4Allocate);\n// export const canvasAllocate = container.get<ICanvasAllocate>(CanvasAllocate);\n// export const arcAllocate = container.get<IArcAllocate>(ArcAllocate);\n// export const areaAllocate = container.get<IAreaAllocate>(AreaAllocate);\n// export const circleAllocate = container.get<ICircleAllocate>(CircleAllocate);\n// export const lineAllocate = container.get<ILineAllocate>(LineAllocate);\n// export const pathAllocate = container.get<IPathAllocate>(PathAllocate);\n// export const rectAllocate = container.get<IRectAllocate>(RectAllocate);\n// export const symbolAllocate = container.get<ISymbolAllocate>(SymbolAllocate);\n// export const textAllocate = container.get<ITextAllocate>(TextAllocate);\nexport const pickerService = container.get<IPickerService>(GlobalPickerService);\nexport const layerService = container.get<ILayerService>(LayerService);\napplication.layerService = layerService;\n"]}
1
+ {"version":3,"sources":["../../src/modules.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,YAAY,MAAM,yBAAyB,CAAC;AACnD,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAE/C,OAAO,aAAa,MAAM,0CAA0C,CAAC;AACrE,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,wBAAwB,MAAM,8BAA8B,CAAC;AACpE,OAAO,uBAAuB,MAAM,gCAAgC,CAAC;AACrE,OAAO,qBAAqB,MAAM,gCAAgC,CAAC;AACnE,OAAO,uBAAuB,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC3B,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAC9B,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAC7B,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAE3B,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAC7B,wBAAwB,CAAC,SAAS,CAAC,CAAC;AACpC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AACnC,qBAAqB,CAAC,SAAS,CAAC,CAAC;AACjC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAGnC,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAU,MAAM,CAAC,CAAC;AACrD,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAe,WAAW,CAAC,CAAC;AACpE,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,GAAG,CAAiB,aAAa,CAAC,CAAC;AAC1E,WAAW,CAAC,aAAa,GAAG,aAAa,CAAC;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAkB,cAAc,CAAC,CAAC;AAC7E,WAAW,CAAC,cAAc,GAAG,cAAc,CAAC;AAY5C,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,GAAG,CAAiB,mBAAmB,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAgB,YAAY,CAAC,CAAC;AACvE,WAAW,CAAC,YAAY,GAAG,YAAY,CAAC","file":"modules.js","sourcesContent":["import { Container } from 'inversify';\nimport coreModule from './core/core-modules';\nimport renderModule from './render/render-modules';\nimport pickModule from './picker/pick-modules';\n// import allocatorModule from './allocator/allocator-modules';\nimport graphicModule from './graphic/graphic-service/graphic-module';\nimport pluginModule from './plugins/plugin-modules';\nimport loadBuiltinContributions from './core/contributions/modules';\nimport loadRenderContributions from './render/contributions/modules';\nimport loadPickContributions from './picker/contributions/modules';\nimport loadCanvasContributions from './canvas/contributions/modules';\nimport { LayerService } from './core/constants';\n// import { IMat4Allocate, IMatrixAllocate, Mat4Allocate, MatrixAllocate } from './allocator/matrix-allocate';\nimport { GlobalPickerService } from './picker/global-picker-service';\nimport type { IGlobal, IGraphicService, IPickerService } from './interface';\nimport { application } from './application';\nimport type { IGraphicUtil, ILayerService, ITransformUtil } from './interface/core';\nimport { GraphicService } from './graphic/constants';\nimport { GraphicUtil, TransformUtil } from './core/constants';\nimport { container } from './container';\nimport { Global } from './constants';\n\ncontainer.load(coreModule);\ncontainer.load(graphicModule);\ncontainer.load(renderModule);\ncontainer.load(pickModule);\n// container.load(allocatorModule);\ncontainer.load(pluginModule);\nloadBuiltinContributions(container);\nloadRenderContributions(container);\nloadPickContributions(container);\nloadCanvasContributions(container);\n\n// 全局变量\nexport const global = container.get<IGlobal>(Global);\napplication.global = global;\nexport const graphicUtil = container.get<IGraphicUtil>(GraphicUtil);\napplication.graphicUtil = graphicUtil;\nexport const transformUtil = container.get<ITransformUtil>(TransformUtil);\napplication.transformUtil = transformUtil;\nexport const graphicService = container.get<IGraphicService>(GraphicService);\napplication.graphicService = graphicService;\n// export const matrixAllocate = container.get<IMatrixAllocate>(MatrixAllocate);\n// export const mat4Allocate = container.get<IMat4Allocate>(Mat4Allocate);\n// export const canvasAllocate = container.get<ICanvasAllocate>(CanvasAllocate);\n// export const arcAllocate = container.get<IArcAllocate>(ArcAllocate);\n// export const areaAllocate = container.get<IAreaAllocate>(AreaAllocate);\n// export const circleAllocate = container.get<ICircleAllocate>(CircleAllocate);\n// export const lineAllocate = container.get<ILineAllocate>(LineAllocate);\n// export const pathAllocate = container.get<IPathAllocate>(PathAllocate);\n// export const rectAllocate = container.get<IRectAllocate>(RectAllocate);\n// export const symbolAllocate = container.get<ISymbolAllocate>(SymbolAllocate);\n// export const textAllocate = container.get<ITextAllocate>(TextAllocate);\nexport const pickerService = container.get<IPickerService>(GlobalPickerService);\nexport const layerService = container.get<ILayerService>(LayerService);\napplication.layerService = layerService;\n"]}
@@ -24,7 +24,7 @@ import { DrawContribution } from "../render";
24
24
 
25
25
  import { PickItemInterceptor } from "./pick-interceptor";
26
26
 
27
- import { VGlobal } from "../constants";
27
+ import { Global } from "../constants";
28
28
 
29
29
  let DefaultCanvasPickerService = class extends DefaultPickService {
30
30
  constructor(contributions, circlePicker, rectPicker, arcPicker, areaPicker, imagePicker, linePicker, pathPicker, symbolPicker, textPicker, polygonPicker, richtextPicker, drawContribution, global, pickItemInterceptorContributions) {
@@ -67,7 +67,7 @@ let DefaultCanvasPickerService = class extends DefaultPickService {
67
67
  };
68
68
 
69
69
  __decorate([ postConstruct(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], DefaultCanvasPickerService.prototype, "init", null),
70
- DefaultCanvasPickerService = __decorate([ injectable(), __param(0, inject(ContributionProvider)), __param(0, named(CanvasPickerContribution)), __param(1, inject(CanvasCirclePicker)), __param(2, inject(CanvasRectPicker)), __param(3, inject(CanvasArcPicker)), __param(4, inject(CanvasAreaPicker)), __param(5, inject(CanvasImagePicker)), __param(6, inject(CanvasLinePicker)), __param(7, inject(CanvasPathPicker)), __param(8, inject(CanvasSymbolPicker)), __param(9, inject(CanvasTextPicker)), __param(10, inject(CanvasPolygonPicker)), __param(11, inject(CanvasRichTextPicker)), __param(12, inject(DrawContribution)), __param(13, inject(VGlobal)), __param(14, inject(ContributionProvider)), __param(14, named(PickItemInterceptor)), __metadata("design:paramtypes", [ Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object ]) ], DefaultCanvasPickerService);
70
+ DefaultCanvasPickerService = __decorate([ injectable(), __param(0, inject(ContributionProvider)), __param(0, named(CanvasPickerContribution)), __param(1, inject(CanvasCirclePicker)), __param(2, inject(CanvasRectPicker)), __param(3, inject(CanvasArcPicker)), __param(4, inject(CanvasAreaPicker)), __param(5, inject(CanvasImagePicker)), __param(6, inject(CanvasLinePicker)), __param(7, inject(CanvasPathPicker)), __param(8, inject(CanvasSymbolPicker)), __param(9, inject(CanvasTextPicker)), __param(10, inject(CanvasPolygonPicker)), __param(11, inject(CanvasRichTextPicker)), __param(12, inject(DrawContribution)), __param(13, inject(Global)), __param(14, inject(ContributionProvider)), __param(14, named(PickItemInterceptor)), __metadata("design:paramtypes", [ Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object ]) ], DefaultCanvasPickerService);
71
71
 
72
72
  export { DefaultCanvasPickerService };
73
73
  //# sourceMappingURL=canvas-picker-service.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/picker/canvas-picker-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAchE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAKhC,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,kBAAkB;IAO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AAC,MAAM,EAAE;YACX,OAAO,IAAI,CAAC;SACb;QACD,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IAClE,CAAC;CACF,CAAA;AA/CC;IAAC,aAAa,EAAE;;;;sDAMf;AA7CU,0BAA0B;IADtC,UAAU,EAAE;IASR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAE/B,WAAA,MAAM,CAAC,kBAAkB,CAAC,CAAA;IAC1B,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxB,WAAA,MAAM,CAAC,eAAe,CAAC,CAAA;IACvB,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxB,WAAA,MAAM,CAAC,iBAAiB,CAAC,CAAA;IACzB,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxB,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxB,WAAA,MAAM,CAAC,kBAAkB,CAAC,CAAA;IAC1B,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxB,YAAA,MAAM,CAAC,mBAAmB,CAAC,CAAA;IAC3B,YAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAE5B,YAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAExB,YAAA,MAAM,CAAC,OAAO,CAAC,CAAA;IAEf,YAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,YAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GA5BlB,0BAA0B,CAsFtC;SAtFY,0BAA0B","file":"canvas-picker-service.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../common/contribution-provider';\nimport { inject, injectable, named, postConstruct } from 'inversify';\nimport { BrowserCanvas } from '../canvas/contributions/browser';\nimport type {\n ICanvas,\n IContext2d,\n IGraphic,\n EnvType,\n IGlobal,\n IGraphicPicker,\n IPickerService,\n IDrawContribution,\n IContributionProvider,\n IPickItemInterceptorContribution,\n IPickParams\n} from '../interface';\nimport {\n CanvasArcPicker,\n CanvasAreaPicker,\n CanvasCirclePicker,\n CanvasImagePicker,\n CanvasLinePicker,\n CanvasPathPicker,\n CanvasPickerContribution,\n CanvasPolygonPicker,\n CanvasRectPicker,\n CanvasSymbolPicker,\n CanvasTextPicker,\n CanvasRichTextPicker\n} from './contributions/constants';\nimport { DefaultPickService } from './picker-service';\nimport { DrawContribution } from '../render';\nimport { PickItemInterceptor } from './pick-interceptor';\nimport { VGlobal } from '../constants';\n\n// 默认的pick-service,提供基本的最优选中策略,尽量不需要用户自己实现contribution\n// 用户可以写plugin\n@injectable()\nexport class DefaultCanvasPickerService extends DefaultPickService implements IPickerService {\n declare type: 'default';\n // pcik canvas\n declare pickCanvas: ICanvas;\n declare pickContext: IContext2d;\n declare pickerMap: Map<number, IGraphicPicker>;\n\n constructor(\n @inject(ContributionProvider)\n @named(CanvasPickerContribution)\n protected readonly contributions: IContributionProvider<IGraphicPicker>,\n @inject(CanvasCirclePicker) private readonly circlePicker: IGraphicPicker, // 默认的circlePicker\n @inject(CanvasRectPicker) private readonly rectPicker: IGraphicPicker, // 默认的rectPicker\n @inject(CanvasArcPicker) private readonly arcPicker: IGraphicPicker, // 默认的arcPicker\n @inject(CanvasAreaPicker) private readonly areaPicker: IGraphicPicker, // 默认的areaPicker\n @inject(CanvasImagePicker) private readonly imagePicker: IGraphicPicker, // 默认的imagePicker\n @inject(CanvasLinePicker) private readonly linePicker: IGraphicPicker, // 默认的linePicker\n @inject(CanvasPathPicker) private readonly pathPicker: IGraphicPicker, // 默认的pathPicker\n @inject(CanvasSymbolPicker) private readonly symbolPicker: IGraphicPicker, // 默认的symbolPicker\n @inject(CanvasTextPicker) private readonly textPicker: IGraphicPicker, // 默认的textPicker\n @inject(CanvasPolygonPicker) private readonly polygonPicker: IGraphicPicker, // 默认的polygonPicker\n @inject(CanvasRichTextPicker) private readonly richtextPicker: IGraphicPicker, // 默认的richtextPicker\n\n @inject(DrawContribution)\n public readonly drawContribution: IDrawContribution,\n @inject(VGlobal) public readonly global: IGlobal,\n // 拦截器\n @inject(ContributionProvider)\n @named(PickItemInterceptor)\n protected readonly pickItemInterceptorContributions: IContributionProvider<IPickItemInterceptorContribution>\n ) {\n super(global, pickItemInterceptorContributions);\n this.global.hooks.onSetEnv.tap('canvas-picker-service', (_, env, global) => {\n this.configure(global, env);\n });\n this.configure(this.global, this.global.env);\n this.pickerMap = new Map();\n }\n\n @postConstruct()\n init() {\n this.contributions.getContributions().forEach(item => {\n this.pickerMap.set(item.numberType, item);\n });\n super._init();\n }\n\n configure(global: IGlobal, env: EnvType) {\n // if (!this.global.env) return;\n // this.contributions.getContributions().forEach(handlerContribution => {\n // handlerContribution.configure(this, this.global);\n // });\n\n // 创建pick canvas\n const options = {\n width: 100,\n height: 100,\n nativeCanvas: global.createCanvas({ width: 100, height: 100 }),\n id: 'for-pick'\n };\n this.pickCanvas = new BrowserCanvas(options);\n this.pickContext = this.pickCanvas.getContext('2d');\n }\n\n // todo: switch统一改为数字map\n pickItem(graphic: IGraphic, point: IPointLike, params: IPickParams): IGraphic | null {\n if (graphic.attribute.pickable === false) {\n return null;\n }\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.beforePickItem) {\n if (drawContribution.beforePickItem(graphic, this, point, params)) {\n return graphic;\n }\n }\n }\n }\n const picker = this.pickerMap.get(graphic.numberType);\n if (!picker) {\n return null;\n }\n return picker.contains(graphic, point, params) ? graphic : null;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/picker/canvas-picker-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,O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A,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxB,WAAA,MAAM,CAAC,kBAAkB,CAAC,CAAA;IAC1B,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxB,YAAA,MAAM,CAAC,mBAAmB,CAAC,CAAA;IAC3B,YAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAE5B,YAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAExB,YAAA,MAAM,CAAC,MAAM,CAAC,CAAA;IAEd,YAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,YAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GA5BlB,0BAA0B,CAsFtC;SAtFY,0BAA0B","file":"canvas-picker-service.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../common/contribution-provider';\nimport { inject, injectable, named, postConstruct } from 'inversify';\nimport { BrowserCanvas } from '../canvas/contributions/browser';\nimport type {\n ICanvas,\n IContext2d,\n IGraphic,\n EnvType,\n IGlobal,\n IGraphicPicker,\n IPickerService,\n IDrawContribution,\n IContributionProvider,\n IPickItemInterceptorContribution,\n IPickParams\n} from '../interface';\nimport {\n CanvasArcPicker,\n CanvasAreaPicker,\n CanvasCirclePicker,\n CanvasImagePicker,\n CanvasLinePicker,\n CanvasPathPicker,\n CanvasPickerContribution,\n CanvasPolygonPicker,\n CanvasRectPicker,\n CanvasSymbolPicker,\n CanvasTextPicker,\n CanvasRichTextPicker\n} from './contributions/constants';\nimport { DefaultPickService } from './picker-service';\nimport { DrawContribution } from '../render';\nimport { PickItemInterceptor } from './pick-interceptor';\nimport { Global } from '../constants';\n\n// 默认的pick-service,提供基本的最优选中策略,尽量不需要用户自己实现contribution\n// 用户可以写plugin\n@injectable()\nexport class DefaultCanvasPickerService extends DefaultPickService implements IPickerService {\n declare type: 'default';\n // pcik canvas\n declare pickCanvas: ICanvas;\n declare pickContext: IContext2d;\n declare pickerMap: Map<number, IGraphicPicker>;\n\n constructor(\n @inject(ContributionProvider)\n @named(CanvasPickerContribution)\n protected readonly contributions: IContributionProvider<IGraphicPicker>,\n @inject(CanvasCirclePicker) private readonly circlePicker: IGraphicPicker, // 默认的circlePicker\n @inject(CanvasRectPicker) private readonly rectPicker: IGraphicPicker, // 默认的rectPicker\n @inject(CanvasArcPicker) private readonly arcPicker: IGraphicPicker, // 默认的arcPicker\n @inject(CanvasAreaPicker) private readonly areaPicker: IGraphicPicker, // 默认的areaPicker\n @inject(CanvasImagePicker) private readonly imagePicker: IGraphicPicker, // 默认的imagePicker\n @inject(CanvasLinePicker) private readonly linePicker: IGraphicPicker, // 默认的linePicker\n @inject(CanvasPathPicker) private readonly pathPicker: IGraphicPicker, // 默认的pathPicker\n @inject(CanvasSymbolPicker) private readonly symbolPicker: IGraphicPicker, // 默认的symbolPicker\n @inject(CanvasTextPicker) private readonly textPicker: IGraphicPicker, // 默认的textPicker\n @inject(CanvasPolygonPicker) private readonly polygonPicker: IGraphicPicker, // 默认的polygonPicker\n @inject(CanvasRichTextPicker) private readonly richtextPicker: IGraphicPicker, // 默认的richtextPicker\n\n @inject(DrawContribution)\n public readonly drawContribution: IDrawContribution,\n @inject(Global) public readonly global: IGlobal,\n // 拦截器\n @inject(ContributionProvider)\n @named(PickItemInterceptor)\n protected readonly pickItemInterceptorContributions: IContributionProvider<IPickItemInterceptorContribution>\n ) {\n super(global, pickItemInterceptorContributions);\n this.global.hooks.onSetEnv.tap('canvas-picker-service', (_, env, global) => {\n this.configure(global, env);\n });\n this.configure(this.global, this.global.env);\n this.pickerMap = new Map();\n }\n\n @postConstruct()\n init() {\n this.contributions.getContributions().forEach(item => {\n this.pickerMap.set(item.numberType, item);\n });\n super._init();\n }\n\n configure(global: IGlobal, env: EnvType) {\n // if (!this.global.env) return;\n // this.contributions.getContributions().forEach(handlerContribution => {\n // handlerContribution.configure(this, this.global);\n // });\n\n // 创建pick canvas\n const options = {\n width: 100,\n height: 100,\n nativeCanvas: global.createCanvas({ width: 100, height: 100 }),\n id: 'for-pick'\n };\n this.pickCanvas = new BrowserCanvas(options);\n this.pickContext = this.pickCanvas.getContext('2d');\n }\n\n // todo: switch统一改为数字map\n pickItem(graphic: IGraphic, point: IPointLike, params: IPickParams): IGraphic | null {\n if (graphic.attribute.pickable === false) {\n return null;\n }\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.beforePickItem) {\n if (drawContribution.beforePickItem(graphic, this, point, params)) {\n return graphic;\n }\n }\n }\n }\n const picker = this.pickerMap.get(graphic.numberType);\n if (!picker) {\n return null;\n }\n return picker.contains(graphic, point, params) ? graphic : null;\n }\n}\n"]}
@@ -14,7 +14,7 @@ import { Matrix, Point } from "@visactor/vutils";
14
14
 
15
15
  import { inject, injectable } from "inversify";
16
16
 
17
- import { VGlobal } from "../constants";
17
+ import { Global } from "../constants";
18
18
 
19
19
  export const BoundsPicker = Symbol.for("BoundsPicker");
20
20
 
@@ -66,7 +66,7 @@ let DefaultGlobalPickerService = class {
66
66
  }
67
67
  };
68
68
 
69
- DefaultGlobalPickerService = __decorate([ injectable(), __param(0, inject(VGlobal)), __metadata("design:paramtypes", [ Object ]) ], DefaultGlobalPickerService);
69
+ DefaultGlobalPickerService = __decorate([ injectable(), __param(0, inject(Global)), __metadata("design:paramtypes", [ Object ]) ], DefaultGlobalPickerService);
70
70
 
71
71
  export { DefaultGlobalPickerService };
72
72
  //# sourceMappingURL=global-picker-service.js.map