react-native-wagmi-charts 2.3.0 → 2.4.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 (391) hide show
  1. package/.DS_Store +0 -0
  2. package/.editorconfig +15 -0
  3. package/.gitattributes +3 -0
  4. package/.gitignore +60 -0
  5. package/.husky/pre-commit +4 -0
  6. package/.prettierrc.js +5 -0
  7. package/.yarnrc +3 -0
  8. package/README.md +25 -24
  9. package/babel.config.js +3 -0
  10. package/example/.expo/README.md +8 -0
  11. package/example/.expo/devices.json +3 -0
  12. package/example/README.md +32 -0
  13. package/example/app.json +22 -0
  14. package/example/babel.config.js +23 -0
  15. package/example/index.js +8 -0
  16. package/example/metro.config.js +40 -0
  17. package/example/package.json +42 -0
  18. package/example/src/App.tsx +64 -0
  19. package/example/src/CandlestickChart.tsx +155 -0
  20. package/example/src/LineChart.tsx +267 -0
  21. package/example/src/data/candlestick-data.json +142 -0
  22. package/example/src/data/candlestick-data2.json +142 -0
  23. package/example/src/data/line-data-non-linear-domain.json +34 -0
  24. package/example/src/data/line-data.json +82 -0
  25. package/example/src/data/line-data2.json +82 -0
  26. package/example/src/line-data-gh.json +18 -0
  27. package/example/tsconfig.json +6 -0
  28. package/example/webpack.config.js +25 -0
  29. package/example/yarn.lock +9306 -0
  30. package/lib/commonjs/charts/candle/Candle.js +6 -19
  31. package/lib/commonjs/charts/candle/Candle.js.map +1 -1
  32. package/lib/commonjs/charts/candle/Candles.js +6 -13
  33. package/lib/commonjs/charts/candle/Candles.js.map +1 -1
  34. package/lib/commonjs/charts/candle/Chart.js +3 -12
  35. package/lib/commonjs/charts/candle/Chart.js.map +1 -1
  36. package/lib/commonjs/charts/candle/Context.js +4 -12
  37. package/lib/commonjs/charts/candle/Context.js.map +1 -1
  38. package/lib/commonjs/charts/candle/Crosshair.js +3 -18
  39. package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
  40. package/lib/commonjs/charts/candle/CrosshairTooltip.js +6 -21
  41. package/lib/commonjs/charts/candle/CrosshairTooltip.js.map +1 -1
  42. package/lib/commonjs/charts/candle/DatetimeText.js +2 -8
  43. package/lib/commonjs/charts/candle/DatetimeText.js.map +1 -1
  44. package/lib/commonjs/charts/candle/HoverTrap/index.web.js +11 -25
  45. package/lib/commonjs/charts/candle/HoverTrap/index.web.js.map +1 -1
  46. package/lib/commonjs/charts/candle/Line.js +3 -12
  47. package/lib/commonjs/charts/candle/Line.js.map +1 -1
  48. package/lib/commonjs/charts/candle/PriceText.js +2 -8
  49. package/lib/commonjs/charts/candle/PriceText.js.map +1 -1
  50. package/lib/commonjs/charts/candle/index.js +1 -32
  51. package/lib/commonjs/charts/candle/index.js.map +1 -1
  52. package/lib/commonjs/charts/candle/types.js.map +1 -1
  53. package/lib/commonjs/charts/candle/useCandleData.js +0 -4
  54. package/lib/commonjs/charts/candle/useCandleData.js.map +1 -1
  55. package/lib/commonjs/charts/candle/useCandlestickChart.js +2 -7
  56. package/lib/commonjs/charts/candle/useCandlestickChart.js.map +1 -1
  57. package/lib/commonjs/charts/candle/useDatetime.js +0 -4
  58. package/lib/commonjs/charts/candle/useDatetime.js.map +1 -1
  59. package/lib/commonjs/charts/candle/usePrice.js +0 -8
  60. package/lib/commonjs/charts/candle/usePrice.js.map +1 -1
  61. package/lib/commonjs/charts/candle/utils/getDomain.js +0 -1
  62. package/lib/commonjs/charts/candle/utils/getDomain.js.map +1 -1
  63. package/lib/commonjs/charts/candle/utils/getHeight.js +0 -2
  64. package/lib/commonjs/charts/candle/utils/getHeight.js.map +1 -1
  65. package/lib/commonjs/charts/candle/utils/getPrice.js +0 -2
  66. package/lib/commonjs/charts/candle/utils/getPrice.js.map +1 -1
  67. package/lib/commonjs/charts/candle/utils/getY.js +0 -2
  68. package/lib/commonjs/charts/candle/utils/getY.js.map +1 -1
  69. package/lib/commonjs/charts/candle/utils/index.js +0 -8
  70. package/lib/commonjs/charts/candle/utils/index.js.map +1 -1
  71. package/lib/commonjs/charts/candle/utils.js +1 -6
  72. package/lib/commonjs/charts/candle/utils.js.map +1 -1
  73. package/lib/commonjs/charts/line/Chart.js +9 -28
  74. package/lib/commonjs/charts/line/Chart.js.map +1 -1
  75. package/lib/commonjs/charts/line/ChartPath.js +23 -46
  76. package/lib/commonjs/charts/line/ChartPath.js.map +1 -1
  77. package/lib/commonjs/charts/line/Context.js +8 -19
  78. package/lib/commonjs/charts/line/Context.js.map +1 -1
  79. package/lib/commonjs/charts/line/Cursor.js +41 -66
  80. package/lib/commonjs/charts/line/Cursor.js.map +1 -1
  81. package/lib/commonjs/charts/line/CursorCrosshair.js +5 -14
  82. package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
  83. package/lib/commonjs/charts/line/CursorLine.js +5 -19
  84. package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
  85. package/lib/commonjs/charts/line/Data.js +5 -17
  86. package/lib/commonjs/charts/line/Data.js.map +1 -1
  87. package/lib/commonjs/charts/line/DatetimeText.js +2 -9
  88. package/lib/commonjs/charts/line/DatetimeText.js.map +1 -1
  89. package/lib/commonjs/charts/line/Dot.js +27 -33
  90. package/lib/commonjs/charts/line/Dot.js.map +1 -1
  91. package/lib/commonjs/charts/line/Gradient.js +12 -19
  92. package/lib/commonjs/charts/line/Gradient.js.map +1 -1
  93. package/lib/commonjs/charts/line/Group.js +2 -14
  94. package/lib/commonjs/charts/line/Group.js.map +1 -1
  95. package/lib/commonjs/charts/line/Highlight.js +9 -21
  96. package/lib/commonjs/charts/line/Highlight.js.map +1 -1
  97. package/lib/commonjs/charts/line/HorizontalLine.js +8 -23
  98. package/lib/commonjs/charts/line/HorizontalLine.js.map +1 -1
  99. package/lib/commonjs/charts/line/HoverTrap/index.js +0 -4
  100. package/lib/commonjs/charts/line/HoverTrap/index.js.map +1 -1
  101. package/lib/commonjs/charts/line/HoverTrap/index.web.js +11 -24
  102. package/lib/commonjs/charts/line/HoverTrap/index.web.js.map +1 -1
  103. package/lib/commonjs/charts/line/LineChartPathContext.js +1 -6
  104. package/lib/commonjs/charts/line/LineChartPathContext.js.map +1 -1
  105. package/lib/commonjs/charts/line/Path.js +9 -18
  106. package/lib/commonjs/charts/line/Path.js.map +1 -1
  107. package/lib/commonjs/charts/line/PriceText.js +2 -9
  108. package/lib/commonjs/charts/line/PriceText.js.map +1 -1
  109. package/lib/commonjs/charts/line/Tooltip.js +25 -47
  110. package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
  111. package/lib/commonjs/charts/line/index.js +1 -39
  112. package/lib/commonjs/charts/line/index.js.map +1 -1
  113. package/lib/commonjs/charts/line/types.js.map +1 -1
  114. package/lib/commonjs/charts/line/useAnimatedPath.js +6 -12
  115. package/lib/commonjs/charts/line/useAnimatedPath.js.map +1 -1
  116. package/lib/commonjs/charts/line/useCurrentY.js +0 -7
  117. package/lib/commonjs/charts/line/useCurrentY.js.map +1 -1
  118. package/lib/commonjs/charts/line/useDatetime.js +0 -4
  119. package/lib/commonjs/charts/line/useDatetime.js.map +1 -1
  120. package/lib/commonjs/charts/line/useLineChart.js +4 -10
  121. package/lib/commonjs/charts/line/useLineChart.js.map +1 -1
  122. package/lib/commonjs/charts/line/usePrice.js +1 -5
  123. package/lib/commonjs/charts/line/usePrice.js.map +1 -1
  124. package/lib/commonjs/charts/line/utils/getArea.js +11 -11
  125. package/lib/commonjs/charts/line/utils/getArea.js.map +1 -1
  126. package/lib/commonjs/charts/line/utils/getDomain.js +0 -1
  127. package/lib/commonjs/charts/line/utils/getDomain.js.map +1 -1
  128. package/lib/commonjs/charts/line/utils/getPath.js +5 -8
  129. package/lib/commonjs/charts/line/utils/getPath.js.map +1 -1
  130. package/lib/commonjs/charts/line/utils/getXPositionForCurve.js +15 -0
  131. package/lib/commonjs/charts/line/utils/getXPositionForCurve.js.map +1 -0
  132. package/lib/commonjs/charts/line/utils/index.js +0 -10
  133. package/lib/commonjs/charts/line/utils/index.js.map +1 -1
  134. package/lib/commonjs/charts/line/utils/interpolatePath.js +119 -124
  135. package/lib/commonjs/charts/line/utils/interpolatePath.js.map +1 -1
  136. package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +0 -3
  137. package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js.map +1 -1
  138. package/lib/commonjs/components/AnimatedText.js +6 -17
  139. package/lib/commonjs/components/AnimatedText.js.map +1 -1
  140. package/lib/commonjs/index.js +0 -8
  141. package/lib/commonjs/index.js.map +1 -1
  142. package/lib/commonjs/utils/formatDatetime.js +0 -1
  143. package/lib/commonjs/utils/formatDatetime.js.map +1 -1
  144. package/lib/commonjs/utils/formatPrice.js +2 -12
  145. package/lib/commonjs/utils/formatPrice.js.map +1 -1
  146. package/lib/commonjs/utils/index.js +0 -6
  147. package/lib/commonjs/utils/index.js.map +1 -1
  148. package/lib/commonjs/utils/usePrevious.js +4 -9
  149. package/lib/commonjs/utils/usePrevious.js.map +1 -1
  150. package/lib/module/charts/candle/Candle.js +4 -2
  151. package/lib/module/charts/candle/Candle.js.map +1 -1
  152. package/lib/module/charts/candle/Candles.js +4 -3
  153. package/lib/module/charts/candle/Candles.js.map +1 -1
  154. package/lib/module/charts/candle/Chart.js.map +1 -1
  155. package/lib/module/charts/candle/Context.js.map +1 -1
  156. package/lib/module/charts/candle/Crosshair.js +1 -4
  157. package/lib/module/charts/candle/Crosshair.js.map +1 -1
  158. package/lib/module/charts/candle/CrosshairTooltip.js +3 -6
  159. package/lib/module/charts/candle/CrosshairTooltip.js.map +1 -1
  160. package/lib/module/charts/candle/DatetimeText.js.map +1 -1
  161. package/lib/module/charts/candle/HoverTrap/index.web.js +11 -15
  162. package/lib/module/charts/candle/HoverTrap/index.web.js.map +1 -1
  163. package/lib/module/charts/candle/Line.js +1 -2
  164. package/lib/module/charts/candle/Line.js.map +1 -1
  165. package/lib/module/charts/candle/PriceText.js.map +1 -1
  166. package/lib/module/charts/candle/index.js.map +1 -1
  167. package/lib/module/charts/candle/types.js.map +1 -1
  168. package/lib/module/charts/candle/useCandleData.js +0 -1
  169. package/lib/module/charts/candle/useCandleData.js.map +1 -1
  170. package/lib/module/charts/candle/useCandlestickChart.js.map +1 -1
  171. package/lib/module/charts/candle/useDatetime.js.map +1 -1
  172. package/lib/module/charts/candle/usePrice.js +0 -2
  173. package/lib/module/charts/candle/usePrice.js.map +1 -1
  174. package/lib/module/charts/candle/utils/getDomain.js.map +1 -1
  175. package/lib/module/charts/candle/utils/getHeight.js.map +1 -1
  176. package/lib/module/charts/candle/utils/getPrice.js.map +1 -1
  177. package/lib/module/charts/candle/utils/getY.js.map +1 -1
  178. package/lib/module/charts/candle/utils/index.js.map +1 -1
  179. package/lib/module/charts/candle/utils.js.map +1 -1
  180. package/lib/module/charts/line/Chart.js +8 -12
  181. package/lib/module/charts/line/Chart.js.map +1 -1
  182. package/lib/module/charts/line/ChartPath.js +21 -28
  183. package/lib/module/charts/line/ChartPath.js.map +1 -1
  184. package/lib/module/charts/line/Context.js +4 -6
  185. package/lib/module/charts/line/Context.js.map +1 -1
  186. package/lib/module/charts/line/Cursor.js +37 -50
  187. package/lib/module/charts/line/Cursor.js.map +1 -1
  188. package/lib/module/charts/line/CursorCrosshair.js +3 -3
  189. package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
  190. package/lib/module/charts/line/CursorLine.js +3 -3
  191. package/lib/module/charts/line/CursorLine.js.map +1 -1
  192. package/lib/module/charts/line/Data.js +0 -2
  193. package/lib/module/charts/line/Data.js.map +1 -1
  194. package/lib/module/charts/line/DatetimeText.js.map +1 -1
  195. package/lib/module/charts/line/Dot.js +25 -18
  196. package/lib/module/charts/line/Dot.js.map +1 -1
  197. package/lib/module/charts/line/Gradient.js +10 -5
  198. package/lib/module/charts/line/Gradient.js.map +1 -1
  199. package/lib/module/charts/line/Group.js +0 -2
  200. package/lib/module/charts/line/Group.js.map +1 -1
  201. package/lib/module/charts/line/Highlight.js +7 -5
  202. package/lib/module/charts/line/Highlight.js.map +1 -1
  203. package/lib/module/charts/line/HorizontalLine.js +6 -8
  204. package/lib/module/charts/line/HorizontalLine.js.map +1 -1
  205. package/lib/module/charts/line/HoverTrap/index.js.map +1 -1
  206. package/lib/module/charts/line/HoverTrap/index.web.js +11 -15
  207. package/lib/module/charts/line/HoverTrap/index.web.js.map +1 -1
  208. package/lib/module/charts/line/LineChartPathContext.js.map +1 -1
  209. package/lib/module/charts/line/Path.js +7 -4
  210. package/lib/module/charts/line/Path.js.map +1 -1
  211. package/lib/module/charts/line/PriceText.js.map +1 -1
  212. package/lib/module/charts/line/Tooltip.js +21 -33
  213. package/lib/module/charts/line/Tooltip.js.map +1 -1
  214. package/lib/module/charts/line/index.js.map +1 -1
  215. package/lib/module/charts/line/types.js.map +1 -1
  216. package/lib/module/charts/line/useAnimatedPath.js +3 -5
  217. package/lib/module/charts/line/useAnimatedPath.js.map +1 -1
  218. package/lib/module/charts/line/useCurrentY.js +0 -1
  219. package/lib/module/charts/line/useCurrentY.js.map +1 -1
  220. package/lib/module/charts/line/useDatetime.js.map +1 -1
  221. package/lib/module/charts/line/useLineChart.js +2 -1
  222. package/lib/module/charts/line/useLineChart.js.map +1 -1
  223. package/lib/module/charts/line/usePrice.js +1 -1
  224. package/lib/module/charts/line/usePrice.js.map +1 -1
  225. package/lib/module/charts/line/utils/getArea.js +9 -6
  226. package/lib/module/charts/line/utils/getArea.js.map +1 -1
  227. package/lib/module/charts/line/utils/getDomain.js.map +1 -1
  228. package/lib/module/charts/line/utils/getPath.js +3 -3
  229. package/lib/module/charts/line/utils/getPath.js.map +1 -1
  230. package/lib/module/charts/line/utils/getXPositionForCurve.js +9 -0
  231. package/lib/module/charts/line/utils/getXPositionForCurve.js.map +1 -0
  232. package/lib/module/charts/line/utils/index.js.map +1 -1
  233. package/lib/module/charts/line/utils/interpolatePath.js +116 -117
  234. package/lib/module/charts/line/utils/interpolatePath.js.map +1 -1
  235. package/lib/module/charts/line/utils/lineChartDataPropToArray.js +0 -2
  236. package/lib/module/charts/line/utils/lineChartDataPropToArray.js.map +1 -1
  237. package/lib/module/components/AnimatedText.js +4 -3
  238. package/lib/module/components/AnimatedText.js.map +1 -1
  239. package/lib/module/index.js.map +1 -1
  240. package/lib/module/utils/formatDatetime.js.map +1 -1
  241. package/lib/module/utils/formatPrice.js +2 -11
  242. package/lib/module/utils/formatPrice.js.map +1 -1
  243. package/lib/module/utils/index.js.map +1 -1
  244. package/lib/module/utils/usePrevious.js +2 -3
  245. package/lib/module/utils/usePrevious.js.map +1 -1
  246. package/lib/typescript/example/src/App.d.ts +4 -0
  247. package/lib/typescript/example/src/App.d.ts.map +1 -0
  248. package/lib/typescript/example/src/CandlestickChart.d.ts +3 -0
  249. package/lib/typescript/example/src/CandlestickChart.d.ts.map +1 -0
  250. package/lib/typescript/example/src/LineChart.d.ts +3 -0
  251. package/lib/typescript/example/src/LineChart.d.ts.map +1 -0
  252. package/lib/typescript/src/charts/candle/Candle.d.ts +7 -5
  253. package/lib/typescript/src/charts/candle/Candle.d.ts.map +1 -0
  254. package/lib/typescript/src/charts/candle/Candles.d.ts +4 -3
  255. package/lib/typescript/src/charts/candle/Candles.d.ts.map +1 -0
  256. package/lib/typescript/src/charts/candle/Chart.d.ts +3 -2
  257. package/lib/typescript/src/charts/candle/Chart.d.ts.map +1 -0
  258. package/lib/typescript/src/charts/candle/Context.d.ts +3 -2
  259. package/lib/typescript/src/charts/candle/Context.d.ts.map +1 -0
  260. package/lib/typescript/src/charts/candle/Crosshair.d.ts +3 -2
  261. package/lib/typescript/src/charts/candle/Crosshair.d.ts.map +1 -0
  262. package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts +4 -3
  263. package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts.map +1 -0
  264. package/lib/typescript/src/charts/candle/DatetimeText.d.ts +4 -3
  265. package/lib/typescript/src/charts/candle/DatetimeText.d.ts.map +1 -0
  266. package/lib/typescript/src/charts/candle/HoverTrap/index.web.d.ts +3 -2
  267. package/lib/typescript/src/charts/candle/HoverTrap/index.web.d.ts.map +1 -0
  268. package/lib/typescript/src/charts/candle/Line.d.ts +4 -3
  269. package/lib/typescript/src/charts/candle/Line.d.ts.map +1 -0
  270. package/lib/typescript/src/charts/candle/PriceText.d.ts +4 -3
  271. package/lib/typescript/src/charts/candle/PriceText.d.ts.map +1 -0
  272. package/lib/typescript/src/charts/candle/index.d.ts +3 -2
  273. package/lib/typescript/src/charts/candle/index.d.ts.map +1 -0
  274. package/lib/typescript/src/charts/candle/types.d.ts +7 -6
  275. package/lib/typescript/src/charts/candle/types.d.ts.map +1 -0
  276. package/lib/typescript/src/charts/candle/useCandleData.d.ts +1 -0
  277. package/lib/typescript/src/charts/candle/useCandleData.d.ts.map +1 -0
  278. package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +1 -0
  279. package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts.map +1 -0
  280. package/lib/typescript/src/charts/candle/useDatetime.d.ts +1 -0
  281. package/lib/typescript/src/charts/candle/useDatetime.d.ts.map +1 -0
  282. package/lib/typescript/src/charts/candle/usePrice.d.ts +1 -0
  283. package/lib/typescript/src/charts/candle/usePrice.d.ts.map +1 -0
  284. package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +1 -0
  285. package/lib/typescript/src/charts/candle/utils/getDomain.d.ts.map +1 -0
  286. package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +1 -0
  287. package/lib/typescript/src/charts/candle/utils/getHeight.d.ts.map +1 -0
  288. package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +1 -0
  289. package/lib/typescript/src/charts/candle/utils/getPrice.d.ts.map +1 -0
  290. package/lib/typescript/src/charts/candle/utils/getY.d.ts +1 -0
  291. package/lib/typescript/src/charts/candle/utils/getY.d.ts.map +1 -0
  292. package/lib/typescript/src/charts/candle/utils/index.d.ts +1 -0
  293. package/lib/typescript/src/charts/candle/utils/index.d.ts.map +1 -0
  294. package/lib/typescript/src/charts/candle/utils.d.ts +1 -0
  295. package/lib/typescript/src/charts/candle/utils.d.ts.map +1 -0
  296. package/lib/typescript/src/charts/line/Chart.d.ts +3 -2
  297. package/lib/typescript/src/charts/line/Chart.d.ts.map +1 -0
  298. package/lib/typescript/src/charts/line/ChartPath.d.ts +3 -2
  299. package/lib/typescript/src/charts/line/ChartPath.d.ts.map +1 -0
  300. package/lib/typescript/src/charts/line/Context.d.ts +3 -2
  301. package/lib/typescript/src/charts/line/Context.d.ts.map +1 -0
  302. package/lib/typescript/src/charts/line/Cursor.d.ts +3 -2
  303. package/lib/typescript/src/charts/line/Cursor.d.ts.map +1 -0
  304. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +3 -2
  305. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts.map +1 -0
  306. package/lib/typescript/src/charts/line/CursorLine.d.ts +3 -2
  307. package/lib/typescript/src/charts/line/CursorLine.d.ts.map +1 -0
  308. package/lib/typescript/src/charts/line/Data.d.ts +6 -4
  309. package/lib/typescript/src/charts/line/Data.d.ts.map +1 -0
  310. package/lib/typescript/src/charts/line/DatetimeText.d.ts +4 -3
  311. package/lib/typescript/src/charts/line/DatetimeText.d.ts.map +1 -0
  312. package/lib/typescript/src/charts/line/Dot.d.ts +4 -3
  313. package/lib/typescript/src/charts/line/Dot.d.ts.map +1 -0
  314. package/lib/typescript/src/charts/line/Gradient.d.ts +3 -2
  315. package/lib/typescript/src/charts/line/Gradient.d.ts.map +1 -0
  316. package/lib/typescript/src/charts/line/Group.d.ts +4 -2
  317. package/lib/typescript/src/charts/line/Group.d.ts.map +1 -0
  318. package/lib/typescript/src/charts/line/Highlight.d.ts +4 -3
  319. package/lib/typescript/src/charts/line/Highlight.d.ts.map +1 -0
  320. package/lib/typescript/src/charts/line/HorizontalLine.d.ts +4 -3
  321. package/lib/typescript/src/charts/line/HorizontalLine.d.ts.map +1 -0
  322. package/lib/typescript/src/charts/line/HoverTrap/index.d.ts +3 -2
  323. package/lib/typescript/src/charts/line/HoverTrap/index.d.ts.map +1 -0
  324. package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts +3 -2
  325. package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts.map +1 -0
  326. package/lib/typescript/src/charts/line/LineChartPathContext.d.ts +1 -0
  327. package/lib/typescript/src/charts/line/LineChartPathContext.d.ts.map +1 -0
  328. package/lib/typescript/src/charts/line/Path.d.ts +4 -3
  329. package/lib/typescript/src/charts/line/Path.d.ts.map +1 -0
  330. package/lib/typescript/src/charts/line/PriceText.d.ts +4 -3
  331. package/lib/typescript/src/charts/line/PriceText.d.ts.map +1 -0
  332. package/lib/typescript/src/charts/line/Tooltip.d.ts +4 -3
  333. package/lib/typescript/src/charts/line/Tooltip.d.ts.map +1 -0
  334. package/lib/typescript/src/charts/line/index.d.ts +2 -1
  335. package/lib/typescript/src/charts/line/index.d.ts.map +1 -0
  336. package/lib/typescript/src/charts/line/types.d.ts +8 -7
  337. package/lib/typescript/src/charts/line/types.d.ts.map +1 -0
  338. package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +1 -0
  339. package/lib/typescript/src/charts/line/useAnimatedPath.d.ts.map +1 -0
  340. package/lib/typescript/src/charts/line/useCurrentY.d.ts +1 -0
  341. package/lib/typescript/src/charts/line/useCurrentY.d.ts.map +1 -0
  342. package/lib/typescript/src/charts/line/useDatetime.d.ts +1 -0
  343. package/lib/typescript/src/charts/line/useDatetime.d.ts.map +1 -0
  344. package/lib/typescript/src/charts/line/useLineChart.d.ts +1 -0
  345. package/lib/typescript/src/charts/line/useLineChart.d.ts.map +1 -0
  346. package/lib/typescript/src/charts/line/usePrice.d.ts +1 -0
  347. package/lib/typescript/src/charts/line/usePrice.d.ts.map +1 -0
  348. package/lib/typescript/src/charts/line/utils/getArea.d.ts +3 -1
  349. package/lib/typescript/src/charts/line/utils/getArea.d.ts.map +1 -0
  350. package/lib/typescript/src/charts/line/utils/getDomain.d.ts +1 -0
  351. package/lib/typescript/src/charts/line/utils/getDomain.d.ts.map +1 -0
  352. package/lib/typescript/src/charts/line/utils/getPath.d.ts +1 -0
  353. package/lib/typescript/src/charts/line/utils/getPath.d.ts.map +1 -0
  354. package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts +3 -0
  355. package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts.map +1 -0
  356. package/lib/typescript/src/charts/line/utils/index.d.ts +1 -0
  357. package/lib/typescript/src/charts/line/utils/index.d.ts.map +1 -0
  358. package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts +1 -0
  359. package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts.map +1 -0
  360. package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +1 -0
  361. package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts.map +1 -0
  362. package/lib/typescript/src/components/AnimatedText.d.ts +3 -2
  363. package/lib/typescript/src/components/AnimatedText.d.ts.map +1 -0
  364. package/lib/typescript/src/index.d.ts +1 -0
  365. package/lib/typescript/src/index.d.ts.map +1 -0
  366. package/lib/typescript/src/utils/formatDatetime.d.ts +1 -0
  367. package/lib/typescript/src/utils/formatDatetime.d.ts.map +1 -0
  368. package/lib/typescript/src/utils/formatPrice.d.ts +1 -0
  369. package/lib/typescript/src/utils/formatPrice.d.ts.map +1 -0
  370. package/lib/typescript/src/utils/index.d.ts +1 -0
  371. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  372. package/lib/typescript/src/utils/usePrevious.d.ts +1 -0
  373. package/lib/typescript/src/utils/usePrevious.d.ts.map +1 -0
  374. package/package.json +12 -9
  375. package/scripts/bootstrap.js +24 -0
  376. package/src/charts/candle/Candle.tsx +3 -3
  377. package/src/charts/candle/CrosshairTooltip.tsx +2 -2
  378. package/src/charts/candle/HoverTrap/index.web.tsx +0 -1
  379. package/src/charts/line/Chart.tsx +6 -4
  380. package/src/charts/line/Cursor.tsx +52 -67
  381. package/src/charts/line/Dot.tsx +8 -8
  382. package/src/charts/line/Gradient.tsx +1 -0
  383. package/src/charts/line/HorizontalLine.tsx +8 -15
  384. package/src/charts/line/HoverTrap/index.web.tsx +0 -1
  385. package/src/charts/line/Tooltip.tsx +21 -13
  386. package/src/charts/line/useAnimatedPath.ts +3 -3
  387. package/src/charts/line/utils/getArea.ts +8 -5
  388. package/src/charts/line/utils/getXPositionForCurve.ts +9 -0
  389. package/tsconfig.build.json +5 -0
  390. package/tsconfig.json +28 -0
  391. package/yarn.lock +8529 -0
