@orderly.network/hooks 1.2.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/esm/configProvider.d.ts +7 -1
  2. package/esm/configProvider.d.ts.map +1 -1
  3. package/esm/configProvider.js +44 -18
  4. package/esm/configProvider.js.map +1 -0
  5. package/esm/dataProvider.js +24 -19
  6. package/esm/dataProvider.js.map +1 -0
  7. package/esm/index.d.ts +1 -0
  8. package/esm/index.d.ts.map +1 -1
  9. package/esm/index.js +4 -1
  10. package/esm/index.js.map +1 -0
  11. package/esm/middleware/signatureMiddleware.js +9 -8
  12. package/esm/middleware/signatureMiddleware.js.map +1 -0
  13. package/esm/orderly/orderbook.service.js +39 -28
  14. package/esm/orderly/orderbook.service.js.map +1 -0
  15. package/esm/orderly/orderlyHooks.d.ts +3 -0
  16. package/esm/orderly/orderlyHooks.d.ts.map +1 -1
  17. package/esm/orderly/orderlyHooks.js +2 -0
  18. package/esm/orderly/orderlyHooks.js.map +1 -0
  19. package/esm/orderly/useAccountInfo.js +3 -1
  20. package/esm/orderly/useAccountInfo.js.map +1 -0
  21. package/esm/orderly/useChain.js +16 -9
  22. package/esm/orderly/useChain.js.map +1 -0
  23. package/esm/orderly/useChains.d.ts +11 -12
  24. package/esm/orderly/useChains.d.ts.map +1 -1
  25. package/esm/orderly/useChains.js +68 -46
  26. package/esm/orderly/useChains.js.map +1 -0
  27. package/esm/orderly/useCollateral.d.ts +3 -4
  28. package/esm/orderly/useCollateral.d.ts.map +1 -1
  29. package/esm/orderly/useCollateral.js +53 -20
  30. package/esm/orderly/useCollateral.js.map +1 -0
  31. package/esm/orderly/useDeposit.js +123 -125
  32. package/esm/orderly/useDeposit.js.map +1 -0
  33. package/esm/orderly/useFundingRate.js +14 -13
  34. package/esm/orderly/useFundingRate.js.map +1 -0
  35. package/esm/orderly/useFundingRates.js +6 -4
  36. package/esm/orderly/useFundingRates.js.map +1 -0
  37. package/esm/orderly/useHoldingStream.js +19 -15
  38. package/esm/orderly/useHoldingStream.js.map +1 -0
  39. package/esm/orderly/useIndexPrice.js +7 -5
  40. package/esm/orderly/useIndexPrice.js.map +1 -0
  41. package/esm/orderly/useLeverage.js +9 -12
  42. package/esm/orderly/useLeverage.js.map +1 -0
  43. package/esm/orderly/useMarginRatio.js +27 -13
  44. package/esm/orderly/useMarginRatio.js.map +1 -0
  45. package/esm/orderly/useMarkPrice.js +13 -7
  46. package/esm/orderly/useMarkPrice.js.map +1 -0
  47. package/esm/orderly/useMarkPricesStream.d.ts +1 -1
  48. package/esm/orderly/useMarkPricesStream.d.ts.map +1 -1
  49. package/esm/orderly/useMarkPricesStream.js +9 -8
  50. package/esm/orderly/useMarkPricesStream.js.map +1 -0
  51. package/esm/orderly/useMarketTradeStream.js +33 -18
  52. package/esm/orderly/useMarketTradeStream.js.map +1 -0
  53. package/esm/orderly/useMarkets.js +144 -81
  54. package/esm/orderly/useMarkets.js.map +1 -0
  55. package/esm/orderly/useMarketsStream.js +23 -28
  56. package/esm/orderly/useMarketsStream.js.map +1 -0
  57. package/esm/orderly/useMaxQty.d.ts +6 -0
  58. package/esm/orderly/useMaxQty.d.ts.map +1 -1
  59. package/esm/orderly/useMaxQty.js +26 -18
  60. package/esm/orderly/useMaxQty.js.map +1 -0
  61. package/esm/orderly/useOpenInterest.js +7 -5
  62. package/esm/orderly/useOpenInterest.js.map +1 -0
  63. package/esm/orderly/useOrderEntry.js +182 -160
  64. package/esm/orderly/useOrderEntry.js.map +1 -0
  65. package/esm/orderly/useOrderStream.js +85 -66
  66. package/esm/orderly/useOrderStream.js.map +1 -0
  67. package/esm/orderly/useOrderbookStream.d.ts +2 -3
  68. package/esm/orderly/useOrderbookStream.d.ts.map +1 -1
  69. package/esm/orderly/useOrderbookStream.js +173 -103
  70. package/esm/orderly/useOrderbookStream.js.map +1 -0
  71. package/esm/orderly/usePositionStream.js +82 -62
  72. package/esm/orderly/usePositionStream.js.map +1 -0
  73. package/esm/orderly/usePrivateDataObserver.js +55 -48
  74. package/esm/orderly/usePrivateDataObserver.js.map +1 -0
  75. package/esm/orderly/useSettleSubscription.js +8 -6
  76. package/esm/orderly/useSettleSubscription.js.map +1 -0
  77. package/esm/orderly/useSymbolPriceRange.js +14 -8
  78. package/esm/orderly/useSymbolPriceRange.js.map +1 -0
  79. package/esm/orderly/useSymbolsInfo.js +7 -5
  80. package/esm/orderly/useSymbolsInfo.js.map +1 -0
  81. package/esm/orderly/useTickerStream.d.ts +5 -1
  82. package/esm/orderly/useTickerStream.d.ts.map +1 -1
  83. package/esm/orderly/useTickerStream.js +26 -29
  84. package/esm/orderly/useTickerStream.js.map +1 -0
  85. package/esm/orderly/useWalletSubscription.js +8 -6
  86. package/esm/orderly/useWalletSubscription.js.map +1 -0
  87. package/esm/orderly/useWithdraw.js +19 -11
  88. package/esm/orderly/useWithdraw.js.map +1 -0
  89. package/esm/orderlyContext.d.ts +8 -1
  90. package/esm/orderlyContext.d.ts.map +1 -1
  91. package/esm/orderlyContext.js +2 -1
  92. package/esm/orderlyContext.js.map +1 -0
  93. package/esm/services/dataCenter.js +10 -8
  94. package/esm/services/dataCenter.js.map +1 -0
  95. package/esm/services/painter/backgroundPaint.js +11 -14
  96. package/esm/services/painter/backgroundPaint.js.map +1 -0
  97. package/esm/services/painter/basePaint.js +5 -1
  98. package/esm/services/painter/basePaint.js.map +1 -0
  99. package/esm/services/painter/dataPaint.js +53 -50
  100. package/esm/services/painter/dataPaint.js.map +1 -0
  101. package/esm/services/painter/layout.config.js +15 -13
  102. package/esm/services/painter/layout.config.js.map +1 -0
  103. package/esm/services/painter/painter.js +14 -13
  104. package/esm/services/painter/painter.js.map +1 -0
  105. package/esm/services/painter/resource.js +6 -4
  106. package/esm/services/painter/resource.js.map +1 -0
  107. package/esm/statusProvider.js +10 -3
  108. package/esm/statusProvider.js.map +1 -0
  109. package/esm/unuse/apiPrefixMiddleware.js +18 -16
  110. package/esm/unuse/apiPrefixMiddleware.js.map +1 -0
  111. package/esm/unuse/fn.js +3 -1
  112. package/esm/unuse/fn.js.map +1 -0
  113. package/esm/unuse/useBalance.js +6 -4
  114. package/esm/unuse/useBalance.js.map +1 -0
  115. package/esm/unuse/useFetures.js +26 -18
  116. package/esm/unuse/useFetures.js.map +1 -0
  117. package/esm/unuse/useRunOnce.js +10 -7
  118. package/esm/unuse/useRunOnce.js.map +1 -0
  119. package/esm/unuse/useSyncEnd.js +5 -4
  120. package/esm/unuse/useSyncEnd.js.map +1 -0
  121. package/esm/unuse/useTokenInfo.js +7 -5
  122. package/esm/unuse/useTokenInfo.js.map +1 -0
  123. package/esm/unuse/useUnsettlementPnL.js +7 -3
  124. package/esm/unuse/useUnsettlementPnL.js.map +1 -0
  125. package/esm/useAccount.js +18 -21
  126. package/esm/useAccount.js.map +1 -0
  127. package/esm/useAccountInstance.js +6 -7
  128. package/esm/useAccountInstance.js.map +1 -0
  129. package/esm/useBoolean.js +14 -5
  130. package/esm/useBoolean.js.map +1 -0
  131. package/esm/useConfig.js +3 -1
  132. package/esm/useConfig.js.map +1 -0
  133. package/esm/useEventEmitter.js +4 -2
  134. package/esm/useEventEmitter.js.map +1 -0
  135. package/esm/useLazyQuery.js +6 -7
  136. package/esm/useLazyQuery.js.map +1 -0
  137. package/esm/useLocalStorage.js +30 -20
  138. package/esm/useLocalStorage.js.map +1 -0
  139. package/esm/useMediaQuery.js +11 -9
  140. package/esm/useMediaQuery.js.map +1 -0
  141. package/esm/useMutation.js +26 -37
  142. package/esm/useMutation.js.map +1 -0
  143. package/esm/useObserve.js +4 -4
  144. package/esm/useObserve.js.map +1 -0
  145. package/esm/useParamsCheck.js +8 -10
  146. package/esm/useParamsCheck.js.map +1 -0
  147. package/esm/usePoster.js +56 -45
  148. package/esm/usePoster.js.map +1 -0
  149. package/esm/usePreloadData.js +9 -5
  150. package/esm/usePreloadData.js.map +1 -0
  151. package/esm/usePrivateInfiniteQuery.js +15 -9
  152. package/esm/usePrivateInfiniteQuery.js.map +1 -0
  153. package/esm/usePrivateQuery.js +15 -8
  154. package/esm/usePrivateQuery.js.map +1 -0
  155. package/esm/useQuery.js +6 -5
  156. package/esm/useQuery.js.map +1 -0
  157. package/esm/useSessionStorage.js +28 -19
  158. package/esm/useSessionStorage.js.map +1 -0
  159. package/esm/useWS.js +15 -13
  160. package/esm/useWS.js.map +1 -0
  161. package/esm/useWsStatus.js +12 -12
  162. package/esm/useWsStatus.js.map +1 -0
  163. package/esm/utils/createGetter.js +8 -8
  164. package/esm/utils/createGetter.js.map +1 -0
  165. package/esm/utils/createOrder.d.ts +1 -0
  166. package/esm/utils/createOrder.d.ts.map +1 -1
  167. package/esm/utils/createOrder.js +59 -43
  168. package/esm/utils/createOrder.js.map +1 -0
  169. package/esm/utils/dev.js +6 -4
  170. package/esm/utils/dev.js.map +1 -0
  171. package/esm/utils/fetcher.js +3 -1
  172. package/esm/utils/fetcher.js.map +1 -0
  173. package/esm/utils/json.js +3 -2
  174. package/esm/utils/json.js.map +1 -0
  175. package/esm/utils/orderEntryHelper.js +92 -63
  176. package/esm/utils/orderEntryHelper.js.map +1 -0
  177. package/esm/utils/parseHolding.js +10 -6
  178. package/esm/utils/parseHolding.js.map +1 -0
  179. package/esm/utils/swr.js +114 -104
  180. package/esm/utils/swr.js.map +1 -0
  181. package/esm/version.d.ts +1 -1
  182. package/esm/version.js +4 -3
  183. package/esm/version.js.map +1 -0
  184. package/esm/walletConnectorContext.js +4 -2
  185. package/esm/walletConnectorContext.js.map +1 -0
  186. package/lib/configProvider.d.ts +7 -1
  187. package/lib/configProvider.d.ts.map +1 -1
  188. package/lib/configProvider.js +108 -56
  189. package/lib/configProvider.js.map +1 -0
  190. package/lib/dataProvider.js +50 -29
  191. package/lib/dataProvider.js.map +1 -0
  192. package/lib/index.d.ts +1 -0
  193. package/lib/index.d.ts.map +1 -1
  194. package/lib/index.js +191 -88
  195. package/lib/index.js.map +1 -0
  196. package/lib/middleware/signatureMiddleware.js +22 -15
  197. package/lib/middleware/signatureMiddleware.js.map +1 -0
  198. package/lib/orderly/orderbook.service.js +59 -33
  199. package/lib/orderly/orderbook.service.js.map +1 -0
  200. package/lib/orderly/orderlyHooks.d.ts +3 -0
  201. package/lib/orderly/orderlyHooks.d.ts.map +1 -1
  202. package/lib/orderly/orderlyHooks.js +124 -57
  203. package/lib/orderly/orderlyHooks.js.map +1 -0
  204. package/lib/orderly/useAccountInfo.js +14 -6
  205. package/lib/orderly/useAccountInfo.js.map +1 -0
  206. package/lib/orderly/useChain.js +30 -17
  207. package/lib/orderly/useChain.js.map +1 -0
  208. package/lib/orderly/useChains.d.ts +11 -12
  209. package/lib/orderly/useChains.d.ts.map +1 -1
  210. package/lib/orderly/useChains.js +100 -59
  211. package/lib/orderly/useChains.js.map +1 -0
  212. package/lib/orderly/useCollateral.d.ts +3 -4
  213. package/lib/orderly/useCollateral.d.ts.map +1 -1
  214. package/lib/orderly/useCollateral.js +81 -42
  215. package/lib/orderly/useCollateral.js.map +1 -0
  216. package/lib/orderly/useDeposit.js +154 -150
  217. package/lib/orderly/useDeposit.js.map +1 -0
  218. package/lib/orderly/useFundingRate.js +29 -22
  219. package/lib/orderly/useFundingRate.js.map +1 -0
  220. package/lib/orderly/useFundingRates.js +19 -11
  221. package/lib/orderly/useFundingRates.js.map +1 -0
  222. package/lib/orderly/useHoldingStream.js +39 -27
  223. package/lib/orderly/useHoldingStream.js.map +1 -0
  224. package/lib/orderly/useIndexPrice.js +24 -14
  225. package/lib/orderly/useIndexPrice.js.map +1 -0
  226. package/lib/orderly/useLeverage.js +27 -24
  227. package/lib/orderly/useLeverage.js.map +1 -0
  228. package/lib/orderly/useMarginRatio.js +49 -29
  229. package/lib/orderly/useMarginRatio.js.map +1 -0
  230. package/lib/orderly/useMarkPrice.js +26 -15
  231. package/lib/orderly/useMarkPrice.js.map +1 -0
  232. package/lib/orderly/useMarkPricesStream.d.ts +1 -1
  233. package/lib/orderly/useMarkPricesStream.d.ts.map +1 -1
  234. package/lib/orderly/useMarkPricesStream.js +26 -17
  235. package/lib/orderly/useMarkPricesStream.js.map +1 -0
  236. package/lib/orderly/useMarketTradeStream.js +47 -26
  237. package/lib/orderly/useMarketTradeStream.js.map +1 -0
  238. package/lib/orderly/useMarkets.js +172 -95
  239. package/lib/orderly/useMarkets.js.map +1 -0
  240. package/lib/orderly/useMarketsStream.js +44 -41
  241. package/lib/orderly/useMarketsStream.js.map +1 -0
  242. package/lib/orderly/useMaxQty.d.ts +6 -0
  243. package/lib/orderly/useMaxQty.d.ts.map +1 -1
  244. package/lib/orderly/useMaxQty.js +52 -43
  245. package/lib/orderly/useMaxQty.js.map +1 -0
  246. package/lib/orderly/useOpenInterest.js +24 -14
  247. package/lib/orderly/useOpenInterest.js.map +1 -0
  248. package/lib/orderly/useOrderEntry.js +238 -210
  249. package/lib/orderly/useOrderEntry.js.map +1 -0
  250. package/lib/orderly/useOrderStream.js +111 -84
  251. package/lib/orderly/useOrderStream.js.map +1 -0
  252. package/lib/orderly/useOrderbookStream.d.ts +2 -3
  253. package/lib/orderly/useOrderbookStream.d.ts.map +1 -1
  254. package/lib/orderly/useOrderbookStream.js +227 -148
  255. package/lib/orderly/useOrderbookStream.js.map +1 -0
  256. package/lib/orderly/usePositionStream.js +134 -100
  257. package/lib/orderly/usePositionStream.js.map +1 -0
  258. package/lib/orderly/usePrivateDataObserver.js +76 -63
  259. package/lib/orderly/usePrivateDataObserver.js.map +1 -0
  260. package/lib/orderly/useSettleSubscription.js +25 -15
  261. package/lib/orderly/useSettleSubscription.js.map +1 -0
  262. package/lib/orderly/useSymbolPriceRange.js +29 -23
  263. package/lib/orderly/useSymbolPriceRange.js.map +1 -0
  264. package/lib/orderly/useSymbolsInfo.js +23 -15
  265. package/lib/orderly/useSymbolsInfo.js.map +1 -0
  266. package/lib/orderly/useTickerStream.d.ts +5 -1
  267. package/lib/orderly/useTickerStream.d.ts.map +1 -1
  268. package/lib/orderly/useTickerStream.js +51 -48
  269. package/lib/orderly/useTickerStream.js.map +1 -0
  270. package/lib/orderly/useWalletSubscription.js +25 -15
  271. package/lib/orderly/useWalletSubscription.js.map +1 -0
  272. package/lib/orderly/useWithdraw.js +36 -22
  273. package/lib/orderly/useWithdraw.js.map +1 -0
  274. package/lib/orderlyContext.d.ts +8 -1
  275. package/lib/orderlyContext.d.ts.map +1 -1
  276. package/lib/orderlyContext.js +22 -6
  277. package/lib/orderlyContext.js.map +1 -0
  278. package/lib/services/dataCenter.js +15 -11
  279. package/lib/services/dataCenter.js.map +1 -0
  280. package/lib/services/painter/backgroundPaint.js +21 -18
  281. package/lib/services/painter/backgroundPaint.js.map +1 -0
  282. package/lib/services/painter/basePaint.js +14 -4
  283. package/lib/services/painter/basePaint.js.map +1 -0
  284. package/lib/services/painter/dataPaint.js +67 -58
  285. package/lib/services/painter/dataPaint.js.map +1 -0
  286. package/lib/services/painter/layout.config.js +25 -16
  287. package/lib/services/painter/layout.config.js.map +1 -0
  288. package/lib/services/painter/painter.js +27 -20
  289. package/lib/services/painter/painter.js.map +1 -0
  290. package/lib/services/painter/resource.js +15 -7
  291. package/lib/services/painter/resource.js.map +1 -0
  292. package/lib/statusProvider.js +31 -10
  293. package/lib/statusProvider.js.map +1 -0
  294. package/lib/unuse/apiPrefixMiddleware.js +30 -22
  295. package/lib/unuse/apiPrefixMiddleware.js.map +1 -0
  296. package/lib/unuse/fn.js +14 -5
  297. package/lib/unuse/fn.js.map +1 -0
  298. package/lib/unuse/useBalance.js +23 -13
  299. package/lib/unuse/useBalance.js.map +1 -0
  300. package/lib/unuse/useFetures.js +41 -28
  301. package/lib/unuse/useFetures.js.map +1 -0
  302. package/lib/unuse/useRunOnce.js +61 -11
  303. package/lib/unuse/useRunOnce.js.map +1 -0
  304. package/lib/unuse/useSyncEnd.js +17 -10
  305. package/lib/unuse/useSyncEnd.js.map +1 -0
  306. package/lib/unuse/useTokenInfo.js +20 -12
  307. package/lib/unuse/useTokenInfo.js.map +1 -0
  308. package/lib/unuse/useUnsettlementPnL.js +21 -11
  309. package/lib/unuse/useUnsettlementPnL.js.map +1 -0
  310. package/lib/useAccount.js +32 -29
  311. package/lib/useAccount.js.map +1 -0
  312. package/lib/useAccountInstance.js +27 -20
  313. package/lib/useAccountInstance.js.map +1 -0
  314. package/lib/useBoolean.js +25 -10
  315. package/lib/useBoolean.js.map +1 -0
  316. package/lib/useConfig.js +15 -7
  317. package/lib/useConfig.js.map +1 -0
  318. package/lib/useEventEmitter.js +23 -13
  319. package/lib/useEventEmitter.js.map +1 -0
  320. package/lib/useLazyQuery.js +25 -23
  321. package/lib/useLazyQuery.js.map +1 -0
  322. package/lib/useLocalStorage.js +44 -28
  323. package/lib/useLocalStorage.js.map +1 -0
  324. package/lib/useMediaQuery.js +22 -14
  325. package/lib/useMediaQuery.js.map +1 -0
  326. package/lib/useMutation.js +47 -52
  327. package/lib/useMutation.js.map +1 -0
  328. package/lib/useObserve.js +22 -8
  329. package/lib/useObserve.js.map +1 -0
  330. package/lib/useParamsCheck.js +18 -14
  331. package/lib/useParamsCheck.js.map +1 -0
  332. package/lib/usePoster.js +80 -74
  333. package/lib/usePoster.js.map +1 -0
  334. package/lib/usePreloadData.js +21 -11
  335. package/lib/usePreloadData.js.map +1 -0
  336. package/lib/usePrivateInfiniteQuery.js +36 -22
  337. package/lib/usePrivateInfiniteQuery.js.map +1 -0
  338. package/lib/usePrivateQuery.js +35 -25
  339. package/lib/usePrivateQuery.js.map +1 -0
  340. package/lib/useQuery.js +24 -20
  341. package/lib/useQuery.js.map +1 -0
  342. package/lib/useSessionStorage.js +41 -26
  343. package/lib/useSessionStorage.js.map +1 -0
  344. package/lib/useWS.js +42 -32
  345. package/lib/useWS.js.map +1 -0
  346. package/lib/useWsStatus.js +34 -20
  347. package/lib/useWsStatus.js.map +1 -0
  348. package/lib/utils/createGetter.js +19 -14
  349. package/lib/utils/createGetter.js.map +1 -0
  350. package/lib/utils/createOrder.d.ts +1 -0
  351. package/lib/utils/createOrder.d.ts.map +1 -1
  352. package/lib/utils/createOrder.js +133 -82
  353. package/lib/utils/createOrder.js.map +1 -0
  354. package/lib/utils/dev.js +13 -9
  355. package/lib/utils/dev.js.map +1 -0
  356. package/lib/utils/fetcher.js +13 -5
  357. package/lib/utils/fetcher.js.map +1 -0
  358. package/lib/utils/json.js +12 -5
  359. package/lib/utils/json.js.map +1 -0
  360. package/lib/utils/orderEntryHelper.js +125 -82
  361. package/lib/utils/orderEntryHelper.js.map +1 -0
  362. package/lib/utils/parseHolding.js +19 -9
  363. package/lib/utils/parseHolding.js.map +1 -0
  364. package/lib/utils/swr.js +134 -111
  365. package/lib/utils/swr.js.map +1 -0
  366. package/lib/version.d.ts +1 -1
  367. package/lib/version.js +13 -4
  368. package/lib/version.js.map +1 -0
  369. package/lib/walletConnectorContext.js +23 -7
  370. package/lib/walletConnectorContext.js.map +1 -0
  371. package/package.json +17 -9
