@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
@@ -0,0 +1,887 @@
1
+ import { __decorate, __metadata, __read, __spreadArray } from "tslib";
2
+ import { postConstruct, singleton, GlobalContainer } from 'mana-syringe';
3
+ import { vec3 } from 'gl-matrix';
4
+ import { ElementEvent } from '..';
5
+ import { dirtifyToRoot, Shape, GeometryUpdaterFactory, AABB } from '..';
6
+ import { CSSStyleValue, CSSUnitValue } from './cssom';
7
+ import { CSSKeywordValue } from './cssom';
8
+ import { convertPercentUnit } from './parser';
9
+ import { CSSPropertyLocalPosition, CSSPropertyOpacity, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage, CSSPropertyLineDash, CSSPropertyShadowBlur, CSSPropertyOffsetPath, CSSPropertyOffsetDistance, CSSPropertyAnchor, CSSPropertyZIndex, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyPath, CSSPropertyClipPath, CSSPropertyPoints, CSSPropertyText, CSSPropertyTextTransform } from './properties';
10
+ import { formatAttribute } from '../utils';
11
+ /**
12
+ * Blink used them in code generation(css_properties.json5)
13
+ */
14
+
15
+ export var BUILT_IN_PROPERTIES = [{
16
+ /**
17
+ * used in CSS Layout API
18
+ * eg. `display: 'flex'`
19
+ */
20
+ name: 'display',
21
+ keywords: ['none']
22
+ }, {
23
+ // x in local space
24
+ name: 'x',
25
+ interpolable: true,
26
+ alias: ['cx'],
27
+ defaultValue: '0',
28
+ syntax: '<length> | <percentage>',
29
+ handler: CSSPropertyLocalPosition
30
+ }, {
31
+ // y in local space
32
+ name: 'y',
33
+ interpolable: true,
34
+ alias: ['cy'],
35
+ defaultValue: '0',
36
+ syntax: '<length> | <percentage>',
37
+ handler: CSSPropertyLocalPosition
38
+ }, {
39
+ // z in local space
40
+ name: 'z',
41
+ interpolable: true,
42
+ defaultValue: '0',
43
+ syntax: '<length> | <percentage>',
44
+ handler: CSSPropertyLocalPosition
45
+ }, {
46
+ /**
47
+ * range [0.0, 1.0]
48
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/opacity
49
+ */
50
+ name: 'opacity',
51
+ interpolable: true,
52
+ defaultValue: '1',
53
+ syntax: '<number>',
54
+ handler: CSSPropertyOpacity
55
+ }, {
56
+ /**
57
+ * range [0.0, 1.0]
58
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-opacity
59
+ */
60
+ name: 'fillOpacity',
61
+ interpolable: true,
62
+ inherited: true,
63
+ defaultValue: '1',
64
+ syntax: '<number>',
65
+ handler: CSSPropertyOpacity
66
+ }, {
67
+ /**
68
+ * range [0.0, 1.0]
69
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-opacity
70
+ */
71
+ name: 'strokeOpacity',
72
+ interpolable: true,
73
+ inherited: true,
74
+ defaultValue: '1',
75
+ syntax: '<number>',
76
+ handler: CSSPropertyOpacity
77
+ }, {
78
+ /**
79
+ * background-color is not inheritable
80
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Fills_and_Strokes
81
+ */
82
+ name: 'fill',
83
+ interpolable: true,
84
+ keywords: ['none'],
85
+ defaultValue: 'none',
86
+ syntax: '<paint>',
87
+ handler: CSSPropertyColor
88
+ }, {
89
+ name: 'stroke',
90
+ interpolable: true,
91
+ keywords: ['none'],
92
+ defaultValue: 'none',
93
+ syntax: '<paint>',
94
+ handler: CSSPropertyColor
95
+ }, {
96
+ name: 'shadowColor',
97
+ interpolable: true,
98
+ syntax: '<color>',
99
+ handler: CSSPropertyColor
100
+ }, {
101
+ name: 'shadowOffsetX',
102
+ interpolable: true,
103
+ layoutDependent: true,
104
+ syntax: '<length> | <percentage>',
105
+ handler: CSSPropertyLengthOrPercentage
106
+ }, {
107
+ name: 'shadowOffsetY',
108
+ interpolable: true,
109
+ layoutDependent: true,
110
+ syntax: '<length> | <percentage>',
111
+ handler: CSSPropertyLengthOrPercentage
112
+ }, {
113
+ name: 'shadowBlur',
114
+ interpolable: true,
115
+ layoutDependent: true,
116
+ handler: CSSPropertyShadowBlur
117
+ }, {
118
+ /**
119
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width
120
+ */
121
+ name: 'lineWidth',
122
+ interpolable: true,
123
+ inherited: true,
124
+ defaultValue: '1',
125
+ layoutDependent: true,
126
+ alias: ['strokeWidth'],
127
+ syntax: '<length> | <percentage>',
128
+ handler: CSSPropertyLengthOrPercentage
129
+ }, {
130
+ name: 'lineJoin',
131
+ inherited: true,
132
+ layoutDependent: true,
133
+ alias: ['strokeLinejoin'],
134
+ keywords: ['miter', 'bevel', 'round'],
135
+ defaultValue: 'miter'
136
+ }, {
137
+ name: 'lineCap',
138
+ inherited: true,
139
+ layoutDependent: true,
140
+ alias: ['strokeLinecap'],
141
+ keywords: ['butt', 'round', 'square'],
142
+ defaultValue: 'butt'
143
+ }, {
144
+ name: 'lineDash',
145
+ interpolable: true,
146
+ inherited: true,
147
+ keywords: ['none'],
148
+ alias: ['strokeDasharray'],
149
+ handler: CSSPropertyLineDash
150
+ }, {
151
+ name: 'lineDashOffset',
152
+ interpolable: true,
153
+ inherited: true,
154
+ defaultValue: '0',
155
+ alias: ['strokeDashoffset'],
156
+ handler: CSSPropertyLengthOrPercentage
157
+ }, {
158
+ name: 'offsetPath',
159
+ handler: CSSPropertyOffsetPath
160
+ }, {
161
+ name: 'offsetDistance',
162
+ interpolable: true,
163
+ handler: CSSPropertyOffsetDistance
164
+ }, {
165
+ name: 'dx',
166
+ interpolable: true,
167
+ layoutDependent: true,
168
+ defaultValue: '0',
169
+ handler: CSSPropertyLengthOrPercentage
170
+ }, {
171
+ name: 'dy',
172
+ interpolable: true,
173
+ layoutDependent: true,
174
+ defaultValue: '0',
175
+ handler: CSSPropertyLengthOrPercentage
176
+ }, {
177
+ name: 'zIndex',
178
+ independent: true,
179
+ interpolable: true,
180
+ defaultValue: '0',
181
+ keywords: ['auto'],
182
+ handler: CSSPropertyZIndex
183
+ }, {
184
+ name: 'visibility',
185
+ keywords: ['visible', 'hidden'],
186
+ independent: true,
187
+ inherited: true,
188
+
189
+ /**
190
+ * TODO: support interpolation
191
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/visibility#interpolation
192
+ */
193
+ // interpolable: true,
194
+ defaultValue: 'visible'
195
+ }, {
196
+ name: 'pointerEvents',
197
+ inherited: true,
198
+ keywords: ['none', 'auto', 'stroke', 'fill', 'painted', 'visible', 'visiblestroke', 'visiblefill', 'visiblepainted', 'bounding-box', 'all'],
199
+ defaultValue: 'auto'
200
+ }, {
201
+ name: 'filter',
202
+ independent: true,
203
+ layoutDependent: true,
204
+ handler: CSSPropertyFilter
205
+ }, {
206
+ name: 'clipPath',
207
+ handler: CSSPropertyClipPath
208
+ }, {
209
+ name: 'transform',
210
+ interpolable: true,
211
+ keywords: ['none'],
212
+ defaultValue: 'none',
213
+ handler: CSSPropertyTransform
214
+ }, {
215
+ name: 'transformOrigin',
216
+ parsePriority: 100,
217
+ // interpolable: true,
218
+ defaultValue: 'left top',
219
+ layoutDependent: true,
220
+ handler: CSSPropertyTransformOrigin
221
+ }, {
222
+ name: 'anchor',
223
+ parsePriority: 99,
224
+ layoutDependent: true,
225
+ handler: CSSPropertyAnchor
226
+ }, // {
227
+ // name: 'origin',
228
+ // layoutDependent: true,
229
+ // handler: CSSPropertyAnchor,
230
+ // },
231
+ // Circle
232
+ {
233
+ name: 'r',
234
+ interpolable: true,
235
+ layoutDependent: true,
236
+ defaultValue: '0',
237
+ handler: CSSPropertyLengthOrPercentage
238
+ }, {
239
+ name: 'rx',
240
+ interpolable: true,
241
+ layoutDependent: true,
242
+ defaultValue: 'auto',
243
+ handler: CSSPropertyLengthOrPercentage
244
+ }, {
245
+ name: 'ry',
246
+ interpolable: true,
247
+ layoutDependent: true,
248
+ defaultValue: 'auto',
249
+ handler: CSSPropertyLengthOrPercentage
250
+ }, // Rect Image
251
+ {
252
+ name: 'width',
253
+ interpolable: true,
254
+ layoutDependent: true,
255
+
256
+ /**
257
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/width
258
+ */
259
+ keywords: ['auto', 'fit-content', 'min-content', 'max-content'],
260
+ defaultValue: '0',
261
+ handler: CSSPropertyLengthOrPercentage
262
+ }, {
263
+ name: 'height',
264
+ interpolable: true,
265
+ layoutDependent: true,
266
+
267
+ /**
268
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/height
269
+ */
270
+ keywords: ['auto', 'fit-content', 'min-content', 'max-content'],
271
+ defaultValue: '0',
272
+ handler: CSSPropertyLengthOrPercentage
273
+ }, {
274
+ name: 'radius',
275
+ interpolable: true,
276
+ layoutDependent: true,
277
+ defaultValue: '0',
278
+ handler: CSSPropertyLengthOrPercentage
279
+ }, // Line
280
+ {
281
+ name: 'x1',
282
+ interpolable: true,
283
+ layoutDependent: true,
284
+ handler: CSSPropertyLocalPosition
285
+ }, {
286
+ name: 'y1',
287
+ interpolable: true,
288
+ layoutDependent: true,
289
+ handler: CSSPropertyLocalPosition
290
+ }, {
291
+ name: 'z1',
292
+ interpolable: true,
293
+ layoutDependent: true,
294
+ handler: CSSPropertyLocalPosition
295
+ }, {
296
+ name: 'x2',
297
+ interpolable: true,
298
+ layoutDependent: true,
299
+ handler: CSSPropertyLocalPosition
300
+ }, {
301
+ name: 'y2',
302
+ interpolable: true,
303
+ layoutDependent: true,
304
+ handler: CSSPropertyLocalPosition
305
+ }, {
306
+ name: 'z2',
307
+ interpolable: true,
308
+ layoutDependent: true,
309
+ handler: CSSPropertyLocalPosition
310
+ }, // Path
311
+ {
312
+ name: 'path',
313
+ interpolable: true,
314
+ layoutDependent: true,
315
+ defaultValue: '',
316
+ handler: CSSPropertyPath
317
+ }, // Polyline
318
+ {
319
+ name: 'points',
320
+ layoutDependent: true,
321
+ handler: CSSPropertyPoints
322
+ }, // Text
323
+ {
324
+ name: 'text',
325
+ layoutDependent: true,
326
+ handler: CSSPropertyText,
327
+ defaultValue: ''
328
+ }, {
329
+ name: 'textTransform',
330
+ layoutDependent: true,
331
+ inherited: true,
332
+ keywords: ['capitalize', 'uppercase', 'lowercase', 'none'],
333
+ defaultValue: 'none',
334
+ handler: CSSPropertyTextTransform
335
+ }, {
336
+ name: 'font',
337
+ layoutDependent: true
338
+ }, {
339
+ name: 'fontSize',
340
+ interpolable: true,
341
+ inherited: true,
342
+
343
+ /**
344
+ * @see https://www.w3schools.com/css/css_font_size.asp
345
+ */
346
+ defaultValue: '16px',
347
+ layoutDependent: true,
348
+ handler: CSSPropertyLengthOrPercentage
349
+ }, {
350
+ name: 'fontFamily',
351
+ layoutDependent: true,
352
+ inherited: true,
353
+ defaultValue: 'sans-serif'
354
+ }, {
355
+ name: 'fontStyle',
356
+ layoutDependent: true,
357
+ inherited: true,
358
+ keywords: ['normal', 'italic', 'oblique'],
359
+ defaultValue: 'normal'
360
+ }, {
361
+ name: 'fontWeight',
362
+ layoutDependent: true,
363
+ inherited: true,
364
+ keywords: ['normal', 'bold', 'bolder', 'lighter'],
365
+ defaultValue: 'normal'
366
+ }, {
367
+ name: 'fontVariant',
368
+ layoutDependent: true,
369
+ inherited: true,
370
+ keywords: ['normal', 'small-caps'],
371
+ defaultValue: 'normal'
372
+ }, {
373
+ name: 'lineHeight',
374
+ layoutDependent: true // interpolable: true,
375
+ // inherited: true,
376
+ // defaultValue: '-100%'
377
+
378
+ }, {
379
+ name: 'letterSpacing',
380
+ layoutDependent: true // interpolable: true,
381
+ // inherited: true,
382
+ // defaultValue: '0',
383
+
384
+ }, {
385
+ name: 'wordWrap',
386
+ layoutDependent: true
387
+ }, {
388
+ name: 'wordWrapWidth',
389
+ layoutDependent: true
390
+ }, {
391
+ name: 'leading',
392
+ layoutDependent: true
393
+ }, {
394
+ name: 'textBaseline',
395
+ layoutDependent: true,
396
+ inherited: true,
397
+ keywords: ['top', 'hanging', 'middle', 'alphabetic', 'ideographic', 'bottom'],
398
+ defaultValue: 'alphabetic'
399
+ }, {
400
+ name: 'textAlign',
401
+ layoutDependent: true,
402
+ inherited: true,
403
+ keywords: ['start', 'center', 'end', 'left', 'right'],
404
+ defaultValue: 'start'
405
+ }, {
406
+ name: 'whiteSpace',
407
+ layoutDependent: true
408
+ }];
409
+
410
+ var StyleValueRegistry =
411
+ /** @class */
412
+ function () {
413
+ function StyleValueRegistry() {
414
+ /**
415
+ * need recalc later
416
+ */
417
+ this.dirty = false;
418
+ this.cache = {};
419
+ this.unresolvedProperties = {};
420
+ /**
421
+ * eg.
422
+ *
423
+ * document: {
424
+ * fontSize: [
425
+ *
426
+ * ]
427
+ * }
428
+ */
429
+
430
+ this.cascadeProperties = {};
431
+ } // private boundsChangeListeners: Record<
432
+ // /**
433
+ // * parent's entity
434
+ // */
435
+ // number,
436
+ // Record<
437
+ // /**
438
+ // * child's entity
439
+ // */
440
+ // number,
441
+ // /**
442
+ // * child properties
443
+ // */
444
+ // string[]
445
+ // >
446
+ // > = {};
447
+
448
+
449
+ StyleValueRegistry.prototype.init = function () {
450
+ var _this = this;
451
+
452
+ BUILT_IN_PROPERTIES.forEach(function (property) {
453
+ _this.registerMetadata(property);
454
+ });
455
+ };
456
+
457
+ StyleValueRegistry.prototype.registerMetadata = function (metadata) {
458
+ var _this = this;
459
+
460
+ __spreadArray([metadata.name], __read(metadata.alias || []), false).forEach(function (name) {
461
+ _this.cache[name] = metadata;
462
+ });
463
+ };
464
+
465
+ StyleValueRegistry.prototype.getMetadata = function (name) {
466
+ return this.cache[name];
467
+ };
468
+ /**
469
+ * * parse value, eg.
470
+ * fill: 'red' => CSSRGB
471
+ * translateX: '10px' => CSSUnitValue { unit: 'px', value: 10 }
472
+ * fontSize: '2em' => { unit: 'px', value: 32 }
473
+ *
474
+ * * calculate used value
475
+ * * post process
476
+ */
477
+
478
+
479
+ StyleValueRegistry.prototype.processProperties = function (object, attributes, options) {
480
+ var _this = this;
481
+
482
+ if (options === void 0) {
483
+ options = {
484
+ skipUpdateAttribute: false,
485
+ skipParse: false
486
+ };
487
+ }
488
+
489
+ var skipUpdateAttribute = options.skipUpdateAttribute,
490
+ skipParse = options.skipParse;
491
+ var needUpdateGeometry = false;
492
+ Object.keys(attributes).forEach(function (attributeName) {
493
+ var _a;
494
+
495
+ var _b = __read(formatAttribute(attributeName, attributes[attributeName]), 2),
496
+ name = _b[0],
497
+ value = _b[1];
498
+
499
+ if (!skipUpdateAttribute) {
500
+ object.attributes[name] = value;
501
+ }
502
+
503
+ if (!needUpdateGeometry && ((_a = _this.getMetadata(name)) === null || _a === void 0 ? void 0 : _a.layoutDependent)) {
504
+ needUpdateGeometry = true;
505
+ }
506
+ }); // parse according to priority
507
+
508
+ var sortedNames = Object.keys(attributes).sort(function (a, b) {
509
+ var _a, _b;
510
+
511
+ return (((_a = _this.getMetadata(a)) === null || _a === void 0 ? void 0 : _a.parsePriority) || 0) - (((_b = _this.getMetadata(b)) === null || _b === void 0 ? void 0 : _b.parsePriority) || 0);
512
+ });
513
+
514
+ if (!skipParse) {
515
+ sortedNames.forEach(function (name) {
516
+ object.computedStyle[name] = _this.parseProperty(name, object.attributes[name]);
517
+ });
518
+ }
519
+
520
+ var hasUnresolvedProperties = false;
521
+ sortedNames.forEach(function (name) {
522
+ // some style props maybe deleted after parsing such as `anchor` in Text
523
+ if (name in object.computedStyle) {
524
+ hasUnresolvedProperties = _this.computeProperty(name, object.computedStyle[name], object);
525
+ }
526
+ });
527
+
528
+ if (hasUnresolvedProperties) {
529
+ this.dirty = true;
530
+ return;
531
+ } // update geometry
532
+
533
+
534
+ if (needUpdateGeometry) {
535
+ this.updateGeometry(object);
536
+ }
537
+
538
+ sortedNames.forEach(function (name) {
539
+ if (name in object.parsedStyle) {
540
+ _this.postProcessProperty(name, object);
541
+ }
542
+ });
543
+ sortedNames.forEach(function (name) {
544
+ if (name in object.parsedStyle && _this.isPropertyInheritable(name)) {
545
+ // update children's inheritable
546
+ object.children.forEach(function (child) {
547
+ child.internalSetAttribute(name, null, {
548
+ skipUpdateAttribute: true,
549
+ skipParse: true
550
+ });
551
+ });
552
+ }
553
+ });
554
+ };
555
+ /**
556
+ * string -> parsed value
557
+ */
558
+
559
+
560
+ StyleValueRegistry.prototype.parseProperty = function (name, value) {
561
+ var metadata = this.getMetadata(name);
562
+ var computed = value;
563
+
564
+ if (value === '') {
565
+ value = 'unset';
566
+ }
567
+
568
+ if (value === 'unset' || value === 'initial' || value === 'inherit') {
569
+ computed = new CSSKeywordValue(value);
570
+ } else {
571
+ if (metadata) {
572
+ var keywords = metadata.keywords,
573
+ handler = metadata.handler; // use keywords
574
+
575
+ if (keywords && keywords.indexOf(value) > -1) {
576
+ computed = new CSSKeywordValue(value);
577
+ } else if (handler) {
578
+ // try to parse value with handler
579
+ var propertyHandler = GlobalContainer.get(handler);
580
+
581
+ if (propertyHandler && propertyHandler.parser) {
582
+ // try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
583
+ computed = propertyHandler.parser(value);
584
+ }
585
+ }
586
+ }
587
+ }
588
+
589
+ return computed;
590
+ };
591
+ /**
592
+ * computed value -> used value
593
+ */
594
+
595
+
596
+ StyleValueRegistry.prototype.computeProperty = function (name, computed, object) {
597
+ var metadata = this.getMetadata(name);
598
+ var isDocumentElement = object.id === 'g-root';
599
+ var used = computed instanceof CSSStyleValue ? computed.clone() : computed;
600
+
601
+ if (metadata) {
602
+ var handler = metadata.handler,
603
+ inherited = metadata.inherited,
604
+ defaultValue = metadata.defaultValue;
605
+
606
+ if (computed instanceof CSSKeywordValue) {
607
+ var value = computed.value;
608
+ /**
609
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/unset
610
+ */
611
+
612
+ if (value === 'unset') {
613
+ if (inherited && !isDocumentElement) {
614
+ value = 'inherit';
615
+ } else {
616
+ value = 'initial';
617
+ }
618
+ }
619
+
620
+ if (value === 'initial') {
621
+ // @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
622
+ if (defaultValue) {
623
+ computed = this.parseProperty(name, defaultValue);
624
+ }
625
+ } else if (value === 'inherit') {
626
+ // @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
627
+ // behave like `inherit`
628
+ var resolved = this.tryToResolveProperty(object, name, {
629
+ inherited: true
630
+ });
631
+
632
+ if (resolved) {
633
+ object.parsedStyle[name] = resolved;
634
+ return false;
635
+ } else {
636
+ this.addUnresolveProperty(object, name);
637
+ return true;
638
+ }
639
+ }
640
+ }
641
+
642
+ if (handler) {
643
+ var propertyHandler = GlobalContainer.get(handler); // convert computed value to used value
644
+
645
+ if (propertyHandler && propertyHandler.calculator) {
646
+ var oldParsedValue = object.parsedStyle[name];
647
+ used = propertyHandler.calculator(name, oldParsedValue, computed, object, this);
648
+ } else {
649
+ used = computed;
650
+ }
651
+ } else {
652
+ used = computed;
653
+ }
654
+ }
655
+
656
+ object.parsedStyle[name] = used;
657
+ return false;
658
+ };
659
+
660
+ StyleValueRegistry.prototype.postProcessProperty = function (name, object) {
661
+ var metadata = this.getMetadata(name);
662
+
663
+ if (metadata && metadata.handler) {
664
+ var propertyHandler = GlobalContainer.get(metadata.handler);
665
+
666
+ if (propertyHandler && propertyHandler.postProcessor) {
667
+ propertyHandler.postProcessor(object);
668
+ }
669
+ }
670
+ };
671
+
672
+ StyleValueRegistry.prototype.isPropertyResolved = function (object, name) {
673
+ if (!this.unresolvedProperties[object.entity] || this.unresolvedProperties[object.entity].length === 0) {
674
+ return true;
675
+ }
676
+
677
+ return this.unresolvedProperties[object.entity].includes(name);
678
+ };
679
+ /**
680
+ * resolve later
681
+ */
682
+
683
+
684
+ StyleValueRegistry.prototype.addUnresolveProperty = function (object, name) {
685
+ if (!this.unresolvedProperties[object.entity]) {
686
+ this.unresolvedProperties[object.entity] = [];
687
+ }
688
+
689
+ if (this.unresolvedProperties[object.entity].indexOf(name) === -1) {
690
+ this.unresolvedProperties[object.entity].push(name);
691
+ }
692
+ };
693
+
694
+ StyleValueRegistry.prototype.tryToResolveProperty = function (object, name, options) {
695
+ if (options === void 0) {
696
+ options = {};
697
+ }
698
+
699
+ var inherited = options.inherited;
700
+
701
+ if (inherited) {
702
+ if (object.parentElement && this.isPropertyResolved(object.parentElement, name)) {
703
+ var usedValue = object.parentElement.parsedStyle[name];
704
+
705
+ if (usedValue instanceof CSSKeywordValue && (usedValue.value === 'unset' || usedValue.value === 'initial' || usedValue.value === 'inherit')) {
706
+ return false;
707
+ } else if (usedValue instanceof CSSUnitValue && CSSUnitValue.isRelativeUnit(usedValue.unit)) {
708
+ return false;
709
+ }
710
+
711
+ return usedValue;
712
+ }
713
+ }
714
+
715
+ return false;
716
+ };
717
+
718
+ StyleValueRegistry.prototype.recalc = function (object) {
719
+ var properties = this.unresolvedProperties[object.entity];
720
+
721
+ if (properties && properties.length) {
722
+ var attributes_1 = {};
723
+ properties.forEach(function (property) {
724
+ attributes_1[property] = object.attributes[property];
725
+ });
726
+ this.processProperties(object, attributes_1);
727
+ delete this.unresolvedProperties[object.entity];
728
+ }
729
+ };
730
+ /**
731
+ * update geometry when relative props changed,
732
+ * eg. r of Circle, width/height of Rect
733
+ */
734
+
735
+
736
+ StyleValueRegistry.prototype.updateGeometry = function (object) {
737
+ var _a;
738
+
739
+ var geometryUpdaterFactory = GlobalContainer.get(GeometryUpdaterFactory);
740
+ var geometryUpdater = geometryUpdaterFactory(object.nodeName);
741
+
742
+ if (geometryUpdater) {
743
+ var geometry_1 = object.geometry;
744
+
745
+ if (!geometry_1.contentBounds) {
746
+ geometry_1.contentBounds = new AABB();
747
+ }
748
+
749
+ if (!geometry_1.renderBounds) {
750
+ geometry_1.renderBounds = new AABB();
751
+ }
752
+
753
+ var parsedStyle = object.parsedStyle;
754
+
755
+ var _b = geometryUpdater.update(parsedStyle, object),
756
+ width = _b.width,
757
+ height = _b.height,
758
+ _c = _b.depth,
759
+ depth = _c === void 0 ? 0 : _c,
760
+ _d = _b.x,
761
+ x = _d === void 0 ? 0 : _d,
762
+ _e = _b.y,
763
+ y = _e === void 0 ? 0 : _e,
764
+ // z = 0,
765
+ _f = _b.offsetX,
766
+ // z = 0,
767
+ offsetX = _f === void 0 ? 0 : _f,
768
+ _g = _b.offsetY,
769
+ offsetY = _g === void 0 ? 0 : _g,
770
+ _h = _b.offsetZ,
771
+ offsetZ = _h === void 0 ? 0 : _h;
772
+
773
+ if (object.nodeName === Shape.LINE || object.nodeName === Shape.POLYLINE || object.nodeName === Shape.POLYGON || object.nodeName === Shape.PATH) {
774
+ parsedStyle.offsetX = x - (parsedStyle.defX || 0);
775
+ parsedStyle.offsetY = y - (parsedStyle.defY || 0);
776
+ parsedStyle.defX = x;
777
+ parsedStyle.defY = y; // modify x/y/z
778
+
779
+ object.attributes.x += parsedStyle.offsetX;
780
+ object.attributes.y += parsedStyle.offsetY;
781
+ parsedStyle.x = parsedStyle.x.add(new CSSUnitValue(parsedStyle.offsetX, 'px'));
782
+ parsedStyle.y = parsedStyle.y.add(new CSSUnitValue(parsedStyle.offsetY, 'px'));
783
+ } // init with content box
784
+
785
+
786
+ var halfExtents = vec3.fromValues(width / 2, height / 2, depth / 2); // anchor is center by default, don't account for lineWidth here
787
+
788
+ var _j = parsedStyle,
789
+ lineWidth = _j.lineWidth,
790
+ shadowColor = _j.shadowColor,
791
+ _k = _j.filter,
792
+ filter = _k === void 0 ? [] : _k,
793
+ transformOrigin = _j.transformOrigin;
794
+ var anchor = parsedStyle.anchor; // <Text> use textAlign & textBaseline instead of anchor
795
+
796
+ if (object.nodeName === Shape.TEXT) {
797
+ delete parsedStyle.anchor;
798
+ }
799
+
800
+ var center = vec3.fromValues((1 - (anchor && anchor[0].value || 0) * 2) * halfExtents[0] + offsetX, (1 - (anchor && anchor[1].value || 0) * 2) * halfExtents[1] + offsetY, (1 - (anchor && ((_a = anchor[2]) === null || _a === void 0 ? void 0 : _a.value) || 0) * 2) * halfExtents[2] + offsetZ); // update geometry's AABB
801
+
802
+ geometry_1.contentBounds.update(center, halfExtents);
803
+
804
+ if (lineWidth) {
805
+ // append border
806
+ vec3.add(halfExtents, halfExtents, vec3.fromValues(lineWidth.value / 2, lineWidth.value / 2, 0));
807
+ }
808
+
809
+ geometry_1.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
810
+
811
+ if (shadowColor) {
812
+ var _l = geometry_1.renderBounds,
813
+ min = _l.min,
814
+ max = _l.max;
815
+ var _m = parsedStyle,
816
+ shadowBlur = _m.shadowBlur,
817
+ shadowOffsetX = _m.shadowOffsetX,
818
+ shadowOffsetY = _m.shadowOffsetY;
819
+ var shadowBlurInPixels = shadowBlur && shadowBlur.value || 0;
820
+ var shadowOffsetXInPixels = shadowOffsetX && shadowOffsetX.value || 0;
821
+ var shadowOffsetYInPixels = shadowOffsetY && shadowOffsetY.value || 0;
822
+ var shadowLeft = min[0] - shadowBlurInPixels + shadowOffsetXInPixels;
823
+ var shadowRight = max[0] + shadowBlurInPixels + shadowOffsetXInPixels;
824
+ var shadowTop = min[1] - shadowBlurInPixels + shadowOffsetYInPixels;
825
+ var shadowBottom = max[1] + shadowBlurInPixels + shadowOffsetYInPixels;
826
+ min[0] = Math.min(min[0], shadowLeft);
827
+ max[0] = Math.max(max[0], shadowRight);
828
+ min[1] = Math.min(min[1], shadowTop);
829
+ max[1] = Math.max(max[1], shadowBottom);
830
+ geometry_1.renderBounds.setMinMax(min, max);
831
+ } // account for filter, eg. blur(5px), drop-shadow()
832
+
833
+
834
+ filter.forEach(function (_a) {
835
+ var name = _a.name,
836
+ params = _a.params;
837
+
838
+ if (name === 'blur') {
839
+ var blurRadius = params[0].value;
840
+ geometry_1.renderBounds.update(geometry_1.renderBounds.center, vec3.add(geometry_1.renderBounds.halfExtents, geometry_1.renderBounds.halfExtents, vec3.fromValues(blurRadius, blurRadius, 0)));
841
+ } else if (name === 'drop-shadow') {
842
+ var shadowOffsetX = params[0].value;
843
+ var shadowOffsetY = params[1].value;
844
+ var shadowBlur = params[2].value;
845
+ var _b = geometry_1.renderBounds,
846
+ min = _b.min,
847
+ max = _b.max;
848
+ var shadowLeft = min[0] - shadowBlur + shadowOffsetX;
849
+ var shadowRight = max[0] + shadowBlur + shadowOffsetX;
850
+ var shadowTop = min[1] - shadowBlur + shadowOffsetY;
851
+ var shadowBottom = max[1] + shadowBlur + shadowOffsetY;
852
+ min[0] = Math.min(min[0], shadowLeft);
853
+ max[0] = Math.max(max[0], shadowRight);
854
+ min[1] = Math.min(min[1], shadowTop);
855
+ max[1] = Math.max(max[1], shadowBottom);
856
+ geometry_1.renderBounds.setMinMax(min, max);
857
+ }
858
+ });
859
+ anchor = parsedStyle.anchor; // set transform origin
860
+
861
+ var usedOriginXValue = convertPercentUnit(transformOrigin[0], 0, object);
862
+ var usedOriginYValue = convertPercentUnit(transformOrigin[1], 1, object);
863
+ usedOriginXValue -= (anchor && anchor[0].value || 0) * geometry_1.contentBounds.halfExtents[0] * 2;
864
+ usedOriginYValue -= (anchor && anchor[1].value || 0) * geometry_1.contentBounds.halfExtents[1] * 2;
865
+ object.setOrigin(usedOriginXValue, usedOriginYValue);
866
+ object.emit(ElementEvent.GEOMETRY_BOUNDS_CHANGED, {});
867
+ dirtifyToRoot(object);
868
+ }
869
+ };
870
+
871
+ StyleValueRegistry.prototype.isPropertyInheritable = function (name) {
872
+ var metadata = this.getMetadata(name);
873
+
874
+ if (!metadata) {
875
+ return false;
876
+ }
877
+
878
+ return metadata.inherited;
879
+ };
880
+
881
+ __decorate([postConstruct(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0)], StyleValueRegistry.prototype, "init", null);
882
+
883
+ StyleValueRegistry = __decorate([singleton()], StyleValueRegistry);
884
+ return StyleValueRegistry;
885
+ }();
886
+
887
+ export { StyleValueRegistry };