@genome-spy/core 0.65.0 → 0.67.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 (249) hide show
  1. package/dist/bundle/browser-BRemItdO.js +138 -0
  2. package/dist/bundle/{index-CD7FLu9x.js → index-BatuyGAI.js} +23 -21
  3. package/dist/bundle/{index-C0llXMqm.js → index-ByuE8dvu.js} +140 -88
  4. package/dist/bundle/index-Cq3QFUxX.js +1781 -0
  5. package/dist/bundle/index-D28m8tSW.js +1607 -0
  6. package/dist/bundle/index-DbJ0oeYM.js +631 -0
  7. package/dist/bundle/index.es.js +15821 -14601
  8. package/dist/bundle/index.js +214 -212
  9. package/dist/bundle/{inflate-DRgHi_KK.js → inflate-GtwLkvSP.js} +222 -224
  10. package/dist/bundle/unzip-NywezaRR.js +1492 -0
  11. package/dist/schema.json +13 -3
  12. package/dist/src/config/scaleDefaults.d.ts +8 -0
  13. package/dist/src/config/scaleDefaults.d.ts.map +1 -0
  14. package/dist/src/config/scaleDefaults.js +45 -0
  15. package/dist/src/data/flowHandle.d.ts +2 -0
  16. package/dist/src/data/flowHandle.d.ts.map +1 -1
  17. package/dist/src/data/flowHandle.js +1 -0
  18. package/dist/src/data/flowInit.d.ts +12 -4
  19. package/dist/src/data/flowInit.d.ts.map +1 -1
  20. package/dist/src/data/flowInit.js +115 -16
  21. package/dist/src/data/sources/lazy/axisTickSource.js +1 -1
  22. package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts +1 -1
  23. package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts.map +1 -1
  24. package/dist/src/data/sources/lazy/singleAxisLazySource.js +10 -3
  25. package/dist/src/data/sources/lazy/singleAxisWindowedSource.d.ts.map +1 -1
  26. package/dist/src/data/sources/lazy/singleAxisWindowedSource.js +5 -1
  27. package/dist/src/data/transforms/filterScoredLabels.d.ts +1 -1
  28. package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -1
  29. package/dist/src/data/transforms/filterScoredLabels.js +1 -1
  30. package/dist/src/data/transforms/linearizeGenomicCoordinate.d.ts.map +1 -1
  31. package/dist/src/data/transforms/linearizeGenomicCoordinate.js +2 -1
  32. package/dist/src/encoder/encoder.d.ts +1 -1
  33. package/dist/src/encoder/encoder.d.ts.map +1 -1
  34. package/dist/src/encoder/encoder.js +1 -1
  35. package/dist/src/genome/scaleLocus.d.ts +39 -0
  36. package/dist/src/genome/scaleLocus.d.ts.map +1 -1
  37. package/dist/src/genome/scaleLocus.js +76 -0
  38. package/dist/src/genomeSpy/canvasExport.d.ts +19 -0
  39. package/dist/src/genomeSpy/canvasExport.d.ts.map +1 -0
  40. package/dist/src/genomeSpy/canvasExport.js +66 -0
  41. package/dist/src/genomeSpy/containerUi.d.ts +17 -0
  42. package/dist/src/genomeSpy/containerUi.d.ts.map +1 -0
  43. package/dist/src/genomeSpy/containerUi.js +78 -0
  44. package/dist/src/genomeSpy/eventListenerRegistry.d.ts +19 -0
  45. package/dist/src/genomeSpy/eventListenerRegistry.d.ts.map +1 -0
  46. package/dist/src/genomeSpy/eventListenerRegistry.js +38 -0
  47. package/dist/src/genomeSpy/inputBindingManager.d.ts +14 -0
  48. package/dist/src/genomeSpy/inputBindingManager.d.ts.map +1 -0
  49. package/dist/src/genomeSpy/inputBindingManager.js +63 -0
  50. package/dist/src/genomeSpy/interactionController.d.ts +40 -0
  51. package/dist/src/genomeSpy/interactionController.d.ts.map +1 -0
  52. package/dist/src/genomeSpy/interactionController.js +371 -0
  53. package/dist/src/genomeSpy/keyboardListenerManager.d.ts +10 -0
  54. package/dist/src/genomeSpy/keyboardListenerManager.d.ts.map +1 -0
  55. package/dist/src/genomeSpy/keyboardListenerManager.js +31 -0
  56. package/dist/src/genomeSpy/loadingIndicatorManager.d.ts +15 -0
  57. package/dist/src/genomeSpy/loadingIndicatorManager.d.ts.map +1 -0
  58. package/dist/src/genomeSpy/loadingIndicatorManager.js +92 -0
  59. package/dist/src/genomeSpy/renderCoordinator.d.ts +22 -0
  60. package/dist/src/genomeSpy/renderCoordinator.d.ts.map +1 -0
  61. package/dist/src/genomeSpy/renderCoordinator.js +118 -0
  62. package/dist/src/genomeSpy/viewContextFactory.d.ts +18 -0
  63. package/dist/src/genomeSpy/viewContextFactory.d.ts.map +1 -0
  64. package/dist/src/genomeSpy/viewContextFactory.js +79 -0
  65. package/dist/src/genomeSpy/viewDataInit.d.ts +22 -0
  66. package/dist/src/genomeSpy/viewDataInit.d.ts.map +1 -0
  67. package/dist/src/genomeSpy/viewDataInit.js +160 -0
  68. package/dist/src/genomeSpy/viewDataInit.test.d.ts +2 -0
  69. package/dist/src/genomeSpy/viewDataInit.test.d.ts.map +1 -0
  70. package/dist/src/genomeSpy/viewHierarchyConfig.d.ts +14 -0
  71. package/dist/src/genomeSpy/viewHierarchyConfig.d.ts.map +1 -0
  72. package/dist/src/genomeSpy/viewHierarchyConfig.js +24 -0
  73. package/dist/src/genomeSpy/viewHighlight.d.ts +5 -0
  74. package/dist/src/genomeSpy/viewHighlight.d.ts.map +1 -0
  75. package/dist/src/genomeSpy/viewHighlight.js +30 -0
  76. package/dist/src/genomeSpy.d.ts +17 -71
  77. package/dist/src/genomeSpy.d.ts.map +1 -1
  78. package/dist/src/genomeSpy.js +197 -741
  79. package/dist/src/gl/dataToVertices.d.ts.map +1 -1
  80. package/dist/src/gl/dataToVertices.js +16 -4
  81. package/dist/src/gl/glslScaleGenerator.d.ts +1 -1
  82. package/dist/src/gl/webGLHelper.d.ts +2 -2
  83. package/dist/src/gl/webGLHelper.d.ts.map +1 -1
  84. package/dist/src/gl/webGLHelper.js +4 -4
  85. package/dist/src/index.d.ts.map +1 -1
  86. package/dist/src/index.js +2 -12
  87. package/dist/src/marks/mark.d.ts.map +1 -1
  88. package/dist/src/marks/mark.js +4 -2
  89. package/dist/src/{view → scales}/axisResolution.d.ts +9 -16
  90. package/dist/src/scales/axisResolution.d.ts.map +1 -0
  91. package/dist/src/{view → scales}/axisResolution.js +29 -18
  92. package/dist/src/scales/axisResolution.test.d.ts.map +1 -0
  93. package/dist/src/scales/scaleDomainAggregator.d.ts +57 -0
  94. package/dist/src/scales/scaleDomainAggregator.d.ts.map +1 -0
  95. package/dist/src/scales/scaleDomainAggregator.js +167 -0
  96. package/dist/src/scales/scaleDomainAggregator.test.d.ts +2 -0
  97. package/dist/src/scales/scaleDomainAggregator.test.d.ts.map +1 -0
  98. package/dist/src/scales/scaleInstanceManager.d.ts +40 -0
  99. package/dist/src/scales/scaleInstanceManager.d.ts.map +1 -0
  100. package/dist/src/scales/scaleInstanceManager.js +317 -0
  101. package/dist/src/scales/scaleInstanceManager.test.d.ts +2 -0
  102. package/dist/src/scales/scaleInstanceManager.test.d.ts.map +1 -0
  103. package/dist/src/scales/scaleInteractionController.d.ts +73 -0
  104. package/dist/src/scales/scaleInteractionController.d.ts.map +1 -0
  105. package/dist/src/scales/scaleInteractionController.js +336 -0
  106. package/dist/src/scales/scaleInteractionController.test.d.ts +2 -0
  107. package/dist/src/scales/scaleInteractionController.test.d.ts.map +1 -0
  108. package/dist/src/scales/scalePropsResolver.d.ts +23 -0
  109. package/dist/src/scales/scalePropsResolver.d.ts.map +1 -0
  110. package/dist/src/scales/scalePropsResolver.js +74 -0
  111. package/dist/src/{view → scales}/scaleResolution.d.ts +53 -35
  112. package/dist/src/scales/scaleResolution.d.ts.map +1 -0
  113. package/dist/src/scales/scaleResolution.js +732 -0
  114. package/dist/src/scales/scaleResolution.test.d.ts.map +1 -0
  115. package/dist/src/scales/scaleResolutionConstants.d.ts +6 -0
  116. package/dist/src/scales/scaleResolutionConstants.d.ts.map +1 -0
  117. package/dist/src/scales/scaleResolutionConstants.js +5 -0
  118. package/dist/src/scales/scaleRules.d.ts +16 -0
  119. package/dist/src/scales/scaleRules.d.ts.map +1 -0
  120. package/dist/src/scales/scaleRules.js +103 -0
  121. package/dist/src/scales/scaleRules.test.d.ts +2 -0
  122. package/dist/src/scales/scaleRules.test.d.ts.map +1 -0
  123. package/dist/src/spec/channel.d.ts +13 -18
  124. package/dist/src/spec/scale.d.ts +6 -0
  125. package/dist/src/types/embedApi.d.ts +5 -0
  126. package/dist/src/types/scaleResolutionApi.d.ts +1 -1
  127. package/dist/src/utils/domainArray.d.ts.map +1 -1
  128. package/dist/src/utils/domainArray.js +3 -0
  129. package/dist/src/utils/indexer.d.ts +3 -0
  130. package/dist/src/utils/indexer.d.ts.map +1 -1
  131. package/dist/src/utils/indexer.js +3 -0
  132. package/dist/src/view/concatView.d.ts +18 -0
  133. package/dist/src/view/concatView.d.ts.map +1 -1
  134. package/dist/src/view/concatView.js +73 -0
  135. package/dist/src/view/concatView.test.d.ts +2 -0
  136. package/dist/src/view/concatView.test.d.ts.map +1 -0
  137. package/dist/src/view/containerMutationHelper.d.ts +74 -0
  138. package/dist/src/view/containerMutationHelper.d.ts.map +1 -0
  139. package/dist/src/view/containerMutationHelper.js +118 -0
  140. package/dist/src/view/containerView.d.ts +0 -7
  141. package/dist/src/view/containerView.d.ts.map +1 -1
  142. package/dist/src/view/containerView.js +0 -10
  143. package/dist/src/view/facetView.d.ts.map +1 -1
  144. package/dist/src/view/facetView.js +0 -15
  145. package/dist/src/view/flowBuilder.d.ts +5 -3
  146. package/dist/src/view/flowBuilder.d.ts.map +1 -1
  147. package/dist/src/view/flowBuilder.js +69 -6
  148. package/dist/src/view/gridView/gridChild.d.ts +11 -0
  149. package/dist/src/view/gridView/gridChild.d.ts.map +1 -1
  150. package/dist/src/view/gridView/gridChild.js +32 -6
  151. package/dist/src/view/gridView/gridView.d.ts +39 -1
  152. package/dist/src/view/gridView/gridView.d.ts.map +1 -1
  153. package/dist/src/view/gridView/gridView.js +106 -48
  154. package/dist/src/view/gridView/gridView.test.d.ts +2 -0
  155. package/dist/src/view/gridView/gridView.test.d.ts.map +1 -0
  156. package/dist/src/view/gridView/scrollbar.d.ts +39 -8
  157. package/dist/src/view/gridView/scrollbar.d.ts.map +1 -1
  158. package/dist/src/view/gridView/scrollbar.js +184 -69
  159. package/dist/src/view/layerView.d.ts +14 -0
  160. package/dist/src/view/layerView.d.ts.map +1 -1
  161. package/dist/src/view/layerView.js +66 -0
  162. package/dist/src/view/layerView.test.d.ts +2 -0
  163. package/dist/src/view/layerView.test.d.ts.map +1 -0
  164. package/dist/src/view/testUtils.d.ts.map +1 -1
  165. package/dist/src/view/testUtils.js +7 -1
  166. package/dist/src/view/unitView.d.ts.map +1 -1
  167. package/dist/src/view/unitView.js +41 -36
  168. package/dist/src/view/view.d.ts +18 -6
  169. package/dist/src/view/view.d.ts.map +1 -1
  170. package/dist/src/view/view.js +30 -4
  171. package/package.json +2 -2
  172. package/dist/bundle/browser-txUcLy2H.js +0 -123
  173. package/dist/bundle/index-BQpbYrv4.js +0 -1712
  174. package/dist/bundle/index-BhtHKLUo.js +0 -73
  175. package/dist/bundle/index-CCe8rnZz.js +0 -716
  176. package/dist/bundle/index-DhcU-Gk-.js +0 -1487
  177. package/dist/src/data/collector.test.js +0 -138
  178. package/dist/src/data/dataFlow.test.js +0 -38
  179. package/dist/src/data/flow.test.js +0 -81
  180. package/dist/src/data/flowInit.test.js +0 -413
  181. package/dist/src/data/flowNode.test.js +0 -50
  182. package/dist/src/data/flowOptimizer.test.js +0 -209
  183. package/dist/src/data/formats/fasta.test.js +0 -27
  184. package/dist/src/data/sources/inlineSource.test.js +0 -63
  185. package/dist/src/data/sources/sequenceSource.test.js +0 -81
  186. package/dist/src/data/transforms/aggregate.test.js +0 -134
  187. package/dist/src/data/transforms/clone.test.js +0 -11
  188. package/dist/src/data/transforms/coverage.test.js +0 -238
  189. package/dist/src/data/transforms/filter.test.js +0 -20
  190. package/dist/src/data/transforms/flatten.test.js +0 -96
  191. package/dist/src/data/transforms/flattenDelimited.test.js +0 -90
  192. package/dist/src/data/transforms/flattenSequence.test.js +0 -34
  193. package/dist/src/data/transforms/formula.test.js +0 -25
  194. package/dist/src/data/transforms/identifier.test.js +0 -92
  195. package/dist/src/data/transforms/pileup.test.js +0 -70
  196. package/dist/src/data/transforms/project.test.js +0 -32
  197. package/dist/src/data/transforms/regexExtract.test.js +0 -70
  198. package/dist/src/data/transforms/regexFold.test.js +0 -201
  199. package/dist/src/data/transforms/sample.test.js +0 -38
  200. package/dist/src/data/transforms/stack.test.js +0 -91
  201. package/dist/src/encoder/accessor.test.js +0 -162
  202. package/dist/src/encoder/encoder.test.js +0 -105
  203. package/dist/src/genome/genome.test.js +0 -268
  204. package/dist/src/genome/genomes.test.js +0 -8
  205. package/dist/src/genome/scaleIndex.test.js +0 -78
  206. package/dist/src/genome/scaleLocus.test.js +0 -4
  207. package/dist/src/scale/scale.test.js +0 -326
  208. package/dist/src/scale/ticks.test.js +0 -46
  209. package/dist/src/selection/selection.test.js +0 -14
  210. package/dist/src/utils/addBaseUrl.test.js +0 -30
  211. package/dist/src/utils/binnedIndex.test.js +0 -201
  212. package/dist/src/utils/cloner.test.js +0 -35
  213. package/dist/src/utils/coalesce.test.js +0 -16
  214. package/dist/src/utils/concatIterables.test.js +0 -8
  215. package/dist/src/utils/domainArray.test.js +0 -130
  216. package/dist/src/utils/indexer.test.js +0 -49
  217. package/dist/src/utils/interactionEvent.test.js +0 -35
  218. package/dist/src/utils/iterateNestedMaps.test.js +0 -33
  219. package/dist/src/utils/kWayMerge.test.js +0 -30
  220. package/dist/src/utils/mergeObjects.test.js +0 -42
  221. package/dist/src/utils/numberExtractor.test.js +0 -6
  222. package/dist/src/utils/propertyCacher.test.js +0 -89
  223. package/dist/src/utils/propertyCoalescer.test.js +0 -25
  224. package/dist/src/utils/radixSort.test.js +0 -51
  225. package/dist/src/utils/reservationMap.test.js +0 -20
  226. package/dist/src/utils/ringBuffer.test.js +0 -39
  227. package/dist/src/utils/topK.test.js +0 -54
  228. package/dist/src/utils/trees.test.js +0 -135
  229. package/dist/src/utils/url.test.js +0 -28
  230. package/dist/src/utils/variableTools.test.js +0 -13
  231. package/dist/src/view/axisResolution.d.ts.map +0 -1
  232. package/dist/src/view/axisResolution.test.d.ts.map +0 -1
  233. package/dist/src/view/axisResolution.test.js +0 -206
  234. package/dist/src/view/flowBuilder.test.js +0 -125
  235. package/dist/src/view/gridView/selectionRect.test.js +0 -87
  236. package/dist/src/view/layout/flexLayout.test.js +0 -323
  237. package/dist/src/view/layout/grid.test.js +0 -71
  238. package/dist/src/view/layout/rectangle.test.js +0 -192
  239. package/dist/src/view/paramMediator.test.js +0 -282
  240. package/dist/src/view/scaleResolution.d.ts.map +0 -1
  241. package/dist/src/view/scaleResolution.js +0 -1059
  242. package/dist/src/view/scaleResolution.test.d.ts.map +0 -1
  243. package/dist/src/view/scaleResolution.test.js +0 -645
  244. package/dist/src/view/view.test.js +0 -245
  245. package/dist/src/view/viewDispose.test.js +0 -110
  246. package/dist/src/view/viewFactory.test.js +0 -25
  247. package/dist/src/view/viewUtils.test.js +0 -87
  248. /package/dist/src/{view → scales}/axisResolution.test.d.ts +0 -0
  249. /package/dist/src/{view → scales}/scaleResolution.test.d.ts +0 -0
