@devexperts/dxcharts-lite 1.0.2 → 2.0.1

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 (258) hide show
  1. package/README.md +2 -2
  2. package/dist/chart/animation/canvas-animation.js +134 -1
  3. package/dist/chart/animation/types/animation.js +43 -1
  4. package/dist/chart/animation/types/color-alpha-animation.d.ts +1 -1
  5. package/dist/chart/animation/types/color-alpha-animation.js +60 -1
  6. package/dist/chart/animation/types/color-transition-animation.d.ts +1 -1
  7. package/dist/chart/animation/types/color-transition-animation.js +86 -1
  8. package/dist/chart/animation/types/viewport-movement-animation.js +63 -1
  9. package/dist/chart/animation/viewport-model-animation.js +20 -1
  10. package/dist/chart/bootstrap.d.ts +51 -48
  11. package/dist/chart/bootstrap.js +449 -1
  12. package/dist/chart/canvas/canvas-bounds-container.d.ts +0 -5
  13. package/dist/chart/canvas/canvas-bounds-container.js +815 -1
  14. package/dist/chart/canvas/canvas-chart-html.js +16 -18
  15. package/dist/chart/canvas/chart-elements.d.ts +1 -4
  16. package/dist/chart/canvas/chart-elements.js +22 -1
  17. package/dist/chart/canvas/cursor.handler.js +122 -1
  18. package/dist/chart/canvas/layout-creator.js +34 -1
  19. package/dist/chart/canvas/y-axis-bounds.container.d.ts +2 -2
  20. package/dist/chart/canvas/y-axis-bounds.container.js +67 -1
  21. package/dist/chart/chart-container.js +1 -1
  22. package/dist/chart/chart.config.d.ts +4 -5
  23. package/dist/chart/chart.config.js +645 -1
  24. package/dist/chart/chart.d.ts +62 -0
  25. package/dist/chart/chart.js +106 -0
  26. package/dist/chart/components/chart/basic-scale.d.ts +2 -2
  27. package/dist/chart/components/chart/basic-scale.js +31 -1
  28. package/dist/chart/components/chart/candle-transformer.functions.js +15 -1
  29. package/dist/chart/components/chart/candle-width-calculator.functions.js +2 -1
  30. package/dist/chart/components/chart/candle.functions.js +44 -1
  31. package/dist/chart/components/chart/chart-area-pan.handler.d.ts +3 -3
  32. package/dist/chart/components/chart/chart-area-pan.handler.js +197 -1
  33. package/dist/chart/components/chart/chart-base.model.js +66 -1
  34. package/dist/chart/components/chart/chart.component.d.ts +7 -3
  35. package/dist/chart/components/chart/chart.component.js +408 -1
  36. package/dist/chart/components/chart/chart.model.d.ts +4 -11
  37. package/dist/chart/components/chart/chart.model.js +954 -1
  38. package/dist/chart/components/chart/data-series.high-low-provider.js +34 -1
  39. package/dist/chart/components/chart/fake-candles.js +97 -1
  40. package/dist/chart/components/chart/price.formatter.js +35 -1
  41. package/dist/chart/components/chart/secondary-chart-colors-pool.js +68 -1
  42. package/dist/chart/components/cross_tool/cross-tool.component.js +85 -1
  43. package/dist/chart/components/cross_tool/cross-tool.drawer.js +32 -1
  44. package/dist/chart/components/cross_tool/cross-tool.model.js +107 -1
  45. package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +137 -1
  46. package/dist/chart/components/cross_tool/types/none.drawer.js +3 -1
  47. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.js +28 -1
  48. package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.js +24 -1
  49. package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.js +53 -1
  50. package/dist/chart/components/dynamic-objects/dynamic-objects.component.d.ts +13 -0
  51. package/dist/chart/components/dynamic-objects/dynamic-objects.component.js +20 -0
  52. package/dist/chart/components/dynamic-objects/dynamic-objects.drawer.d.ts +18 -0
  53. package/dist/chart/components/dynamic-objects/dynamic-objects.drawer.js +23 -0
  54. package/dist/chart/components/dynamic-objects/dynamic-objects.model.d.ts +63 -0
  55. package/dist/chart/components/dynamic-objects/dynamic-objects.model.js +136 -0
  56. package/dist/chart/components/events/events-hit-test.drawer.js +63 -1
  57. package/dist/chart/components/events/events.component.js +61 -1
  58. package/dist/chart/components/events/events.drawer.js +195 -1
  59. package/dist/chart/components/events/events.model.js +69 -1
  60. package/dist/chart/components/grid/grid.component.d.ts +2 -2
  61. package/dist/chart/components/grid/grid.component.js +31 -1
  62. package/dist/chart/components/grid/grid.drawer.d.ts +4 -3
  63. package/dist/chart/components/grid/grid.drawer.js +106 -1
  64. package/dist/chart/components/high_low/high-low.component.js +12 -1
  65. package/dist/chart/components/high_low/high-low.drawer.js +126 -1
  66. package/dist/chart/components/highlights/highlights.component.js +46 -1
  67. package/dist/chart/components/highlights/highlights.drawer.js +154 -1
  68. package/dist/chart/components/highlights/highlights.model.js +75 -1
  69. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.d.ts +1 -1
  70. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.js +199 -1
  71. package/dist/chart/components/navigation_map/navigation-map-move.handler.d.ts +2 -2
  72. package/dist/chart/components/navigation_map/navigation-map-move.handler.js +108 -1
  73. package/dist/chart/components/navigation_map/navigation-map.component.js +112 -1
  74. package/dist/chart/components/navigation_map/navigation-map.drawer.js +244 -1
  75. package/dist/chart/components/navigation_map/navigation-map.model.js +33 -2
  76. package/dist/chart/components/pan/chart-pan.component.d.ts +2 -2
  77. package/dist/chart/components/pan/chart-pan.component.js +51 -1
  78. package/dist/chart/components/pane/extent/y-extent-component.d.ts +12 -18
  79. package/dist/chart/components/pane/extent/y-extent-component.js +120 -1
  80. package/dist/chart/components/pane/pane-hit-test.controller.d.ts +2 -2
  81. package/dist/chart/components/pane/pane-hit-test.controller.js +55 -1
  82. package/dist/chart/components/pane/pane-manager.component.d.ts +12 -6
  83. package/dist/chart/components/pane/pane-manager.component.js +149 -1
  84. package/dist/chart/components/pane/pane.component.d.ts +16 -32
  85. package/dist/chart/components/pane/pane.component.js +278 -1
  86. package/dist/chart/components/resizer/bar-resizer.component.js +139 -1
  87. package/dist/chart/components/resizer/bar-resizer.drawer.js +46 -1
  88. package/dist/chart/components/snapshot/snapshot.component.js +48 -1
  89. package/dist/chart/components/volumes/separate-volumes.component.d.ts +6 -10
  90. package/dist/chart/components/volumes/separate-volumes.component.js +63 -1
  91. package/dist/chart/components/volumes/volume-color-resolvers.functions.js +18 -1
  92. package/dist/chart/components/volumes/volumes.component.d.ts +6 -7
  93. package/dist/chart/components/volumes/volumes.component.js +94 -1
  94. package/dist/chart/components/volumes/volumes.drawer.d.ts +5 -12
  95. package/dist/chart/components/volumes/volumes.drawer.js +140 -1
  96. package/dist/chart/components/volumes/volumes.formatter.js +31 -1
  97. package/dist/chart/components/volumes/volumes.model.d.ts +2 -2
  98. package/dist/chart/components/volumes/volumes.model.js +43 -1
  99. package/dist/chart/components/watermark/water-mark.component.js +103 -1
  100. package/dist/chart/components/watermark/water-mark.drawer.js +187 -1
  101. package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.js +27 -1
  102. package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.js +187 -1
  103. package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.js +76 -1
  104. package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.js +79 -1
  105. package/dist/chart/components/x_axis/time/parser/time-formats.model.js +14 -1
  106. package/dist/chart/components/x_axis/time/x-axis-weights.functions.d.ts +1 -1
  107. package/dist/chart/components/x_axis/time/x-axis-weights.functions.js +143 -1
  108. package/dist/chart/components/x_axis/time/x-axis-weights.generator.js +73 -1
  109. package/dist/chart/components/x_axis/x-axis-draw.functions.js +49 -1
  110. package/dist/chart/components/x_axis/x-axis-labels.drawer.js +70 -1
  111. package/dist/chart/components/x_axis/x-axis-labels.generator.d.ts +2 -2
  112. package/dist/chart/components/x_axis/x-axis-labels.generator.js +332 -1
  113. package/dist/chart/components/x_axis/x-axis-labels.model.js +35 -1
  114. package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +2 -2
  115. package/dist/chart/components/x_axis/x-axis-scale.handler.js +60 -1
  116. package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +82 -1
  117. package/dist/chart/components/x_axis/x-axis.component.d.ts +2 -2
  118. package/dist/chart/components/x_axis/x-axis.component.js +119 -1
  119. package/dist/chart/components/y_axis/label-color.functions.js +53 -1
  120. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.d.ts +4 -4
  121. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.js +33 -1
  122. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.d.ts +3 -3
  123. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +67 -1
  124. package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.js +56 -1
  125. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.d.ts +4 -3
  126. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +96 -1
  127. package/dist/chart/components/y_axis/price_labels/price-label.drawer.d.ts +2 -2
  128. package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +119 -1
  129. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +9 -8
  130. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +201 -1
  131. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +6 -7
  132. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +58 -1
  133. package/dist/chart/components/y_axis/y-axis-base-labels.model.d.ts +6 -4
  134. package/dist/chart/components/y_axis/y-axis-base-labels.model.js +47 -1
  135. package/dist/chart/components/y_axis/y-axis-labels.drawer.d.ts +4 -4
  136. package/dist/chart/components/y_axis/y-axis-labels.drawer.js +161 -1
  137. package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +2 -2
  138. package/dist/chart/components/y_axis/y-axis-scale.handler.js +72 -1
  139. package/dist/chart/components/y_axis/y-axis.component.d.ts +32 -41
  140. package/dist/chart/components/y_axis/y-axis.component.js +220 -1
  141. package/dist/chart/components/y_axis/y-axis.drawer.d.ts +9 -12
  142. package/dist/chart/components/y_axis/y-axis.drawer.js +96 -1
  143. package/dist/chart/components/y_axis/y-axis.model.d.ts +10 -17
  144. package/dist/chart/components/y_axis/y-axis.model.js +34 -1
  145. package/dist/chart/drawers/chart-background.drawer.js +69 -1
  146. package/dist/chart/drawers/chart-type-drawers/area.drawer.js +69 -1
  147. package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +57 -1
  148. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +84 -1
  149. package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +162 -1
  150. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +57 -1
  151. package/dist/chart/drawers/chart-type-drawers/line.drawer.js +38 -1
  152. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +19 -1
  153. package/dist/chart/drawers/clear-canvas.drawer.js +14 -1
  154. package/dist/chart/drawers/composite.drawer.js +67 -1
  155. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +50 -1
  156. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +35 -1
  157. package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.js +16 -1
  158. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +106 -1
  159. package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +23 -1
  160. package/dist/chart/drawers/data-series-drawers/linear.drawer.js +19 -1
  161. package/dist/chart/drawers/data-series-drawers/points.drawer.js +19 -1
  162. package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.js +7 -1
  163. package/dist/chart/drawers/data-series-drawers/text.drawer.js +25 -1
  164. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +35 -1
  165. package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +22 -1
  166. package/dist/chart/drawers/data-series.drawer.d.ts +5 -7
  167. package/dist/chart/drawers/data-series.drawer.js +56 -1
  168. package/dist/chart/drawers/drawing-manager.d.ts +1 -1
  169. package/dist/chart/drawers/drawing-manager.js +177 -1
  170. package/dist/chart/drawers/ht-data-series.drawer.js +37 -1
  171. package/dist/chart/events/event-bus.js +73 -1
  172. package/dist/chart/events/events.js +3 -1
  173. package/dist/chart/inputhandlers/candle-tap.handler.js +46 -1
  174. package/dist/chart/inputhandlers/chart-resize.handler.js +98 -1
  175. package/dist/chart/inputhandlers/cross-event-producer.component.js +67 -1
  176. package/dist/chart/inputhandlers/hover-producer.component.d.ts +2 -2
  177. package/dist/chart/inputhandlers/hover-producer.component.js +228 -1
  178. package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +2 -2
  179. package/dist/chart/inputhandlers/main-canvas-touch.handler.js +80 -1
  180. package/dist/chart/inputlisteners/canvas-input-listener.component.js +629 -1
  181. package/dist/chart/model/baseline.model.js +88 -1
  182. package/dist/chart/model/bounds.model.js +1 -1
  183. package/dist/chart/model/candle-hover.js +70 -1
  184. package/dist/chart/model/candle-series-high-low.provider.js +45 -1
  185. package/dist/chart/model/candle-series.model.d.ts +3 -3
  186. package/dist/chart/model/candle-series.model.js +245 -1
  187. package/dist/chart/model/candle.model.js +69 -1
  188. package/dist/chart/model/canvas.model.js +228 -1
  189. package/dist/chart/model/chart-base-element.js +129 -1
  190. package/dist/chart/model/compare-series-hover.js +25 -1
  191. package/dist/chart/model/data-series-view.d.ts +5 -5
  192. package/dist/chart/model/data-series-view.js +111 -1
  193. package/dist/chart/model/data-series.config.js +14 -1
  194. package/dist/chart/model/data-series.model.d.ts +4 -4
  195. package/dist/chart/model/data-series.model.js +281 -1
  196. package/dist/chart/model/date-time.formatter.js +151 -1
  197. package/dist/chart/model/hit-test-canvas.model.d.ts +1 -1
  198. package/dist/chart/model/hit-test-canvas.model.js +256 -1
  199. package/dist/chart/model/main-candle-series.model.d.ts +1 -1
  200. package/dist/chart/model/main-candle-series.model.js +29 -1
  201. package/dist/chart/model/scale.model.d.ts +3 -2
  202. package/dist/chart/model/scale.model.js +316 -1
  203. package/dist/chart/model/scaling/auto-scale.model.d.ts +2 -4
  204. package/dist/chart/model/scaling/auto-scale.model.js +91 -1
  205. package/dist/chart/model/scaling/constrait.functions.js +61 -1
  206. package/dist/chart/model/scaling/lock-ratio.model.js +17 -1
  207. package/dist/chart/model/scaling/move-chart.functions.js +22 -1
  208. package/dist/chart/model/scaling/viewport.model.d.ts +2 -2
  209. package/dist/chart/model/scaling/viewport.model.js +279 -1
  210. package/dist/chart/model/scaling/x-zooming.functions.js +35 -1
  211. package/dist/chart/model/time-zone.model.js +109 -1
  212. package/dist/chart/model/visual-candle.js +134 -1
  213. package/dist/chart/utils/__tests__/array.utils.test.js +135 -1
  214. package/dist/chart/utils/__tests__/math.utils.test.js +14 -1
  215. package/dist/chart/utils/__tests__/object.utils.test.js +11 -1
  216. package/dist/chart/utils/__tests__/priceIncrementsUtils.test.js +29 -1
  217. package/dist/chart/utils/array.utils.d.ts +1 -1
  218. package/dist/chart/utils/array.utils.js +269 -1
  219. package/dist/chart/utils/auto-period-detector.utils.js +39 -1
  220. package/dist/chart/utils/candles-generator-ts.utils.js +20 -1
  221. package/dist/chart/utils/candles-generator.utils.js +161 -1
  222. package/dist/chart/utils/candles.utils.js +42 -1
  223. package/dist/chart/utils/canvas/canvas-drawing-functions.utils.js +144 -1
  224. package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.js +51 -1
  225. package/dist/chart/utils/canvas/canvas-text-functions.utils.js +156 -1
  226. package/dist/chart/utils/color.utils.js +31 -1
  227. package/dist/chart/utils/device/browser.utils.js +10 -1
  228. package/dist/chart/utils/device/device-detector.utils.js +24 -1
  229. package/dist/chart/utils/device/device-pixel-ratio.utils.js +21 -1
  230. package/dist/chart/utils/device/touchpad.utils.js +91 -1
  231. package/dist/chart/utils/dom.utils.js +15 -1
  232. package/dist/chart/utils/function.utils.js +16 -1
  233. package/dist/chart/utils/linkedList.utils.d.ts +28 -0
  234. package/dist/chart/utils/linkedList.utils.js +138 -0
  235. package/dist/chart/utils/math.utils.js +115 -1
  236. package/dist/chart/utils/merge.utils.js +56 -1
  237. package/dist/chart/utils/object.utils.js +43 -1
  238. package/dist/chart/utils/performance/animation-frame-cache.utils.js +77 -0
  239. package/dist/chart/utils/{perfomance → performance}/debounce.utils.js +7 -1
  240. package/dist/chart/utils/performance/memoize.utils.js +74 -0
  241. package/dist/chart/utils/performance/request-animation-frame-throttle.utils.js +43 -0
  242. package/dist/chart/utils/performance/throttle.utils.js +26 -0
  243. package/dist/chart/utils/price-increments.utils.d.ts +1 -0
  244. package/dist/chart/utils/price-increments.utils.js +127 -1
  245. package/dist/chart/utils/uuid.utils.js +4 -1
  246. package/dist/dxchart.min.js +9 -12
  247. package/dist/index.d.ts +3 -3
  248. package/dist/index.js +20 -1
  249. package/package.json +4 -4
  250. package/dist/chart/utils/perfomance/animation-frame-cache.utils.js +0 -6
  251. package/dist/chart/utils/perfomance/memoize.utils.js +0 -6
  252. package/dist/chart/utils/perfomance/request-animation-frame-throttle.utils.js +0 -6
  253. package/dist/chart/utils/perfomance/throttle.utils.js +0 -6
  254. /package/dist/chart/utils/{perfomance → performance}/animation-frame-cache.utils.d.ts +0 -0
  255. /package/dist/chart/utils/{perfomance → performance}/debounce.utils.d.ts +0 -0
  256. /package/dist/chart/utils/{perfomance → performance}/memoize.utils.d.ts +0 -0
  257. /package/dist/chart/utils/{perfomance → performance}/request-animation-frame-throttle.utils.d.ts +0 -0
  258. /package/dist/chart/utils/{perfomance → performance}/throttle.utils.d.ts +0 -0
