@devexperts/dxcharts-lite 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) 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.js +55 -1
  81. package/dist/chart/components/pane/pane-manager.component.d.ts +10 -5
  82. package/dist/chart/components/pane/pane-manager.component.js +148 -1
  83. package/dist/chart/components/pane/pane.component.d.ts +16 -32
  84. package/dist/chart/components/pane/pane.component.js +278 -1
  85. package/dist/chart/components/resizer/bar-resizer.component.js +139 -1
  86. package/dist/chart/components/resizer/bar-resizer.drawer.js +46 -1
  87. package/dist/chart/components/snapshot/snapshot.component.js +48 -1
  88. package/dist/chart/components/volumes/separate-volumes.component.d.ts +6 -10
  89. package/dist/chart/components/volumes/separate-volumes.component.js +63 -1
  90. package/dist/chart/components/volumes/volume-color-resolvers.functions.js +18 -1
  91. package/dist/chart/components/volumes/volumes.component.d.ts +6 -7
  92. package/dist/chart/components/volumes/volumes.component.js +94 -1
  93. package/dist/chart/components/volumes/volumes.drawer.d.ts +5 -12
  94. package/dist/chart/components/volumes/volumes.drawer.js +140 -1
  95. package/dist/chart/components/volumes/volumes.formatter.js +31 -1
  96. package/dist/chart/components/volumes/volumes.model.d.ts +2 -2
  97. package/dist/chart/components/volumes/volumes.model.js +43 -1
  98. package/dist/chart/components/watermark/water-mark.component.js +103 -1
  99. package/dist/chart/components/watermark/water-mark.drawer.js +187 -1
  100. package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.js +27 -1
  101. package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.js +187 -1
  102. package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.js +76 -1
  103. package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.js +79 -1
  104. package/dist/chart/components/x_axis/time/parser/time-formats.model.js +14 -1
  105. package/dist/chart/components/x_axis/time/x-axis-weights.functions.d.ts +1 -1
  106. package/dist/chart/components/x_axis/time/x-axis-weights.functions.js +143 -1
  107. package/dist/chart/components/x_axis/time/x-axis-weights.generator.js +73 -1
  108. package/dist/chart/components/x_axis/x-axis-draw.functions.js +49 -1
  109. package/dist/chart/components/x_axis/x-axis-labels.drawer.js +70 -1
  110. package/dist/chart/components/x_axis/x-axis-labels.generator.d.ts +2 -2
  111. package/dist/chart/components/x_axis/x-axis-labels.generator.js +332 -1
  112. package/dist/chart/components/x_axis/x-axis-labels.model.js +35 -1
  113. package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +2 -2
  114. package/dist/chart/components/x_axis/x-axis-scale.handler.js +60 -1
  115. package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +82 -1
  116. package/dist/chart/components/x_axis/x-axis.component.d.ts +2 -2
  117. package/dist/chart/components/x_axis/x-axis.component.js +119 -1
  118. package/dist/chart/components/y_axis/label-color.functions.js +53 -1
  119. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.d.ts +4 -4
  120. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.js +33 -1
  121. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.d.ts +3 -3
  122. package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +67 -1
  123. package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.js +56 -1
  124. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +95 -1
  125. package/dist/chart/components/y_axis/price_labels/price-label.drawer.d.ts +2 -2
  126. package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +119 -1
  127. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +9 -8
  128. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +201 -1
  129. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +6 -7
  130. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +58 -1
  131. package/dist/chart/components/y_axis/y-axis-base-labels.model.d.ts +6 -4
  132. package/dist/chart/components/y_axis/y-axis-base-labels.model.js +47 -1
  133. package/dist/chart/components/y_axis/y-axis-labels.drawer.d.ts +4 -4
  134. package/dist/chart/components/y_axis/y-axis-labels.drawer.js +161 -1
  135. package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +2 -2
  136. package/dist/chart/components/y_axis/y-axis-scale.handler.js +72 -1
  137. package/dist/chart/components/y_axis/y-axis.component.d.ts +32 -41
  138. package/dist/chart/components/y_axis/y-axis.component.js +220 -1
  139. package/dist/chart/components/y_axis/y-axis.drawer.d.ts +9 -12
  140. package/dist/chart/components/y_axis/y-axis.drawer.js +96 -1
  141. package/dist/chart/components/y_axis/y-axis.model.d.ts +9 -17
  142. package/dist/chart/components/y_axis/y-axis.model.js +33 -1
  143. package/dist/chart/drawers/chart-background.drawer.js +69 -1
  144. package/dist/chart/drawers/chart-type-drawers/area.drawer.js +69 -1
  145. package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +57 -1
  146. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +84 -1
  147. package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +162 -1
  148. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +57 -1
  149. package/dist/chart/drawers/chart-type-drawers/line.drawer.js +38 -1
  150. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +19 -1
  151. package/dist/chart/drawers/clear-canvas.drawer.js +14 -1
  152. package/dist/chart/drawers/composite.drawer.js +67 -1
  153. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +50 -1
  154. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +35 -1
  155. package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.js +16 -1
  156. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +106 -1
  157. package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +23 -1
  158. package/dist/chart/drawers/data-series-drawers/linear.drawer.js +19 -1
  159. package/dist/chart/drawers/data-series-drawers/points.drawer.js +19 -1
  160. package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.js +7 -1
  161. package/dist/chart/drawers/data-series-drawers/text.drawer.js +25 -1
  162. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +35 -1
  163. package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +22 -1
  164. package/dist/chart/drawers/data-series.drawer.d.ts +5 -7
  165. package/dist/chart/drawers/data-series.drawer.js +56 -1
  166. package/dist/chart/drawers/drawing-manager.d.ts +1 -1
  167. package/dist/chart/drawers/drawing-manager.js +177 -1
  168. package/dist/chart/drawers/ht-data-series.drawer.js +37 -1
  169. package/dist/chart/events/event-bus.js +73 -1
  170. package/dist/chart/events/events.js +3 -1
  171. package/dist/chart/inputhandlers/candle-tap.handler.js +46 -1
  172. package/dist/chart/inputhandlers/chart-resize.handler.js +98 -1
  173. package/dist/chart/inputhandlers/cross-event-producer.component.js +67 -1
  174. package/dist/chart/inputhandlers/hover-producer.component.d.ts +2 -2
  175. package/dist/chart/inputhandlers/hover-producer.component.js +228 -1
  176. package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +2 -2
  177. package/dist/chart/inputhandlers/main-canvas-touch.handler.js +80 -1
  178. package/dist/chart/inputlisteners/canvas-input-listener.component.js +629 -1
  179. package/dist/chart/model/baseline.model.js +88 -1
  180. package/dist/chart/model/bounds.model.js +1 -1
  181. package/dist/chart/model/candle-hover.js +70 -1
  182. package/dist/chart/model/candle-series-high-low.provider.js +45 -1
  183. package/dist/chart/model/candle-series.model.d.ts +3 -3
  184. package/dist/chart/model/candle-series.model.js +245 -1
  185. package/dist/chart/model/candle.model.js +69 -1
  186. package/dist/chart/model/canvas.model.js +228 -1
  187. package/dist/chart/model/chart-base-element.js +129 -1
  188. package/dist/chart/model/compare-series-hover.js +25 -1
  189. package/dist/chart/model/data-series-view.d.ts +5 -5
  190. package/dist/chart/model/data-series-view.js +111 -1
  191. package/dist/chart/model/data-series.config.js +14 -1
  192. package/dist/chart/model/data-series.model.d.ts +4 -4
  193. package/dist/chart/model/data-series.model.js +281 -1
  194. package/dist/chart/model/date-time.formatter.js +151 -1
  195. package/dist/chart/model/hit-test-canvas.model.d.ts +1 -1
  196. package/dist/chart/model/hit-test-canvas.model.js +256 -1
  197. package/dist/chart/model/main-candle-series.model.d.ts +1 -1
  198. package/dist/chart/model/main-candle-series.model.js +29 -1
  199. package/dist/chart/model/scale.model.d.ts +2 -1
  200. package/dist/chart/model/scale.model.js +316 -1
  201. package/dist/chart/model/scaling/auto-scale.model.js +97 -1
  202. package/dist/chart/model/scaling/constrait.functions.js +61 -1
  203. package/dist/chart/model/scaling/lock-ratio.model.js +17 -1
  204. package/dist/chart/model/scaling/move-chart.functions.js +22 -1
  205. package/dist/chart/model/scaling/viewport.model.d.ts +2 -2
  206. package/dist/chart/model/scaling/viewport.model.js +279 -1
  207. package/dist/chart/model/scaling/x-zooming.functions.js +35 -1
  208. package/dist/chart/model/time-zone.model.js +109 -1
  209. package/dist/chart/model/visual-candle.js +134 -1
  210. package/dist/chart/utils/__tests__/array.utils.test.js +135 -1
  211. package/dist/chart/utils/__tests__/math.utils.test.js +14 -1
  212. package/dist/chart/utils/__tests__/object.utils.test.js +11 -1
  213. package/dist/chart/utils/__tests__/priceIncrementsUtils.test.js +29 -1
  214. package/dist/chart/utils/array.utils.d.ts +1 -1
  215. package/dist/chart/utils/array.utils.js +269 -1
  216. package/dist/chart/utils/auto-period-detector.utils.js +39 -1
  217. package/dist/chart/utils/candles-generator-ts.utils.js +20 -1
  218. package/dist/chart/utils/candles-generator.utils.js +161 -1
  219. package/dist/chart/utils/candles.utils.js +42 -1
  220. package/dist/chart/utils/canvas/canvas-drawing-functions.utils.js +144 -1
  221. package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.js +51 -1
  222. package/dist/chart/utils/canvas/canvas-text-functions.utils.js +156 -1
  223. package/dist/chart/utils/color.utils.js +31 -1
  224. package/dist/chart/utils/device/browser.utils.js +10 -1
  225. package/dist/chart/utils/device/device-detector.utils.js +24 -1
  226. package/dist/chart/utils/device/device-pixel-ratio.utils.js +21 -1
  227. package/dist/chart/utils/device/touchpad.utils.js +91 -1
  228. package/dist/chart/utils/dom.utils.js +15 -1
  229. package/dist/chart/utils/function.utils.js +16 -1
  230. package/dist/chart/utils/linkedList.utils.d.ts +28 -0
  231. package/dist/chart/utils/linkedList.utils.js +138 -0
  232. package/dist/chart/utils/math.utils.js +115 -1
  233. package/dist/chart/utils/merge.utils.js +56 -1
  234. package/dist/chart/utils/object.utils.js +43 -1
  235. package/dist/chart/utils/performance/animation-frame-cache.utils.js +77 -0
  236. package/dist/chart/utils/{perfomance → performance}/debounce.utils.js +7 -1
  237. package/dist/chart/utils/performance/memoize.utils.js +74 -0
  238. package/dist/chart/utils/performance/request-animation-frame-throttle.utils.js +43 -0
  239. package/dist/chart/utils/performance/throttle.utils.js +26 -0
  240. package/dist/chart/utils/price-increments.utils.d.ts +1 -0
  241. package/dist/chart/utils/price-increments.utils.js +127 -1
  242. package/dist/chart/utils/uuid.utils.js +4 -1
  243. package/dist/dxchart.min.js +9 -12
  244. package/dist/index.d.ts +3 -3
  245. package/dist/index.js +20 -1
  246. package/package.json +4 -4
  247. package/dist/chart/utils/perfomance/animation-frame-cache.utils.js +0 -6
  248. package/dist/chart/utils/perfomance/memoize.utils.js +0 -6
  249. package/dist/chart/utils/perfomance/request-animation-frame-throttle.utils.js +0 -6
  250. package/dist/chart/utils/perfomance/throttle.utils.js +0 -6
  251. /package/dist/chart/utils/{perfomance → performance}/animation-frame-cache.utils.d.ts +0 -0
  252. /package/dist/chart/utils/{perfomance → performance}/debounce.utils.d.ts +0 -0
  253. /package/dist/chart/utils/{perfomance → performance}/memoize.utils.d.ts +0 -0
  254. /package/dist/chart/utils/{perfomance → performance}/request-animation-frame-throttle.utils.d.ts +0 -0
  255. /package/dist/chart/utils/{perfomance → performance}/throttle.utils.d.ts +0 -0
