@antv/g 5.0.18 → 5.0.22-alpha.0

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 (506) hide show
  1. package/dist/index.umd.min.js +16 -17
  2. package/es/Canvas.d.ts +39 -6
  3. package/es/Canvas.js +61 -23
  4. package/es/camera/Camera.d.ts +14 -7
  5. package/es/camera/Camera.js +56 -25
  6. package/es/camera/Landmark.d.ts +2 -0
  7. package/es/camera/Landmark.js +9 -3
  8. package/es/css/CSS.d.ts +84 -0
  9. package/es/css/CSS.js +113 -0
  10. package/es/css/CSSProperty.d.ts +40 -0
  11. package/es/css/CSSProperty.js +1 -0
  12. package/es/css/LayoutRegistry.d.ts +11 -0
  13. package/es/css/LayoutRegistry.js +22 -0
  14. package/es/css/StyleValueRegistry.d.ts +113 -0
  15. package/es/css/StyleValueRegistry.js +887 -0
  16. package/es/css/cssom/CSSColorValue.d.ts +23 -0
  17. package/es/css/cssom/CSSColorValue.js +43 -0
  18. package/es/css/cssom/CSSGradientValue.d.ts +39 -0
  19. package/es/css/cssom/CSSGradientValue.js +54 -0
  20. package/es/css/cssom/CSSImageValue.d.ts +1 -0
  21. package/es/css/cssom/CSSImageValue.js +0 -0
  22. package/es/css/cssom/CSSKeywordValue.d.ts +15 -0
  23. package/es/css/cssom/CSSKeywordValue.js +37 -0
  24. package/es/css/cssom/CSSMathInvert.d.ts +14 -0
  25. package/es/css/cssom/CSSMathInvert.js +84 -0
  26. package/es/css/cssom/CSSMathMax.d.ts +17 -0
  27. package/es/css/cssom/CSSMathMax.js +118 -0
  28. package/es/css/cssom/CSSMathMin.d.ts +17 -0
  29. package/es/css/cssom/CSSMathMin.js +119 -0
  30. package/es/css/cssom/CSSMathNegate.d.ts +14 -0
  31. package/es/css/cssom/CSSMathNegate.js +80 -0
  32. package/es/css/cssom/CSSMathOperator.d.ts +11 -0
  33. package/es/css/cssom/CSSMathOperator.js +32 -0
  34. package/es/css/cssom/CSSMathProduct.d.ts +16 -0
  35. package/es/css/cssom/CSSMathProduct.js +109 -0
  36. package/es/css/cssom/CSSMathSum.d.ts +17 -0
  37. package/es/css/cssom/CSSMathSum.js +117 -0
  38. package/es/css/cssom/CSSMathValue.d.ts +11 -0
  39. package/es/css/cssom/CSSMathValue.js +27 -0
  40. package/es/css/cssom/CSSMathVariadic.d.ts +9 -0
  41. package/es/css/cssom/CSSMathVariadic.js +44 -0
  42. package/es/css/cssom/CSSNumericSumValue.d.ts +7 -0
  43. package/es/css/cssom/CSSNumericSumValue.js +1 -0
  44. package/es/css/cssom/CSSNumericValue.d.ts +75 -0
  45. package/es/css/cssom/CSSNumericValue.js +500 -0
  46. package/es/css/cssom/CSSNumericValueType.d.ts +33 -0
  47. package/es/css/cssom/CSSNumericValueType.js +259 -0
  48. package/es/css/cssom/CSSRGB.d.ts +25 -0
  49. package/es/css/cssom/CSSRGB.js +48 -0
  50. package/es/css/cssom/CSSStyleValue.d.ts +53 -0
  51. package/es/css/cssom/CSSStyleValue.js +625 -0
  52. package/es/css/cssom/CSSTransformComponent.d.ts +22 -0
  53. package/es/css/cssom/CSSTransformComponent.js +32 -0
  54. package/es/css/cssom/CSSTransformValue.d.ts +30 -0
  55. package/es/css/cssom/CSSTransformValue.js +48 -0
  56. package/es/css/cssom/CSSTranslate.d.ts +15 -0
  57. package/es/css/cssom/CSSTranslate.js +44 -0
  58. package/es/css/cssom/CSSUnitValue.d.ts +33 -0
  59. package/es/css/cssom/CSSUnitValue.js +252 -0
  60. package/es/css/cssom/index.d.ts +29 -0
  61. package/es/css/cssom/index.js +29 -0
  62. package/es/css/cssom/types.d.ts +86 -0
  63. package/es/css/cssom/types.js +119 -0
  64. package/es/css/index.d.ts +10 -0
  65. package/es/css/index.js +10 -0
  66. package/es/css/parser/color.d.ts +6 -0
  67. package/es/{property-handlers → css/parser}/color.js +26 -41
  68. package/es/css/parser/dimension.d.ts +36 -0
  69. package/es/css/parser/dimension.js +146 -0
  70. package/es/css/parser/filter.d.ts +7 -0
  71. package/es/{property-handlers → css/parser}/filter.js +0 -0
  72. package/es/css/parser/index.d.ts +15 -0
  73. package/es/css/parser/index.js +15 -0
  74. package/es/css/parser/numeric.d.ts +19 -0
  75. package/es/css/parser/numeric.js +62 -0
  76. package/es/css/parser/path.d.ts +5 -0
  77. package/es/{property-handlers → css/parser}/path.js +4 -4
  78. package/es/{property-handlers → css/parser}/points.d.ts +1 -1
  79. package/es/{property-handlers → css/parser}/points.js +5 -0
  80. package/es/css/parser/transform-origin.d.ts +6 -0
  81. package/es/css/parser/transform-origin.js +45 -0
  82. package/es/css/parser/transform.d.ts +15 -0
  83. package/es/{property-handlers → css/parser}/transform.js +16 -139
  84. package/es/css/parser/types.d.ts +2 -0
  85. package/es/css/parser/types.js +1 -0
  86. package/es/css/properties/CSSPropertyAnchor.d.ts +6 -0
  87. package/es/css/properties/CSSPropertyAnchor.js +24 -0
  88. package/es/{property-handlers/clipPath.d.ts → css/properties/CSSPropertyClipPath.d.ts} +4 -2
  89. package/es/css/properties/CSSPropertyClipPath.js +50 -0
  90. package/es/css/properties/CSSPropertyColor.d.ts +13 -0
  91. package/es/css/properties/CSSPropertyColor.js +30 -0
  92. package/es/css/properties/CSSPropertyFilter.d.ts +5 -0
  93. package/es/css/properties/CSSPropertyFilter.js +16 -0
  94. package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +19 -0
  95. package/es/css/properties/CSSPropertyLengthOrPercentage.js +74 -0
  96. package/es/css/properties/CSSPropertyLineDash.d.ts +7 -0
  97. package/es/css/properties/CSSPropertyLineDash.js +25 -0
  98. package/es/css/properties/CSSPropertyLocalPosition.d.ts +20 -0
  99. package/es/css/properties/CSSPropertyLocalPosition.js +46 -0
  100. package/es/css/properties/CSSPropertyOffsetDistance.d.ts +7 -0
  101. package/es/css/properties/CSSPropertyOffsetDistance.js +33 -0
  102. package/es/css/properties/CSSPropertyOffsetPath.d.ts +4 -0
  103. package/es/css/properties/CSSPropertyOffsetPath.js +31 -0
  104. package/es/css/properties/CSSPropertyOpacity.d.ts +9 -0
  105. package/es/css/properties/CSSPropertyOpacity.js +20 -0
  106. package/es/css/properties/CSSPropertyPath.d.ts +14 -0
  107. package/es/css/properties/CSSPropertyPath.js +51 -0
  108. package/es/css/properties/CSSPropertyPoints.d.ts +17 -0
  109. package/es/css/properties/CSSPropertyPoints.js +28 -0
  110. package/es/css/properties/CSSPropertyShadowBlur.d.ts +4 -0
  111. package/es/css/properties/CSSPropertyShadowBlur.js +22 -0
  112. package/es/css/properties/CSSPropertyText.d.ts +6 -0
  113. package/es/css/properties/CSSPropertyText.js +30 -0
  114. package/es/css/properties/CSSPropertyTextTransform.d.ts +4 -0
  115. package/es/css/properties/CSSPropertyTextTransform.js +29 -0
  116. package/es/{property-handlers/transform.d.ts → css/properties/CSSPropertyTransform.d.ts} +7 -15
  117. package/es/css/properties/CSSPropertyTransform.js +157 -0
  118. package/es/css/properties/CSSPropertyTransformOrigin.d.ts +10 -0
  119. package/es/css/properties/CSSPropertyTransformOrigin.js +21 -0
  120. package/es/css/properties/CSSPropertyVisibility.d.ts +11 -0
  121. package/es/css/properties/CSSPropertyVisibility.js +24 -0
  122. package/es/css/properties/CSSPropertyZIndex.d.ts +6 -0
  123. package/es/css/properties/CSSPropertyZIndex.js +33 -0
  124. package/es/css/properties/index.d.ts +18 -0
  125. package/es/css/properties/index.js +18 -0
  126. package/es/display-objects/Circle.d.ts +3 -4
  127. package/es/display-objects/Circle.js +3 -2
  128. package/es/display-objects/DisplayObject.d.ts +27 -10
  129. package/es/display-objects/DisplayObject.js +131 -149
  130. package/es/display-objects/Ellipse.d.ts +5 -7
  131. package/es/display-objects/Ellipse.js +4 -3
  132. package/es/display-objects/Group.d.ts +14 -11
  133. package/es/display-objects/Group.js +12 -4
  134. package/es/display-objects/HTML.d.ts +3 -3
  135. package/es/display-objects/Image.d.ts +3 -5
  136. package/es/display-objects/Image.js +3 -3
  137. package/es/display-objects/Line.d.ts +7 -6
  138. package/es/display-objects/Line.js +3 -5
  139. package/es/display-objects/Path.d.ts +2 -2
  140. package/es/display-objects/Path.js +1 -3
  141. package/es/display-objects/Polyline.js +1 -3
  142. package/es/display-objects/Rect.d.ts +5 -7
  143. package/es/display-objects/Rect.js +4 -3
  144. package/es/display-objects/Text.d.ts +15 -19
  145. package/es/display-objects/Text.js +13 -14
  146. package/es/dom/AnimationTimeline.d.ts +3 -0
  147. package/es/dom/AnimationTimeline.js +5 -5
  148. package/es/dom/Document.d.ts +12 -0
  149. package/es/dom/Document.js +133 -11
  150. package/es/dom/Element.d.ts +6 -1
  151. package/es/dom/Element.js +13 -3
  152. package/es/dom/FederatedEvent.d.ts +1 -5
  153. package/es/dom/FederatedEvent.js +0 -10
  154. package/es/dom/MutationObserver.d.ts +0 -1
  155. package/es/dom/MutationObserver.js +6 -3
  156. package/es/dom/interfaces.d.ts +14 -2
  157. package/es/dom/interfaces.js +1 -0
  158. package/es/global-module.d.ts +0 -8
  159. package/es/global-module.js +25 -71
  160. package/es/index.d.ts +4 -5
  161. package/es/index.js +9 -10
  162. package/es/plugins/CullingPlugin.js +2 -2
  163. package/es/plugins/DirtyCheckPlugin.d.ts +0 -1
  164. package/es/plugins/DirtyCheckPlugin.js +5 -8
  165. package/es/plugins/EventPlugin.d.ts +1 -0
  166. package/es/plugins/EventPlugin.js +74 -19
  167. package/es/plugins/PrepareRendererPlugin.d.ts +1 -0
  168. package/es/plugins/PrepareRendererPlugin.js +13 -19
  169. package/es/services/EventService.d.ts +1 -0
  170. package/es/services/EventService.js +59 -21
  171. package/es/services/OffscreenCanvasCreator.d.ts +13 -0
  172. package/es/services/{text/OffscreenCanvasCreator.js → OffscreenCanvasCreator.js} +23 -12
  173. package/es/services/RenderingContext.d.ts +2 -1
  174. package/es/services/RenderingContext.js +3 -1
  175. package/es/services/RenderingService.d.ts +35 -2
  176. package/es/services/RenderingService.js +52 -11
  177. package/es/services/SceneGraphSelector.d.ts +3 -1
  178. package/es/services/SceneGraphSelector.js +43 -12
  179. package/es/services/SceneGraphService.d.ts +7 -1
  180. package/es/services/SceneGraphService.js +15 -12
  181. package/es/services/{text/index.d.ts → TextService.d.ts} +5 -4
  182. package/es/services/{text/index.js → TextService.js} +35 -39
  183. package/es/services/aabb/CircleUpdater.js +6 -17
  184. package/es/services/aabb/EllipseUpdater.js +6 -23
  185. package/es/services/aabb/LineUpdater.js +4 -4
  186. package/es/services/aabb/RectUpdater.d.ts +2 -2
  187. package/es/services/aabb/RectUpdater.js +21 -16
  188. package/es/services/aabb/TextUpdater.d.ts +3 -1
  189. package/es/services/aabb/TextUpdater.js +63 -25
  190. package/es/services/aabb/interfaces.d.ts +3 -2
  191. package/es/services/aabb/interfaces.js +3 -2
  192. package/es/services/index.d.ts +2 -2
  193. package/es/services/index.js +2 -2
  194. package/es/shapes/index.d.ts +0 -1
  195. package/es/shapes/index.js +1 -2
  196. package/es/types.d.ts +70 -28
  197. package/es/types.js +2 -1
  198. package/es/utils/animation.js +1 -1
  199. package/es/utils/assert.d.ts +3 -0
  200. package/es/utils/assert.js +15 -0
  201. package/es/utils/custom-easing.d.ts +0 -9
  202. package/es/utils/custom-easing.js +37 -53
  203. package/es/utils/event.d.ts +41 -9
  204. package/es/utils/event.js +2 -65
  205. package/es/utils/index.d.ts +2 -1
  206. package/es/utils/index.js +3 -2
  207. package/es/utils/interpolation.js +39 -37
  208. package/es/utils/math.d.ts +5 -0
  209. package/es/utils/math.js +54 -0
  210. package/es/utils/path.d.ts +1 -1
  211. package/es/utils/path.js +27 -29
  212. package/es/utils/text.js +3 -7
  213. package/lib/Canvas.d.ts +39 -6
  214. package/lib/Canvas.js +64 -27
  215. package/lib/camera/Camera.d.ts +14 -7
  216. package/lib/camera/Camera.js +59 -25
  217. package/lib/camera/Landmark.d.ts +2 -0
  218. package/lib/camera/Landmark.js +9 -3
  219. package/lib/css/CSS.d.ts +84 -0
  220. package/lib/css/CSS.js +125 -0
  221. package/lib/css/CSSProperty.d.ts +40 -0
  222. package/lib/css/CSSProperty.js +5 -0
  223. package/lib/css/LayoutRegistry.d.ts +11 -0
  224. package/lib/css/LayoutRegistry.js +30 -0
  225. package/lib/css/StyleValueRegistry.d.ts +113 -0
  226. package/lib/css/StyleValueRegistry.js +903 -0
  227. package/lib/css/cssom/CSSColorValue.d.ts +23 -0
  228. package/lib/css/cssom/CSSColorValue.js +51 -0
  229. package/lib/css/cssom/CSSGradientValue.d.ts +39 -0
  230. package/lib/css/cssom/CSSGradientValue.js +64 -0
  231. package/lib/css/cssom/CSSImageValue.d.ts +1 -0
  232. package/lib/css/cssom/CSSImageValue.js +1 -0
  233. package/lib/css/cssom/CSSKeywordValue.d.ts +15 -0
  234. package/lib/css/cssom/CSSKeywordValue.js +45 -0
  235. package/lib/css/cssom/CSSMathInvert.d.ts +14 -0
  236. package/lib/css/cssom/CSSMathInvert.js +94 -0
  237. package/lib/css/cssom/CSSMathMax.d.ts +17 -0
  238. package/lib/css/cssom/CSSMathMax.js +128 -0
  239. package/lib/css/cssom/CSSMathMin.d.ts +17 -0
  240. package/lib/css/cssom/CSSMathMin.js +128 -0
  241. package/lib/css/cssom/CSSMathNegate.d.ts +14 -0
  242. package/lib/css/cssom/CSSMathNegate.js +89 -0
  243. package/lib/css/cssom/CSSMathOperator.d.ts +11 -0
  244. package/lib/css/cssom/CSSMathOperator.js +40 -0
  245. package/lib/css/cssom/CSSMathProduct.d.ts +16 -0
  246. package/lib/css/cssom/CSSMathProduct.js +119 -0
  247. package/lib/css/cssom/CSSMathSum.d.ts +17 -0
  248. package/lib/css/cssom/CSSMathSum.js +129 -0
  249. package/lib/css/cssom/CSSMathValue.d.ts +11 -0
  250. package/lib/css/cssom/CSSMathValue.js +35 -0
  251. package/lib/css/cssom/CSSMathVariadic.d.ts +9 -0
  252. package/lib/css/cssom/CSSMathVariadic.js +55 -0
  253. package/lib/css/cssom/CSSNumericSumValue.d.ts +7 -0
  254. package/lib/css/cssom/CSSNumericSumValue.js +5 -0
  255. package/lib/css/cssom/CSSNumericValue.d.ts +75 -0
  256. package/lib/css/cssom/CSSNumericValue.js +511 -0
  257. package/lib/css/cssom/CSSNumericValueType.d.ts +33 -0
  258. package/lib/css/cssom/CSSNumericValueType.js +272 -0
  259. package/lib/css/cssom/CSSRGB.d.ts +25 -0
  260. package/lib/css/cssom/CSSRGB.js +56 -0
  261. package/lib/css/cssom/CSSStyleValue.d.ts +53 -0
  262. package/lib/css/cssom/CSSStyleValue.js +634 -0
  263. package/lib/css/cssom/CSSTransformComponent.d.ts +22 -0
  264. package/lib/css/cssom/CSSTransformComponent.js +39 -0
  265. package/lib/css/cssom/CSSTransformValue.d.ts +30 -0
  266. package/lib/css/cssom/CSSTransformValue.js +56 -0
  267. package/lib/css/cssom/CSSTranslate.d.ts +15 -0
  268. package/lib/css/cssom/CSSTranslate.js +53 -0
  269. package/lib/css/cssom/CSSUnitValue.d.ts +33 -0
  270. package/lib/css/cssom/CSSUnitValue.js +267 -0
  271. package/lib/css/cssom/index.d.ts +29 -0
  272. package/lib/css/cssom/index.js +278 -0
  273. package/lib/css/cssom/types.d.ts +86 -0
  274. package/lib/css/cssom/types.js +130 -0
  275. package/lib/css/index.d.ts +10 -0
  276. package/lib/css/index.js +96 -0
  277. package/lib/css/parser/color.d.ts +6 -0
  278. package/lib/{property-handlers → css/parser}/color.js +25 -42
  279. package/lib/css/parser/dimension.d.ts +36 -0
  280. package/lib/css/parser/dimension.js +173 -0
  281. package/lib/css/parser/filter.d.ts +7 -0
  282. package/lib/{property-handlers → css/parser}/filter.js +0 -0
  283. package/lib/css/parser/index.d.ts +15 -0
  284. package/lib/css/parser/index.js +122 -0
  285. package/lib/css/parser/numeric.d.ts +19 -0
  286. package/lib/css/parser/numeric.js +81 -0
  287. package/lib/css/parser/path.d.ts +5 -0
  288. package/lib/{property-handlers → css/parser}/path.js +4 -4
  289. package/lib/{property-handlers → css/parser}/points.d.ts +1 -1
  290. package/lib/{property-handlers → css/parser}/points.js +6 -0
  291. package/lib/css/parser/transform-origin.d.ts +6 -0
  292. package/lib/css/parser/transform-origin.js +52 -0
  293. package/lib/css/parser/transform.d.ts +15 -0
  294. package/lib/{property-handlers → css/parser}/transform.js +22 -146
  295. package/lib/css/parser/types.d.ts +2 -0
  296. package/lib/css/parser/types.js +5 -0
  297. package/lib/css/properties/CSSPropertyAnchor.d.ts +6 -0
  298. package/lib/css/properties/CSSPropertyAnchor.js +33 -0
  299. package/lib/{property-handlers/clipPath.d.ts → css/properties/CSSPropertyClipPath.d.ts} +4 -2
  300. package/lib/css/properties/CSSPropertyClipPath.js +59 -0
  301. package/lib/css/properties/CSSPropertyColor.d.ts +13 -0
  302. package/lib/css/properties/CSSPropertyColor.js +40 -0
  303. package/lib/css/properties/CSSPropertyFilter.d.ts +5 -0
  304. package/lib/css/properties/CSSPropertyFilter.js +25 -0
  305. package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +19 -0
  306. package/lib/css/properties/CSSPropertyLengthOrPercentage.js +83 -0
  307. package/lib/css/properties/CSSPropertyLineDash.d.ts +7 -0
  308. package/lib/css/properties/CSSPropertyLineDash.js +34 -0
  309. package/lib/css/properties/CSSPropertyLocalPosition.d.ts +20 -0
  310. package/lib/css/properties/CSSPropertyLocalPosition.js +56 -0
  311. package/lib/css/properties/CSSPropertyOffsetDistance.d.ts +7 -0
  312. package/lib/css/properties/CSSPropertyOffsetDistance.js +42 -0
  313. package/lib/css/properties/CSSPropertyOffsetPath.d.ts +4 -0
  314. package/lib/css/properties/CSSPropertyOffsetPath.js +39 -0
  315. package/lib/css/properties/CSSPropertyOpacity.d.ts +9 -0
  316. package/lib/css/properties/CSSPropertyOpacity.js +29 -0
  317. package/lib/css/properties/CSSPropertyPath.d.ts +14 -0
  318. package/lib/css/properties/CSSPropertyPath.js +60 -0
  319. package/lib/css/properties/CSSPropertyPoints.d.ts +17 -0
  320. package/lib/css/properties/CSSPropertyPoints.js +37 -0
  321. package/lib/css/properties/CSSPropertyShadowBlur.d.ts +4 -0
  322. package/lib/css/properties/CSSPropertyShadowBlur.js +32 -0
  323. package/lib/css/properties/CSSPropertyText.d.ts +6 -0
  324. package/lib/css/properties/CSSPropertyText.js +39 -0
  325. package/lib/css/properties/CSSPropertyTextTransform.d.ts +4 -0
  326. package/lib/css/properties/CSSPropertyTextTransform.js +38 -0
  327. package/lib/{property-handlers/transform.d.ts → css/properties/CSSPropertyTransform.d.ts} +7 -15
  328. package/lib/css/properties/CSSPropertyTransform.js +168 -0
  329. package/lib/css/properties/CSSPropertyTransformOrigin.d.ts +10 -0
  330. package/lib/css/properties/CSSPropertyTransformOrigin.js +30 -0
  331. package/lib/css/properties/CSSPropertyVisibility.d.ts +11 -0
  332. package/lib/css/properties/CSSPropertyVisibility.js +32 -0
  333. package/lib/css/properties/CSSPropertyZIndex.d.ts +6 -0
  334. package/lib/css/properties/CSSPropertyZIndex.js +42 -0
  335. package/lib/css/properties/index.d.ts +18 -0
  336. package/lib/css/properties/index.js +239 -0
  337. package/lib/display-objects/Circle.d.ts +3 -4
  338. package/lib/display-objects/Circle.js +3 -2
  339. package/lib/display-objects/DisplayObject.d.ts +27 -10
  340. package/lib/display-objects/DisplayObject.js +132 -148
  341. package/lib/display-objects/Ellipse.d.ts +5 -7
  342. package/lib/display-objects/Ellipse.js +4 -3
  343. package/lib/display-objects/Group.d.ts +14 -11
  344. package/lib/display-objects/Group.js +12 -4
  345. package/lib/display-objects/HTML.d.ts +3 -3
  346. package/lib/display-objects/Image.d.ts +3 -5
  347. package/lib/display-objects/Image.js +3 -3
  348. package/lib/display-objects/Line.d.ts +7 -6
  349. package/lib/display-objects/Line.js +2 -4
  350. package/lib/display-objects/Path.d.ts +2 -2
  351. package/lib/display-objects/Path.js +0 -2
  352. package/lib/display-objects/Polyline.js +0 -2
  353. package/lib/display-objects/Rect.d.ts +5 -7
  354. package/lib/display-objects/Rect.js +4 -3
  355. package/lib/display-objects/Text.d.ts +15 -19
  356. package/lib/display-objects/Text.js +12 -13
  357. package/lib/dom/AnimationTimeline.d.ts +3 -0
  358. package/lib/dom/AnimationTimeline.js +5 -6
  359. package/lib/dom/Document.d.ts +12 -0
  360. package/lib/dom/Document.js +134 -10
  361. package/lib/dom/Element.d.ts +6 -1
  362. package/lib/dom/Element.js +14 -4
  363. package/lib/dom/FederatedEvent.d.ts +1 -5
  364. package/lib/dom/FederatedEvent.js +0 -10
  365. package/lib/dom/MutationObserver.d.ts +0 -1
  366. package/lib/dom/MutationObserver.js +6 -4
  367. package/lib/dom/interfaces.d.ts +14 -2
  368. package/lib/dom/interfaces.js +1 -0
  369. package/lib/global-module.d.ts +0 -8
  370. package/lib/global-module.js +42 -104
  371. package/lib/index.d.ts +4 -5
  372. package/lib/index.js +41 -54
  373. package/lib/plugins/CullingPlugin.js +2 -2
  374. package/lib/plugins/DirtyCheckPlugin.d.ts +0 -1
  375. package/lib/plugins/DirtyCheckPlugin.js +5 -8
  376. package/lib/plugins/EventPlugin.d.ts +1 -0
  377. package/lib/plugins/EventPlugin.js +74 -18
  378. package/lib/plugins/PrepareRendererPlugin.d.ts +1 -0
  379. package/lib/plugins/PrepareRendererPlugin.js +10 -20
  380. package/lib/services/EventService.d.ts +1 -0
  381. package/lib/services/EventService.js +60 -22
  382. package/lib/services/OffscreenCanvasCreator.d.ts +13 -0
  383. package/lib/services/{text/OffscreenCanvasCreator.js → OffscreenCanvasCreator.js} +23 -12
  384. package/lib/services/RenderingContext.d.ts +2 -1
  385. package/lib/services/RenderingContext.js +4 -1
  386. package/lib/services/RenderingService.d.ts +35 -2
  387. package/lib/services/RenderingService.js +52 -12
  388. package/lib/services/SceneGraphSelector.d.ts +3 -1
  389. package/lib/services/SceneGraphSelector.js +45 -15
  390. package/lib/services/SceneGraphService.d.ts +7 -1
  391. package/lib/services/SceneGraphService.js +15 -11
  392. package/lib/services/{text/index.d.ts → TextService.d.ts} +5 -4
  393. package/lib/services/{text/index.js → TextService.js} +36 -41
  394. package/lib/services/aabb/CircleUpdater.js +6 -17
  395. package/lib/services/aabb/EllipseUpdater.js +6 -23
  396. package/lib/services/aabb/LineUpdater.js +4 -4
  397. package/lib/services/aabb/RectUpdater.d.ts +2 -2
  398. package/lib/services/aabb/RectUpdater.js +22 -16
  399. package/lib/services/aabb/TextUpdater.d.ts +3 -1
  400. package/lib/services/aabb/TextUpdater.js +65 -26
  401. package/lib/services/aabb/interfaces.d.ts +3 -2
  402. package/lib/services/aabb/interfaces.js +8 -2
  403. package/lib/services/index.d.ts +2 -2
  404. package/lib/services/index.js +8 -8
  405. package/lib/shapes/index.d.ts +0 -1
  406. package/lib/shapes/index.js +0 -13
  407. package/lib/types.d.ts +70 -28
  408. package/lib/types.js +5 -1
  409. package/lib/utils/animation.js +1 -1
  410. package/lib/utils/assert.d.ts +3 -0
  411. package/lib/utils/assert.js +26 -0
  412. package/lib/utils/custom-easing.d.ts +0 -9
  413. package/lib/utils/custom-easing.js +41 -65
  414. package/lib/utils/event.d.ts +41 -9
  415. package/lib/utils/event.js +2 -76
  416. package/lib/utils/index.d.ts +2 -1
  417. package/lib/utils/index.js +26 -13
  418. package/lib/utils/interpolation.js +35 -30
  419. package/lib/utils/math.d.ts +5 -0
  420. package/lib/utils/math.js +64 -0
  421. package/lib/utils/path.d.ts +1 -1
  422. package/lib/utils/path.js +27 -29
  423. package/lib/utils/text.js +2 -6
  424. package/package.json +3 -4
  425. package/es/property-handlers/aabb.d.ts +0 -2
  426. package/es/property-handlers/aabb.js +0 -134
  427. package/es/property-handlers/anchor.d.ts +0 -4
  428. package/es/property-handlers/anchor.js +0 -21
  429. package/es/property-handlers/clipPath.js +0 -36
  430. package/es/property-handlers/color.d.ts +0 -34
  431. package/es/property-handlers/dimension.d.ts +0 -31
  432. package/es/property-handlers/dimension.js +0 -192
  433. package/es/property-handlers/filter.d.ts +0 -8
  434. package/es/property-handlers/index.d.ts +0 -21
  435. package/es/property-handlers/index.js +0 -21
  436. package/es/property-handlers/inherit.d.ts +0 -6
  437. package/es/property-handlers/inherit.js +0 -25
  438. package/es/property-handlers/interfaces.d.ts +0 -20
  439. package/es/property-handlers/interfaces.js +0 -6
  440. package/es/property-handlers/lineDash.d.ts +0 -6
  441. package/es/property-handlers/lineDash.js +0 -27
  442. package/es/property-handlers/localPosition.d.ts +0 -2
  443. package/es/property-handlers/localPosition.js +0 -11
  444. package/es/property-handlers/numeric.d.ts +0 -5
  445. package/es/property-handlers/numeric.js +0 -34
  446. package/es/property-handlers/offsetDistance.d.ts +0 -5
  447. package/es/property-handlers/offsetDistance.js +0 -20
  448. package/es/property-handlers/offsetPath.d.ts +0 -5
  449. package/es/property-handlers/offsetPath.js +0 -18
  450. package/es/property-handlers/origin.d.ts +0 -11
  451. package/es/property-handlers/origin.js +0 -68
  452. package/es/property-handlers/path.d.ts +0 -4
  453. package/es/property-handlers/text.d.ts +0 -2
  454. package/es/property-handlers/text.js +0 -3
  455. package/es/property-handlers/textTransform.d.ts +0 -6
  456. package/es/property-handlers/textTransform.js +0 -19
  457. package/es/property-handlers/zIndex.d.ts +0 -2
  458. package/es/property-handlers/zIndex.js +0 -16
  459. package/es/services/text/OffscreenCanvasCreator.d.ts +0 -6
  460. package/es/shapes/Polygon.d.ts +0 -9
  461. package/es/shapes/Polygon.js +0 -64
  462. package/es/shapes/Rect.d.ts +0 -12
  463. package/es/shapes/Rect.js +0 -24
  464. package/es/utils/raf.d.ts +0 -6
  465. package/es/utils/raf.js +0 -13
  466. package/lib/property-handlers/aabb.d.ts +0 -2
  467. package/lib/property-handlers/aabb.js +0 -150
  468. package/lib/property-handlers/anchor.d.ts +0 -4
  469. package/lib/property-handlers/anchor.js +0 -34
  470. package/lib/property-handlers/clipPath.js +0 -43
  471. package/lib/property-handlers/color.d.ts +0 -34
  472. package/lib/property-handlers/dimension.d.ts +0 -31
  473. package/lib/property-handlers/dimension.js +0 -217
  474. package/lib/property-handlers/filter.d.ts +0 -8
  475. package/lib/property-handlers/index.d.ts +0 -21
  476. package/lib/property-handlers/index.js +0 -265
  477. package/lib/property-handlers/inherit.d.ts +0 -6
  478. package/lib/property-handlers/inherit.js +0 -34
  479. package/lib/property-handlers/interfaces.d.ts +0 -20
  480. package/lib/property-handlers/interfaces.js +0 -18
  481. package/lib/property-handlers/lineDash.d.ts +0 -6
  482. package/lib/property-handlers/lineDash.js +0 -36
  483. package/lib/property-handlers/localPosition.d.ts +0 -2
  484. package/lib/property-handlers/localPosition.js +0 -18
  485. package/lib/property-handlers/numeric.d.ts +0 -5
  486. package/lib/property-handlers/numeric.js +0 -50
  487. package/lib/property-handlers/offsetDistance.d.ts +0 -5
  488. package/lib/property-handlers/offsetDistance.js +0 -27
  489. package/lib/property-handlers/offsetPath.d.ts +0 -5
  490. package/lib/property-handlers/offsetPath.js +0 -25
  491. package/lib/property-handlers/origin.d.ts +0 -11
  492. package/lib/property-handlers/origin.js +0 -79
  493. package/lib/property-handlers/path.d.ts +0 -4
  494. package/lib/property-handlers/text.d.ts +0 -2
  495. package/lib/property-handlers/text.js +0 -10
  496. package/lib/property-handlers/textTransform.d.ts +0 -6
  497. package/lib/property-handlers/textTransform.js +0 -27
  498. package/lib/property-handlers/zIndex.d.ts +0 -2
  499. package/lib/property-handlers/zIndex.js +0 -23
  500. package/lib/services/text/OffscreenCanvasCreator.d.ts +0 -6
  501. package/lib/shapes/Polygon.d.ts +0 -9
  502. package/lib/shapes/Polygon.js +0 -71
  503. package/lib/shapes/Rect.d.ts +0 -12
  504. package/lib/shapes/Rect.js +0 -31
  505. package/lib/utils/raf.d.ts +0 -6
  506. package/lib/utils/raf.js +0 -26