@@ -0,0 +1,138 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
+ * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+ export class ListNode {
7
+ constructor(data) {
8
+ this.data = data;
9
+ this.next = null;
10
+ }
11
+ }
12
+ /**
13
+ * Implementation of Linked list data structure.
14
+ * @param _head
15
+ */
16
+ export class LinkedList {
17
+ constructor(head) {
18
+ this._head = null;
19
+ this._tail = null;
20
+ this.length = 0;
21
+ this._head = head !== null && head !== void 0 ? head : null;
22
+ // init tail
23
+ if (this.head !== null) {
24
+ let current;
25
+ current = this.head;
26
+ while (current.next) {
27
+ current = current.next;
28
+ }
29
+ this._tail = current;
30
+ }
31
+ }
32
+ insertAtEnd(data) {
33
+ const node = new ListNode(data);
34
+ let current;
35
+ if (this.head === null) {
36
+ this._head = node;
37
+ }
38
+ else {
39
+ current = this.head;
40
+ while (current.next) {
41
+ current = current.next;
42
+ }
43
+ current.next = node;
44
+ }
45
+ this._tail = node;
46
+ this.length++;
47
+ return node;
48
+ }
49
+ insertAt(position, data) {
50
+ if (position > -1 && position < this.length && this.head) {
51
+ let current = this.head;
52
+ let index = 0;
53
+ let previous = null;
54
+ const node = new ListNode(data);
55
+ if (position === this.length - 1) {
56
+ this._tail = node;
57
+ }
58
+ if (position === 0) {
59
+ node.next = current;
60
+ this._head = node;
61
+ }
62
+ else {
63
+ while (index < position && current.next) {
64
+ index++;
65
+ previous = current;
66
+ current = current.next;
67
+ }
68
+ node.next = current;
69
+ if (previous) {
70
+ previous.next = node;
71
+ }
72
+ }
73
+ this.length++;
74
+ return current;
75
+ }
76
+ else {
77
+ this._head = new ListNode(data);
78
+ this.length++;
79
+ return this.head;
80
+ }
81
+ }
82
+ removeAt(position) {
83
+ if (position > -1 && position < this.length && this.head) {
84
+ let current = this.head;
85
+ let previous = null;
86
+ let index = 0;
87
+ if (position === 0) {
88
+ this._head = current.next;
89
+ }
90
+ else {
91
+ while (index < position && current.next) {
92
+ index++;
93
+ previous = current;
94
+ current = current.next;
95
+ }
96
+ if (previous) {
97
+ previous.next = current.next;
98
+ }
99
+ if (position === this.length - 1) {
100
+ this._tail = current;
101
+ }
102
+ }
103
+ this.length--;
104
+ return current;
105
+ }
106
+ else {
107
+ return null;
108
+ }
109
+ }
110
+ getNodePosition(node) {
111
+ let index = 0;
112
+ let current = this.head;
113
+ while (node) {
114
+ if ((current === null || current === void 0 ? void 0 : current.data) === node.data) {
115
+ return index;
116
+ }
117
+ current = current && current.next;
118
+ index++;
119
+ }
120
+ return -1;
121
+ }
122
+ size() {
123
+ return this.length;
124
+ }
125
+ get head() {
126
+ return this._head;
127
+ }
128
+ get tail() {
129
+ return this._tail;
130
+ }
131
+ *[Symbol.iterator]() {
132
+ let current = this.head;
133
+ while (current) {
134
+ yield current.data;
135
+ current = current.next;
136
+ }
137
+ }
138
+ }
@@ -3,4 +3,118 @@
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
4
  * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
  */