@@ -3,6 +3,7 @@
3
3
  /**
4
4
  * Reanimated compatible fork of https://github.com/pbeshai/d3-interpolate-path
5
5
  */
6
+
6
7
  //////////////////////////////////////////////////////////////////////////////////////////////////////
7
8
 
8
9
  /**
@@ -20,7 +21,6 @@ function decasteljau(points, t) {
20
21
 
21
22
  const left = [];
22
23
  const right = [];
23
-
24
24
  function decasteljauRecurse(points, t) {
25
25
  'worklet';
26
26
 
@@ -29,32 +29,27 @@ function decasteljau(points, t) {
29
29
  right.push(points[0]);
30
30
  } else {
31
31
  const newPoints = Array(points.length - 1);
32
-
33
32
  for (let i = 0; i < newPoints.length; i++) {
34
33
  if (i === 0) {
35
34
  left.push(points[0]);
36
35
  }
37
-
38
36
  if (i === newPoints.length - 1) {
39
37
  right.push(points[i + 1]);
40
38
  }
41
-
42
39
  newPoints[i] = [(1 - t) * points[i][0] + t * points[i + 1][0], (1 - t) * points[i][1] + t * points[i + 1][1]];
43
40
  }
44
-
45
41
  decasteljauRecurse(newPoints, t);
46
42
  }
47
43
  }
48
-
49
44
  if (points.length) {
50
45
  decasteljauRecurse(points, t);
51
46
  }
52
-
53
47
  return {
54
48
  left,
55
49
  right: right.reverse()
56
50
  };
57
51
  }
52
+
58
53
  /**
59
54
  * Convert segments represented as points back into a command object
60
55
  *
@@ -62,26 +57,20 @@ function decasteljau(points, t) {
62
57
  * Represents a segment
63
58
  * @return {Object} A command object representing the segment.
64
59
  */