@@ -2,16 +2,12 @@ import { commify } from "@orderly.network/utils";
2
2
  import { BasePaint } from "./basePaint";
3
3
  import { path } from "ramda";
4
4
  export class DataPaint extends BasePaint {
5
- constructor() {
6
- super(...arguments);
7
- this.positionInfoCellWidth = 110;
8
- this.DEFAULT_PROFIT_COLOR = "rgb(0,181,159)";
9
- this.DEFAULT_LOSS_COLOR = "rgb(255,103,194)";
10
- this.transformTop = 0;
11
- }
5
+ positionInfoCellWidth = 110;
6
+ DEFAULT_PROFIT_COLOR = "rgb(0,181,159)";
7
+ DEFAULT_LOSS_COLOR = "rgb(255,103,194)";
8
+ transformTop = 0;
12
9
  async draw(options) {
13
- const needDrawDetails = Array.isArray(options.data?.position?.informations) &&
14
- (options.data?.position?.informations?.length ?? 0) > 0;
10
+ const needDrawDetails = Array.isArray(options.data?.position?.informations) && (options.data?.position?.informations?.length ?? 0) > 0;
15
11
  // const hasMessage = !!options.data?.message;
16
12
  const hasMessage = true;
17
13
  this.transformTop = hasMessage ? 0 : needDrawDetails ? -40 : -150;
@@ -38,7 +34,10 @@ export class DataPaint extends BasePaint {
38
34
  }
39
35
  drawMessage(options) {
40
36
  // console.log("draw message", options);
41
- const layout = path(["layout", "message"], options);
37
+ const layout = path([
38
+ "layout",
39
+ "message"
40
+ ], options);
42
41
  const { position } = layout;
43
42
  this._drawText(`"${options.data?.message}"`, {
44
43
  color: layout.color,
@@ -46,11 +45,14 @@ export class DataPaint extends BasePaint {
46
45
  top: this._ratio(position.top),
47
46
  left: this._ratio(position.left),
48
47
  textBaseline: "top",
49
- fontFamily: options.fontFamily,
48
+ fontFamily: options.fontFamily
50
49
  });
51
50
  }
52
51
  drawPosition(options, offsetTop = 0) {
53
- const layout = path(["layout", "position"], options);
52
+ const layout = path([
53
+ "layout",
54
+ "position"
55
+ ], options);
54
56
  const { position, fontSize = 14 } = layout;
55
57
  let left = this._ratio(position.left);
56
58
  let top = layout.position.top + offsetTop + this.transformTop;
@@ -58,13 +60,11 @@ export class DataPaint extends BasePaint {
58
60
  // draw position side;
59
61
  if (typeof options.data?.position.side !== "undefined") {
60
62
  prevElementBoundingBox = this._drawText(options.data.position.side, {
61
- color: options.data?.position.side.toUpperCase() === "LONG"
62
- ? this.DEFAULT_PROFIT_COLOR
63
- : this.DEFAULT_LOSS_COLOR,
63
+ color: options.data?.position.side.toUpperCase() === "LONG" ? this.DEFAULT_PROFIT_COLOR : this.DEFAULT_LOSS_COLOR,
64
64
  left,
65
65
  top: this._ratio(top),
66
66
  fontSize: this._ratio(fontSize),
67
- fontFamily: options.fontFamily,
67
+ fontFamily: options.fontFamily
68
68
  });
69
69
  }
70
70
  if (typeof options.data?.position.symbol !== "undefined") {
@@ -75,7 +75,7 @@ export class DataPaint extends BasePaint {
75
75
  left,
76
76
  top: this._ratio(top),
77
77
  fontSize: this._ratio(fontSize),
78
- fontFamily: options.fontFamily,
78
+ fontFamily: options.fontFamily
79
79
  });
80
80
  }
81
81
  left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);
@@ -84,7 +84,7 @@ export class DataPaint extends BasePaint {
84
84
  left: left,
85
85
  top: this._ratio(top),
86
86
  fontSize: this._ratio(fontSize),
87
- fontFamily: options.fontFamily,
87
+ fontFamily: options.fontFamily
88
88
  });
89
89
  }
90
90
  if (typeof options.data?.position.leverage !== "undefined") {
@@ -95,7 +95,7 @@ export class DataPaint extends BasePaint {
95
95
  left,
96
96
  top: this._ratio(top),
97
97
  fontSize: this._ratio(fontSize),
98
- fontFamily: options.fontFamily,
98
+ fontFamily: options.fontFamily
99
99
  });
100
100
  }