6
- export const MAX_DECIMAL_DIGITS=14;const s=[];for(let n=0;n<14+1;n++)s.push(Math.pow(10,n));const c=5e-13;export class MathUtils{static roundToNearest(t,r){return isFinite(t)?MathUtils.isZero(t)?0:(t>0?t+=c:t<0&&(t-=c),MathUtils.roundDecimal(Math.round(MathUtils.roundDecimal(t/r))*r)):t}static roundUpToNearest(t,r){return MathUtils.roundDecimal(Math.ceil(t/r))*r}static roundDecimal(t){if(isNaN(t)||t===Math.floor(t))return t;const r=Math.sign(t),e=Math.abs(t),i=Math.min(14,14-1-Math.floor(Math.log10(e)));for(let o=i;o>=0;o--){const a=Math.floor(s[o]*e+.5);if(a<s[14])return r*a/s[o]}return Math.round(t)}static makeDecimal(t,r,e){if(isFinite(t)){const i=t.toFixed(r);return e?i.replace(".",e):i}else return""}static compare(t,r,e){return t>r+e?1:t<r-e?-1:(isNaN(t)?1:0)-(isNaN(r)?1:0)}static isZero(t){return MathUtils.compare(t,0,c)===0}static cutNumber(t,r,e=0){return{K:o=>o/1e3,M:o=>o/1e6}[r](t).toFixed(e)+r}}export function isDiffersBy(n,t,r){const e=n/t;return e>=r||e<=1/r}export function clamp(n,t,r){return Math.max(t,Math.min(n,r))}export function easeExpOut(n){return 1-(Math.pow(2,-10*n)-.0009765625)*1.0009775171065494}export function finite(...n){for(const t of n)if(t!==void 0&&isFinite(t))return t;return NaN}export const floor=n=>~~n,ceil=n=>~~(n+1),round=n=>~~(n+.5),shiftRight=(n,t)=>n>>t;
6
+ export const MAX_DECIMAL_DIGITS = 14;
7
+ // Array of powers of 10. Used in roundDecimal to walk through mantissa.
8
+ const POW10 = [];
9
+ for (let i = 0; i < MAX_DECIMAL_DIGITS + 1; i++) {
10
+ POW10.push(Math.pow(10, i));
11
+ }
12
+ const EPS = 5e-13;
13
+ export class MathUtils {
14
+ static roundToNearest(value, precision) {
15
+ if (!isFinite(value)) {
16
+ return value;
17
+ }
18
+ if (MathUtils.isZero(value)) {
19
+ return 0.0;
20
+ }
21
+ if (value > 0) {
22
+ value += EPS;
23
+ }
24
+ else if (value < 0) {
25
+ value -= EPS;
26
+ }
27
+ return MathUtils.roundDecimal(Math.round(MathUtils.roundDecimal(value / precision)) * precision);
28
+ }
29
+ static roundUpToNearest(value, precision) {
30
+ return MathUtils.roundDecimal(Math.ceil(value / precision)) * precision;
31
+ }
32
+ static roundDecimal(x) {
33
+ if (isNaN(x) || x === Math.floor(x)) {
34
+ return x;
35
+ } // integer, NaN, or +/- inf
36
+ const signum = Math.sign(x);
37
+ const abs = Math.abs(x);
38
+ const pow = Math.min(MAX_DECIMAL_DIGITS, MAX_DECIMAL_DIGITS - 1 - Math.floor(Math.log10(abs)));
39
+ for (let i = pow; i >= 0; i--) {
40
+ const mantissa = Math.floor(POW10[i] * abs + 0.5);
41
+ if (mantissa < POW10[MAX_DECIMAL_DIGITS]) {
42
+ return (signum * mantissa) / POW10[i];
43
+ }
44
+ }
45
+ // Mantissa >= 10^14 with fractions -- just round
46
+ return Math.round(x);
47
+ }
48
+ static makeDecimal(value, precision, decimal) {
49
+ if (isFinite(value)) {
50
+ const stringValue = value.toFixed(precision);
51
+ return decimal ? stringValue.replace('.', decimal) : stringValue;
52
+ }
53
+ else {
54
+ return '';
55
+ }
56
+ }
57
+ static compare(a, b, eps) {
58
+ if (a > b + eps) {
59
+ return +1;
60
+ }
61
+ else if (a < b - eps) {
62
+ return -1;
63
+ }
64
+ else {
65
+ return (isNaN(a) ? 1 : 0) - (isNaN(b) ? 1 : 0);
66
+ }
67
+ }
68
+ static isZero(a) {
69
+ return MathUtils.compare(a, 0, EPS) === 0;
70
+ }
71
+ static cutNumber(value, amountToCut, zeros = 0) {
72
+ const cutMap = {
73
+ K: v => v / 1000,
74
+ M: v => v / 1000000,
75
+ };
76
+ return cutMap[amountToCut](value).toFixed(zeros) + amountToCut;
77
+ }
78
+ }
79
+ /**
80
+ * Checks if first and second number are differs by specified times
81
+ * @param first {number}
82
+ * @param second {number}
83
+ * @param times {number}
84
+ * @doc-tags utility,math
85
+ */
86
+ export function isDiffersBy(first, second, times) {
87
+ const diff = first / second;
88
+ return diff >= times || diff <= 1 / times;
89
+ }
90
+ export function clamp(value, min, max) {
91
+ return Math.max(min, Math.min(value, max));
92
+ }
93
+ export function easeExpOut(value) {
94
+ return 1 - (Math.pow(2, -10 * value) - 0.0009765625) * 1.0009775171065494;
95
+ }
96
+ /**
97
+ * Returns the first finite number in a list of numbers. If no finite number is found,
98
+ * returns NaN.
99
+ * @param {...number} args - A list of numbers to search for a finite value.
100
+ * @returns {number} The first finite number in the list, or NaN if no finite number is found.
101
+ */
102
+ export function finite(...args) {
103
+ for (const arg of args) {
104
+ if (arg !== undefined && isFinite(arg)) {
105
+ return arg;
106
+ }
107
+ }
108
+ return NaN;
109
+ }
110
+ /**
111
+ * These functions can be used only for chart coordinates because they all are working in positive coordinates!!!
112
+ */
113
+ // eslint-disable-next-line no-bitwise
114
+ export const floor = (value) => ~~value;
115
+ // eslint-disable-next-line no-bitwise
116
+ export const ceil = (value) => ~~(value + 1);
117
+ // eslint-disable-next-line no-bitwise
118
+ export const round = (value) => ~~(value + 0.5);
119
+ // eslint-disable-next-line no-bitwise
120
+ export const shiftRight = (value, shift) => value >> shift;
@@ -3,4 +3,59 @@
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
4
  * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
  */