65
-
66
-
67
60
  function pointsToCommand(points) {
68
61
  'worklet';
69
62
 
70
63
  const command = {};
71
-
72
64
  if (points.length === 4) {
73
65
  command.x2 = points[2][0];
74
66
  command.y2 = points[2][1];
75
67
  }
76
-
77
68
  if (points.length >= 3) {
78
69
  command.x1 = points[1][0];
79
70
  command.y1 = points[1][1];
80
71
  }
81
-
82
72
  command.x = points[points.length - 1][0];
83
73
  command.y = points[points.length - 1][1];
84
-
85
74
  if (points.length === 4) {
86
75
  // start, control1, control2, end
87
76
  command.type = 'C';
@@ -92,9 +81,9 @@ function pointsToCommand(points) {
92
81
  // start, end
93
82
  command.type = 'L';
94
83
  }
95
-
96
84
  return command;
97
85
  }
86
+
98
87
  /**
99
88
  * Runs de Casteljau's algorithm enough times to produce the desired number of segments.
100
89
  *
@@ -102,20 +91,21 @@ function pointsToCommand(points) {
102
91
  * @param {Number} segmentCount Number of segments to split the original into
103
92
  * @return {Number[][][]} Array of segments
104
93
  */
105
-
106
-
107
94
  function splitCurveAsPoints(points, segmentCount) {
108
95
  'worklet';
109
96
 
110
97
  segmentCount = segmentCount || 2;
111
98
  const segments = [];
112
99
  let remainingCurve = points;
113
- const tIncrement = 1 / segmentCount; // x-----x-----x-----x
100
+ const tIncrement = 1 / segmentCount;
101
+
102
+ // x-----x-----x-----x
114
103
  // t= 0.33 0.66 1
115
104
  // x-----o-----------x
116
105
  // r= 0.33
117
106
  // x-----o-----x
118
107
  // r= 0.5 (0.33 / (1 - 0.33)) === tIncrement / (1 - (tIncrement * (i - 1))
108
+
119
109
  // x-----x-----x-----x----x
120
110
  // t= 0.25 0.5 0.75 1
121
111
  // x-----o----------------x
@@ -130,12 +120,13 @@ function splitCurveAsPoints(points, segmentCount) {
130
120
  const split = decasteljau(remainingCurve, tRelative);
131
121
  segments.push(split.left);
132
122
  remainingCurve = split.right;
133
- } // last segment is just to the end from the last point
134
-
123
+ }
135
124
 
125
+ // last segment is just to the end from the last point
136
126
  segments.push(remainingCurve);
137
127
  return segments;
138
128
  }
