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