@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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/services/dataCenter.ts"],"sourcesContent":["import { EventEmitter } from \"@orderly.network/core\";\n\nclass DataCenter extends EventEmitter {\n constructor() {\n super();\n }\n\n observe = (key: string, callback: (value: any) => void) => {\n // merge data\n this.on(key, callback);\n };\n\n unobserve = (key: string, callback: (value: any) => void) => {\n this.off(key, callback);\n };\n}\n"],"names":["DataCenter","EventEmitter","constructor","observe","key","callback","on","unobserve","off"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":";;;;sBAA6B;AAE7B,MAAMA,mBAAmBC,kBAAY;IACnCC,aAAc;QACZ,KAAK;IACP;IAEAC,UAAU,CAACC,KAAaC;QACtB,aAAa;QACb,IAAI,CAACC,EAAE,CAACF,KAAKC;IACf,EAAE;IAEFE,YAAY,CAACH,KAAaC;QACxB,IAAI,CAACG,GAAG,CAACJ,KAAKC;IAChB,EAAE;AACJ"}
@@ -1,45 +1,48 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BackgroundPaint = void 0;
4
- const basePaint_1 = require("./basePaint");
5
- class BackgroundPaint extends basePaint_1.BasePaint {
6
- constructor() {
7
- super(...arguments);
8
- this.img = null;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "BackgroundPaint", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return BackgroundPaint;
9
9
  }
10
+ });
11
+ const _basePaint = require("./basePaint");
12
+ class BackgroundPaint extends _basePaint.BasePaint {
13
+ img = null;
10
14
  async draw(options) {
11
- console.log("BackgroundPaint draw: ", options.backgroundColor);
12
- if (typeof options.backgroundImg !== "undefined" &&
13
- options.backgroundImg !== "") {
15
+ ;
16
+ if (typeof options.backgroundImg !== "undefined" && options.backgroundImg !== "") {
14
17
  return this._drawImage(options);
15
- }
16
- else if (typeof options.backgroundColor !== "undefined") {
18
+ } else if (typeof options.backgroundColor !== "undefined") {
17
19
  return this._drawColor(options);
18
20
  }
19
21
  }
20
22
  _drawColor(options) {
21
- console.log("graw background color", options);
23
+ ;
22
24
  this.ctx.fillStyle = options.backgroundColor || "black";
23
25
  this.ctx.fillRect(0, 0, this.painter.width * this.painter.ratio, this.painter.height * this.painter.ratio);
24
26
  }
25
27
  async _drawImage(options) {
26
- return this.loadImg(options.backgroundImg).then((img) => {
28
+ return this.loadImg(options.backgroundImg).then((img)=>{
27
29
  this.img = img;
28
30
  this.ctx.drawImage(this.img, 0, 0, this.painter.width * this.painter.ratio, this.painter.height * this.painter.ratio);
29
31
  });
30
32
  }
31
33
  loadImg(url) {
32
- return new Promise((resolve, reject) => {
34
+ return new Promise((resolve, reject)=>{
33
35
  const img = new Image();
34
36
  img.crossOrigin = "anonymous";
35
- img.onload = () => {
37
+ img.onload = ()=>{
36
38
  resolve(img);
37
39
  };
38
- img.onerror = (e) => {
40
+ img.onerror = (e)=>{
39
41
  reject(e);
40
42
  };
41
43
  img.src = url;
42
44
  });
43
45
  }
44
46
  }
45
- exports.BackgroundPaint = BackgroundPaint;
47
+
48
+ //# sourceMappingURL=backgroundPaint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/painter/backgroundPaint.ts"],"sourcesContent":["import { BasePaint, type DrawOptions } from \"./basePaint\";\n\nexport class BackgroundPaint extends BasePaint {\n private img: HTMLImageElement | null = null;\n\n async draw(options: DrawOptions) {\n console.log(\"BackgroundPaint draw: \", options.backgroundColor);\n\n if (\n typeof options.backgroundImg !== \"undefined\" &&\n options.backgroundImg !== \"\"\n ) {\n return this._drawImage(options);\n } else if (typeof options.backgroundColor !== \"undefined\") {\n return this._drawColor(options);\n }\n }\n\n _drawColor(options: DrawOptions) {\n console.log(\"graw background color\", options);\n this.ctx.fillStyle = options.backgroundColor || \"black\";\n this.ctx.fillRect(\n 0,\n 0,\n this.painter.width * this.painter.ratio,\n this.painter.height * this.painter.ratio\n );\n }\n\n async _drawImage(options: DrawOptions) {\n return this.loadImg(options.backgroundImg!).then((img) => {\n this.img = img;\n this.ctx.drawImage(\n this.img!,\n 0,\n 0,\n this.painter.width * this.painter.ratio,\n this.painter.height * this.painter.ratio\n );\n });\n }\n\n private loadImg(url: string): Promise<HTMLImageElement> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.crossOrigin = \"anonymous\";\n img.onload = () => {\n resolve(img);\n };\n img.onerror = (e) => {\n reject(e);\n };\n img.src = url;\n });\n }\n}\n"],"names":["BackgroundPaint","BasePaint","img","draw","options","backgroundImg","_drawImage","backgroundColor","_drawColor","ctx","fillStyle","fillRect","painter","width","ratio","height","loadImg","then","drawImage","url","Promise","resolve","reject","Image","crossOrigin","onload","onerror","e","src"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAEaA;;;eAAAA;;;2BAF+B;AAErC,MAAMA,wBAAwBC,oBAAS;IACpCC,MAA+B,KAAK;IAE5C,MAAMC,KAAKC,OAAoB,EAAE;;QAG/B,IACE,OAAOA,QAAQC,aAAa,KAAK,eACjCD,QAAQC,aAAa,KAAK,IAC1B;YACA,OAAO,IAAI,CAACC,UAAU,CAACF;QACzB,OAAO,IAAI,OAAOA,QAAQG,eAAe,KAAK,aAAa;YACzD,OAAO,IAAI,CAACC,UAAU,CAACJ;QACzB;IACF;IAEAI,WAAWJ,OAAoB,EAAE;;QAE/B,IAAI,CAACK,GAAG,CAACC,SAAS,GAAGN,QAAQG,eAAe,IAAI;QAChD,IAAI,CAACE,GAAG,CAACE,QAAQ,CACf,GACA,GACA,IAAI,CAACC,OAAO,CAACC,KAAK,GAAG,IAAI,CAACD,OAAO,CAACE,KAAK,EACvC,IAAI,CAACF,OAAO,CAACG,MAAM,GAAG,IAAI,CAACH,OAAO,CAACE,KAAK;IAE5C;IAEA,MAAMR,WAAWF,OAAoB,EAAE;QACrC,OAAO,IAAI,CAACY,OAAO,CAACZ,QAAQC,aAAa,EAAGY,IAAI,CAAC,CAACf;YAChD,IAAI,CAACA,GAAG,GAAGA;YACX,IAAI,CAACO,GAAG,CAACS,SAAS,CAChB,IAAI,CAAChB,GAAG,EACR,GACA,GACA,IAAI,CAACU,OAAO,CAACC,KAAK,GAAG,IAAI,CAACD,OAAO,CAACE,KAAK,EACvC,IAAI,CAACF,OAAO,CAACG,MAAM,GAAG,IAAI,CAACH,OAAO,CAACE,KAAK;QAE5C;IACF;IAEQE,QAAQG,GAAW,EAA6B;QACtD,OAAO,IAAIC,QAAQ,CAACC,SAASC;YAC3B,MAAMpB,MAAM,IAAIqB;YAChBrB,IAAIsB,WAAW,GAAG;YAClBtB,IAAIuB,MAAM,GAAG;gBACXJ,QAAQnB;YACV;YACAA,IAAIwB,OAAO,GAAG,CAACC;gBACbL,OAAOK;YACT;YACAzB,IAAI0B,GAAG,GAAGT;QACZ;IACF;AACF"}
@@ -1,10 +1,20 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BasePaint = void 0;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "BasePaint", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return BasePaint;
9
+ }
10
+ });
4
11
  class BasePaint {
5
- constructor(ctx, painter) {
12
+ ctx;
13
+ painter;
14
+ constructor(ctx, painter){
6
15
  this.ctx = ctx;
7
16
  this.painter = painter;
8
17
  }
9
18
  }
10
- exports.BasePaint = BasePaint;
19
+
20
+ //# sourceMappingURL=basePaint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/painter/basePaint.ts"],"sourcesContent":["import { OrderSide } from \"@orderly.network/types\";\nimport { PosterPainter } from \"./painter\";\n\nexport type posterDataSource = {\n /**\n * slogan of the poster\n */\n message?: string;\n position: {\n symbol: string;\n // side: OrderSide;\n side: \"LONG\" | \"SHORT\";\n /**\n * The leverage of the position\n */\n leverage: number;\n /**\n * The unrealized PnL of the position\n */\n pnl: number;\n /**\n * The return on investment of the position\n */\n ROI: number;\n /**\n * The informations of the position, such as open price, opened at, mark price, quantity and custom message.\n */\n informations: { title: string; value: string }[];\n /**\n * The quote currency of the position\n */\n currency: string;\n };\n /**\n * The domain of the application\n */\n domain: string;\n\n /**\n * The update time of the position\n */\n updateTime: string;\n};\n\nexport type layoutInfo = {\n width?: number;\n height?: number;\n // padding?: number;\n // margin?: number;\n fontSize?: number;\n\n color?: string;\n textAlign?: CanvasTextAlign;\n textBaseline?: CanvasTextBaseline;\n position: Partial<{\n left: number;\n right: number;\n top: number;\n bottom: number;\n }>;\n};\n\nexport type PosterLayoutConfig = {\n message?: layoutInfo;\n\n domain?: layoutInfo;\n position?: layoutInfo;\n unrealizedPnl?: layoutInfo & {\n secondaryColor: string;\n secondaryFontSize: number;\n };\n\n informations?: layoutInfo & {\n labelColor?: string;\n };\n updateTime?: layoutInfo;\n};\n\nexport type DrawOptions = {\n /**\n * Color of common text\n */\n color?: string;\n fontFamily?: string;\n /**\n * Lose color\n */\n lossColor?: string;\n /**\n * Profit color\n */\n profitColor?: string;\n /**\n * The brand color of the application\n */\n brandColor?: string;\n backgroundColor?: string;\n backgroundImg?: string;\n data?: posterDataSource;\n layout?: PosterLayoutConfig;\n};\n\nexport abstract class BasePaint {\n constructor(\n protected ctx: CanvasRenderingContext2D,\n protected painter: PosterPainter\n ) {}\n abstract draw(options: DrawOptions): Promise<void>;\n}\n"],"names":["BasePaint","constructor","ctx","painter"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";;;;+BAsGsBA;;;eAAAA;;;AAAf,MAAeA;;;IACpBC,YACE,AAAUC,GAA6B,EACvC,AAAUC,OAAsB,CAChC;aAFUD,MAAAA;aACAC,UAAAA;IACT;AAEL"}
@@ -1,20 +1,23 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DataPaint = void 0;
4
- const utils_1 = require("@orderly.network/utils");
5
- const basePaint_1 = require("./basePaint");
6
- const ramda_1 = require("ramda");
7
- class DataPaint extends basePaint_1.BasePaint {
8
- constructor() {
9
- super(...arguments);
10
- this.positionInfoCellWidth = 110;
11
- this.DEFAULT_PROFIT_COLOR = "rgb(0,181,159)";
12
- this.DEFAULT_LOSS_COLOR = "rgb(255,103,194)";
13
- this.transformTop = 0;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "DataPaint", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return DataPaint;
14
9
  }
10
+ });
11
+ const _utils = require("@orderly.network/utils");
12
+ const _basePaint = require("./basePaint");
13
+ const _ramda = require("ramda");
14
+ class DataPaint extends _basePaint.BasePaint {
15
+ positionInfoCellWidth = 110;
16
+ DEFAULT_PROFIT_COLOR = "rgb(0,181,159)";
17
+ DEFAULT_LOSS_COLOR = "rgb(255,103,194)";
18
+ transformTop = 0;
15
19
  async draw(options) {
16
- const needDrawDetails = Array.isArray(options.data?.position?.informations) &&
17
- (options.data?.position?.informations?.length ?? 0) > 0;
20
+ const needDrawDetails = Array.isArray(options.data?.position?.informations) && (options.data?.position?.informations?.length ?? 0) > 0;
18
21
  // const hasMessage = !!options.data?.message;
19
22
  const hasMessage = true;
20
23
  this.transformTop = hasMessage ? 0 : needDrawDetails ? -40 : -150;
@@ -41,7 +44,10 @@ class DataPaint extends basePaint_1.BasePaint {
41
44
  }
42
45
  drawMessage(options) {
43
46
  // console.log("draw message", options);
44
- const layout = (0, ramda_1.path)(["layout", "message"], options);
47
+ const layout = (0, _ramda.path)([
48
+ "layout",
49
+ "message"
50
+ ], options);
45
51
  const { position } = layout;
46
52
  this._drawText(`"${options.data?.message}"`, {
47
53
  color: layout.color,
@@ -49,11 +55,14 @@ class DataPaint extends basePaint_1.BasePaint {
49
55
  top: this._ratio(position.top),
50
56
  left: this._ratio(position.left),
51
57
  textBaseline: "top",
52
- fontFamily: options.fontFamily,
58
+ fontFamily: options.fontFamily
53
59
  });
54
60
  }
55
61
  drawPosition(options, offsetTop = 0) {
56
- const layout = (0, ramda_1.path)(["layout", "position"], options);
62
+ const layout = (0, _ramda.path)([
63
+ "layout",
64
+ "position"
65
+ ], options);
57
66
  const { position, fontSize = 14 } = layout;
58
67
  let left = this._ratio(position.left);
59
68
  let top = layout.position.top + offsetTop + this.transformTop;
@@ -61,13 +70,11 @@ class DataPaint extends basePaint_1.BasePaint {
61
70
  // draw position side;
62
71
  if (typeof options.data?.position.side !== "undefined") {
63
72
  prevElementBoundingBox = this._drawText(options.data.position.side, {
64
- color: options.data?.position.side.toUpperCase() === "LONG"
65
- ? this.DEFAULT_PROFIT_COLOR
66
- : this.DEFAULT_LOSS_COLOR,
73
+ color: options.data?.position.side.toUpperCase() === "LONG" ? this.DEFAULT_PROFIT_COLOR : this.DEFAULT_LOSS_COLOR,
67
74
  left,
68
75
  top: this._ratio(top),
69
76
  fontSize: this._ratio(fontSize),
70
- fontFamily: options.fontFamily,
77
+ fontFamily: options.fontFamily
71
78
  });
72
79
  }
73
80
  if (typeof options.data?.position.symbol !== "undefined") {
@@ -78,7 +85,7 @@ class DataPaint extends basePaint_1.BasePaint {
78
85
  left,
79
86
  top: this._ratio(top),
80
87
  fontSize: this._ratio(fontSize),
81
- fontFamily: options.fontFamily,
88
+ fontFamily: options.fontFamily
82
89
  });
83
90
  }
84
91
  left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);
@@ -87,7 +94,7 @@ class DataPaint extends basePaint_1.BasePaint {
87
94
  left: left,
88
95
  top: this._ratio(top),
89
96
  fontSize: this._ratio(fontSize),
90
- fontFamily: options.fontFamily,
97
+ fontFamily: options.fontFamily
91
98
  });
92
99
  }
93
100
  if (typeof options.data?.position.leverage !== "undefined") {
@@ -98,7 +105,7 @@ class DataPaint extends basePaint_1.BasePaint {
98
105
  left,
99
106
  top: this._ratio(top),
100
107
  fontSize: this._ratio(fontSize),
101
- fontFamily: options.fontFamily,
108
+ fontFamily: options.fontFamily
102
109
  });
103
110
  }
104
111
  left += (prevElementBoundingBox.width ?? 0) + this._ratio(7);
@@ -107,13 +114,16 @@ class DataPaint extends basePaint_1.BasePaint {
107
114
  left,
108
115
  top: this._ratio(top),
109
116
  fontSize: this._ratio(fontSize),
110
- fontFamily: options.fontFamily,
117
+ fontFamily: options.fontFamily
111
118
  });
112
119
  }
113
120
  }
114
121
  drawUnrealizedPnL(options, offsetTop = 0) {
115
122
  // reset left value;
116
- const layout = (0, ramda_1.path)(["layout", "unrealizedPnl"], options);
123
+ const layout = (0, _ramda.path)([
124
+ "layout",
125
+ "unrealizedPnl"
126
+ ], options);
117
127
  const { position } = layout;
118
128
  let left = this._ratio(position.left);
119
129
  let prevElementBoundingBox = {};
@@ -121,65 +131,57 @@ class DataPaint extends basePaint_1.BasePaint {
121
131
  // ROI
122
132
  if (typeof options.data?.position.ROI !== "undefined") {
123
133
  const prefix = options.data?.position.ROI > 0 ? "+" : "";
124
- prevElementBoundingBox = this._drawText(`${prefix}${(0, utils_1.commify)(options.data?.position.ROI)}%`, {
125
- color: prefix === "+"
126
- ? options.profitColor || this.DEFAULT_PROFIT_COLOR
127
- : options.lossColor || this.DEFAULT_LOSS_COLOR,
134
+ prevElementBoundingBox = this._drawText(`${prefix}${(0, _utils.commify)(options.data?.position.ROI)}%`, {
135
+ color: prefix === "+" ? options.profitColor || this.DEFAULT_PROFIT_COLOR : options.lossColor || this.DEFAULT_LOSS_COLOR,
128
136
  left,
129
137
  top: this._ratio(top),
130
138
  fontSize: this._ratio(layout.fontSize),
131
139
  fontWeight: 700,
132
- fontFamily: options.fontFamily,
140
+ fontFamily: options.fontFamily
133
141
  });
134
142
  }
135
143
  // unrelPnL
136
144
  if (typeof options.data?.position.pnl !== "undefined") {
137
145
  const prefix = options.data?.position.pnl > 0 ? "+" : "";
138
- let text = `${prefix}${(0, utils_1.commify)(options.data?.position.pnl)} ${options.data?.position.currency}`;
146
+ let text = `${prefix}${(0, _utils.commify)(options.data?.position.pnl)} ${options.data?.position.currency}`;
139
147
  let fontWeight = 600;
140
148
  if (prevElementBoundingBox.width) {
141
149
  left += (prevElementBoundingBox.width ?? 0) + this._ratio(8);
142
150
  text = `(${text})`;
143
- }
144
- else {
151
+ } else {
145
152
  left = this._ratio(position.left);
146
153
  fontWeight = 700;
147
154
  }
148
- const color = typeof options.data.position.ROI === "undefined"
149
- ? prefix === "+"
150
- ? options.profitColor || this.DEFAULT_PROFIT_COLOR
151
- : options.lossColor || this.DEFAULT_LOSS_COLOR
152
- : layout.secondaryColor;
153
- const fontSize = typeof options.data.position.ROI === "undefined"
154
- ? this._ratio(layout.fontSize)
155
- : this._ratio(layout.secondaryFontSize);
155
+ const color = typeof options.data.position.ROI === "undefined" ? prefix === "+" ? options.profitColor || this.DEFAULT_PROFIT_COLOR : options.lossColor || this.DEFAULT_LOSS_COLOR : layout.secondaryColor;
156
+ const fontSize = typeof options.data.position.ROI === "undefined" ? this._ratio(layout.fontSize) : this._ratio(layout.secondaryFontSize);
156
157
  prevElementBoundingBox = this._drawText(text, {
157
158
  color,
158
159
  left,
159
160
  top: this._ratio(top),
160
161
  fontSize,
161
162
  fontWeight,
162
- fontFamily: options.fontFamily,
163
+ fontFamily: options.fontFamily
163
164
  });
164
165
  }
165
166
  }
166
167
  drawInformations(options) {
167
- const layout = (0, ramda_1.path)(["layout", "informations"], options);
168
+ const layout = (0, _ramda.path)([
169
+ "layout",
170
+ "informations"
171
+ ], options);
168
172
  const { position } = layout;
169
173
  const isVertical = (options.data?.position.informations.length ?? 0) === 2;
170
- options.data?.position.informations.forEach((info, index) => {
174
+ options.data?.position.informations.forEach((info, index)=>{
171
175
  // let cellWidth = this.positionInfoCellWidth;
172
- let left = position.left + (index % 2) * this.positionInfoCellWidth;
176
+ let left = position.left + index % 2 * this.positionInfoCellWidth;
173
177
  // let top = (position.top as number) + (index / 2) * 38 + this.transformTop;
174
- let top = position.top +
175
- Math.floor(index / 2) * 38 +
176
- this.transformTop;
178
+ let top = position.top + Math.floor(index / 2) * 38 + this.transformTop;
177
179
  this._drawText(info.title, {
178
180
  left: this._ratio(left),
179
181
  top: this._ratio(top),
180
182
  fontSize: this._ratio(10),
181
183
  color: layout.labelColor,
182
- fontFamily: options.fontFamily,
184
+ fontFamily: options.fontFamily
183
185
  });
184
186
  this._drawText(info.value, {
185
187
  left: this._ratio(left),
@@ -187,12 +189,15 @@ class DataPaint extends basePaint_1.BasePaint {
187
189
  fontSize: this._ratio(layout.fontSize),
188
190
  fontWeight: 500,
189
191
  color: layout.color,
190
- fontFamily: options.fontFamily,
192
+ fontFamily: options.fontFamily
191
193
  });
192
194
  });
193
195
  }
194
196
  drawDomainUrl(options) {
195
- const layout = (0, ramda_1.path)(["layout", "domain"], options);
197
+ const layout = (0, _ramda.path)([
198
+ "layout",
199
+ "domain"
200
+ ], options);
196
201
  const { position } = layout;
197
202
  const top = this.painter.height - position.bottom;
198
203
  this._drawText(options.data?.domain, {
@@ -202,15 +207,18 @@ class DataPaint extends basePaint_1.BasePaint {
202
207
  color: options.brandColor ?? this.DEFAULT_PROFIT_COLOR,
203
208
  fontFamily: options.fontFamily,
204
209
  textBaseline: layout.textBaseline,
205
- fontWeight: 600,
210
+ fontWeight: 600
206
211
  });
207
212
  }
208
213
  drawPositionTime(options) {
209
- const layout = (0, ramda_1.path)(["layout", "updateTime"], options);
214
+ const layout = (0, _ramda.path)([
215
+ "layout",
216
+ "updateTime"
217
+ ], options);
210
218
  const { position } = layout;
211
219
  const top = this.painter.height - position.bottom;
212
220
  const left = position.left;
213
- console.log("*******", left, top, options.data?.updateTime);
221
+ ;
214
222
  this._drawText(options.data?.updateTime, {
215
223
  left: this._ratio(left),
216
224
  top: this._ratio(top),
@@ -218,12 +226,12 @@ class DataPaint extends basePaint_1.BasePaint {
218
226
  color: layout.color,
219
227
  textAlign: layout.textAlign,
220
228
  fontFamily: options.fontFamily,
221
- textBaseline: layout.textBaseline,
229
+ textBaseline: layout.textBaseline
222
230
  });
223
231
  }
224
232
  _drawText(str, options) {
225
233
  let boundingBox;
226
- const { left = 30, top = 30, fontSize = 13, fontWeight = 500, color = "black", textBaseline = "middle", textAlign = "start", } = options ?? {};
234
+ const { left = 30, top = 30, fontSize = 13, fontWeight = 500, color = "black", textBaseline = "middle", textAlign = "start" } = options ?? {};
227
235
  this.ctx.save();
228
236
  // "Nunito Sans",-apple-system,"San Francisco",BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Helvetica,Arial,sans-serif
229
237
  this.ctx.font = `${fontWeight} ${fontSize}px ${options?.fontFamily}`;
@@ -239,4 +247,5 @@ class DataPaint extends basePaint_1.BasePaint {
239
247
  return num * this.painter.ratio;
240
248
  }
241
249
  }
242
- exports.DataPaint = DataPaint;
250
+
251
+ //# 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":["DataPaint","BasePaint","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","path","_drawText","color","fontSize","_ratio","top","left","textBaseline","fontFamily","prevElementBoundingBox","side","toUpperCase","symbol","width","leverage","ROI","prefix","commify","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAIaA;;;eAAAA;;;uBAJW;2BAC2B;uBAC9B;AAEd,MAAMA,kBAAkBC,oBAAS;IAC9BC,wBAAwB,IAAI;IAE5BC,uBAAuB,iBAAiB;IACxCC,qBAAqB,mBAAmB;IAExCC,eAAe,EAAE;IAEzB,MAAMC,KAAKC,OAAoB,EAAE;QAC/B,MAAMC,kBACJC,MAAMC,OAAO,CAACH,QAAQI,IAAI,EAAEC,UAAUC,iBACtC,AAACN,CAAAA,QAAQI,IAAI,EAAEC,UAAUC,cAAcC,UAAU,CAAA,IAAK;QAExD,8CAA8C;QAC9C,M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AAOG,KAAK;YACnBqC,WAAWxC,OAAOwC,SAAS;YAC3B/B,YAAY5B,QAAQ4B,UAAU;YAC9BD,cAAcR,OAAOQ,YAAY;QACnC;IACF;IAEQN,UACNuC,GAAW,EACX5D,OASC,EACY;QACb,IAAI6D;QACJ,MAAM,EACJnC,OAAO,EAAE,EACTD,MAAM,EAAE,EACRF,WAAW,EAAE,EACbiB,aAAa,GAAG,EAChBlB,QAAQ,OAAO,EACfK,eAAe,QAAQ,EACvBgC,YAAY,OAAO,EACpB,GAAG3D,WAAW,CAAC;QAEhB,IAAI,CAAC8D,GAAG,CAACC,IAAI;QACb,wHAAwH;QACxH,IAAI,CAACD,GAAG,CAACE,IAAI,GAAG,CAAC,EAAExB,WAAW,CAAC,EAAEjB,SAAS,GAAG,EAAEvB,SAAS4B,WAAW,CAAC;QAEpE,IAAI,CAACkC,GAAG,CAACG,SAAS,GAAG3C;QACrB,IAAI,CAACwC,GAAG,CAACnC,YAAY,GAAGA;QACxB,IAAI,CAACmC,GAAG,CAACH,SAAS,GAAGA;QACrBE,cAAc,IAAI,CAACC,GAAG,CAACI,WAAW,CAACN;QAEnC,IAAI,CAACE,GAAG,CAACK,QAAQ,CAACP,KAAKlC,MAAMD;QAC7B,IAAI,CAACqC,GAAG,CAACM,OAAO;QAEhB,OAAOP;IACT;IAEQrC,OAAO6C,GAAW,EAAE;QAC1B,OAAOA,MAAM,IAAI,CAACd,OAAO,CAACe,KAAK;IACjC;AACF"}
@@ -1,15 +1,22 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultLayoutConfig = void 0;
4
- exports.DefaultLayoutConfig = {
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "DefaultLayoutConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return DefaultLayoutConfig;
9
+ }
10
+ });
11
+ const DefaultLayoutConfig = {
5
12
  domain: {
6
13
  fontSize: 13,
7
14
  // color: undefined,
8
15
  textBaseline: "bottom",
9
16
  position: {
10
17
  left: 20,
11
- bottom: 32,
12
- },
18
+ bottom: 32
19
+ }
13
20
  },
14
21
  message: {
15
22
  fontSize: 20,
@@ -17,16 +24,16 @@ exports.DefaultLayoutConfig = {
17
24
  textBaseline: "top",
18
25
  position: {
19
26
  left: 20,
20
- top: 16,
21
- },
27
+ top: 16
28
+ }
22
29
  },
23
30
  position: {
24
31
  fontSize: 14,
25
32
  color: "rgba(255,255,255,0.98)",
26
33
  position: {
27
34
  left: 20,
28
- top: 70,
29
- },
35
+ top: 70
36
+ }
30
37
  },
31
38
  unrealizedPnl: {
32
39
  fontSize: 36,
@@ -35,8 +42,8 @@ exports.DefaultLayoutConfig = {
35
42
  secondaryFontSize: 20,
36
43
  position: {
37
44
  left: 20,
38
- top: 110,
39
- },
45
+ top: 110
46
+ }
40
47
  },
41
48
  informations: {
42
49
  fontSize: 12,
@@ -44,8 +51,8 @@ exports.DefaultLayoutConfig = {
44
51
  labelColor: "rgba(255,255,255,0.36)",
45
52
  position: {
46
53
  left: 20,
47
- top: 150,
48
- },
54
+ top: 150
55
+ }
49
56
  },
50
57
  updateTime: {
51
58
  fontSize: 10,
@@ -54,7 +61,9 @@ exports.DefaultLayoutConfig = {
54
61
  textBaseline: "bottom",
55
62
  position: {
56
63
  left: 20,
57
- bottom: 17,
58
- },
59
- },
64
+ bottom: 17
65
+ }
66
+ }
60
67
  };
68
+
69
+ //# 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":";;;;+BAEaA;;;eAAAA;;;AAAN,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"}
@@ -1,46 +1,53 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PosterPainter = void 0;
4
- const backgroundPaint_1 = require("./backgroundPaint");
5
- const dataPaint_1 = require("./dataPaint");
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "PosterPainter", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return PosterPainter;
9
+ }
10
+ });
11
+ const _backgroundPaint = require("./backgroundPaint");
12
+ const _dataPaint = require("./dataPaint");
6
13
  class PosterPainter {
14
+ canvas;
15
+ ctx;
16
+ width;
17
+ height;
18
+ ratio;
7
19
  // resourceManager: Resource;
8
- constructor(canvas, options) {
9
- // console.log("PosterPainter constructor");
20
+ constructor(canvas, options){
10
21
  this.canvas = canvas;
11
22
  this.width = 0;
12
23
  this.height = 0;
24
+ // console.log("PosterPainter constructor");
13
25
  this.ctx = this.canvas.getContext("2d");
14
26
  this.width = this.canvas.width;
15
27
  this.height = this.canvas.height;
16
- this.ratio =
17
- options?.ratio ||
18
- (typeof window !== "undefined"
19
- ? Math.floor(window.devicePixelRatio)
20
- : 1) ||
21
- 1;
22
- console.log("this ratio", this.ratio);
28
+ this.ratio = options?.ratio || (typeof window !== "undefined" ? Math.floor(window.devicePixelRatio) : 1) || 1;
29
+ ;
23
30
  // render to high resolution
24
31
  this.canvas.width = this.width * this.ratio;
25
32
  this.canvas.height = this.height * this.ratio;
26
33
  this.canvas.style.width = this.width + "px";
27
34
  this.canvas.style.height = this.height + "px";
28
- //
35
+ //
29
36
  }
30
37
  draw(options) {
31
- requestAnimationFrame(() => this._draw.bind(this)(options));
38
+ requestAnimationFrame(()=>this._draw.bind(this)(options));
32
39
  }
33
40
  async _draw(options) {
34
- if (this.ctx === null)
35
- return;
41
+ if (this.ctx === null) return;
36
42
  // console.log("============ DRAW ============");
37
43
  // this.ctx.font = options.fontFamily!;
38
44
  // this.ctx.clearRect(0, 0, this.width * this.ratio, this.height * this.ratio);
39
45
  // start draw
40
46
  // background
41
- await new backgroundPaint_1.BackgroundPaint(this.ctx, this).draw(options);
47
+ await new _backgroundPaint.BackgroundPaint(this.ctx, this).draw(options);
42
48
  // data paint
43
- await new dataPaint_1.DataPaint(this.ctx, this).draw(options);
49
+ await new _dataPaint.DataPaint(this.ctx, this).draw(options);
44
50
  }
45
51
  }
46
- exports.PosterPainter = PosterPainter;
52
+
53
+ //# 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":["PosterPainter","ctx","width","height","ratio","constructor","canvas","options","getContext","window","Math","floor","devicePixelRatio","style","draw","requestAnimationFrame","_draw","bind","BackgroundPaint","DataPaint"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAGaA;;;eAAAA;;;iCAHmB;2BAEN;AACnB,MAAMA;;IACHC,IAA8B;IACtCC,MAAkB;IAClBC,OAAmB;IACnBC,MAAc;IACd,6BAA6B;IAC7BC,YACE,AAAQC,MAAyB,EACjCC,OAEC,CACD;aAJQD,SAAAA;aALVJ,QAAgB;aAChBC,SAAiB;QASf,4CAA4C;QAE5C,IAAI,CAACF,GAAG,GAAG,IAAI,CAACK,MAAM,CAACE,UAAU,CAAC;QAElC,IAAI,CAACN,KAAK,GAAG,IAAI,CAACI,MAAM,CAACJ,KAAK;QAC9B,IAAI,CAACC,MAAM,GAAG,IAAI,CAACG,MAAM,CAACH,MAAM;QAEhC,IAAI,CAACC,KAAK,GACRG,SAASH,SACR,CAAA,OAAOK,WAAW,cACfC,KAAKC,KAAK,CAACF,OAAOG,gBAAgB,IAClC,CAAA,KACJ;;QAIF,4BAA4B;QAC5B,IAAI,CAACN,MAAM,CAACJ,KAAK,GAAG,IAAI,CAACA,KAAK,GAAG,IAAI,CAACE,KAAK;QAC3C,IAAI,CAACE,MAAM,CAACH,MAAM,GAAG,IAAI,CAACA,MAAM,GAAG,IAAI,CAACC,KAAK;QAC7C,IAAI,CAACE,MAAM,CAACO,KAAK,CAACX,KAAK,GAAG,IAAI,CAACA,KAAK,GAAG;QACvC,IAAI,CAACI,MAAM,CAACO,KAAK,CAACV,MAAM,GAAG,IAAI,CAACA,MAAM,GAAG;IAEzC,EAAE;IACJ;IAEAW,KAAKP,OAAoB,EAAE;QACzBQ,sBAAsB,IAAM,IAAI,CAACC,KAAK,CAACC,IAAI,CAAC,IAAI,EAAEV;IACpD;IAEA,MAAMS,MAAMT,OAAoB,EAAE;QAChC,IAAI,IAAI,CAACN,GAAG,KAAK,MAAM;QACvB,iDAAiD;QACjD,uCAAuC;QACvC,+EAA+E;QAC/E,aAAa;QACb,aAAa;QACb,MAAM,IAAIiB,gCAAe,CAAC,IAAI,CAACjB,GAAG,EAAE,IAAI,EAAEa,IAAI,CAACP;QAC/C,aAAa;QACb,MAAM,IAAIY,oBAAS,CAAC,IAAI,CAAClB,GAAG,EAAE,IAAI,EAAEa,IAAI,CAACP;IAC3C;AACF"}
@@ -1,19 +1,27 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Resource = void 0;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Resource", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Resource;
9
+ }
10
+ });
4
11
  class Resource {
5
- constructor() {
6
- this.sourceMap = new Map();
7
- console.log("Resource constructor");
12
+ sourceMap = new Map();
13
+ constructor(){
14
+ ;
8
15
  }
9
16
  has(source) {
10
17
  return this.sourceMap.has(source);
11
18
  }
12
19
  load(source) {
13
- console.log("Resource load: ", source);
20
+ ;
14
21
  const img = new Image();
15
22
  img.src = source;
16
23
  this.sourceMap.set(source, img);
17
24
  }
18
25
  }
19
- exports.Resource = Resource;
26
+
27
+ //# 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":";;;;+BAAaA;;;eAAAA;;;AAAN,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"}