129
+
139
130
  /**
140
131
  * Convert command objects to arrays of points, run de Casteljau's algorithm on it
141
132
  * to split into to the desired number of segments.
@@ -145,28 +136,23 @@ function splitCurveAsPoints(points, segmentCount) {
145
136
  * @param {Number} segmentCount The number of segments to create
146
137
  * @return {Object[]} An array of commands representing the segments in sequence
147
138
  */
148
-
149
-
150
139
  export function splitCurve(commandStart, commandEnd, segmentCount) {
151
140
  'worklet';
152
141
 
153
142
  const points = [[commandStart.x, commandStart.y]];
154
-
155
143
  if (commandEnd.x1 != null) {
156
144
  points.push([commandEnd.x1, commandEnd.y1]);
157
145
  }
158
-
159
146
  if (commandEnd.x2 != null) {
160
147
  points.push([commandEnd.x2, commandEnd.y2]);
161
148
  }
162
-
163
149
  points.push([commandEnd.x, commandEnd.y]);
164
150
  return splitCurveAsPoints(points, segmentCount).map(pointsToCommand);
165
151
  }
152
+
166
153
  /**
167
154
  * List of params for each command type in a path `d` attribute
168
155
  */
169
-
170
156
  const typeMap = {
171
157
  M: ['x', 'y'],
172
158
  L: ['x', 'y'],
@@ -178,35 +164,33 @@ const typeMap = {
178
164
  T: ['x', 'y'],
179
165
  A: ['rx', 'ry', 'xAxisRotation', 'largeArcFlag', 'sweepFlag', 'x', 'y'],
180
166
  Z: []
181
- }; // Add lower case entries too matching uppercase (e.g. 'm' == 'M')
167
+ };
182
168
 