@@ -3,4 +3,34 @@
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
- const c=/^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,o=/^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i;function i(n){const t=c.exec(n)||o.exec(n);let s=[];return t&&(s=t.slice(2,5),t[1]==="#")?s.map(function(e){return parseInt(e,16)}):s}const r={};export function toRGBA(n,t){let s=r[n+t];if(!s){const e=i(n);s=e&&"rgba("+e.join(",")+","+t+")",r[n+t]=s}return s}
6
+ const HEX_COLOR_REGEXP = /^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i;
7
+ const RGB_COLOR_REGEXP = /^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i;
8
+ function parseColor(color) {
9
+ const match = HEX_COLOR_REGEXP.exec(color) || RGB_COLOR_REGEXP.exec(color);
10
+ let colors = [];
11
+ if (match) {
12
+ colors = match.slice(2, 5);
13
+ if (match[1] === '#') {
14
+ return colors.map(function (s) {
15
+ return parseInt(s, 16);
16
+ });
17
+ }
18
+ }
19
+ return colors;
20
+ }
21
+ /**
22
+ *
23
+ * @param {String} color
24
+ * @param {Number} alpha
25
+ * @returns {String}
26
+ */
27
+ const rgbaCache = {};
28
+ export function toRGBA(color, alpha) {
29
+ let result = rgbaCache[color + alpha];
30
+ if (!result) {
31
+ const colors = parseColor(color);
32
+ result = colors && 'rgba(' + colors.join(',') + ',' + alpha + ')';
33
+ rgbaCache[color + alpha] = result;
34
+ }
35
+ return result;
36
+ }
@@ -3,4 +3,13 @@
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
- let e;export const isMobile=()=>(e||(e=!!navigator.userAgent.match(/Android|iPhone|Opera Mini/)||!1),e);
6
+ let isMobileCache = undefined;
7
+ /**
8
+ * @doc-tags utility,mobile
9
+ */
10
+ export const isMobile = () => {
11
+ if (!isMobileCache) {
12
+ isMobileCache = !!navigator.userAgent.match(/Android|iPhone|Opera Mini/) || false;
13
+ }
14
+ return isMobileCache;
15
+ };
@@ -3,4 +3,27 @@
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 deviceDetector=()=>{const e=/Mac|iPod|iPhone|iPad/i.test(navigator.userAgent),i=[/Android/i,/webOS/i,/BlackBerry/i,/Windows Phone/i].some(o=>navigator.userAgent.match(o));return e?"apple":i?"mobile":"other"},multiplyZoomByDevice=(e,t)=>e==="apple"||e==="mobile"?3:t;
6
+ /**
7
+ * Detects the user device. Naive approach.
8
+ * @doc-tags tricky,mobile
9
+ */
10
+ export const deviceDetector = () => {
11
+ const isApple = /Mac|iPod|iPhone|iPad/i.test(navigator.userAgent);
12
+ const mobileMatch = [/Android/i, /webOS/i, /BlackBerry/i, /Windows Phone/i];
13
+ const isMobile = mobileMatch.some(os => {
14
+ return navigator.userAgent.match(os);
15
+ });
16
+ if (isApple) {
17
+ return 'apple';
18
+ }
19
+ if (isMobile) {
20
+ return 'mobile';
21
+ }
22
+ return 'other';
23
+ };
24
+ export const multiplyZoomByDevice = (device, defaultValue) => {
25
+ if (device === 'apple' || device === 'mobile') {
26
+ return 3;
27
+ }
28
+ return defaultValue;
29
+ };
@@ -3,4 +3,24 @@
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
- import{ceil as t,floor as n,round as d}from"../math.utils";export let dpr=window.devicePixelRatio;let o=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);const i=()=>{o.removeEventListener("change",i),dpr=window.devicePixelRatio,o=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`),o.addEventListener("change",i)};o.addEventListener("change",i);export const getDPR=()=>dpr,roundToDPR=e=>d(dpr*e)/dpr,floorToDPR=e=>n(dpr*e)/dpr,ceilToDPR=e=>t(dpr*e)/dpr;
6
+ import { ceil, floor, round } from '../math.utils';
7
+ export let dpr = window.devicePixelRatio;
8
+ // A media matcher which watches for changes in the device pixel ratio.
9
+ let mediaMatcher = window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);
10
+ const updateDevicePixelRatio = () => {
11
+ mediaMatcher.removeEventListener('change', updateDevicePixelRatio);
12
+ dpr = window.devicePixelRatio;
13
+ mediaMatcher = window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);
14
+ mediaMatcher.addEventListener('change', updateDevicePixelRatio);
15
+ };
16
+ mediaMatcher.addEventListener('change', updateDevicePixelRatio);
17
+ export const getDPR = () => dpr;
18
+ /**
19
+ * Rounds a given number according to the inverse of current DPR.
20
+ * For example, DPR = 2, num = 2, res => 2; DPR = 2, num = 2.5, res => 2.5; DPR = 2, num = 2.333, res => 2.5
21
+ * @param num
22
+ * @doc-tags chart-core,math,dpr
23
+ */
24
+ export const roundToDPR = (num) => round(dpr * num) / dpr;
25
+ export const floorToDPR = (num) => floor(dpr * num) / dpr;
26
+ export const ceilToDPR = (num) => ceil(dpr * num) / dpr;
@@ -3,4 +3,94 @@
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
- const o=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),l=!!window.chrome;export const isFirefox=typeof InstallTrigger!="undefined";const d=navigator.platform.indexOf("Win")>-1;export const touchpadDetector=t=>{let i=!1;const{wheelDeltaY:a,wheelDeltaX:s}=t;if(a||s){let e;if(o)e=a===t.deltaY*-3||Math.abs(a+Math.sign(a))===Math.abs(Math.round(t.deltaY)*3)||Math.abs(a-Math.sign(a))===Math.abs(Math.round(t.deltaY)*3);else if(l){if(e=a+Math.sign(a)===t.deltaY*-3?a+Math.sign(a)===t.deltaY*-3:a===t.deltaY*-3,d){const n=Math.round(t.deltaY)===a||Math.abs(Math.round(t.deltaY)+Math.sign(t.deltaY))===Math.abs(a)||Math.abs(Math.round(t.deltaY)-Math.sign(t.deltaY))===Math.abs(a);e=Math.abs(a)===Math.abs(t.deltaY)||n}}else isFirefox?Math.abs(t.deltaY)>Math.abs(t.deltaX)?e=!1:e=s===t.deltaX*-3:e=a===t.deltaY*-3;e&&(i=!0)}else t.deltaMode===0&&(i=!0);return isFirefox&&t.deltaY>=16&&Math.abs(t.deltaY)%16===0&&(i=!1),t.ctrlKey&&(i=!0),i},getTouchpadSensitivity=t=>t.components.yAxis.type==="percent"?t.scale.zoomSensitivity/4:t.scale.zoomSensitivity;
6
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
7
+ //@ts-ignore
8
+ const isChrome = !!window.chrome;
9
+ //@ts-ignore
10
+ export const isFirefox = typeof InstallTrigger !== 'undefined';
11
+ const isWindows = navigator.platform.indexOf('Win') > -1;
12
+ /**
13
+ * this function determines whether the event was triggered with the mouse or the touchpad
14
+ *
15
+ * This works because wheelDeltaY measures the physical distance that the actual hardware mouse wheel has travelled,
16
+ * while deltaY measures the amount of scrolling produced on screen.
17
+ * A conventional mouse typically has a much lower "scroll resolution" than a trackpad.
18
+ * The wheelDeltaY is exactly 3x the deltaY value(in most browsers)
19
+ * This function consist a lot of empiric if statements for some cases in different browsers and systems
20
+ * @param {WheelEvent} e
21
+ * @returns {boolean}
22
+ *
23
+ * @doc-tags chart-core, utility,
24
+ */
25
+ export const touchpadDetector = (e) => {
26
+ let isTouchpad = false;
27
+ // this is essential prop to separate touchpad from mouse wheel
28
+ //@ts-ignore
29
+ const { wheelDeltaY, wheelDeltaX } = e;
30
+ if (wheelDeltaY || wheelDeltaX) {
31
+ let condition;
32
+ if (isSafari) {
33
+ condition =
34
+ wheelDeltaY === e.deltaY * -3 ||
35
+ Math.abs(wheelDeltaY + Math.sign(wheelDeltaY)) === Math.abs(Math.round(e.deltaY) * 3) ||
36
+ Math.abs(wheelDeltaY - Math.sign(wheelDeltaY)) === Math.abs(Math.round(e.deltaY) * 3);
37
+ }
38
+ else if (isChrome) {
39
+ condition =
40
+ wheelDeltaY + Math.sign(wheelDeltaY) === e.deltaY * -3
41
+ ? wheelDeltaY + Math.sign(wheelDeltaY) === e.deltaY * -3
42
+ : wheelDeltaY === e.deltaY * -3;
43
+ // Chrome windows case
44
+ if (isWindows) {
45
+ const diapazoneCondition = Math.round(e.deltaY) === wheelDeltaY ||
46
+ Math.abs(Math.round(e.deltaY) + Math.sign(e.deltaY)) === Math.abs(wheelDeltaY) ||
47
+ Math.abs(Math.round(e.deltaY) - Math.sign(e.deltaY)) === Math.abs(wheelDeltaY);
48
+ const equalCondition = Math.abs(wheelDeltaY) === Math.abs(e.deltaY);
49
+ condition = equalCondition || diapazoneCondition;
50
+ }
51
+ }
52
+ else if (isFirefox) {
53
+ if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) {
54
+ // disable vertical scroll in Firefox bcs it is unstable
55
+ condition = false;
56
+ }
57
+ else {
58
+ condition = wheelDeltaX === e.deltaX * -3;
59
+ }
60
+ }
61
+ else {
62
+ // basic rule
63
+ condition = wheelDeltaY === e.deltaY * -3;
64
+ }
65
+ if (condition) {
66
+ isTouchpad = true;
67
+ }
68
+ }
69
+ else if (e.deltaMode === 0) {
70
+ isTouchpad = true;
71
+ }
72
+ // Firefox for some reason is not obey to rules above
73
+ // so we just this trigger this as mouse wheel event
74
+ if (isFirefox && e.deltaY >= 16 && Math.abs(e.deltaY) % 16 === 0) {
75
+ isTouchpad = false;
76
+ }
77
+ // it is necessary to correctly recognize pinch on touchpad
78
+ // could be emulated mouse wheel + ctrl key BE AWARE!!
79
+ if (e.ctrlKey) {
80
+ isTouchpad = true;
81
+ }
82
+ return isTouchpad;
83
+ };
84
+ /**
85
+ * this function returns different ящщь sensitivity for the percent axis and the others
86
+ * @param config
87
+ * @param isTouchpad
88
+ * @returns {number}
89
+ *
90
+ * @doc-tags chart-core, zoom
91
+ */
92
+ export const getTouchpadSensitivity = (config) => {
93
+ const isPercentAxisType = config.components.yAxis.type === 'percent';
94
+ const zoomSensitivity = isPercentAxisType ? config.scale.zoomSensitivity / 4 : config.scale.zoomSensitivity;
95
+ return zoomSensitivity;
96
+ };
@@ -3,4 +3,18 @@
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 subscribeListener(n,r,i,t){return n.addEventListener(i,r,t),function(){n.removeEventListener(i,r,t)}}
6
+ /**
7
+ * @param {Element} element
8
+ * @param {function} listener
9
+ * @param {string} eventType
10
+ * @param {boolean?} useCapture
11
+ * @return {Function}
12
+ */
13
+ export function subscribeListener(element, listener, eventType, useCapture) {
14
+ // @ts-ignore
15
+ element.addEventListener(eventType, listener, useCapture);
16
+ return function () {
17
+ // @ts-ignore
18
+ element.removeEventListener(eventType, listener, useCapture);
19
+ };
20
+ }
@@ -3,4 +3,19 @@
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 clearerSafe(n){return function(){n.forEach(t=>typeof t=="function"&&t()),n.length=0}}export function identity(n){return n}export function notEmpty(n){return n!=null}export const constVoid=()=>{};export function nonNullableTypeGuard(n){return n!=null}
6
+ export function clearerSafe(arr) {
7
+ return function doClearSafe() {
8
+ arr.forEach(f => typeof f === 'function' && f());
9
+ arr.length = 0;
10
+ };
11
+ }
12
+ export function identity(x) {
13
+ return x;
14
+ }
15
+ export function notEmpty(value) {
16
+ return value !== null && value !== undefined;
17
+ }
18
+ export const constVoid = () => void 0;
19
+ export function nonNullableTypeGuard(x) {
20
+ return x !== undefined && x !== null;
21
+ }
@@ -0,0 +1,28 @@
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 declare class ListNode<T> {
7
+ data: T;
8
+ next: ListNode<T> | null;
9
+ constructor(data: T);
10
+ }
11
+ /**
12
+ * Implementation of Linked list data structure.
13
+ * @param _head
14
+ */
15
+ export declare class LinkedList<T> {
16
+ private _head;
17
+ private _tail;
18
+ private length;
19
+ constructor(head?: ListNode<T>);
20
+ insertAtEnd(data: T): ListNode<T>;
21
+ insertAt(position: number, data: T): ListNode<T> | null;
22
+ removeAt(position: number): ListNode<T> | null;
23
+ getNodePosition(node: ListNode<T>): number;
24
+ size(): number;
25
+ get head(): ListNode<T> | null;
26
+ get tail(): ListNode<T> | null;
27
+ [Symbol.iterator](): Generator<T, void, unknown>;
28
+ }
@@ -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
+ }