101
101
  left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);
@@ -104,13 +104,16 @@ export class DataPaint extends BasePaint {
104
104
  left,
105
105
  top: this._ratio(top),
106
106
  fontSize: this._ratio(fontSize),
107
- fontFamily: options.fontFamily,
107
+ fontFamily: options.fontFamily
108
108
  });
109
109
  }
110
110
  }
111
111
  drawUnrealizedPnL(options, offsetTop = 0) {
112
112
  // reset left value;
113
- const layout = path(["layout", "unrealizedPnl"], options);
113
+ const layout = path([
114
+ "layout",
115
+ "unrealizedPnl"
116
+ ], options);
114
117
  const { position } = layout;
115
118
  let left = this._ratio(position.left);
116
119
  let prevElementBoundingBox = {};
@@ -119,14 +122,12 @@ export class DataPaint extends BasePaint {
119
122
  if (typeof options.data?.position.ROI !== "undefined") {
120
123
  const prefix = options.data?.position.ROI > 0 ? "+" : "";
121
124
  prevElementBoundingBox = this._drawText(`${prefix}${commify(options.data?.position.ROI)}%`, {
122
- color: prefix === "+"
123
- ? options.profitColor || this.DEFAULT_PROFIT_COLOR
124
- : options.lossColor || this.DEFAULT_LOSS_COLOR,
125
+ color: prefix === "+" ? options.profitColor || this.DEFAULT_PROFIT_COLOR : options.lossColor || this.DEFAULT_LOSS_COLOR,
125
126
  left,
126
127
  top: this._ratio(top),
127
128
  fontSize: this._ratio(layout.fontSize),
128
129
  fontWeight: 700,
129
- fontFamily: options.fontFamily,
130
+ fontFamily: options.fontFamily
130
131
  });
131
132
  }
132
133
  // unrelPnL
@@ -137,46 +138,40 @@ export class DataPaint extends BasePaint {
137
138
  if (prevElementBoundingBox.width) {
138
139
  left += (prevElementBoundingBox.width ?? 0) + this._ratio(8);
139
140
  text = `(${text})`;
140
- }
141
- else {
141
+ } else {
142
142
  left = this._ratio(position.left);
143
143
  fontWeight = 700;
144
144
  }
145
- const color = typeof options.data.position.ROI === "undefined"
146
- ? prefix === "+"
147
- ? options.profitColor || this.DEFAULT_PROFIT_COLOR
148
- : options.lossColor || this.DEFAULT_LOSS_COLOR
149
- : layout.secondaryColor;
150
- const fontSize = typeof options.data.position.ROI === "undefined"
151
- ? this._ratio(layout.fontSize)
152
- : this._ratio(layout.secondaryFontSize);
145
+ const color = typeof options.data.position.ROI === "undefined" ? prefix === "+" ? options.profitColor || this.DEFAULT_PROFIT_COLOR : options.lossColor || this.DEFAULT_LOSS_COLOR : layout.secondaryColor;
146
+ const fontSize = typeof options.data.position.ROI === "undefined" ? this._ratio(layout.fontSize) : this._ratio(layout.secondaryFontSize);
153
147
  prevElementBoundingBox = this._drawText(text, {
154
148
  color,
155
149
  left,
156
150
  top: this._ratio(top),
157
151
  fontSize,
158
152
  fontWeight,
159
- fontFamily: options.fontFamily,
153
+ fontFamily: options.fontFamily
160
154
  });
161
155
  }
162
156
  }
163
157
  drawInformations(options) {
164
- const layout = path(["layout", "informations"], options);
158
+ const layout = path([
159
+ "layout",
160
+ "informations"
161
+ ], options);
165
162
  const { position } = layout;
166
163
  const isVertical = (options.data?.position.informations.length ?? 0) === 2;
167
- options.data?.position.informations.forEach((info, index) => {
164
+ options.data?.position.informations.forEach((info, index)=>{
168
165
  // let cellWidth = this.positionInfoCellWidth;
169
- let left = position.left + (index % 2) * this.positionInfoCellWidth;
166
+ let left = position.left + index % 2 * this.positionInfoCellWidth;
170
167
  // let top = (position.top as number) + (index / 2) * 38 + this.transformTop;
171
- let top = position.top +
172
- Math.floor(index / 2) * 38 +
173
- this.transformTop;
168
+ let top = position.top + Math.floor(index / 2) * 38 + this.transformTop;
174
169
  this._drawText(info.title, {
175
170
  left: this._ratio(left),
176
171
  top: this._ratio(top),
177
172
  fontSize: this._ratio(10),
178
173
  color: layout.labelColor,
179
- fontFamily: options.fontFamily,
174
+ fontFamily: options.fontFamily
180
175
  });
181
176
  this._drawText(info.value, {
182
177
  left: this._ratio(left),
@@ -184,12 +179,15 @@ export class DataPaint extends BasePaint {
184
179
  fontSize: this._ratio(layout.fontSize),
185
180
  fontWeight: 500,
186
181
  color: layout.color,
187
- fontFamily: options.fontFamily,
182
+ fontFamily: options.fontFamily
188
183
  });
189
184
  });
190
185
  }
191
186
  drawDomainUrl(options) {
192
- const layout = path(["layout", "domain"], options);
187
+ const layout = path([
188
+ "layout",
189
+ "domain"
190
+ ], options);
193
191
  const { position } = layout;
194
192
  const top = this.painter.height - position.bottom;
195
193
  this._drawText(options.data?.domain, {
@@ -199,15 +197,18 @@ export class DataPaint extends BasePaint {
199
197
  color: options.brandColor ?? this.DEFAULT_PROFIT_COLOR,
200
198
  fontFamily: options.fontFamily,
201
199
  textBaseline: layout.textBaseline,
202
- fontWeight: 600,
200
+ fontWeight: 600
203
201
  });
204
202
  }
205
203
  drawPositionTime(options) {
206
- const layout = path(["layout", "updateTime"], options);
204
+ const layout = path([
205
+ "layout",
206
+ "updateTime"
207
+ ], options);
207
208
  const { position } = layout;
208
209
  const top = this.painter.height - position.bottom;
209
210
  const left = position.left;
210
- console.log("*******", left, top, options.data?.updateTime);
211
+ ;
211
212
  this._drawText(options.data?.updateTime, {
212
213
  left: this._ratio(left),
213
214
  top: this._ratio(top),
@@ -215,12 +216,12 @@ export class DataPaint extends BasePaint {
215
216
  color: layout.color,
216
217
  textAlign: layout.textAlign,
217
218
  fontFamily: options.fontFamily,
218
- textBaseline: layout.textBaseline,
219
+ textBaseline: layout.textBaseline
219
220
  });
220
221
  }
221
222
  _drawText(str, options) {
222
223
  let boundingBox;
223
- const { left = 30, top = 30, fontSize = 13, fontWeight = 500, color = "black", textBaseline = "middle", textAlign = "start", } = options ?? {};
224
+ const { left = 30, top = 30, fontSize = 13, fontWeight = 500, color = "black", textBaseline = "middle", textAlign = "start" } = options ?? {};
224
225
  this.ctx.save();
225
226
  // "Nunito Sans",-apple-system,"San Francisco",BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Helvetica,Arial,sans-serif
226
227
  this.ctx.font = `${fontWeight} ${fontSize}px ${options?.fontFamily}`;
@@ -236,3 +237,5 @@ export class DataPaint extends BasePaint {
236
237
  return num * this.painter.ratio;
237
238
  }
238
239
  }
240
+
241
+ //# sourceMappingURL=dataPaint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/painter/dataPaint.ts"],"sourcesContent":["import { commify } from \"@orderly.network/utils\";\nimport { BasePaint, DrawOptions, layoutInfo } from \"./basePaint\";\nimport { path } from \"ramda\";\n\nexport class DataPaint extends BasePaint {\n private positionInfoCellWidth = 110;\n\n private DEFAULT_PROFIT_COLOR = \"rgb(0,181,159)\";\n private DEFAULT_LOSS_COLOR = \"rgb(255,103,194)\";\n\n private transformTop = 0;\n\n async draw(options: DrawOptions) {\n const needDrawDetails =\n Array.isArray(options.data?.position?.informations) &&\n (options.data?.position?.informations?.length ?? 0) > 0;\n\n // const hasMessage = !!options.data?.message;\n const hasMessage = true;\n\n this.transformTop = hasMessage ? 0 : needDrawDetails ? -40 : -150;\n\n // If position details are not displayed, the position PNL information will be margin\n // const offsetTop = hasMessage ? 50 : 100;\n const offsetTop = 100;\n // const offsetMessage = hasMessage ? 0 : -50;\n\n if (!!options.data?.message) {\n this.drawMessage(options);\n }\n\n if (!!options.data?.position) {\n this.drawPosition(options, needDrawDetails ? 0 : offsetTop);\n }\n\n if (needDrawDetails) {\n this.drawInformations(options);\n }\n\n this.drawUnrealizedPnL(options, needDrawDetails ? 0 : offsetTop);\n\n if (!!options.data?.domain) {\n this.drawDomainUrl(options);\n }\n\n if (typeof options.data?.updateTime !== \"undefined\") {\n this.drawPositionTime(options);\n }\n }\n\n private drawMessage(options: DrawOptions) {\n // console.log(\"draw message\", options);\n\n const layout = path<layoutInfo>(\n [\"layout\", \"message\"],\n options\n ) as layoutInfo;\n const { position } = layout;\n\n this._drawText(`\"${options.data?.message!}\"`, {\n color: layout.color,\n fontSize: this._ratio(layout.fontSize as number),\n top: this._ratio(position.top!),\n left: this._ratio(position.left!),\n textBaseline: \"top\",\n fontFamily: options.fontFamily,\n });\n }\n private drawPosition(options: DrawOptions, offsetTop: number = 0) {\n const layout = path<layoutInfo>(\n [\"layout\", \"position\"],\n options\n ) as layoutInfo;\n const { position, fontSize = 14 } = layout;\n let left = this._ratio(position.left!);\n\n let top = layout.position.top! + offsetTop + this.transformTop;\n let prevElementBoundingBox: TextMetrics = {} as TextMetrics;\n\n // draw position side;\n\n if (typeof options.data?.position.side !== \"undefined\") {\n prevElementBoundingBox = this._drawText(options.data.position.side, {\n color:\n options.data?.position.side.toUpperCase() === \"LONG\"\n ? this.DEFAULT_PROFIT_COLOR\n : this.DEFAULT_LOSS_COLOR,\n left,\n top: this._ratio(top),\n fontSize: this._ratio(fontSize),\n fontFamily: options.fontFamily,\n });\n }\n\n if (typeof options.data?.position.symbol !== \"undefined\") {\n left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);\n\n if (prevElementBoundingBox.width) {\n prevElementBoundingBox = this._drawText(\"|\", {\n color: \"rgba(255,255,255,0.2)\",\n left,\n top: this._ratio(top),\n fontSize: this._ratio(fontSize),\n fontFamily: options.fontFamily,\n });\n }\n\n left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);\n prevElementBoundingBox = this._drawText(options.data?.position.symbol!, {\n color: layout.color,\n left: left,\n top: this._ratio(top),\n fontSize: this._ratio(fontSize),\n fontFamily: options.fontFamily,\n });\n }\n\n if (typeof options.data?.position.leverage !== \"undefined\") {\n left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);\n\n if (prevElementBoundingBox.width) {\n prevElementBoundingBox = this._drawText(\"|\", {\n color: \"rgba(255,255,255,0.2)\",\n left,\n top: this._ratio(top),\n fontSize: this._ratio(fontSize),\n fontFamily: options.fontFamily,\n });\n }\n left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);\n prevElementBoundingBox = this._drawText(\n `${options.data?.position.leverage}X`,\n {\n color: layout.color,\n left,\n top: this._ratio(top),\n fontSize: this._ratio(fontSize),\n fontFamily: options.fontFamily,\n }\n );\n }\n }\n\n private drawUnrealizedPnL(options: DrawOptions, offsetTop: number = 0) {\n // reset left value;\n const layout = path<layoutInfo>(\n [\"layout\", \"unrealizedPnl\"],\n options\n ) as layoutInfo & {\n secondaryColor: string;\n secondaryFontSize: number;\n };\n const { position } = layout;\n let left = this._ratio(position.left!);\n let prevElementBoundingBox: TextMetrics = {} as TextMetrics;\n\n const top = (position.top ?? 0) + offsetTop + this.transformTop;\n\n // ROI\n if (typeof options.data?.position.ROI !== \"undefined\") {\n const prefix = options.data?.position.ROI! > 0 ? \"+\" : \"\";\n prevElementBoundingBox = this._drawText(\n `${prefix}${commify(options.data?.position.ROI)}%`,\n {\n color:\n prefix === \"+\"\n ? options.profitColor || this.DEFAULT_PROFIT_COLOR\n : options.lossColor || this.DEFAULT_LOSS_COLOR,\n left,\n top: this._ratio(top),\n\n fontSize: this._ratio(layout.fontSize as number),\n fontWeight: 700,\n fontFamily: options.fontFamily,\n }\n );\n }\n // unrelPnL\n if (typeof options.data?.position.pnl !== \"undefined\") {\n const prefix = options.data?.position.pnl! > 0 ? \"+\" : \"\";\n let text = `${prefix}${commify(options.data?.position.pnl)} ${\n options.data?.position.currency\n }`;\n let fontWeight = 600;\n\n if (prevElementBoundingBox.width) {\n left += (prevElementBoundingBox.width ?? 0) + this._ratio(8);\n text = `(${text})`;\n } else {\n left = this._ratio(position.left!);\n fontWeight = 700;\n }\n\n const color =\n typeof options.data.position.ROI === \"undefined\"\n ? prefix === \"+\"\n ? options.profitColor || this.DEFAULT_PROFIT_COLOR\n : options.lossColor || this.DEFAULT_LOSS_COLOR\n : layout.secondaryColor;\n\n const fontSize =\n typeof options.data.position.ROI === \"undefined\"\n ? this._ratio(layout.fontSize as number)\n : this._ratio(layout.secondaryFontSize as number);\n\n prevElementBoundingBox = this._drawText(text, {\n color,\n left,\n top: this._ratio(top),\n fontSize,\n fontWeight,\n fontFamily: options.fontFamily,\n });\n }\n }\n\n private drawInformations(options: DrawOptions) {\n const layout = path<layoutInfo>(\n [\"layout\", \"informations\"],\n options\n ) as layoutInfo & {\n labelColor?: string;\n };\n const { position } = layout;\n\n const isVertical = (options.data?.position.informations.length ?? 0) === 2;\n\n options.data?.position.informations.forEach((info, index) => {\n // let cellWidth = this.positionInfoCellWidth;\n let left = position.left! + (index % 2) * this.positionInfoCellWidth;\n // let top = (position.top as number) + (index / 2) * 38 + this.transformTop;\n let top =\n (position.top as number) +\n Math.floor(index / 2) * 38 +\n this.transformTop;\n\n this._drawText(info.title, {\n left: this._ratio(left),\n top: this._ratio(top),\n fontSize: this._ratio(10),\n color: layout.labelColor,\n fontFamily: options.fontFamily,\n });\n\n this._drawText(info.value, {\n left: this._ratio(left),\n top: this._ratio(top + 17),\n fontSize: this._ratio(layout.fontSize as number),\n fontWeight: 500,\n color: layout.color as string,\n fontFamily: options.fontFamily,\n });\n });\n }\n\n private drawDomainUrl(options: DrawOptions) {\n const layout = path<layoutInfo>(\n [\"layout\", \"domain\"],\n options\n ) as layoutInfo;\n const { position } = layout;\n const top = this.painter.height - position.bottom!;\n\n this._drawText(options.data?.domain!, {\n left: this._ratio(position.left!),\n top: this._ratio(top),\n fontSize: this._ratio(layout.fontSize as number),\n color: options.brandColor ?? this.DEFAULT_PROFIT_COLOR,\n fontFamily: options.fontFamily,\n textBaseline: layout.textBaseline,\n fontWeight: 600,\n });\n }\n\n private drawPositionTime(options: DrawOptions) {\n const layout = path<layoutInfo>(\n [\"layout\", \"updateTime\"],\n options\n ) as layoutInfo;\n const { position } = layout;\n const top = this.painter.height - position.bottom!;\n const left = position.left!;\n\n console.log(\"*******\", left, top, options.data?.updateTime);\n\n this._drawText(options.data?.updateTime!, {\n left: this._ratio(left),\n top: this._ratio(top),\n fontSize: this._ratio(layout.fontSize as number),\n color: layout.color as string,\n textAlign: layout.textAlign,\n fontFamily: options.fontFamily,\n textBaseline: layout.textBaseline,\n });\n }\n\n private _drawText(\n str: string,\n options?: {\n left?: number;\n top?: number;\n fontSize?: number;\n fontFamily?: string;\n fontWeight?: number;\n color?: string;\n textBaseline?: CanvasTextBaseline;\n textAlign?: CanvasTextAlign;\n }\n ): TextMetrics {\n let boundingBox: TextMetrics;\n const {\n left = 30,\n top = 30,\n fontSize = 13,\n fontWeight = 500,\n color = \"black\",\n textBaseline = \"middle\",\n textAlign = \"start\",\n } = options ?? {};\n\n this.ctx.save();\n // \"Nunito Sans\",-apple-system,\"San Francisco\",BlinkMacSystemFont,\"Segoe UI\",\"Helvetica Neue\",Helvetica,Arial,sans-serif\n this.ctx.font = `${fontWeight} ${fontSize}px ${options?.fontFamily}`;\n\n this.ctx.fillStyle = color;\n this.ctx.textBaseline = textBaseline;\n this.ctx.textAlign = textAlign;\n boundingBox = this.ctx.measureText(str);\n\n this.ctx.fillText(str, left, top);\n this.ctx.restore();\n\n return boundingBox;\n }\n\n private _ratio(num: number) {\n return num * this.painter.ratio;\n }\n}\n"],"names":["commify","BasePaint","path","DataPaint","positionInfoCellWidth","DEFAULT_PROFIT_COLOR","DEFAULT_LOSS_COLOR","transformTop","draw","options","needDrawDetails","Array","isArray","data","position","informations","length","hasMessage","offsetTop","message","drawMessage","drawPosition","drawInformations","drawUnrealizedPnL","domain","drawDomainUrl","updateTime","drawPositionTime","layout","_drawText","color","fontSize","_ratio","top","left","textBaseline","fontFamily","prevElementBoundingBox","side","toUpperCase","symbol","width","leverage","ROI","prefix","profitColor","lossColor","fontWeight","pnl","text","currency","secondaryColor","secondaryFontSize","isVertical","forEach","info","index","Math","floor","title","labelColor","value","painter","height","bottom","brandColor","textAlign","str","boundingBox","ctx","save","font","fillStyle","measureText","fillText","restore","num","ratio"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAACE,GAAG,CAACK,QAAQ,CAACP,KAAKjC,MAAMD;QAC7B,IAAI,CAACoC,GAAG,CAACM,OAAO;QAEhB,OAAOP;IACT;IAEQpC,OAAO4C,GAAW,EAAE;QAC1B,OAAOA,MAAM,IAAI,CAACd,OAAO,CAACe,KAAK;IACjC;AACF"}
@@ -5,8 +5,8 @@ export const DefaultLayoutConfig = {
5
5
  textBaseline: "bottom",
6
6
  position: {
7
7
  left: 20,
8
- bottom: 32,
9
- },
8
+ bottom: 32
9
+ }
10
10
  },
11
11
  message: {
12
12
  fontSize: 20,
@@ -14,16 +14,16 @@ export const DefaultLayoutConfig = {
14
14
  textBaseline: "top",
15
15
  position: {
16
16
  left: 20,
17
- top: 16,
18
- },
17
+ top: 16
18
+ }
19
19
  },
20
20
  position: {
21
21
  fontSize: 14,
22
22
  color: "rgba(255,255,255,0.98)",
23
23
  position: {
24
24
  left: 20,
25
- top: 70,
26
- },
25
+ top: 70
26
+ }
27
27
  },
28
28
  unrealizedPnl: {
29
29
  fontSize: 36,
@@ -32,8 +32,8 @@ export const DefaultLayoutConfig = {
32
32
  secondaryFontSize: 20,
33
33
  position: {
34
34
  left: 20,
35
- top: 110,
36
- },
35
+ top: 110
36
+ }
37
37
  },
38
38
  informations: {
39
39
  fontSize: 12,
@@ -41,8 +41,8 @@ export const DefaultLayoutConfig = {
41
41
  labelColor: "rgba(255,255,255,0.36)",
42
42
  position: {
43
43
  left: 20,
44
- top: 150,
45
- },
44
+ top: 150
45
+ }
46
46
  },
47
47
  updateTime: {
48
48
  fontSize: 10,
@@ -51,7 +51,9 @@ export const DefaultLayoutConfig = {
51
51
  textBaseline: "bottom",
52
52
  position: {
53
53
  left: 20,
54
- bottom: 17,
55
- },
56
- },
54
+ bottom: 17
55
+ }
56
+ }
57
57
  };
58
+
59
+ //# sourceMappingURL=layout.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/painter/layout.config.ts"],"sourcesContent":["import { type PosterLayoutConfig } from \"./basePaint\";\n\nexport const DefaultLayoutConfig: PosterLayoutConfig = {\n domain: {\n fontSize: 13,\n // color: undefined,\n textBaseline: \"bottom\",\n position: {\n left: 20,\n bottom: 32,\n },\n },\n message: {\n fontSize: 20,\n color: \"rgba(255, 255, 255, 0.98)\",\n textBaseline: \"top\",\n position: {\n left: 20,\n top: 16,\n },\n },\n position: {\n fontSize: 14,\n color: \"rgba(255,255,255,0.98)\",\n position: {\n left: 20,\n top: 70,\n },\n },\n unrealizedPnl: {\n fontSize: 36,\n color: \"rgba(255,255,255,0.5)\",\n secondaryColor: \"rgba(255,255,255,0.54)\",\n secondaryFontSize: 20,\n position: {\n left: 20,\n top: 110,\n },\n },\n informations: {\n fontSize: 12,\n color: \"rgba(255, 255, 255, 0.8)\",\n labelColor: \"rgba(255,255,255,0.36)\",\n position: {\n left: 20,\n top: 150,\n },\n },\n\n updateTime: {\n fontSize: 10,\n color: \"rgba(255,255,255,0.3)\",\n // textAlign: \"end\",\n textBaseline: \"bottom\",\n position: {\n left: 20,\n bottom: 17,\n },\n },\n};\n"],"names":["DefaultLayoutConfig","domain","fontSize","textBaseline","position","left","bottom","message","color","top","unrealizedPnl","secondaryColor","secondaryFontSize","informations","labelColor","updateTime"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,sBAA0C;IACrDC,QAAQ;QACNC,UAAU;QACV,oBAAoB;QACpBC,cAAc;QACdC,UAAU;YACRC,MAAM;YACNC,QAAQ;QACV;IACF;IACAC,SAAS;QACPL,UAAU;QACVM,OAAO;QACPL,cAAc;QACdC,UAAU;YACRC,MAAM;YACNI,KAAK;QACP;IACF;IACAL,UAAU;QACRF,UAAU;QACVM,OAAO;QACPJ,UAAU;YACRC,MAAM;YACNI,KAAK;QACP;IACF;IACAC,eAAe;QACbR,UAAU;QACVM,OAAO;QACPG,gBAAgB;QAChBC,mBAAmB;QACnBR,UAAU;YACRC,MAAM;YACNI,KAAK;QACP;IACF;IACAI,cAAc;QACZX,UAAU;QACVM,OAAO;QACPM,YAAY;QACZV,UAAU;YACRC,MAAM;YACNI,KAAK;QACP;IACF;IAEAM,YAAY;QACVb,UAAU;QACVM,OAAO;QACP,oBAAoB;QACpBL,cAAc;QACdC,UAAU;YACRC,MAAM;YACNC,QAAQ;QACV;IACF;AACF,EAAE"}
@@ -1,35 +1,34 @@
1
1
  import { BackgroundPaint } from "./backgroundPaint";
2
2
  import { DataPaint } from "./dataPaint";
3
3
  export class PosterPainter {
4
+ canvas;
5
+ ctx;
6
+ width;
7
+ height;
8
+ ratio;
4
9
  // resourceManager: Resource;
5
- constructor(canvas, options) {
6
- // console.log("PosterPainter constructor");
10
+ constructor(canvas, options){
7
11
  this.canvas = canvas;
8
12
  this.width = 0;
9
13
  this.height = 0;
14
+ // console.log("PosterPainter constructor");
10
15
  this.ctx = this.canvas.getContext("2d");
11
16
  this.width = this.canvas.width;
12
17
  this.height = this.canvas.height;
13
- this.ratio =
14
- options?.ratio ||
15
- (typeof window !== "undefined"
16
- ? Math.floor(window.devicePixelRatio)
17
- : 1) ||
18
- 1;
19
- console.log("this ratio", this.ratio);
18
+ this.ratio = options?.ratio || (typeof window !== "undefined" ? Math.floor(window.devicePixelRatio) : 1) || 1;
19
+ ;
20
20
  // render to high resolution
21
21
  this.canvas.width = this.width * this.ratio;
22
22
  this.canvas.height = this.height * this.ratio;
23
23
  this.canvas.style.width = this.width + "px";
24
24
  this.canvas.style.height = this.height + "px";
25
- //
25
+ //
26
26
  }
27
27
  draw(options) {
28
- requestAnimationFrame(() => this._draw.bind(this)(options));
28
+ requestAnimationFrame(()=>this._draw.bind(this)(options));
29
29
  }
30
30
  async _draw(options) {
31
- if (this.ctx === null)
32
- return;
31
+ if (this.ctx === null) return;
33
32
  // console.log("============ DRAW ============");
34
33
  // this.ctx.font = options.fontFamily!;
35
34
  // this.ctx.clearRect(0, 0, this.width * this.ratio, this.height * this.ratio);
@@ -40,3 +39,5 @@ export class PosterPainter {
40
39
  await new DataPaint(this.ctx, this).draw(options);
41
40
  }
42
41
  }
42
+
43
+ //# sourceMappingURL=painter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/painter/painter.ts"],"sourcesContent":["import { BackgroundPaint } from \"./backgroundPaint\";\nimport { DrawOptions } from \"./basePaint\";\nimport { DataPaint } from \"./dataPaint\";\nexport class PosterPainter {\n private ctx: CanvasRenderingContext2D;\n width: number = 0;\n height: number = 0;\n ratio: number;\n // resourceManager: Resource;\n constructor(\n private canvas: HTMLCanvasElement,\n options?: {\n ratio: number;\n }\n ) {\n // console.log(\"PosterPainter constructor\");\n\n this.ctx = this.canvas.getContext(\"2d\")!;\n\n this.width = this.canvas.width;\n this.height = this.canvas.height;\n\n this.ratio =\n options?.ratio ||\n (typeof window !== \"undefined\"\n ? Math.floor(window.devicePixelRatio)\n : 1) ||\n 1;\n\n console.log(\"this ratio\", this.ratio);\n\n // render to high resolution\n this.canvas.width = this.width * this.ratio;\n this.canvas.height = this.height * this.ratio;\n this.canvas.style.width = this.width + \"px\";\n this.canvas.style.height = this.height + \"px\";\n\n //\n }\n\n draw(options: DrawOptions) {\n requestAnimationFrame(() => this._draw.bind(this)(options));\n }\n\n async _draw(options: DrawOptions) {\n if (this.ctx === null) return;\n // console.log(\"============ DRAW ============\");\n // this.ctx.font = options.fontFamily!;\n // this.ctx.clearRect(0, 0, this.width * this.ratio, this.height * this.ratio);\n // start draw\n // background\n await new BackgroundPaint(this.ctx, this).draw(options);\n // data paint\n await new DataPaint(this.ctx, this).draw(options);\n }\n}\n"],"names":["BackgroundPaint","DataPaint","PosterPainter","ctx","width","height","ratio","constructor","canvas","options","getContext","window","Math","floor","devicePixelRatio","style","draw","requestAnimationFrame","_draw","bind"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AAEpD,SAASC,SAA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AAIR,UAAU,IAAI,CAACE,GAAG,EAAE,IAAI,EAAEa,IAAI,CAACP;IAC3C;AACF"}
@@ -1,15 +1,17 @@
1
1
  export class Resource {
2
- constructor() {
3
- this.sourceMap = new Map();
4
- console.log("Resource constructor");
2
+ sourceMap = new Map();
3
+ constructor(){
4
+ ;
5
5
  }
6
6
  has(source) {
7
7
  return this.sourceMap.has(source);
8
8
  }
9
9
  load(source) {
10
- console.log("Resource load: ", source);
10
+ ;
11
11
  const img = new Image();
12
12
  img.src = source;
13
13
  this.sourceMap.set(source, img);
14
14
  }
15
15
  }
16
+
17
+ //# sourceMappingURL=resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/painter/resource.ts"],"sourcesContent":["export class Resource {\n sourceMap: Map<string, HTMLImageElement> = new Map();\n\n constructor() {\n console.log(\"Resource constructor\");\n }\n\n has(source: string) {\n return this.sourceMap.has(source);\n }\n\n load(source: string) {\n console.log(\"Resource load: \", source);\n const img = new Image();\n img.src = source;\n this.sourceMap.set(source, img);\n }\n}\n"],"names":["Resource","sourceMap","Map","constructor","has","source","load","img","Image","src","set"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAAA,OAAO,MAAMA;IACXC,YAA2C,IAAIC,MAAM;IAErDC,aAAc;;IAEd;IAEAC,IAAIC,MAAc,EAAE;QAClB,OAAO,IAAI,CAACJ,SAAS,CAACG,GAAG,CAACC;IAC5B;IAEAC,KAAKD,MAAc,EAAE;;QAEnB,MAAME,MAAM,IAAIC;QAChBD,IAAIE,GAAG,GAAGJ;QACV,IAAI,CAACJ,SAAS,CAACS,GAAG,CAACL,QAAQE;IAC7B;AACF"}
@@ -1,8 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext } from "react";
3
3
  import { useWsStatus } from "./useWsStatus";
4
- export const StatusContext = createContext({});
5
- export const StatusProvider = (props) => {
4
+ export const StatusContext = /*#__PURE__*/ createContext({});
5
+ export const StatusProvider = (props)=>{
6
6
  const wsStatus = useWsStatus();
7
- return (_jsx(StatusContext.Provider, { value: { ws: wsStatus }, children: props.children }));
7
+ return /*#__PURE__*/ _jsx(StatusContext.Provider, {
8
+ value: {
9
+ ws: wsStatus
10
+ },
11
+ children: props.children
12
+ });
8
13
  };
14
+
15
+ //# sourceMappingURL=statusProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/statusProvider.tsx"],"sourcesContent":["import { PropsWithChildren, createContext } from \"react\";\nimport { useWsStatus, type WsNetworkStatus } from \"./useWsStatus\";\n\nexport interface StatusContextState {\n ws?: WsNetworkStatus;\n}\n\nexport const StatusContext = createContext({} as StatusContextState);\n\nexport const StatusProvider: React.FC<PropsWithChildren> = (props) => {\n const wsStatus = useWsStatus();\n\n return (\n <StatusContext.Provider value={{ ws: wsStatus }}>\n {props.children}\n </StatusContext.Provider>\n );\n};\n"],"names":["createContext","useWsStatus","StatusContext","StatusProvider","props","wsStatus","Provider","value","ws","children"],"rangeMappings":";;;;;;;;;;;;","mappings":";AAAA,SAA4BA,aAAa,QAAQ,QAAQ;AACzD,SAASC,WAAW,QAA8B,gBAAgB;AAMlE,OAAO,MAAMC,8BAAgBF,cAAc,CAAC,GAAyB;AAErE,OAAO,MAAMG,iBAA8C,CAACC;IAC1D,MAAMC,WAAWJ;IAEjB,qBACE,KAACC,cAAcI,QAAQ;QAACC,OAAO;YAAEC,IAAIH;QAAS;kBAC3CD,MAAMK,QAAQ;;AAGrB,EAAE"}
@@ -1,27 +1,29 @@
1
1
  import { useContext } from "react";
2
2
  import { OrderlyContext } from "../orderlyContext";
3
- export const apiPrefixMiddleware = (useSWRNext) => {
3
+ export const apiPrefixMiddleware = (useSWRNext)=>{
4
4
  // @ts-ignore
5
5
  const { apiBaseUrl } = useContext(OrderlyContext);
6
- return (key, fetcher, config) => {
7
- const extendedFetcher = (...args) => {
6
+ return (key, fetcher, config)=>{
7
+ const extendedFetcher = (...args)=>{
8
8
  // @ts-ignore
9
9
  return fetcher(...args);
10
10
  };
11
11
  // key = `${apiBaseUrl}${key}`;
12
12
  return useSWRNext(key, extendedFetcher, config);
13
13
  };
14
- // return (key, fetcher, config) => {
15
- //
16
- // const { apiBaseUrl } = useContext(OrderlyContext);
17
- // const extendedFetcher = async (url: string) => {
18
- //
19
- // // if (!url.startsWith("http")){
20
- // // // const apiPrefix = (window as any)[__ORDERLY_API_URL_KEY__];
21
- // // url = `${apiBaseUrl}${url}`;
22
- // // }
23
- // return fetcher!(url);
24
- // };
25
- // return useSWRNext(key, extendedFetcher, config);
26
- // };
14
+ // return (key, fetcher, config) => {
15
+ //
16
+ // const { apiBaseUrl } = useContext(OrderlyContext);
17
+ // const extendedFetcher = async (url: string) => {
18
+ //
19
+ // // if (!url.startsWith("http")){
20
+ // // // const apiPrefix = (window as any)[__ORDERLY_API_URL_KEY__];
21
+ // // url = `${apiBaseUrl}${url}`;
22
+ // // }
23
+ // return fetcher!(url);
24
+ // };
25
+ // return useSWRNext(key, extendedFetcher, config);
26
+ // };
27
27
  };
28
+
29
+ //# sourceMappingURL=apiPrefixMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/unuse/apiPrefixMiddleware.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport type { Middleware, SWRHook } from \"swr\";\nimport { OrderlyContext } from \"../orderlyContext\";\n\nexport const apiPrefixMiddleware: Middleware = (useSWRNext: SWRHook) => {\n // @ts-ignore\n const { apiBaseUrl } = useContext(OrderlyContext);\n\n return (key, fetcher, config) => {\n const extendedFetcher = (...args: any[]) => {\n // @ts-ignore\n return fetcher(...args);\n };\n // key = `${apiBaseUrl}${key}`;\n\n return useSWRNext(key, extendedFetcher, config);\n };\n // return (key, fetcher, config) => {\n //\n // const { apiBaseUrl } = useContext(OrderlyContext);\n // const extendedFetcher = async (url: string) => {\n //\n // // if (!url.startsWith(\"http\")){\n // // // const apiPrefix = (window as any)[__ORDERLY_API_URL_KEY__];\n // // url = `${apiBaseUrl}${url}`;\n // // }\n // return fetcher!(url);\n // };\n // return useSWRNext(key, extendedFetcher, config);\n // };\n};\n"],"names":["useContext","OrderlyContext","apiPrefixMiddleware","useSWRNext","apiBaseUrl","key","fetcher","config","extendedFetcher","args"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,cAAc,QAAQ,oBAAoB;AAEnD,OAAO,MAAMC,sBAAkC,CAACC;IAC9C,aAAa;IACb,MAAM,EAAEC,UAAU,EAAE,GAAGJ,WAAWC;IAElC,OAAO,CAACI,KAAKC,SAASC;QACpB,MAAMC,kBAAkB,CAAC,GAAGC;YAC1B,aAAa;YACb,OAAOH,WAAWG;QACpB;QACA,gCAAgC;QAEhC,OAAON,WAAWE,KAAKG,iBAAiBD;IAC1C;AACA,qCAAqC;AACrC,EAAE;AACF,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2CAA2C;AAC3C,gFAAgF;AAChF,8CAA8C;AAC9C,eAAe;AACf,+BAA+B;AAC/B,SAAS;AACT,uDAAuD;AACvD,KAAK;AACP,EAAE"}
package/esm/unuse/fn.js CHANGED
@@ -2,5 +2,7 @@ import { pathOr } from "ramda";
2
2
  export const totalUnsettlementPnLPath = pathOr(0, [
3
3
  0,
4
4
  "aggregated",
5
- "unsettledPnL",
5
+ "unsettledPnL"
6
6
  ]);
7
+
8
+ //# sourceMappingURL=fn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/unuse/fn.ts"],"sourcesContent":["import { pathOr } from \"ramda\";\n\nexport const totalUnsettlementPnLPath = pathOr(0, [\n 0,\n \"aggregated\",\n \"unsettledPnL\",\n]);\n"],"names":["pathOr","totalUnsettlementPnLPath"],"rangeMappings":";;;;;","mappings":"AAAA,SAASA,MAAM,QAAQ,QAAQ;AAE/B,OAAO,MAAMC,2BAA2BD,OAAO,GAAG;IAChD;IACA;IACA;CACD,EAAE"}
@@ -1,12 +1,14 @@
1
1
  import { useWS } from "../useWS";
2
2
  import useSWRSubscription from "swr/subscription";
3
- export const useBalance = () => {
3
+ export const useBalance = ()=>{
4
4
  const ws = useWS();
5
- const { data } = useSWRSubscription("balance", (_, { next }) => {
5
+ const { data } = useSWRSubscription("balance", (_, { next })=>{
6
6
  const unsubscribe = ws.privateSubscribe("balance", {
7
- onMessage: (data) => { },
7
+ onMessage: (data)=>{}
8
8
  });
9
- return () => unsubscribe();
9
+ return ()=>unsubscribe();
10
10
  });
11
11
  return data;
12
12
  };
13
+
14
+ //# sourceMappingURL=useBalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/unuse/useBalance.ts"],"sourcesContent":["import { useWS } from \"../useWS\";\nimport useSWRSubscription from \"swr/subscription\";\n\nexport const useBalance = () => {\n const ws = useWS();\n const { data } = useSWRSubscription(\"balance\", (_, { next }) => {\n const unsubscribe = ws.privateSubscribe(\"balance\", {\n onMessage: (data: any) => {},\n });\n return () => unsubscribe();\n });\n\n return data;\n};\n"],"names":["useWS","useSWRSubscription","useBalance","ws","data","_","next","unsubscribe","privateSubscribe","onMessage"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,SAASA,KAAK,QAAQ,WAAW;AACjC,OAAOC,wBAAwB,mBAAmB;AAElD,OAAO,MAAMC,aAAa;IACxB,MAAMC,KAAKH;IACX,MAAM,EAAEI,IAAI,EAAE,GAAGH,mBAAmB,WAAW,CAACI,GAAG,EAAEC,IAAI,EAAE;QACzD,MAAMC,cAAcJ,GAAGK,gBAAgB,CAAC,WAAW;YACjDC,WAAW,CAACL,QAAe;QAC7B;QACA,OAAO,IAAMG;IACf;IAEA,OAAOH;AACT,EAAE"}
@@ -2,38 +2,46 @@ import { useCallback, useEffect, useState } from "react";
2
2
  import { useQuery } from "../useQuery";
3
3
  import { useWS } from "../useWS";
4
4
  // api: /public/futures
5
- export const useFetures = () => {
5
+ export const useFetures = ()=>{
6
6
  const { data, isLoading, error } = useQuery(`/v1/public/futures`, {
7
- revalidateOnFocus: false,
7
+ revalidateOnFocus: false
8
8
  });
9
9
  const [sortedData, setSortedData] = useState(data);
10
10
  const ws = useWS();
11
- useEffect(() => {
12
- // const sub = ws
13
- // .observe<WSMessage.Ticker>(`tickers`)
14
- // .subscribe((value: any) => {
15
- //
16
- // // setData(value);
17
- // });
18
- // return () => {
19
- // sub.unsubscribe();
20
- // };
11
+ useEffect(()=>{
12
+ // const sub = ws
13
+ // .observe<WSMessage.Ticker>(`tickers`)
14
+ // .subscribe((value: any) => {
15
+ //
16
+ // // setData(value);
17
+ // });
18
+ // return () => {
19
+ // sub.unsubscribe();
20
+ // };
21
21
  }, []);
22
- useEffect(() => {
22
+ useEffect(()=>{
23
23
  if (data) {
24
- const sortedData = data.sort((a, b) => {
24
+ const sortedData = data.sort((a, b)=>{
25
25
  return 0;
26
26
  });
27
27
  setSortedData(sortedData);
28
28
  }
29
- }, [data]);
30
- const sortBy = useCallback((key) => { }, [data]);
31
- const filterBy = useCallback((key) => { }, [data]);
29
+ }, [
30
+ data
31
+ ]);
32
+ const sortBy = useCallback((key)=>{}, [
33
+ data
34
+ ]);
35
+ const filterBy = useCallback((key)=>{}, [
36
+ data
37
+ ]);
32
38
  return {
33
39
  data: sortedData,
34
40
  sortBy,
35
41
  filterBy,
36
42
  isLoading,
37
- error,
43
+ error
38
44
  };
39
45
  };
46
+
47
+ //# sourceMappingURL=useFetures.js.map