169
+ // Add lower case entries too matching uppercase (e.g. 'm' == 'M')
183
170
  Object.keys(typeMap).forEach(key => {
184
171
  typeMap[key.toLowerCase()] = typeMap[key];
185
172
  });
186
-
187
173
  function arrayOfLength(length, value) {
188
174
  'worklet';
189
175
 
190
176
  const array = Array(length);
191
-
192
177
  for (let i = 0; i < length; i++) {
193
178
  array[i] = value;
194
179
  }
195
-
196
180
  return array;
197
181
  }
182
+
198
183
  /**
199
184
  * Converts a command object to a string to be used in a `d` attribute
200
185
  * @param {Object} command A command object
201
186
  * @return {String} The string for the `d` attribute
202
187
  */
203
-
204
-
205
188
  function commandToString(command) {
206
189
  'worklet';
207
190
 
208
191
  return `${command.type}${typeMap[command.type].map(p => command[p]).join(',')}`;
209
192
  }
193
+
210
194
  /**
211
195
  * Converts command A to have the same type as command B.
212
196
  *
@@ -227,8 +211,6 @@ function commandToString(command) {
227
211
  * @param {Object} bCommand Command object from path `d` attribute to match against
228
212
  * @return {Object} aCommand converted to type of bCommand
229
213
  */