@@ -1,89 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import {
3
- getCachedOrCall,
4
- invalidate,
5
- invalidateAll,
6
- } from "./propertyCacher.js";
7
-
8
- class TestClass {
9
- constructor() {
10
- /** @type {number} */
11
- this._x;
12
- /** @type {number} */
13
- this._y;
14
-
15
- this._xCalls = 0;
16
- this._yCalls = 0;
17
-
18
- this.resetAll();
19
- }
20
-
21
- get x() {
22
- return getCachedOrCall(this, "x", () => {
23
- this._xCalls++;
24
- return this._x;
25
- });
26
- }
27
-
28
- set x(x) {
29
- this._x = x;
30
- invalidate(this, "x");
31
- }
32
-
33
- get y() {
34
- return getCachedOrCall(this, "y", () => {
35
- this._yCalls++;
36
- return this._y;
37
- });
38
- }
39
-
40
- set y(y) {
41
- this._y = y;
42
- invalidate(this, "y");
43
- }
44
-
45
- resetAll() {
46
- this._x = 10;
47
- this._y = 20;
48
- invalidateAll(this);
49
- }
50
- }
51
-
52
- test("Initial cached get returns correct values and calls callable only once", () => {
53
- const instance = new TestClass();
54
-
55
- expect(instance._xCalls).toEqual(0);
56
- expect(instance.x).toEqual(10);
57
- expect(instance._xCalls).toEqual(1);
58
- expect(instance.x).toEqual(10);
59
- expect(instance._xCalls).toEqual(1);
60
- });
61
-
62
- test("Invalidate invalidates", () => {
63
- const instance = new TestClass();
64
-
65
- expect(instance._xCalls).toEqual(0);
66
- expect(instance.x).toEqual(10);
67
- expect(instance._xCalls).toEqual(1);
68
-
69
- instance.x = 123;
70
- expect(instance._xCalls).toEqual(1);
71
-
72
- expect(instance.x).toEqual(123);
73
- expect(instance._xCalls).toEqual(2);
74
- });
75
-
76
- test("InvalidateAll invalidates everything", () => {
77
- const instance = new TestClass();
78
-
79
- instance.x = 123;
80
- instance.y = 321;
81
-
82
- expect(instance.x).toEqual(123);
83
- expect(instance.y).toEqual(321);
84
-
85
- instance.resetAll();
86
-
87
- expect(instance.x).toEqual(10);
88
- expect(instance.y).toEqual(20);
89
- });
@@ -1,25 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import coalesceProperties from "./propertyCoalescer.js";
3
-
4
- test("CoalesceProperties works as expected", () => {
5
- const defaults = { a: 10, b: 11 };
6
- const props = { a: 1, c: 2 };
7
-
8
- const coalesced = coalesceProperties(
9
- () => props,
10
- // @ts-expect-error
11
- () => defaults
12
- );
13
-
14
- expect(coalesced.a).toEqual(1);
15
- // @ts-expect-error
16
- expect(coalesced.b).toEqual(11);
17
- expect(coalesced.c).toEqual(2);
18
- // @ts-expect-error
19
- expect(coalesced.undef).toBeUndefined();
20
-
21
- expect("a" in coalesced).toBeTruthy();
22
- expect("b" in coalesced).toBeTruthy();
23
- expect("c" in coalesced).toBeTruthy();
24
- expect("undef" in coalesced).toBeFalsy();
25
- });
@@ -1,51 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import radixSort, { radixSortIntoLookupArray } from "./radixSort.js";
3
-
4
- /**
5
- * Checks that numbers in an array are in ascending order.
6
-
7
- * @param {number[]} arr An array of unsigned integers
8
- */
9
- function isSorted(arr) {
10
- for (let i = 1; i < arr.length; i++) {
11
- if (arr[i - 1] > arr[i]) {
12
- return false;
13
- }
14
- }
15
-
16
- return true;
17
- }
18
-
19
- /**
20
- * Generates a random array of unsigned integers.
21
- *
22
- * @param {number} length
23
- */
24
- function generateArray(length) {
25
- const arr = new Array(length);
26
-
27
- for (let i = 0; i < length; i++) {
28
- arr[i] = Math.floor(Math.random() * 10_000_000_000);
29
- }
30
-
31
- return arr;
32
- }
33
-
34
- test("Radix Sort correctly sorts numbers", () => {
35
- expect(isSorted(radixSort([1, 2, 3]))).toBeTruthy();
36
- expect(isSorted(radixSort([3, 2, 1]))).toBeTruthy();
37
- expect(isSorted(radixSort([123, 1234567, 12, 1, 1234]))).toBeTruthy();
38
- expect(isSorted(radixSort(generateArray(1_000_000)))).toBeTruthy();
39
- });
40
-
41
- test("Lookup", () => {
42
- expect(radixSortIntoLookupArray([1, 2, 3])).toEqual([0, 1, 2]);
43
- expect(radixSortIntoLookupArray([3, 2, 1])).toEqual([2, 1, 0]);
44
- expect(radixSortIntoLookupArray([10000, 100, 1000, 10, 1])).toEqual([
45
- 4, 3, 1, 2, 0,
46
- ]);
47
-
48
- const arr = generateArray(1_000_000);
49
- const lookup = radixSortIntoLookupArray(arr);
50
- expect(isSorted(arr.map((_, i) => arr[lookup[i]]))).toBeTruthy();
51
- });
@@ -1,20 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import ReservationMap from "./reservationMap.js";
3
-
4
- test("ReservationMap works correctly", () => {
5
- const m = new ReservationMap(20);
6
-
7
- expect(m.reserve(0, 3)).toBeTruthy();
8
- expect(m.reserve(15, 17)).toBeTruthy();
9
- expect(m.reserve(5, 11)).toBeTruthy();
10
- expect(m.reserve(19, 22)).toBeTruthy();
11
- expect(m.reserve(23, 26)).toBeTruthy();
12
- expect(m.reserve(12, 13)).toBeTruthy();
13
- expect(m.reserve(13, 14)).toBeTruthy();
14
- expect(m.reserve(4, 5)).toBeTruthy();
15
-
16
- expect(m.reserve(6, 8)).toBeFalsy();
17
- expect(m.reserve(10, 13)).toBeFalsy();
18
- expect(m.reserve(-2, 1)).toBeFalsy();
19
- expect(m.reserve(25, 28)).toBeFalsy();
20
- });
@@ -1,39 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import RingBuffer from "./ringBuffer.js";
3
-
4
- describe("ringBuffer", () => {
5
- test("Empty buffer", () => {
6
- const buffer = new RingBuffer(10);
7
- expect(buffer.length).toBe(0);
8
- expect(buffer.get()).toEqual([]);
9
- });
10
-
11
- test("Partially filled buffer", () => {
12
- const buffer = new RingBuffer(10);
13
- buffer.push(1);
14
- buffer.push(2);
15
- buffer.push(3);
16
- expect(buffer.length).toBe(3);
17
- expect(buffer.get()).toEqual([1, 2, 3]);
18
- });
19
-
20
- test("Full buffer", () => {
21
- const buffer = new RingBuffer(3);
22
- buffer.push(1);
23
- buffer.push(2);
24
- buffer.push(3);
25
- expect(buffer.length).toBe(3);
26
- expect(buffer.get()).toEqual([1, 2, 3]);
27
- });
28
-
29
- test("Overfilled buffer", () => {
30
- const buffer = new RingBuffer(3);
31
- buffer.push(1);
32
- buffer.push(2);
33
- buffer.push(3);
34
- buffer.push(4);
35
- buffer.push(5);
36
- expect(buffer.length).toBe(3);
37
- expect(buffer.get()).toEqual([3, 4, 5]);
38
- });
39
- });
@@ -1,54 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { topK } from "./topK.js";
3
-
4
- test("topK returns top k numbers in priority order", () => {
5
- /** @param {number} x */
6
- const priorityAccessor = (x) => x;
7
-
8
- expect(topK([1, 2, 3], 3, priorityAccessor)).toEqual([3, 2, 1]);
9
- expect(topK([1, 2, 3], 1, priorityAccessor)).toEqual([3]);
10
- expect(topK([1, 2, 3], 6, priorityAccessor)).toEqual([3, 2, 1]);
11
- expect(topK([1, 2, 3, 4, 5, 6], 3, priorityAccessor)).toEqual([6, 5, 4]);
12
- expect(topK([0, 9, 1, 8, 2, 7, 3, 6, 4, 5], 3, priorityAccessor)).toEqual([
13
- 9, 8, 7,
14
- ]);
15
- expect(topK([1, 1, 1], 3, priorityAccessor)).toEqual([1, 1, 1]);
16
- });
17
-
18
- test("topK returns top k objects in priority order within a start-end range", () => {
19
- const arr = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5].map((x) => ({ priority: x }));
20
- const priorityAccessor = (/** @type {{priority: number}} */ d) =>
21
- d.priority;
22
-
23
- // Range: indices 2 to 8 (1,8,2,7,3,6)
24
- expect(topK(arr, 2, priorityAccessor, 2, 8)).toEqual([
25
- { priority: 8 },
26
- { priority: 7 },
27
- ]);
28
-
29
- // Range: indices 4 to 10 (2,7,3,6,4,5)
30
- expect(topK(arr, 3, priorityAccessor, 4, 10)).toEqual([
31
- { priority: 7 },
32
- { priority: 6 },
33
- { priority: 5 },
34
- ]);
35
-
36
- // Range: indices 0 to 3 (0,9,1)
37
- expect(topK(arr, 2, priorityAccessor, 0, 3)).toEqual([
38
- { priority: 9 },
39
- { priority: 1 },
40
- ]);
41
- });
42
-
43
- test("topK returns empty array if start >= end", () => {
44
- const arr = [1, 2, 3, 4, 5];
45
- expect(topK(arr, 3, (x) => x, 4, 4)).toEqual([]);
46
- expect(topK(arr, 3, (x) => x, 5, 5)).toEqual([]);
47
- expect(topK(arr, 3, (x) => x, 6, 6)).toEqual([]);
48
- });
49
-
50
- test("topK works with negative and zero priorities in a range", () => {
51
- const arr = [-10, 0, 5, -2, 3, 0, -1];
52
- expect(topK(arr, 2, (x) => x, 1, 6)).toEqual([5, 3]);
53
- expect(topK(arr, 3, (x) => x, 0, 4)).toEqual([5, 0, -2]);
54
- });
@@ -1,135 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { nodesToTrees, visitTree } from "./trees.js";
3
- import { describe } from "vitest";
4
-
5
- describe("NodesToTrees", () => {
6
- const NULL = /** @type {any} */ (null);
7
-
8
- test("NodesToTrees converts an array of nodes to a tree", () => {
9
- const a = { parent: NULL };
10
- const b = { parent: a };
11
- const c = { parent: a };
12
- const d = { parent: b };
13
- const e = { parent: b };
14
-
15
- const nodes = [a, b, c, d, e];
16
-
17
- const trees = nodesToTrees(nodes);
18
-
19
- expect(trees).toEqual([
20
- {
21
- ref: a,
22
- children: [
23
- {
24
- ref: b,
25
- children: [
26
- {
27
- ref: d,
28
- children: [],
29
- },
30
- {
31
- ref: e,
32
- children: [],
33
- },
34
- ],
35
- },
36
- {
37
- ref: c,
38
- children: [],
39
- },
40
- ],
41
- },
42
- ]);
43
- });
44
-
45
- test("NodesToTrees converts two disjoint node arrays to two trees", () => {
46
- const a = { parent: NULL };
47
- const b = { parent: a };
48
-
49
- const c = { parent: NULL };
50
- const d = { parent: c };
51
-
52
- const nodes = [a, b, c, d];
53
-
54
- const trees = nodesToTrees(nodes);
55
-
56
- expect(trees).toEqual([
57
- {
58
- ref: a,
59
- children: [
60
- {
61
- ref: b,
62
- children: [],
63
- },
64
- ],
65
- },
66
- {
67
- ref: c,
68
- children: [
69
- {
70
- ref: d,
71
- children: [],
72
- },
73
- ],
74
- },
75
- ]);
76
- });
77
- });
78
-
79
- describe("VisitTree", () => {
80
- test("VisitTree visits all nodes in a tree in correct order", () => {
81
- const tree = {
82
- id: "a",
83
- children: [
84
- {
85
- id: "b",
86
- children: [
87
- {
88
- id: "d",
89
- /** @type {any[]} */
90
- children: [],
91
- },
92
- {
93
- id: "e",
94
- children: [],
95
- },
96
- ],
97
- },
98
- {
99
- id: "c",
100
- children: [],
101
- },
102
- ],
103
- };
104
-
105
- /** @type {any[]} */
106
- const visitedPre = [];
107
- /** @type {any[]} */
108
- const visitedPost = [];
109
-
110
- visitTree(tree, {
111
- preOrder: (node) => {
112
- visitedPre.push(node);
113
- },
114
- postOrder: (node) => {
115
- visitedPost.push(node);
116
- },
117
- });
118
-
119
- expect(visitedPre.map((node) => node.id)).toEqual([
120
- "a",
121
- "b",
122
- "d",
123
- "e",
124
- "c",
125
- ]);
126
-
127
- expect(visitedPost.map((node) => node.id)).toEqual([
128
- "d",
129
- "e",
130
- "b",
131
- "c",
132
- "a",
133
- ]);
134
- });
135
- });
@@ -1,28 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { concatUrl, getDirectory } from "./url.js";
3
-
4
- test("getDirectory", () => {
5
- expect(getDirectory("foo")).toBeUndefined();
6
- expect(getDirectory("foo/")).toBe("foo/");
7
- expect(getDirectory("foo/index")).toBe("foo/");
8
- expect(getDirectory("http://example.com")).toBe("http://example.com/");
9
- expect(getDirectory("http://example.com/")).toBe("http://example.com/");
10
- expect(getDirectory("http://example.com/a")).toBe("http://example.com/");
11
- expect(getDirectory("http://example.com/a/")).toBe("http://example.com/a/");
12
- });
13
-
14
- test("concatUrl", () => {
15
- expect(concatUrl("http://example.com", "foo")).toEqual(
16
- "http://example.com/foo"
17
- );
18
- expect(concatUrl(() => "http://example.com", "foo")).toEqual(
19
- "http://example.com/foo"
20
- );
21
- expect(concatUrl("http://example.com/", "http://genomespy.app/")).toEqual(
22
- "http://genomespy.app/"
23
- );
24
- expect(concatUrl("foo/", "bar")).toEqual("foo/bar");
25
- expect(concatUrl("foo/baz", "bar")).toEqual("foo/bar");
26
- expect(concatUrl(undefined, "bar")).toEqual("bar");
27
- expect(concatUrl("bar", undefined)).toEqual("bar");
28
- });
@@ -1,13 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import * as vt from "./variableTools.js";
3
-
4
- test("InferNumerality", () => {
5
- expect(vt.inferNumeric(["0", "1", "2.2", "-4"])).toBeTruthy();
6
- expect(vt.inferNumeric(["0", ...vt.NAs.values()])).toBeTruthy();
7
- expect(vt.inferNumeric([])).toBeTruthy();
8
-
9
- expect(vt.inferNumeric(["0", "x"])).toBeFalsy();
10
- expect(vt.inferNumeric(["0", " "])).toBeFalsy();
11
- expect(vt.inferNumeric(["0", "1,2"])).toBeFalsy();
12
- expect(vt.inferNumeric(["0", "20x"])).toBeFalsy();
13
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"axisResolution.d.ts","sourceRoot":"","sources":["../../../src/view/axisResolution.js"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH;IACI;;;OAGG;IAEH;;OAEG;IACH,qBAFW,OAAO,oBAAoB,EAAE,wBAAwB,EAM/D;IAHG,+DAAsB;IACtB,wDAAwD;IACxD,SADW,oBAAoB,EAAE,CAChB;IAGrB,8DAEC;IAED;;;;;OAKG;IACH,qBAFW,oBAAoB,QAyB9B;IAED;;;OAGG;IACH,4DAFa,OAAO,CAUnB;IAED,qDAuBC;IAED,mBAyDC;CACJ;iCA1J6D,CAAC,SAAlD,OAAQ,oBAAoB,EAAE,iBAAkB;UAGnD,OAAO,eAAe,EAAE,OAAO;aAC/B,CAAC;gBACD,OAAO,oBAAoB,EAAE,mBAAmB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"axisResolution.test.d.ts","sourceRoot":"","sources":["../../../src/view/axisResolution.test.js"],"names":[],"mappings":""}
@@ -1,206 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import { createAndInitialize } from "./testUtils.js";
3
- import UnitView from "./unitView.js";
4
- import View from "./view.js";
5
-
6
- /** @type {import("../spec/view.js").LayerSpec} */
7
- const spec = {
8
- data: { values: [] },
9
- layer: [
10
- {
11
- mark: "point",
12
- encoding: {
13
- x: { field: "a", type: "quantitative" },
14
- y: {
15
- field: "a",
16
- type: "quantitative",
17
- scale: { domain: [1, 2] },
18
- },
19
- color: { value: "red" },
20
- },
21
- },
22
- {
23
- mark: "point",
24
- encoding: {
25
- x: { field: "a", type: "quantitative" },
26
- y: {
27
- field: "b",
28
- type: "quantitative",
29
- scale: { domain: [4, 5] },
30
- },
31
- color: { value: "green" },
32
- },
33
- },
34
- ],
35
- };
36
-
37
- describe("Axes resolve properly", () => {
38
- test("Independent axes are independent", async () => {
39
- const view = await createAndInitialize(
40
- {
41
- ...spec,
42
- resolve: { scale: { y: "shared" }, axis: { y: "independent" } },
43
- },
44
- View
45
- );
46
-
47
- const [r0, r1] = [0, 1].map((i) =>
48
- // @ts-ignore
49
- view.children[i].getAxisResolution("y")
50
- );
51
-
52
- expect(r0).toBeDefined();
53
- expect(r1).toBeDefined();
54
- expect(r0).not.toBe(r1);
55
- });
56
-
57
- test("Shared axes have joined titles", async () => {
58
- const view = await createAndInitialize(
59
- {
60
- ...spec,
61
- resolve: { scale: { y: "shared" }, axis: { y: "shared" } },
62
- },
63
- View
64
- );
65
- // @ts-ignore
66
- expect(view.children[0].getAxisResolution("y").getTitle()).toEqual(
67
- "a, b"
68
- );
69
- });
70
-
71
- test("Title is taken from axis title, encoding title, and field name, in that order.", async () => {
72
- let view = await createAndInitialize(
73
- {
74
- data: { values: [] },
75
- mark: "point",
76
- encoding: {
77
- x: { field: "a", type: "quantitative" },
78
- y: {
79
- field: "a",
80
- type: "quantitative",
81
- },
82
- },
83
- },
84
- UnitView
85
- );
86
- expect(view.getAxisResolution("y").getTitle()).toEqual("a");
87
-
88
- view = await createAndInitialize(
89
- {
90
- data: { values: [] },
91
- mark: "point",
92
- encoding: {
93
- x: { field: "a", type: "quantitative" },
94
- y: {
95
- field: "a",
96
- title: "x",
97
- type: "quantitative",
98
- },
99
- },
100
- },
101
- UnitView
102
- );
103
- expect(view.getAxisResolution("y").getTitle()).toEqual("x");
104
-
105
- view = await createAndInitialize(
106
- {
107
- data: { values: [] },
108
- mark: "point",
109
- encoding: {
110
- x: { field: "a", type: "quantitative" },
111
- y: {
112
- field: "a",
113
- title: "x",
114
- type: "quantitative",
115
- axis: {
116
- title: "z",
117
- },
118
- },
119
- },
120
- },
121
- UnitView
122
- );
123
- expect(view.getAxisResolution("y").getTitle()).toEqual("z");
124
- });
125
-
126
- test("Primary and secondary channels are included in the title", async () => {
127
- let view = await createAndInitialize(
128
- {
129
- data: { values: [] },
130
- mark: "rule",
131
- encoding: {
132
- x: { field: "a", type: "quantitative" },
133
- x2: { field: "b" },
134
- },
135
- },
136
- UnitView
137
- );
138
- expect(view.getAxisResolution("x").getTitle()).toEqual("a, b");
139
- });
140
-
141
- test("Secondary channel's field name is hidden if primary channel has an explicit title", async () => {
142
- let view = await createAndInitialize(
143
- {
144
- data: { values: [] },
145
- mark: "rule",
146
- encoding: {
147
- x: { field: "a", type: "quantitative", title: "foo" },
148
- x2: { field: "b" },
149
- },
150
- },
151
- UnitView
152
- );
153
- expect(view.getAxisResolution("x").getTitle()).toEqual("foo");
154
-
155
- let view2 = await createAndInitialize(
156
- {
157
- data: { values: [] },
158
- mark: "rule",
159
- encoding: {
160
- x: {
161
- field: "a",
162
- type: "quantitative",
163
- axis: { title: "foo" },
164
- },
165
- x2: { field: "b" },
166
- },
167
- },
168
- UnitView
169
- );
170
- expect(view2.getAxisResolution("x").getTitle()).toEqual("foo");
171
-
172
- let view3 = await createAndInitialize(
173
- {
174
- data: { values: [] },
175
- mark: "rule",
176
- encoding: {
177
- x: {
178
- field: "a",
179
- type: "quantitative",
180
- axis: { title: "foo" },
181
- },
182
- x2: { field: "b", title: "bar" },
183
- },
184
- },
185
- UnitView
186
- );
187
- expect(view3.getAxisResolution("x").getTitle()).toEqual("foo, bar");
188
-
189
- let view4 = await createAndInitialize(
190
- {
191
- data: { values: [] },
192
- mark: "rule",
193
- encoding: {
194
- x: {
195
- field: "a",
196
- type: "quantitative",
197
- title: null,
198
- },
199
- x2: { field: "b" },
200
- },
201
- },
202
- UnitView
203
- );
204
- expect(view4.getAxisResolution("x").getTitle()).toBeNull();
205
- });
206
- });