6
- export function merge(r,e,f=DEFAULT_MERGE_OPTIONS){function l(n,t){for(const i in t)i in n?typeof n[i]=="object"&&n[i]!==null&&!Array.isArray(n[i])?l(n[i],t[i]):f!=null&&f.overrideExisting&&(n[i]=t[i]):f!=null&&f.addIfMissing&&(n[i]=t[i]);return n}return l(r,e)}export function mergeArray(r,e,f,l=!1){!r||!e||e.length===0||e.forEach(n=>{const t=f(n),i=r.findIndex(u=>f(u)===t);i===-1?r.push(n):l?merge(r[i],n,{overrideExisting:!0,addIfMissing:!0}):r.splice(i,1,n)})}export const DEFAULT_MERGE_OPTIONS={overrideExisting:!1,addIfMissing:!0};
6
+ /**
7
+ * Merges 2 js objects recursively with all properties.
8
+ * - does not modify base object
9
+ * - can override or only add missing ones
10
+ *
11
+ * @param base - base object to merge data into
12
+ * @param override - object with new data which should be merged
13
+ * @param options - merge options
14
+ * @doc-tags tricky,utility
15
+ */
16
+ export function merge(base, override, options = DEFAULT_MERGE_OPTIONS) {
17
+ function doMerge(base, override) {
18
+ for (const k in override) {
19
+ if (k in base) {
20
+ if (typeof base[k] === 'object' && base[k] !== null && !Array.isArray(base[k])) {
21
+ doMerge(base[k], override[k]);
22
+ }
23
+ else {
24
+ // do not merge arrays or functions
25
+ if (options === null || options === void 0 ? void 0 : options.overrideExisting) {
26
+ base[k] = override[k];
27
+ }
28
+ }
29
+ }
30
+ else {
31
+ if (options === null || options === void 0 ? void 0 : options.addIfMissing) {
32
+ base[k] = override[k];
33
+ }
34
+ }
35
+ }
36
+ return base;
37
+ }
38
+ return doMerge(base, override);
39
+ }
40
+ export function mergeArray(base, override, hashFn, mergeObjects = false) {
41
+ if (!base || !override || override.length === 0) {
42
+ return;
43
+ }
44
+ override.forEach(o => {
45
+ const hash = hashFn(o);
46
+ const existingIndex = base.findIndex(b => hashFn(b) === hash);
47
+ if (existingIndex === -1) {
48
+ base.push(o);
49
+ }
50
+ else {
51
+ if (mergeObjects) {
52
+ // try merging objects in array
53
+ merge(base[existingIndex], o, { overrideExisting: true, addIfMissing: true });
54
+ }
55
+ else {
56
+ base.splice(existingIndex, 1, o);
57
+ }
58
+ }
59
+ });
60
+ }
61
+ export const DEFAULT_MERGE_OPTIONS = { overrideExisting: false, addIfMissing: true };
@@ -3,4 +3,46 @@
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
4
  * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
  */