230
-
231
-
232
214
  function convertToSameType(aCommand, bCommand) {
233
215
  'worklet';
234
216
 
@@ -238,15 +220,17 @@ function convertToSameType(aCommand, bCommand) {
238
220
  x2: 'x',
239
221
  y2: 'y'
240
222
  };
241
- const readFromBKeys = ['xAxisRotation', 'largeArcFlag', 'sweepFlag']; // convert (but ignore M types)
223
+ const readFromBKeys = ['xAxisRotation', 'largeArcFlag', 'sweepFlag'];
242
224
 
225
+ // convert (but ignore M types)
243
226
  if (aCommand.type !== bCommand.type && bCommand.type.toUpperCase() !== 'M') {
244
227
  const aConverted = {};
245
228
  Object.keys(bCommand).forEach(bKey => {
246
- const bValue = bCommand[bKey]; // first read from the A command
247
-
248
- let aValue = aCommand[bKey]; // if it is one of these values, read from B no matter what
229
+ const bValue = bCommand[bKey];
230
+ // first read from the A command
231
+ let aValue = aCommand[bKey];
249
232
 
233
+ // if it is one of these values, read from B no matter what
250
234
  if (aValue === undefined) {
251
235
  if (readFromBKeys.includes(bKey)) {
252
236
  aValue = bValue;
@@ -254,24 +238,24 @@ function convertToSameType(aCommand, bCommand) {
254
238
  // if it wasn't in the A command, see if an equivalent was
255
239
  if (aValue === undefined && conversionMap[bKey]) {
256
240
  aValue = aCommand[conversionMap[bKey]];
257
- } // if it doesn't have a converted value, use 0
258
-
241
+ }
259
242
 
243
+ // if it doesn't have a converted value, use 0
260
244
  if (aValue === undefined) {
261
245
  aValue = 0;
262
246
  }
263
247
  }
264
248
  }
265
-
266
249
  aConverted[bKey] = aValue;
267
- }); // update the type to match B
250
+ });
268
251
 
252
+ // update the type to match B
269
253
  aConverted.type = bCommand.type;
270
254
  aCommand = aConverted;
271
255
  }
272
-
273
256
  return aCommand;
274
257
  }
258
+
275
259
  /**
276
260
  * Interpolate between command objects commandStart and commandEnd segmentCount times.
277
261
  * If the types are L, Q, or C then the curves are split as per de Casteljau's algorithm.
@@ -284,26 +268,26 @@ function convertToSameType(aCommand, bCommand) {
284
268
  * @return {Object[]} Array of ~segmentCount command objects between commandStart and
285
269
  * commandEnd. (Can be segmentCount+1 objects if commandStart is type M).
286
270
  */
287
-
288
-
289
271
  function splitSegment(commandStart, commandEnd, segmentCount) {
290
272
  'worklet';
291
273
 
292
- let segments = []; // line, quadratic bezier, or cubic bezier
274
+ let segments = [];
293
275
 
276
+ // line, quadratic bezier, or cubic bezier
294
277
  if (commandEnd.type === 'L' || commandEnd.type === 'Q' || commandEnd.type === 'C') {
295
- segments = segments.concat(splitCurve(commandStart, commandEnd, segmentCount)); // general case - just copy the same point
278
+ segments = segments.concat(splitCurve(commandStart, commandEnd, segmentCount));
279
+
280
+ // general case - just copy the same point
296
281
  } else {
297
- const copyCommand = Object.assign({}, commandStart); // convert M to L
282
+ const copyCommand = Object.assign({}, commandStart);
298
283
 
284
+ // convert M to L
299
285
  if (copyCommand.type === 'M') {
300
286
  copyCommand.type = 'L';
301
287
  }
302
-
303
288
  segments = segments.concat(arrayOfLength(segmentCount - 1).map(() => copyCommand));
304
289
  segments.push(commandEnd);
305
290
  }
306
-
307
291
  return segments;
308
292
  }
309
293
  /**
@@ -317,114 +301,128 @@ function splitSegment(commandStart, commandEnd, segmentCount) {
317
301
  * end command object and returns true if the segment should be excluded from splitting.
318
302
  * @return {Object[]} The extended commandsToExtend array
319
303
  */