@@ -11,6 +11,8 @@ var _manaSyringe = require("mana-syringe");
11
11
 
12
12
  var _tapable = require("tapable");
13
13
 
14
+ var _css = require("../css");
15
+
14
16
  var _dom = require("../dom");
15
17
 
16
18
  var _RenderingContext = require("./RenderingContext");
@@ -54,19 +56,51 @@ function () {
54
56
  };
55
57
  this.zIndexCounter = 0;
56
58
  this.hooks = {
59
+ /**
60
+ * called before any frame rendered
61
+ */
57
62
  init: new _tapable.AsyncParallelHook(),
58
- prepare: new _tapable.SyncWaterfallHook(['object']),
63
+
64
+ /**
65
+ * only dirty object which has sth changed will be rendered
66
+ */
67
+ dirtycheck: new _tapable.SyncWaterfallHook(['object']),
68
+
69
+ /**
70
+ * do culling
71
+ */
72
+ cull: new _tapable.SyncWaterfallHook(['object']),
59
73
 
60
74
  /**
61
75
  * called at beginning of each frame, won't get called if nothing to re-render
62
76
  */
63
77
  beginFrame: new _tapable.SyncHook([]),
78
+
79
+ /**
80
+ * called before every dirty object get rendered
81
+ */
64
82
  beforeRender: new _tapable.SyncHook(['objectToRender']),
83
+
84
+ /**
85
+ * called when every dirty object rendering even it's culled
86
+ */
65
87
  render: new _tapable.SyncHook(['objectToRender']),
88
+
89
+ /**
90
+ * called after every dirty object get rendered
91
+ */
66
92
  afterRender: new _tapable.SyncHook(['objectToRender']),
67
93
  endFrame: new _tapable.SyncHook([]),
68
94
  destroy: new _tapable.SyncHook([]),
95
+
96
+ /**
97
+ * use async but faster method such as GPU-based picking in `g-plugin-webgl-renderer`
98
+ */
69
99
  pick: new _tapable.AsyncSeriesWaterfallHook(['result']),
100
+
101
+ /**
102
+ * used in event system
103
+ */
70
104
  pointerDown: new _tapable.SyncHook(['event']),
71
105
  pointerUp: new _tapable.SyncHook(['event']),
72
106
  pointerMove: new _tapable.SyncHook(['event']),
@@ -110,7 +144,6 @@ function () {
110
144
  };
111
145
 
112
146
  RenderingService.prototype.render = function (canvasConfig) {
113
- var renderedOnscreenInLastFrame = this.stats.renderedOnscreen;
114
147
  this.stats.total = 0;
115
148
  this.stats.rendered = 0;
116
149
  this.zIndexCounter = 0;
@@ -135,14 +168,18 @@ function () {
135
168
  };
136
169
 
137
170
  RenderingService.prototype.renderDisplayObject = function (displayObject) {
138
- var _this = this; // render itself
171
+ var _this = this; // recalc style values
139
172
 
140
173
 
141
- var objectToRender = this.hooks.prepare.call(displayObject);
142
- displayObject.sortable.renderOrder = this.zIndexCounter++;
143
- this.stats.total++;
174
+ this.styleValueRegistry.recalc(displayObject); // TODO: relayout
175
+ // dirtycheck first
176
+
177
+ var objectChanged = this.hooks.dirtycheck.call(displayObject);
178
+
179
+ if (objectChanged) {
180
+ // const objectToRender = this.hooks.cull.call(objectChanged);
181
+ this.hooks.cull.call(objectChanged); // if (objectToRender) {
144
182
 
145
- if (objectToRender) {
146
183
  this.stats.rendered++;
147
184
 
148
185
  if (!this.renderingContext.dirty) {
@@ -150,12 +187,14 @@ function () {
150
187
  this.hooks.beginFrame.call();
151
188
  }
152
189
 
153
- this.hooks.beforeRender.call(objectToRender);
154
- this.hooks.render.call(objectToRender);
155
- this.hooks.afterRender.call(objectToRender);
156
- displayObject.renderable.dirty = false;
157
- } // sort is very expensive, use cached result if posible
190
+ this.hooks.beforeRender.call(objectChanged);
191
+ this.hooks.render.call(objectChanged);
192
+ this.hooks.afterRender.call(objectChanged);
193
+ displayObject.renderable.dirty = false; // }
194
+ }
158
195
 
196
+ displayObject.sortable.renderOrder = this.zIndexCounter++;
197
+ this.stats.total++; // sort is very expensive, use cached result if posible
159
198
 
160
199
  var sortable = displayObject.sortable;
161
200
  var renderOrderChanged = false;
@@ -193,6 +232,7 @@ function () {
193
232
  (0, _tslib.__decorate)([(0, _manaSyringe.contrib)(RenderingPluginContribution), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "renderingPluginProvider", void 0);
194
233
  (0, _tslib.__decorate)([(0, _manaSyringe.inject)(_RenderingContext.RenderingContext), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "renderingContext", void 0);
195
234
  (0, _tslib.__decorate)([(0, _manaSyringe.inject)(_SceneGraphService.SceneGraphService), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "sceneGraphService", void 0);
235
+ (0, _tslib.__decorate)([(0, _manaSyringe.inject)(_css.StyleValueRegistry), (0, _tslib.__metadata)("design:type", _css.StyleValueRegistry)], RenderingService.prototype, "styleValueRegistry", void 0);
196
236
  RenderingService = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], RenderingService);
197
237
  return RenderingService;
198
238
  }();
@@ -8,11 +8,13 @@ export interface SceneGraphSelector {
8
8
  is: <T extends IElement>(query: string, element: T) => boolean;
9
9
  }
10
10
  /**
11
- * support following DOM API
11
+ * support the following DOM API:
12
12
  * * getElementById
13
13
  * * getElementsByClassName
14
14
  * * getElementsByName
15
15
  * * getElementsByTag
16
+ * * querySelector
17
+ * * querySelectorAll
16
18
  */
17
19
  export declare class DefaultSceneGraphSelector implements SceneGraphSelector {
18
20
  selectOne<R extends IElement, T extends IElement>(query: string, root: R): T | null;
@@ -16,55 +16,85 @@ exports.SceneGraphSelectorFactory = SceneGraphSelectorFactory;
16
16
  var SceneGraphSelector = _manaSyringe.Syringe.defineToken('SceneGraphSelector', {
17
17
  multiple: false
18
18
  });
19
+
20
+ exports.SceneGraphSelector = SceneGraphSelector;
21
+ var NAME_REGEXP = /\[\s*name=(.*)\s*\]/;
19
22
  /**
20
- * support following DOM API
23
+ * support the following DOM API:
21
24
  * * getElementById
22
25
  * * getElementsByClassName
23
26
  * * getElementsByName
24
27
  * * getElementsByTag
28
+ * * querySelector
29
+ * * querySelectorAll
25
30
  */
26
31
 
27
-
28
- exports.SceneGraphSelector = SceneGraphSelector;
29
-
30
32
  var DefaultSceneGraphSelector =
31
33
  /** @class */
32
34
  function () {
33
35
  function DefaultSceneGraphSelector() {}
34
36
 
35
37
  DefaultSceneGraphSelector.prototype.selectOne = function (query, root) {
36
- if (query.startsWith('#')) {
38
+ if (query.startsWith('.')) {
39
+ return root.find(function (node) {
40
+ // return !node.shadow && node.id === query.substring(1);
41
+ return node.className === query.substring(1);
42
+ });
43
+ } else if (query.startsWith('#')) {
37
44
  // getElementById('id')
38
45
  return root.find(function (node) {
39
46
  // return !node.shadow && node.id === query.substring(1);
40
47
  return node.id === query.substring(1);
41
48
  });
42
- }
49
+ } else if (query.startsWith('[name=')) {
50
+ var matches = query.match(NAME_REGEXP);
43
51
 
44
- return null;
52
+ if (matches && matches.length > 1) {
53
+ var targetName_1 = matches[1].replace(/"/g, ''); // getElementByName();
54
+
55
+ return root.find(function (node) {
56
+ return root !== node && node.name === targetName_1;
57
+ });
58
+ } else {
59
+ return null;
60
+ }
61
+ } else {
62
+ // getElementsByTag('circle');
63
+ return root.find(function (node) {
64
+ return root !== node && node.nodeName === query;
65
+ });
66
+ }
45
67
  };
46
68
 
47
69
  DefaultSceneGraphSelector.prototype.selectAll = function (query, root) {
48
- // TODO: only support `[name="${name}"]` `.className`
70
+ // only support `[name="${name}"]` `.className` `#id`
49
71
  if (query.startsWith('.')) {
50
72
  // getElementsByClassName('className');
51
- // TODO: should include itself?
73
+ // should not include itself
52
74
  return root.findAll(function (node) {
53
- return node.className === query.substring(1);
75
+ return root !== node && node.className === query.substring(1);
54
76
  });
55
77
  } else if (query.startsWith('#')) {
56
78
  return root.findAll(function (node) {
57
- return node.id === query.substring(1);
79
+ return root !== node && node.id === query.substring(1);
58
80
  });
59
81
  } else if (query.startsWith('[name=')) {
60
82
  // getElementsByName();
61
- return root.findAll(function (node) {
62
- return node.name === query.substring(7, query.length - 2);
63
- });
83
+ var matches = query.match(NAME_REGEXP);
84
+
85
+ if (matches && matches.length > 1) {
86
+ var targetName_2 = matches[1].replace(/"/g, ''); // getElementByName();
87
+
88
+ return root.findAll(function (node) {
89
+ return root !== node && node.name === targetName_2;
90
+ });
91
+ } else {
92
+ return [];
93
+ }
64
94
  } else {
65
95
  // getElementsByTag('circle');
66
96
  return root.findAll(function (node) {
67
- return node.nodeName === query;
97
+ return root !== node && node.nodeName === query;
68
98
  });
69
99
  }
70
100
  }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1,3 +1,4 @@
1
+ import { Syringe } from 'mana-syringe';
1
2
  import type { Transform } from '../components';
2
3
  import type { vec2 } from 'gl-matrix';
3
4
  import { mat4, quat, vec3 } from 'gl-matrix';
@@ -5,7 +6,7 @@ import { AABB, Rectangle } from '../shapes';
5
6
  import type { IElement, INode, IParentNode } from '../dom/interfaces';
6
7
  export declare function sortByZIndex(o1: IElement, o2: IElement): number;
7
8
  export declare function dirtifyToRoot(element: INode, affectChildren?: boolean): void;
8
- export declare const SceneGraphService = "SceneGraphService";
9
+ export declare const SceneGraphService: Syringe.DefinedToken;
9
10
  export interface SceneGraphService {
10
11
  matches: <T extends IElement>(query: string, root: T) => boolean;
11
12
  querySelector: <R extends IElement, T extends IElement>(query: string, root: R) => T | null;
@@ -54,6 +55,11 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
54
55
  attach<C extends INode, P extends INode & IParentNode>(child: C, parent: P, index?: number): void;
55
56
  detach<C extends INode>(child: C): void;
56
57
  getOrigin(element: INode): vec3;
58
+ /**
59
+ * same as pivot in Pixi.js
60
+ *
61
+ * @see https://stackoverflow.com/questions/40748452/how-to-change-css-transform-origin-but-preserve-transformation
62
+ */
57
63
  setOrigin(element: INode, origin: vec3 | number, y?: number, z?: number): void;
58
64
  /**
59
65
  * rotate in world space
@@ -64,13 +64,14 @@ function dirtifyToRoot(element, affectChildren) {
64
64
  });
65
65
  }
66
66
 
67
- var SceneGraphService = 'SceneGraphService';
67
+ var SceneGraphService = _manaSyringe.Syringe.defineToken('SceneGraphService');
68
68
  /**
69
69
  * update transform in scene graph
70
70
  *
71
71
  * @see https://community.khronos.org/t/scene-graphs/50542/7
72
72
  */
73
73
 
74
+
74
75
  exports.SceneGraphService = SceneGraphService;
75
76
 
76
77
  var DefaultSceneGraphService =
@@ -246,7 +247,7 @@ function () {
246
247
 
247
248
  return function (element, position) {
248
249
  var transform = element.transformable;
249
- position = _glMatrix.vec3.fromValues(position[0], position[1], position[2] || transform.position[2]);
250
+ position = _glMatrix.vec3.fromValues(position[0], position[1], position[2] || 0);
250
251
 
251
252
  if (_glMatrix.vec3.equals(_this.getPosition(element), position)) {
252
253
  return;
@@ -416,6 +417,12 @@ function () {
416
417
  DefaultSceneGraphService.prototype.getOrigin = function (element) {
417
418
  return element.transformable.origin;
418
419
  };
420
+ /**
421
+ * same as pivot in Pixi.js
422
+ *
423
+ * @see https://stackoverflow.com/questions/40748452/how-to-change-css-transform-origin-but-preserve-transformation
424
+ */
425
+
419
426
 
420
427
  DefaultSceneGraphService.prototype.setOrigin = function (element, origin, y, z) {
421
428
  if (y === void 0) {
@@ -436,7 +443,10 @@ function () {
436
443
  return;
437
444
  }
438
445
 
439
- var originVec = transform.origin;
446
+ var originVec = transform.origin; // const delta = vec3.subtract(vec3.create(), origin, originVec);
447
+ // vec3.add(transform.localPosition, transform.localPosition, delta);
448
+ // update origin
449
+
440
450
  originVec[0] = origin[0];
441
451
  originVec[1] = origin[1];
442
452
  originVec[2] = origin[2] || 0;
@@ -473,7 +483,7 @@ function () {
473
483
 
474
484
  DefaultSceneGraphService.prototype.setLocalPosition = function (element, position) {
475
485
  var transform = element.transformable;
476
- position = _glMatrix.vec3.fromValues(position[0], position[1], position[2] || transform.localPosition[2]);
486
+ position = _glMatrix.vec3.fromValues(position[0], position[1], position[2] || 0);
477
487
 
478
488
  if (_glMatrix.vec3.equals(transform.localPosition, position)) {
479
489
  return;
@@ -780,13 +790,7 @@ function () {
780
790
  renderable.renderBoundsDirty = true;
781
791
  renderable.boundsDirty = true;
782
792
  renderable.dirty = true;
783
- } // model matrix changed
784
- // element.emit(ElementEvent.ATTR_MODIFIED, {
785
- // attributeName: 'modelMatrix',
786
- // oldValue: null,
787
- // newValue: null,
788
- // });
789
-
793
+ }
790
794
 
791
795
  element.dispatchEvent(new _MutationEvent.MutationEvent(_interfaces.ElementEvent.ATTR_MODIFIED, element, null, null, 'modelMatrix', _MutationEvent.MutationEvent.MODIFICATION, null, null));
792
796
  }
@@ -1,5 +1,6 @@
1
- import type { ParsedTextStyleProps } from '../../display-objects/Text';
2
- import { Rectangle } from '../../shapes';
1
+ /// <reference types="offscreencanvas" />
2
+ import type { ParsedTextStyleProps } from '..';
3
+ import { Rectangle } from '..';
3
4
  export interface TextMetrics {
4
5
  font: string;
5
6
  width: number;
@@ -19,8 +20,8 @@ interface IFontMetrics {
19
20
  export declare class TextService {
20
21
  private cache;
21
22
  private offscreenCanvas;
22
- measureFont(font: string): IFontMetrics;
23
- measureText(text: string, attributes: ParsedTextStyleProps): TextMetrics;
23
+ measureFont(font: string, offscreenCanvas: HTMLCanvasElement | OffscreenCanvas): IFontMetrics;
24
+ measureText(text: string, parsedStyle: ParsedTextStyleProps, offscreenCanvas: HTMLCanvasElement | OffscreenCanvas): TextMetrics;
24
25
  private wordWrap;
25
26
  private isBreakingSpace;
26
27
  private isNewline;
@@ -9,9 +9,7 @@ var _tslib = require("tslib");
9
9
 
10
10
  var _manaSyringe = require("mana-syringe");
11
11
 
12
- var _shapes = require("../../shapes");
13
-
14
- var _text = require("../../utils/text");
12
+ var _ = require("..");
15
13
 
16
14
  var _OffscreenCanvasCreator = require("./OffscreenCanvasCreator");
17
15
 
@@ -75,7 +73,7 @@ function () {
75
73
  };
76
74
  }
77
75
 
78
- TextService.prototype.measureFont = function (font) {
76
+ TextService.prototype.measureFont = function (font, offscreenCanvas) {
79
77
  // as this method is used for preparing assets, don't recalculate things if we don't need to
80
78
  if (this.cache[font]) {
81
79
  return this.cache[font];
@@ -86,8 +84,8 @@ function () {
86
84
  descent: 0,
87
85
  fontSize: 0
88
86
  };
89
- var canvas = this.offscreenCanvas.getOrCreateCanvas();
90
- var context = this.offscreenCanvas.getOrCreateContext();
87
+ var canvas = this.offscreenCanvas.getOrCreateCanvas(offscreenCanvas);
88
+ var context = this.offscreenCanvas.getOrCreateContext(offscreenCanvas);
91
89
  context.font = font;
92
90
  var metricsString = TEXT_METRICS.MetricsString + TEXT_METRICS.BaselineSymbol;
93
91
  var width = Math.ceil(context.measureText(metricsString).width);
@@ -151,23 +149,24 @@ function () {
151
149
  return properties;
152
150
  };
153
151
 
154
- TextService.prototype.measureText = function (text, attributes) {
155
- var fontSize = attributes.fontSize,
156
- wordWrap = attributes.wordWrap,
157
- _a = attributes.lineHeight,
152
+ TextService.prototype.measureText = function (text, parsedStyle, offscreenCanvas) {
153
+ var fontSize = parsedStyle.fontSize,
154
+ wordWrap = parsedStyle.wordWrap,
155
+ _a = parsedStyle.lineHeight,
158
156
  strokeHeight = _a === void 0 ? 0 : _a,
159
- lineWidth = attributes.lineWidth,
160
- textBaseline = attributes.textBaseline,
161
- textAlign = attributes.textAlign,
162
- _b = attributes.letterSpacing,
157
+ lineWidth = parsedStyle.lineWidth,
158
+ textBaseline = parsedStyle.textBaseline,
159
+ textAlign = parsedStyle.textAlign,
160
+ _b = parsedStyle.letterSpacing,
163
161
  letterSpacing = _b === void 0 ? 0 : _b,
164
- dropShadow = attributes.dropShadow,
165
- _c = attributes.dropShadowDistance,
166
- dropShadowDistance = _c === void 0 ? 0 : _c,
167
- _d = attributes.leading,
168
- leading = _d === void 0 ? 0 : _d;
169
- var font = (0, _text.toFontString)(attributes);
170
- var fontProperties = this.measureFont(font); // fallback in case UA disallow canvas data extraction
162
+ // dropShadow = 0,
163
+ // dropShadowDistance = 0,
164
+ _c = parsedStyle.leading,
165
+ // dropShadow = 0,
166
+ // dropShadowDistance = 0,
167
+ leading = _c === void 0 ? 0 : _c;
168
+ var font = (0, _.toFontString)(parsedStyle);
169
+ var fontProperties = this.measureFont(font, offscreenCanvas); // fallback in case UA disallow canvas data extraction
171
170
  // (toDataURI, getImageData functions)
172
171
 
173
172
  if (fontProperties.fontSize === 0) {
@@ -175,9 +174,9 @@ function () {
175
174
  fontProperties.ascent = fontSize.value;
176
175
  }
177
176
 
178
- var context = this.offscreenCanvas.getOrCreateContext();
177
+ var context = this.offscreenCanvas.getOrCreateContext(offscreenCanvas);
179
178
  context.font = font;
180
- var outputText = wordWrap ? this.wordWrap(text, attributes) : text;
179
+ var outputText = wordWrap ? this.wordWrap(text, parsedStyle, offscreenCanvas) : text;
181
180
  var lines = outputText.split(/(?:\r\n|\r|\n)/);
182
181
  var lineWidths = new Array(lines.length);
183
182
  var maxLineWidth = 0;
@@ -188,28 +187,24 @@ function () {
188
187
  maxLineWidth = Math.max(maxLineWidth, lineWidth_1);
189
188
  }
190
189
 
191
- var width = maxLineWidth + lineWidth.value;
192
-
193
- if (dropShadow) {
194
- width += dropShadowDistance;
195
- }
190
+ var width = maxLineWidth + lineWidth.value; // if (dropShadow) {
191
+ // width += dropShadowDistance;
192
+ // }
196
193
 
197
194
  var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth.value;
198
- var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth.value) + (lines.length - 1) * (lineHeight + leading);
199
-
200
- if (dropShadow) {
201
- height += dropShadowDistance;
202
- }
195
+ var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth.value) + (lines.length - 1) * (lineHeight + leading); // if (dropShadow) {
196
+ // height += dropShadowDistance;
197
+ // }
203
198
 
204
199
  lineHeight += leading; // handle vertical text baseline
205
200
 
206
201
  var offsetY = 0;
207
202
 
208
- if (textBaseline === 'middle') {
203
+ if (textBaseline.value === 'middle') {
209
204
  offsetY = -height / 2;
210
- } else if (textBaseline === 'bottom' || textBaseline === 'alphabetic' || textBaseline === 'ideographic') {
205
+ } else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
211
206
  offsetY = -height;
212
- } else if (textBaseline === 'top' || textBaseline === 'hanging') {
207
+ } else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
213
208
  offsetY = 0;
214
209
  }
215
210
 
@@ -225,25 +220,25 @@ function () {
225
220
  lineMetrics: lineWidths.map(function (width, i) {
226
221
  var offsetX = 0; // handle horizontal text align
227
222
 
228
- if (textAlign === 'center') {
223
+ if (textAlign.value === 'center') {
229
224
  offsetX -= width / 2;
230
- } else if (textAlign === 'right' || textAlign === 'end') {
225
+ } else if (textAlign.value === 'right' || textAlign.value === 'end') {
231
226
  offsetX -= width;
232
227
  }
233
228
 
234
- return new _shapes.Rectangle(offsetX - lineWidth.value / 2, offsetY + i * lineHeight, width + lineWidth.value, lineHeight);
229
+ return new _.Rectangle(offsetX - lineWidth.value / 2, offsetY + i * lineHeight, width + lineWidth.value, lineHeight);
235
230
  })
236
231
  };
237
232
  };
238
233
 
239
- TextService.prototype.wordWrap = function (text, _a) {
234
+ TextService.prototype.wordWrap = function (text, _a, offscreenCanvas) {
240
235
  var _this = this;
241
236
 
242
237
  var _b = _a.wordWrapWidth,
243
238
  wordWrapWidth = _b === void 0 ? 0 : _b,
244
239
  _c = _a.letterSpacing,
245
240
  letterSpacing = _c === void 0 ? 0 : _c;
246
- var context = this.offscreenCanvas.getOrCreateContext();
241
+ var context = this.offscreenCanvas.getOrCreateContext(offscreenCanvas);
247
242
  var maxWidth = wordWrapWidth + letterSpacing;
248
243
  var lines = [];
249
244
  var currentIndex = 0;
@@ -20,26 +20,15 @@ function () {
20
20
 
21
21
  CircleUpdater.prototype.update = function (parsedStyle, object) {
22
22
  var r = parsedStyle.r,
23
- _a = parsedStyle.x,
24
- x = _a === void 0 ? 0 : _a,
25
- _b = parsedStyle.y,
26
- y = _b === void 0 ? 0 : _b;
27
- var unit = r.unit,
28
- value = r.value;
29
- var width = 0;
30
- var height = 0; // absolute unit
31
-
32
- if (unit === '' || unit === 'px') {
33
- width = value * 2;
34
- height = value * 2;
35
- }
36
-
37
- object.parsedStyle.rInPixels = width / 2;
23
+ x = parsedStyle.x,
24
+ y = parsedStyle.y;
25
+ var width = r.value * 2;
26
+ var height = r.value * 2;
38
27
  return {
39
28
  width: width,
40
29
  height: height,
41
- x: x,
42
- y: y
30
+ x: x.value || 0,
31
+ y: y.value || 0
43
32
  };
44
33
  };
45
34
 
@@ -21,32 +21,15 @@ function () {
21
21
  EllipseUpdater.prototype.update = function (parsedStyle, object) {
22
22
  var rx = parsedStyle.rx,
23
23
  ry = parsedStyle.ry,
24
- _a = parsedStyle.x,
25
- x = _a === void 0 ? 0 : _a,
26
- _b = parsedStyle.y,
27
- y = _b === void 0 ? 0 : _b;
28
- var rxUnit = rx.unit,
29
- rxValue = rx.value;
30
- var ryUnit = ry.unit,
31
- ryValue = ry.value;
32
- var width = 0;
33
- var height = 0;
34
-
35
- if (rxUnit === '' || rxUnit === 'px') {
36
- width = rxValue * 2;
37
- }
38
-
39
- if (ryUnit === '' || ryUnit === 'px') {
40
- height = ryValue * 2;
41
- }
42
-
43
- object.parsedStyle.rxInPixels = width / 2;
44
- object.parsedStyle.ryInPixels = height / 2;
24
+ x = parsedStyle.x,
25
+ y = parsedStyle.y;
26
+ var width = rx.value * 2;
27
+ var height = ry.value * 2;
45
28
  return {
46
29
  width: width,
47
30
  height: height,
48
- x: x,
49
- y: y
31
+ x: x.value || 0,
32
+ y: y.value || 0
50
33
  };
51
34
  };
52
35
 
@@ -23,10 +23,10 @@ function () {
23
23
  y1 = parsedStyle.y1,
24
24
  x2 = parsedStyle.x2,
25
25
  y2 = parsedStyle.y2;
26
- var minX = Math.min(x1, x2);
27
- var maxX = Math.max(x1, x2);
28
- var minY = Math.min(y1, y2);
29
- var maxY = Math.max(y1, y2);
26
+ var minX = Math.min(x1.value, x2.value);
27
+ var maxX = Math.max(x1.value, x2.value);
28
+ var minY = Math.min(y1.value, y2.value);
29
+ var maxY = Math.max(y1.value, y2.value);
30
30
  var width = maxX - minX;
31
31
  var height = maxY - minY;
32
32
  return {
@@ -1,7 +1,7 @@
1
1
  import { GeometryAABBUpdater } from './interfaces';
2
- import type { Image, ParsedImageStyleProps } from '../../display-objects/Image';
2
+ import type { Image, Rect, Group, ParsedImageStyleProps } from '../../display-objects';
3
3
  export declare class RectUpdater implements GeometryAABBUpdater<ParsedImageStyleProps> {
4
- update(parsedStyle: ParsedImageStyleProps, object: Image): {
4
+ update(parsedStyle: ParsedImageStyleProps, object: Image | Rect | Group): {
5
5
  width: number;
6
6
  height: number;
7
7
  x: number;