6
- export const cloneUnsafe=e=>JSON.parse(JSON.stringify(e));export function typedEntries_UNSAFE(e){return Object.entries(e)}export const findKeyFromValue=(e,t)=>{for(const[r,s]of Array.from(e.entries()))if(s===t)return r};export function keys(e){return Object.keys(e)}export function deepEqual(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;for(let n=0,f=r.length;n<f;n++)if(!hasOwnProperty.call(t,r[n])||!deepEqual(e[r[n]],t[r[n]]))return!1;return!0}
6
+ export const cloneUnsafe = (value) => JSON.parse(JSON.stringify(value));
7
+ export function typedEntries_UNSAFE(obj) {
8
+ // eslint-disable-next-line no-restricted-syntax
9
+ return Object.entries(obj);
10
+ }
11
+ export const findKeyFromValue = (map, mapValue) => {
12
+ for (const [key, value] of Array.from(map.entries())) {
13
+ if (value === mapValue) {
14
+ return key;
15
+ }
16
+ }
17
+ };
18
+ export function keys(r) {
19
+ // eslint-disable-next-line no-restricted-syntax
20
+ return Object.keys(r);
21
+ }
22
+ /**
23
+ * Deeply compares two objects
24
+ * @param {*} objA
25
+ * @param {*} objB
26
+ * @returns {Boolean}
27
+ */
28
+ export function deepEqual(objA, objB) {
29
+ if (Object.is(objA, objB)) {
30
+ return true;
31
+ }
32
+ if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
33
+ return false;
34
+ }
35
+ const keysA = Object.keys(objA);
36
+ const keysB = Object.keys(objB);
37
+ if (keysA.length !== keysB.length) {
38
+ return false;
39
+ }
40
+ // Test for A's keys different from B.
41
+ for (let i = 0, len = keysA.length; i < len; i++) {
42
+ // @ts-ignore
43
+ if (!hasOwnProperty.call(objB, keysA[i]) || !deepEqual(objA[keysA[i]], objB[keysA[i]])) {
44
+ return false;
45
+ }
46
+ }
47
+ return true;
48
+ }
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
+ * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+ import { animationFrameThrottled } from './request-animation-frame-throttle.utils';
7
+ import { uuid } from '../uuid.utils';
8
+ /**
9
+ * Use this as a wrapper to cache calculation results during single animation frame cycle.
10
+ * It is useful if
11
+ * - you have multiple invocations of same code in same animation frame
12
+ * - you're sure that result will always be the same
13
+ */
14
+ export class AnimationFrameCache {
15
+ constructor(dataProvider, dataUpdatedPredicate = () => true) {
16
+ this.dataProvider = dataProvider;
17
+ this.dataUpdatedPredicate = dataUpdatedPredicate;
18
+ this.calculatedInThisFrame = false;
19
+ this.animFrameId = `anim_cache_${uuid()}`;
20
+ }
21
+ /**
22
+ * Calculates or retrieves a cached value.
23
+ * If the value has not been calculated in the current frame, it calculates it by calling the dataProvider function.
24
+ * If the data has been updated, it sets the calculatedInThisFrame flag to true.
25
+ * It also sets a throttled animation frame to reset the calculatedInThisFrame flag to false.
26
+ * If the cache is not null, it returns the cached value, otherwise it calls the dataProvider function and returns its result.
27
+ * @returns {T} The cached or calculated value.
28
+ */
29
+ calculateOrGet() {
30
+ var _a;
31
+ if (!this.calculatedInThisFrame) {
32
+ this.cache = this.dataProvider();
33
+ if (this.dataUpdatedPredicate()) {
34
+ this.calculatedInThisFrame = true;
35
+ }
36
+ animationFrameThrottled(this.animFrameId, () => {
37
+ this.calculatedInThisFrame = false;
38
+ });
39
+ }
40
+ return (_a = this.cache) !== null && _a !== void 0 ? _a : this.dataProvider();
41
+ }
42
+ /**
43
+ * Invalidates the current state and returns the result of the calculateOrGet() method.
44
+ * @returns {T} The result of the calculateOrGet() method.
45
+ */
46
+ forceCalculateOrGet() {
47
+ this.invalidate();
48
+ return this.calculateOrGet();
49
+ }
50
+ /**
51
+ * Returns the last cached value or undefined if there is no cached value.
52
+ * @returns {T | undefined} The last cached value or undefined.
53
+ */
54
+ getLastCachedValue() {
55
+ return this.cache;
56
+ }
57
+ /**
58
+ * Updates the cache value with the provided value.
59
+ * @param {T} value - The new value to be set in the cache.
60
+ * @returns {void}
61
+ */
62
+ updateCacheValue(value) {
63
+ this.cache = value;
64
+ }
65
+ /**
66
+ * Invalidates the cache and sets the calculatedInThisFrame flag to false.
67
+ * @function
68
+ * @name invalidate
69
+ * @memberof ClassName
70
+ * @instance
71
+ * @returns {void}
72
+ */
73
+ invalidate() {
74
+ this.cache = undefined;
75
+ this.calculatedInThisFrame = false;
76
+ }
77
+ }
@@ -3,4 +3,10 @@
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
4
  * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
  */