320
-
321
-
322
304
  function extend(commandsToExtend, referenceCommands, excludeSegment) {
323
- 'worklet'; // compute insertion points:
305
+ 'worklet';
306
+
307
+ // compute insertion points:
324
308
  // number of segments in the path to extend
309
+ const numSegmentsToExtend = commandsToExtend.length - 1;
325
310
 
326
- const numSegmentsToExtend = commandsToExtend.length - 1; // number of segments in the reference path.
311
+ // number of segments in the reference path.
312
+ const numReferenceSegments = referenceCommands.length - 1;
327
313
 
328
- const numReferenceSegments = referenceCommands.length - 1; // this value is always between [0, 1].
314
+ // this value is always between [0, 1].
315
+ const segmentRatio = numSegmentsToExtend / numReferenceSegments;
329
316
 
330
- const segmentRatio = numSegmentsToExtend / numReferenceSegments; // create a map, mapping segments in referenceCommands to how many points
317
+ // create a map, mapping segments in referenceCommands to how many points
331
318
  // should be added in that segment (should always be >= 1 since we need each
332
319
  // point itself).
333
320
  // 0 = segment 0-1, 1 = segment 1-2, n-1 = last vertex
334
-
335
321
  const countPointsPerSegment = arrayOfLength(numReferenceSegments).reduce((accum, d, i) => {
336
- let insertIndex = Math.floor(segmentRatio * i); // handle excluding segments
322
+ let insertIndex = Math.floor(segmentRatio * i);
337
323
 
324
+ // handle excluding segments
338
325
  if (excludeSegment && insertIndex < commandsToExtend.length - 1 && excludeSegment(commandsToExtend[insertIndex], commandsToExtend[insertIndex + 1])) {
339
326
  // set the insertIndex to the segment that this point should be added to:
327
+
340
328
  // round the insertIndex essentially so we split half and half on
341
329
  // neighbouring segments. hence the segmentRatio * i < 0.5
342
- const addToPriorSegment = segmentRatio * i % 1 < 0.5; // only skip segment if we already have 1 point in it (can't entirely remove a segment)
330
+ const addToPriorSegment = segmentRatio * i % 1 < 0.5;
343
331
 
332
+ // only skip segment if we already have 1 point in it (can't entirely remove a segment)
344
333
  if (accum[insertIndex]) {
345
334
  // TODO - Note this is a naive algorithm that should work for most d3-area use cases
346
335
  // but if two adjacent segments are supposed to be skipped, this will not perform as
347
336
  // expected. Could be updated to search for nearest segment to place the point in, but
348
337
  // will only do that if necessary.
338
+
349
339
  // add to the prior segment
350
340
  if (addToPriorSegment) {
351
341
  if (insertIndex > 0) {
352
- insertIndex -= 1; // not possible to add to previous so adding to next
342
+ insertIndex -= 1;
343
+
344
+ // not possible to add to previous so adding to next
353
345
  } else if (insertIndex < commandsToExtend.length - 1) {
354
346
  insertIndex += 1;
355
- } // add to next segment
356
-
347
+ }
348
+ // add to next segment
357
349
  } else if (insertIndex < commandsToExtend.length - 1) {
358
- insertIndex += 1; // not possible to add to next so adding to previous
350
+ insertIndex += 1;
351
+
352
+ // not possible to add to next so adding to previous
359
353
  } else if (insertIndex > 0) {
360
354
  insertIndex -= 1;
361
355
  }
362
356
  }
363
357
  }
364
-
365
358
  accum[insertIndex] = (accum[insertIndex] || 0) + 1;
366
359
  return accum;
367
- }, []); // extend each segment to have the correct number of points for a smooth interpolation
360
+ }, []);
368
361
 
362
+ // extend each segment to have the correct number of points for a smooth interpolation
369
363
  const extended = countPointsPerSegment.reduce((extended, segmentCount, i) => {
370
364
  // if last command, just add `segmentCount` number of times
371
365
  if (i === commandsToExtend.length - 1) {
372
- const lastCommandCopies = arrayOfLength(segmentCount, Object.assign({}, commandsToExtend[commandsToExtend.length - 1])); // convert M to L
366
+ const lastCommandCopies = arrayOfLength(segmentCount, Object.assign({}, commandsToExtend[commandsToExtend.length - 1]));
373
367
 
368
+ // convert M to L
374
369
  if (lastCommandCopies[0].type === 'M') {
375
370
  lastCommandCopies.forEach(d => {
376
371
  d.type = 'L';
377
372
  });
378
373
  }
379
-
380
374
  return extended.concat(lastCommandCopies);
381
- } // otherwise, split the segment segmentCount times.
382
-
375
+ }
383
376
 
377
+ // otherwise, split the segment segmentCount times.
384
378
  return extended.concat(splitSegment(commandsToExtend[i], commandsToExtend[i + 1], segmentCount));
385
- }, []); // add in the very first point since splitSegment only adds in the ones after it
379
+ }, []);
386
380
 
381
+ // add in the very first point since splitSegment only adds in the ones after it
387
382
  extended.unshift(commandsToExtend[0]);
388
383
  return extended;
389
384
  }
385
+
390
386
  /**
391
387
  * Takes a path `d` string and converts it into an array of command
392
388
  * objects. Drops the `Z` character.
393
389
  *
394
390
  * @param {String|null} d A path `d` string
395
391
  */
396
-
397
-
398
392
  export function pathCommandsFromString(d) {
399
- 'worklet'; // split into valid tokens
393
+ 'worklet';
400
394
 
395
+ // split into valid tokens
401
396
  const tokens = (d || '').match(/[MLCSTQAHVZmlcstqahv]|-?[\d.e+-]+/g) || [];
402
397
  const commands = [];
403
398
  let commandArgs;
404
- let command; // iterate over each token, checking if we are at a new command
405
- // by presence in the typeMap
399
+ let command;
406
400
 
401
+ // iterate over each token, checking if we are at a new command
402
+ // by presence in the typeMap
407
403
  for (let i = 0; i < tokens.length; ++i) {
408
- commandArgs = typeMap[tokens[i]]; // new command found:
404
+ commandArgs = typeMap[tokens[i]];
409
405
 
406
+ // new command found:
410
407
  if (commandArgs) {
411
408
  command = {
412
409
  type: tokens[i]
413
- }; // add each of the expected args for this command:
410
+ };
414
411
 
412
+ // add each of the expected args for this command:
415
413
  for (let a = 0; a < commandArgs.length; ++a) {
416
414
  command[commandArgs[a]] = +tokens[i + a + 1];
417
- } // need to increment our token index appropriately since
418
- // we consumed token args
419
-
415
+ }
420
416
 
417
+ // need to increment our token index appropriately since
418
+ // we consumed token args
421
419
  i += commandArgs.length;
422
420
  commands.push(command);
423
421
  }
424
422
  }
425
-
426
423
  return commands;
427
424
  }
425
+
428
426
  /**
429
427
  * Interpolate from A to B by extending A and B during interpolation to have
430
428
  * the same number of points. This allows for a smooth transition when they
@@ -441,59 +439,63 @@ export function pathCommandsFromString(d) {
441
439
  * end command object and returns true if the segment should be excluded from splitting.
442
440
  * @returns {Function} Interpolation function that maps t ([0, 1]) to an array of path commands.
443
441
  */
444
-
445
442
  export function interpolatePathCommands(aCommandsInput, bCommandsInput, excludeSegment) {
446
- 'worklet'; // make a copy so we don't mess with the input arrays
443
+ 'worklet';
447
444
 
445
+ // make a copy so we don't mess with the input arrays
448
446
  let aCommands = aCommandsInput == null ? [] : aCommandsInput.slice();
449
- let bCommands = bCommandsInput == null ? [] : bCommandsInput.slice(); // both input sets are empty, so we don't interpolate
447
+ let bCommands = bCommandsInput == null ? [] : bCommandsInput.slice();
450
448
 
449
+ // both input sets are empty, so we don't interpolate
451
450
  if (!aCommands.length && !bCommands.length) {
452
451
  return function nullInterpolator() {
453
452
  'worklet';
454
453
 
455
454
  return [];
456
455
  };
457
- } // do we add Z during interpolation? yes if both have it. (we'd expect both to have it or not)
458
-
456
+ }
459
457
 
460
- const addZ = (aCommands.length === 0 || aCommands[aCommands.length - 1].type === 'Z') && (bCommands.length === 0 || bCommands[bCommands.length - 1].type === 'Z'); // we temporarily remove Z
458
+ // do we add Z during interpolation? yes if both have it. (we'd expect both to have it or not)
459
+ const addZ = (aCommands.length === 0 || aCommands[aCommands.length - 1].type === 'Z') && (bCommands.length === 0 || bCommands[bCommands.length - 1].type === 'Z');
461
460
 
461
+ // we temporarily remove Z
462
462
  if (aCommands.length > 0 && aCommands[aCommands.length - 1].type === 'Z') {
463
463
  aCommands.pop();
464
464
  }
465
-
466
465
  if (bCommands.length > 0 && bCommands[bCommands.length - 1].type === 'Z') {
467
466
  bCommands.pop();
468
- } // if A is empty, treat it as if it used to contain just the first point
469
- // of B. This makes it so the line extends out of from that first point.
470
-
467
+ }
471
468
 
469
+ // if A is empty, treat it as if it used to contain just the first point
470
+ // of B. This makes it so the line extends out of from that first point.
472
471
  if (!aCommands.length) {
473
- aCommands.push(bCommands[0]); // otherwise if B is empty, treat it as if it contains the first point
472
+ aCommands.push(bCommands[0]);
473
+
474
+ // otherwise if B is empty, treat it as if it contains the first point
474
475
  // of A. This makes it so the line retracts into the first point.
475
476
  } else if (!bCommands.length) {
476
477
  bCommands.push(aCommands[0]);
477
- } // extend to match equal size
478
-
478
+ }
479
479
 
480
+ // extend to match equal size
480
481
  const numPointsToExtend = Math.abs(bCommands.length - aCommands.length);
481
-
482
482
  if (numPointsToExtend !== 0) {
483
483
  // B has more points than A, so add points to A before interpolating
484
484
  if (bCommands.length > aCommands.length) {
485
- aCommands = extend(aCommands, bCommands, excludeSegment); // else if A has more points than B, add more points to B
485
+ aCommands = extend(aCommands, bCommands, excludeSegment);
486
+
487
+ // else if A has more points than B, add more points to B
486
488
  } else if (bCommands.length < aCommands.length) {
487
489
  bCommands = extend(bCommands, aCommands, excludeSegment);
488
490
  }
489
- } // commands have same length now.
490
- // convert commands in A to the same type as those in B
491
-
491
+ }
492
492
 
493
- aCommands = aCommands.map((aCommand, i) => convertToSameType(aCommand, bCommands[i])); // create mutable interpolated command objects
493
+ // commands have same length now.
494
+ // convert commands in A to the same type as those in B
495
+ aCommands = aCommands.map((aCommand, i) => convertToSameType(aCommand, bCommands[i]));
494
496
 
497
+ // create mutable interpolated command objects
495
498
  const interpolatedCommands = aCommands.map(aCommand => aCommand);
496
-
497
499
  if (addZ) {
498
500
  interpolatedCommands.push({
499
501
  type: 'Z'
@@ -502,39 +504,40 @@ export function interpolatePathCommands(aCommandsInput, bCommandsInput, excludeS
502
504
  type: 'Z'
503
505
  }); // required for when returning at t == 0
504
506
  }
505
-
506
507
  return function pathCommandInterpolator(t) {
507
- 'worklet'; // at 1 return the final value without the extensions used during interpolation
508
+ 'worklet';
508
509
 
510
+ // at 1 return the final value without the extensions used during interpolation
509
511
  if (t === 1) {
510
512
  return bCommandsInput == null ? [] : bCommandsInput;
511
- } // work with aCommands directly since interpolatedCommands are mutated
512
-
513
+ }
513
514
 
515
+ // work with aCommands directly since interpolatedCommands are mutated
514
516
  if (t === 0) {
515
517
  return aCommands;
516
- } // interpolate the commands using the mutable interpolated command objs
517
-
518
+ }
518
519
 
520
+ // interpolate the commands using the mutable interpolated command objs
519
521
  for (let i = 0; i < interpolatedCommands.length; ++i) {
520
522
  // if (interpolatedCommands[i].type === 'Z') continue;
523
+
521
524
  const aCommand = aCommands[i];
522
525
  const bCommand = bCommands[i];
523
526
  const interpolatedCommand = interpolatedCommands[i];
524
-
525
527
  for (let j = 0; j < typeMap[interpolatedCommand.type].length; j++) {
526
528
  const arg = typeMap[interpolatedCommand.type][j];
527
- interpolatedCommand[arg] = (1 - t) * aCommand[arg] + t * bCommand[arg]; // do not use floats for flags (#27), round to integer
529
+ interpolatedCommand[arg] = (1 - t) * aCommand[arg] + t * bCommand[arg];
528
530
 
531
+ // do not use floats for flags (#27), round to integer
529
532
  if (arg === 'largeArcFlag' || arg === 'sweepFlag') {
530
533
  interpolatedCommand[arg] = Math.round(interpolatedCommand[arg]);
531
534
  }
532
535
  }
533
536
  }
534
-
535
537
  return interpolatedCommands;
536
538
  };
537
539
  }
540
+
538
541
  /**
539
542
  * Interpolate from A to B by extending A and B during interpolation to have
540
543
  * the same number of points. This allows for a smooth transition when they
@@ -548,13 +551,11 @@ export function interpolatePathCommands(aCommandsInput, bCommandsInput, excludeS
548
551
  * end command object and returns true if the segment should be excluded from splitting.
549
552
  * @returns {Function} Interpolation function that maps t ([0, 1]) to a path `d` string.
550
553
  */
551
-
552
554
  export function interpolatePath(a, b, excludeSegment) {
553
555
  'worklet';
554
556
 
555
557
  let aCommands = pathCommandsFromString(a);
556
558
  let bCommands = pathCommandsFromString(b);
557
-
558
559
  if (!aCommands.length && !bCommands.length) {
559
560
  return function nullInterpolator() {
560
561
  'worklet';
@@ -562,24 +563,22 @@ export function interpolatePath(a, b, excludeSegment) {
562
563
  return '';
563
564
  };
564
565
  }
565
-
566
566
  const commandInterpolator = interpolatePathCommands(aCommands, bCommands, excludeSegment);
567
567
  return function pathStringInterpolator(t) {
568
- 'worklet'; // at 1 return the final value without the extensions used during interpolation
568
+ 'worklet';
569
569
 
570
+ // at 1 return the final value without the extensions used during interpolation
570
571
  if (t === 1) {
571
572
  return b == null ? '' : b;
572
573
  }
574
+ const interpolatedCommands = commandInterpolator(t);
573
575
 
574
- const interpolatedCommands = commandInterpolator(t); // convert to a string (fastest concat: https://jsperf.com/join-concat/150)
575
-
576
+ // convert to a string (fastest concat: https://jsperf.com/join-concat/150)
576
577
  let interpolatedString = '';
577
-
578
578
  for (let i = 0; i < interpolatedCommands.length; i++) {
579
579
  const interpolatedCommand = interpolatedCommands[i];
580
580
  interpolatedString += commandToString(interpolatedCommand);
581
581
  }
582
-
583
582
  return interpolatedString;
584
583
  };
585
584
  }