6
- export const debounce=(t,o)=>{let e=0;return(...u)=>{clearTimeout(e),e=+setTimeout(()=>t(...u),o)}};
6
+ export const debounce = (callback, waitFor) => {
7
+ let timeout = 0;
8
+ return (...args) => {
9
+ clearTimeout(timeout);
10
+ timeout = +setTimeout(() => callback(...args), waitFor);
11
+ };
12
+ };
@@ -0,0 +1,74 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
+ * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+ // eslint-disable-next-line no-restricted-syntax
7
+ export const MEMOIZE_CLEAR_FUNCTION = Symbol('MEMOIZE_CLEAR_FUNCTION');
8
+ /**
9
+ * Memoizes function for passed arguments
10
+ * @doc-tags utility
11
+ */
12
+ // eslint-disable-next-line @typescript-eslint/ban-types
13
+ export function memoize(fn) {
14
+ const storage = {};
15
+ const result = function () {
16
+ const args = Array.prototype.slice.call(arguments);
17
+ const key = serialize(args);
18
+ if (typeof storage[key] === 'undefined') {
19
+ // eslint-disable-next-line no-restricted-syntax
20
+ storage[key] = fn.apply(this, args);
21
+ }
22
+ return storage[key];
23
+ }.bind(this);
24
+ // inject clearer
25
+ // @ts-ignore
26
+ result[MEMOIZE_CLEAR_FUNCTION] = function () {
27
+ const args = Array.prototype.slice.call(arguments);
28
+ const key = serialize(args);
29
+ delete storage[key];
30
+ };
31
+ // eslint-disable-next-line no-restricted-syntax
32
+ return result;
33
+ }
34
+ export const memoOnce = (E) => (f) => {
35
+ let hasValue = false;
36
+ let cachedR;
37
+ // eslint-disable-next-line no-restricted-syntax
38
+ let cachedArgs = [];
39
+ const update = (args) => {
40
+ cachedR = f(...args);
41
+ hasValue = true;
42
+ cachedArgs = args;
43
+ };
44
+ return (...args) => {
45
+ const length = args.length;
46
+ if (hasValue && length === 0) {
47
+ return cachedR;
48
+ }
49
+ if (!hasValue || cachedArgs.length !== length) {
50
+ update(args);
51
+ return cachedR;
52
+ }
53
+ for (let i = 0; i < length; i++) {
54
+ if (!E.equals(cachedArgs[i], args[i])) {
55
+ update(args);
56
+ return cachedR;
57
+ }
58
+ }
59
+ return cachedR;
60
+ };
61
+ };
62
+ /**
63
+ * @param {Array.<*>} args
64
+ * @returns {String}
65
+ */
66
+ export function serialize(args) {
67
+ const argsAreValid = args.every(arg => {
68
+ return typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'boolean';
69
+ });
70
+ if (!argsAreValid) {
71
+ throw Error('Arguments to memoized function can only be strings or numbers');
72
+ }
73
+ return JSON.stringify(args);
74
+ }
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
+ * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+ let fired = false;
7
+ export let animationFrameId = 0;
8
+ // map is faster than record
9
+ const actions = new Map();
10
+ const priorActions = new Map();
11
+ const animFrame = () => {
12
+ if (!fired) {
13
+ fired = true;
14
+ animationFrameId = requestAnimationFrame(() => {
15
+ priorActions.forEach((action, key) => {
16
+ action();
17
+ priorActions.delete(key);
18
+ });
19
+ actions.forEach((action, key) => {
20
+ action();
21
+ actions.delete(key);
22
+ });
23
+ fired = false;
24
+ });
25
+ }
26
+ };
27
+ export const animationFrameThrottled = (name, action) => {
28
+ actions.set(name, action);
29
+ animFrame();
30
+ };
31
+ export const cancelThrottledAnimationFrame = (name) => {
32
+ actions.delete(name);
33
+ };
34
+ /**
35
+ * Prior actions will be called before regular actions
36
+ * An example of regular action - draw event
37
+ * @param name
38
+ * @param action
39
+ */
40
+ export const animationFrameThrottledPrior = (name, action) => {
41
+ priorActions.set(name, action);
42
+ animFrame();
43
+ };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
3
+ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
+ * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+ import { uuid } from '../uuid.utils';
7
+ import { animationFrameThrottled } from './request-animation-frame-throttle.utils';
8
+ export function throttle(shouldPreventDefault, listener, isSuppressed) {
9
+ let last;
10
+ const animFrameId = uuid();
11
+ function fireLastEvent() {
12
+ const event = last;
13
+ last = void 0;
14
+ if (event) {
15
+ listener(event);
16
+ }
17
+ }
18
+ return function (event) {
19
+ const hasEvent = last;
20
+ last = event;
21
+ shouldPreventDefault && event.preventDefault();
22
+ if (!hasEvent && !(typeof isSuppressed === 'function' && isSuppressed())) {
23
+ animationFrameThrottled(animFrameId, fireLastEvent);
24
+ }
25
+ };
26
+ }
@@ -42,3 +42,4 @@ export declare class PriceIncrementsUtils {
42
42
  */
43
43
  static validatePriceIncrementsOrPrecisions(data: number[]): boolean;
44
44
  }
45
+ export declare const precisionsToIncrement: (price: number, precisions: number[]) => number;