@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,125 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import Collector from "../data/collector.js";
3
- import FlowNode from "../data/flowNode.js";
4
- import FilterTransform from "../data/transforms/filter.js";
5
- import FormulaTransform from "../data/transforms/formula.js";
6
- import InlineSource from "../data/sources/inlineSource.js";
7
- import SequenceSource from "../data/sources/sequenceSource.js";
8
- import { buildDataFlow } from "./flowBuilder.js";
9
- import { create } from "./testUtils.js";
10
- import CloneTransform from "../data/transforms/clone.js";
11
- import LayerView from "./layerView.js";
12
- import UnitView from "./unitView.js";
13
-
14
- /**
15
- *
16
- * @param {FlowNode} root
17
- * @param {number[]} path
18
- */
19
- function byPath(root, path) {
20
- for (const elem of path) {
21
- root = root.children[elem];
22
- }
23
- return root;
24
- }
25
-
26
- /** @type {import("../spec/mark.js").MarkProps} */
27
- const mark = {
28
- type: "rect",
29
- tooltip: null,
30
- };
31
-
32
- test("Trivial flow", async () => {
33
- const root = await create(
34
- {
35
- data: { values: [3.141] },
36
- transform: [
37
- {
38
- type: "formula",
39
- expr: "datum.data * 2",
40
- as: "x",
41
- },
42
- ],
43
- mark,
44
- },
45
- UnitView
46
- );
47
-
48
- const flow = buildDataFlow(root);
49
- const dataSource = flow.dataSources[0];
50
-
51
- expect(dataSource).toBeInstanceOf(InlineSource);
52
- expect(byPath(dataSource, [0])).toBeInstanceOf(CloneTransform);
53
- expect(byPath(dataSource, [0, 0])).toBeInstanceOf(FormulaTransform);
54
- expect(byPath(dataSource, [0, 0, 0])).toBeInstanceOf(Collector);
55
-
56
- expect(flow.collectors[0]).toBe(byPath(dataSource, [0, 0, 0]));
57
- });
58
-
59
- test("Branching flow", async () => {
60
- const root = await create(
61
- {
62
- data: { values: [3.141] },
63
- layer: [
64
- {
65
- transform: [
66
- {
67
- type: "formula",
68
- expr: "datum.data * 2",
69
- as: "x",
70
- },
71
- ],
72
- mark,
73
- },
74
- {
75
- transform: [
76
- {
77
- type: "filter",
78
- expr: "datum.data > 4",
79
- },
80
- ],
81
- mark,
82
- },
83
- ],
84
- },
85
- LayerView
86
- );
87
-
88
- const dataSource = buildDataFlow(root).dataSources[0];
89
-
90
- expect(dataSource).toBeInstanceOf(InlineSource);
91
- // Formula transform modifies data and it should be implicitly preceded by CloneTransform
92
- expect(byPath(dataSource, [0])).toBeInstanceOf(CloneTransform);
93
- expect(byPath(dataSource, [0, 0])).toBeInstanceOf(FormulaTransform);
94
- expect(byPath(dataSource, [0, 0, 0])).toBeInstanceOf(Collector);
95
- expect(byPath(dataSource, [1])).toBeInstanceOf(FilterTransform);
96
- expect(byPath(dataSource, [1, 0])).toBeInstanceOf(Collector);
97
- });
98
-
99
- test("Nested data sources", async () => {
100
- const root = await create(
101
- {
102
- data: { values: [1] },
103
- transform: [{ type: "filter", expr: "datum.data > 0" }],
104
- layer: [
105
- {
106
- data: { sequence: { start: 0, stop: 5 } },
107
- transform: [{ type: "formula", expr: "3", as: "foo" }],
108
- mark,
109
- },
110
- ],
111
- },
112
- LayerView
113
- );
114
-
115
- const dataSources = buildDataFlow(root).dataSources;
116
-
117
- expect(dataSources[0]).toBeInstanceOf(InlineSource);
118
- expect(dataSources[0].children[0]).toBeInstanceOf(FilterTransform);
119
- expect(dataSources[0].children[0].children.length).toEqual(0);
120
-
121
- expect(byPath(dataSources[1], [])).toBeInstanceOf(SequenceSource);
122
- expect(byPath(dataSources[1], [0])).toBeInstanceOf(CloneTransform);
123
- expect(byPath(dataSources[1], [0, 0])).toBeInstanceOf(FormulaTransform);
124
- expect(byPath(dataSources[1], [0, 0, 0])).toBeInstanceOf(Collector);
125
- });
@@ -1,87 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
-
3
- import ConcatView from "../concatView.js";
4
- import UnitView from "../unitView.js";
5
- import SelectionRect from "./selectionRect.js";
6
- import { createTestViewContext } from "../testUtils.js";
7
- import { buildDataFlow } from "../flowBuilder.js";
8
- import { optimizeDataFlow } from "../../data/flowOptimizer.js";
9
- import { syncFlowHandles } from "../../data/flowInit.js";
10
-
11
- describe("SelectionRect", () => {
12
- it("uses flow handles for dynamic data updates", () => {
13
- const context = createTestViewContext();
14
- const parent = new ConcatView(
15
- { hconcat: [] },
16
- context,
17
- null,
18
- null,
19
- "p"
20
- );
21
-
22
- /** @type {import("../../spec/view.js").UnitSpec} */
23
- const unitSpec = {
24
- data: { values: [{ x: 0, y: 0 }] },
25
- mark: "point",
26
- encoding: {
27
- x: { field: "x", type: "quantitative" },
28
- y: { field: "y", type: "quantitative" },
29
- },
30
- };
31
-
32
- const unitView = new UnitView(unitSpec, context, parent, parent, "u");
33
-
34
- let selection = {
35
- intervals: { x: [0, 1], y: [2, 3] },
36
- };
37
-
38
- /** @type {(listener: () => void) => void} */
39
- const addListener = () => undefined;
40
- /** @type {(listener: () => void) => void} */
41
- const removeListener = () => undefined;
42
- /** @type {() => void} */
43
- const invalidate = () => undefined;
44
-
45
- /** @type {import("../paramMediator.js").ExprRefFunction} */
46
- const selectionExpr = Object.assign(() => selection, {
47
- addListener,
48
- removeListener,
49
- invalidate,
50
- identifier: () => "selection",
51
- fields: [],
52
- globals: [],
53
- code: "selection",
54
- });
55
-
56
- const gridChild = /** @type {import("./gridChild.js").default} */ (
57
- /** @type {unknown} */ ({
58
- layoutParent: parent,
59
- view: unitView,
60
- })
61
- );
62
-
63
- const selectionRect = new SelectionRect(gridChild, selectionExpr);
64
-
65
- const flow = buildDataFlow(selectionRect, context.dataFlow);
66
- syncFlowHandles(selectionRect, optimizeDataFlow(flow));
67
-
68
- const dataSource =
69
- /** @type {import("../../data/sources/inlineSource.js").default} */ (
70
- selectionRect.flowHandle?.dataSource
71
- );
72
- expect(dataSource).toBeDefined();
73
-
74
- // Selection updates should push new interval data to the inline source.
75
- const updateSpy = vi.spyOn(dataSource, "updateDynamicData");
76
- selection = {
77
- intervals: { x: [5, 6], y: [7, 8] },
78
- };
79
-
80
- selectionRect._selectionListener();
81
-
82
- expect(updateSpy).toHaveBeenCalledTimes(1);
83
- expect(updateSpy).toHaveBeenCalledWith([
84
- { _x: 5, _x2: 6, _y: 7, _y2: 8 },
85
- ]);
86
- });
87
- });
@@ -1,323 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import {
3
- mapToPixelCoords,
4
- getMinimumSize,
5
- getLargestSize,
6
- isStretching,
7
- parseSizeDef,
8
- sumSizeDefs,
9
- } from "./flexLayout.js";
10
-
11
- test("parseSize", () => {
12
- expect(parseSizeDef(10)).toEqual({ px: 10, grow: 0 });
13
- expect(parseSizeDef({ px: 20, grow: 2 })).toEqual({ px: 20, grow: 2 });
14
- expect(parseSizeDef(undefined)).toEqual({ px: 0, grow: 1 });
15
- expect(parseSizeDef(null)).toEqual({ px: 0, grow: 1 });
16
- expect(parseSizeDef("container")).toEqual({ px: 0, grow: 1 });
17
- expect(() => parseSizeDef({})).toThrow();
18
- });
19
-
20
- describe("Basic flex functionality", () => {
21
- test("Absolute sizes", () => {
22
- const items = [10, 30, 20].map((x) => ({ px: x }));
23
- const containerSize = 100;
24
-
25
- const mapped = mapToPixelCoords(items, containerSize);
26
-
27
- expect(mapped[0]).toEqual({ location: 0, size: 10 });
28
- expect(mapped[1]).toEqual({ location: 10, size: 30 });
29
- expect(mapped[2]).toEqual({ location: 40, size: 20 });
30
- });
31
-
32
- test("Absolute sizes with spacing", () => {
33
- const items = [10, 30, 20].map((x) => ({ px: x }));
34
- const containerSize = 100;
35
-
36
- const mapped = mapToPixelCoords(items, containerSize, { spacing: 10 });
37
-
38
- expect(mapped[0]).toEqual({ location: 0, size: 10 });
39
- expect(mapped[1]).toEqual({ location: 20, size: 30 });
40
- expect(mapped[2]).toEqual({ location: 60, size: 20 });
41
- });
42
-
43
- test("Absolute sizes with spacing, reversed", () => {
44
- const items = [10, 30, 20].map((x) => ({ px: x }));
45
- const containerSize = 100;
46
-
47
- const mapped = mapToPixelCoords(items, containerSize, {
48
- spacing: 10,
49
- reverse: true,
50
- });
51
-
52
- expect(mapped[0]).toEqual({ location: 90, size: 10 });
53
- expect(mapped[1]).toEqual({ location: 50, size: 30 });
54
- expect(mapped[2]).toEqual({ location: 20, size: 20 });
55
- });
56
-
57
- test("Absolute sizes with spacing, reversed and insufficient containerSize", () => {
58
- const items = [10, 30, 20].map((x) => ({ px: x }));
59
- const containerSize = 0;
60
-
61
- const mapped = mapToPixelCoords(items, containerSize, {
62
- spacing: 10,
63
- reverse: true,
64
- });
65
-
66
- expect(mapped[0]).toEqual({ location: 70, size: 10 });
67
- expect(mapped[1]).toEqual({ location: 30, size: 30 });
68
- expect(mapped[2]).toEqual({ location: 0, size: 20 });
69
- });
70
-
71
- test("Growing sizes", () => {
72
- const items = [10, 20, 70].map((x) => ({ grow: x }));
73
- const containerSize = 200;
74
-
75
- const mapped = mapToPixelCoords(items, containerSize);
76
-
77
- expect(mapped[0]).toEqual({ location: 0, size: 20 });
78
- expect(mapped[1]).toEqual({ location: 20, size: 40 });
79
- expect(mapped[2]).toEqual({ location: 60, size: 140 });
80
- });
81
-
82
- test("Growing sizes with spacing", () => {
83
- const items = [10, 20, 70].map((x) => ({ grow: x }));
84
- const containerSize = 220;
85
- const mapped = mapToPixelCoords(items, containerSize, { spacing: 10 });
86
-
87
- expect(mapped[0]).toEqual({ location: 0, size: 20 });
88
- expect(mapped[1]).toEqual({ location: 30, size: 40 });
89
- expect(mapped[2]).toEqual({ location: 80, size: 140 });
90
- });
91
-
92
- test("Mixed absolute and relative sizes", () => {
93
- const items = [{ px: 100 }, { grow: 1 }, { grow: 9 }, { px: 200 }];
94
- const containerSize = 1100;
95
- const mapped = mapToPixelCoords(items, containerSize);
96
-
97
- expect(mapped[0]).toEqual({ location: 0, size: 100 });
98
- expect(mapped[1]).toEqual({ location: 100, size: 80 });
99
- expect(mapped[2]).toEqual({ location: 180, size: 720 });
100
- expect(mapped[3]).toEqual({ location: 900, size: 200 });
101
- });
102
-
103
- test("Sizes having both absolute and growing components", () => {
104
- const items = [
105
- { px: 1 },
106
- { px: 2 },
107
- { px: 3, grow: 2 },
108
- { px: 4, grow: 1 },
109
- ];
110
- const containerSize = 16;
111
- const mapped = mapToPixelCoords(items, containerSize);
112
-
113
- expect(mapped[0]).toEqual({ location: 0, size: 1 });
114
- expect(mapped[1]).toEqual({ location: 1, size: 2 });
115
- expect(mapped[2]).toEqual({ location: 3, size: 7 });
116
- expect(mapped[3]).toEqual({ location: 10, size: 6 });
117
- });
118
-
119
- test("Zero sizes return zero coords", () => {
120
- const items = [{ grow: 0 }, { grow: 0 }];
121
-
122
- const mapped = mapToPixelCoords(items, 0);
123
- expect(mapped[0]).toEqual({ location: 0, size: 0 });
124
- expect(mapped[1]).toEqual({ location: 0, size: 0 });
125
-
126
- const mapped2 = mapToPixelCoords(items, 1);
127
- expect(mapped2[0]).toEqual({ location: 0, size: 0 });
128
- expect(mapped2[1]).toEqual({ location: 0, size: 0 });
129
- });
130
-
131
- test("Offset is added", () => {
132
- const items = [10, 30, 20].map((x) => ({ px: x }));
133
- const containerSize = 100;
134
-
135
- const mapped = mapToPixelCoords(items, containerSize, { offset: 5 });
136
-
137
- expect(mapped[0]).toEqual({ location: 5, size: 10 });
138
- expect(mapped[1]).toEqual({ location: 15, size: 30 });
139
- expect(mapped[2]).toEqual({ location: 45, size: 20 });
140
- });
141
- });
142
-
143
- describe("Collapse gaps when items have zero px and grow", () => {
144
- test("Zero as first", () => {
145
- const items = [0, 30, 20].map((x) => ({ px: x }));
146
- const containerSize = 100;
147
-
148
- const mapped = mapToPixelCoords(items, containerSize, { spacing: 10 });
149
-
150
- expect(mapped[0]).toEqual({ location: 0, size: 0 });
151
- expect(mapped[1]).toEqual({ location: 0, size: 30 });
152
- expect(mapped[2]).toEqual({ location: 40, size: 20 });
153
- });
154
-
155
- test("Zero in the middle", () => {
156
- const items = [10, 0, 20].map((x) => ({ px: x }));
157
- const containerSize = 100;
158
-
159
- const mapped = mapToPixelCoords(items, containerSize, { spacing: 10 });
160
-
161
- expect(mapped[0]).toEqual({ location: 0, size: 10 });
162
- expect(mapped[1]).toEqual({ location: 15, size: 0 });
163
- expect(mapped[2]).toEqual({ location: 20, size: 20 });
164
- });
165
-
166
- test("Multiple zeroes in the middle", () => {
167
- const items = [10, 0, 0, 0, 20].map((x) => ({ px: x }));
168
- const containerSize = 100;
169
-
170
- const mapped = mapToPixelCoords(items, containerSize, { spacing: 10 });
171
-
172
- expect(mapped[0]).toEqual({ location: 0, size: 10 });
173
- expect(mapped[1]).toEqual({ location: 12.5, size: 0 });
174
- expect(mapped[2]).toEqual({ location: 15, size: 0 });
175
- expect(mapped[3]).toEqual({ location: 17.5, size: 0 });
176
- expect(mapped[4]).toEqual({ location: 20, size: 20 });
177
- });
178
-
179
- test("Zero as last", () => {
180
- const items = [10, 30, 0].map((x) => ({ px: x }));
181
- const containerSize = 100;
182
-
183
- const mapped = mapToPixelCoords(items, containerSize, { spacing: 10 });
184
-
185
- expect(mapped[0]).toEqual({ location: 0, size: 10 });
186
- expect(mapped[1]).toEqual({ location: 20, size: 30 });
187
- expect(mapped[2]).toEqual({ location: 50, size: 0 });
188
- });
189
-
190
- test("Only a zero", () => {
191
- const items = [0].map((x) => ({ px: x }));
192
- const containerSize = 100;
193
-
194
- const mapped = mapToPixelCoords(items, containerSize, { spacing: 10 });
195
-
196
- expect(mapped[0]).toEqual({ location: 0, size: 0 });
197
- });
198
- });
199
-
200
- describe("Collapse gaps when items have zero px and grow, reversed", () => {
201
- test("Zero as first", () => {
202
- const items = [0, 30, 20].map((x) => ({ px: x }));
203
- const containerSize = 100;
204
-
205
- const mapped = mapToPixelCoords(items, containerSize, {
206
- spacing: 10,
207
- reverse: true,
208
- });
209
-
210
- expect(mapped[0]).toEqual({ location: 100, size: 0 });
211
- expect(mapped[1]).toEqual({ location: 70, size: 30 });
212
- expect(mapped[2]).toEqual({ location: 40, size: 20 });
213
- });
214
-
215
- test("Zero in the middle", () => {
216
- const items = [10, 0, 20].map((x) => ({ px: x }));
217
- const containerSize = 100;
218
-
219
- const mapped = mapToPixelCoords(items, containerSize, {
220
- spacing: 10,
221
- reverse: true,
222
- });
223
-
224
- expect(mapped[0]).toEqual({ location: 90, size: 10 });
225
- expect(mapped[1]).toEqual({ location: 85, size: 0 });
226
- expect(mapped[2]).toEqual({ location: 60, size: 20 });
227
- });
228
-
229
- test("Multiple zeroes in the middle", () => {
230
- const items = [10, 0, 0, 0, 20].map((x) => ({ px: x }));
231
- const containerSize = 100;
232
-
233
- const mapped = mapToPixelCoords(items, containerSize, {
234
- spacing: 10,
235
- reverse: true,
236
- });
237
-
238
- expect(mapped[0]).toEqual({ location: 90, size: 10 });
239
- expect(mapped[1]).toEqual({ location: 87.5, size: 0 });
240
- expect(mapped[2]).toEqual({ location: 85, size: 0 });
241
- expect(mapped[3]).toEqual({ location: 82.5, size: 0 });
242
- expect(mapped[4]).toEqual({ location: 60, size: 20 });
243
- });
244
-
245
- test("Zero as last", () => {
246
- const items = [10, 30, 0].map((x) => ({ px: x }));
247
- const containerSize = 100;
248
-
249
- const mapped = mapToPixelCoords(items, containerSize, {
250
- spacing: 10,
251
- reverse: true,
252
- });
253
-
254
- expect(mapped[0]).toEqual({ location: 90, size: 10 });
255
- expect(mapped[1]).toEqual({ location: 50, size: 30 });
256
- expect(mapped[2]).toEqual({ location: 50, size: 0 });
257
- });
258
-
259
- test("Only a zero", () => {
260
- const items = [0].map((x) => ({ px: x }));
261
- const containerSize = 100;
262
-
263
- const mapped = mapToPixelCoords(items, containerSize, {
264
- spacing: 10,
265
- reverse: true,
266
- });
267
-
268
- expect(mapped[0]).toEqual({ location: 100, size: 0 });
269
- });
270
- });
271
-
272
- describe("Utility fuctions", () => {
273
- test("sumSizeDefs", () => {
274
- const items = [
275
- { px: 100 },
276
- { px: 10, grow: 1 },
277
- { grow: 9 },
278
- { px: 200 },
279
- ];
280
-
281
- expect(sumSizeDefs(items)).toEqual({ px: 310, grow: 10 });
282
- });
283
-
284
- test("getMinimumSize", () => {
285
- const items = [{ px: 100 }, { grow: 1 }, { grow: 9 }, { px: 200 }];
286
-
287
- expect(getMinimumSize(items)).toEqual(300);
288
-
289
- expect(getMinimumSize(items, { spacing: 10 })).toEqual(330);
290
- });
291
-
292
- test("getMinimumSize, items include zeroes", () => {
293
- const items = [
294
- { px: 100 },
295
- { px: 0, grow: 0 },
296
- { grow: 1 },
297
- { grow: 9 },
298
- { px: 200 },
299
- ];
300
-
301
- expect(getMinimumSize(items)).toEqual(300);
302
-
303
- expect(getMinimumSize(items, { spacing: 10 })).toEqual(330);
304
- });
305
-
306
- test("getLargestSize", () => {
307
- const items = [
308
- { px: 100 },
309
- { px: 0, grow: 0 },
310
- { grow: 1 },
311
- { grow: 9 },
312
- { px: 200 },
313
- { px: 50 },
314
- ];
315
-
316
- expect(getLargestSize(items)).toEqual({ px: 200, grow: 9 });
317
- });
318
-
319
- test("isStretching", () => {
320
- expect(isStretching([{ grow: 1 }])).toBeTruthy();
321
- expect(isStretching([{ px: 1 }])).toBeFalsy();
322
- });
323
- });
@@ -1,71 +0,0 @@
1
- import { expect, test, describe } from "vitest";
2
-
3
- import Grid from "./grid.js";
4
-
5
- describe("Grid indexing", () => {
6
- test("Single row", () => {
7
- const g = new Grid(3);
8
-
9
- expect(g.maxCols).toEqual(Infinity);
10
- expect(g.nCols).toEqual(3);
11
- expect(g.nRows).toEqual(1);
12
- expect(g.colIndices).toEqual([[0], [1], [2]]);
13
- expect(g.rowIndices).toEqual([[0, 1, 2]]);
14
- expect(g.getCellIndex(1, 0)).toEqual(1);
15
- expect(g.getCellIndex(1, 1)).toBeUndefined();
16
- expect(g.getCellCoords(1)).toEqual([1, 0]);
17
- expect(g.getCellCoords(-1)).toBeUndefined();
18
- expect(g.getCellCoords(3)).toBeUndefined();
19
- });
20
-
21
- test("Single column", () => {
22
- const g = new Grid(3, 1);
23
-
24
- expect(g.maxCols).toEqual(1);
25
- expect(g.nCols).toEqual(1);
26
- expect(g.nRows).toEqual(3);
27
- expect(g.colIndices).toEqual([[0, 1, 2]]);
28
- expect(g.rowIndices).toEqual([[0], [1], [2]]);
29
- expect(g.getCellIndex(0, 1)).toEqual(1);
30
- expect(g.getCellIndex(1, 1)).toBeUndefined();
31
- expect(g.getCellCoords(1)).toEqual([0, 1]);
32
- });
33
-
34
- test("Two columns", () => {
35
- const g = new Grid(6, 2);
36
-
37
- expect(g.maxCols).toEqual(2);
38
- expect(g.nCols).toEqual(2);
39
- expect(g.nRows).toEqual(3);
40
- expect(g.colIndices).toEqual([
41
- [0, 2, 4],
42
- [1, 3, 5],
43
- ]);
44
- expect(g.rowIndices).toEqual([
45
- [0, 1],
46
- [2, 3],
47
- [4, 5],
48
- ]);
49
- expect(g.getCellIndex(1, 0)).toEqual(1);
50
- expect(g.getCellIndex(0, 1)).toEqual(2);
51
- expect(g.getCellIndex(1, 1)).toEqual(3);
52
- expect(g.getCellCoords(3)).toEqual([1, 1]);
53
- });
54
-
55
- test("Two columns, second is partial", () => {
56
- const g = new Grid(5, 2);
57
-
58
- expect(g.maxCols).toEqual(2);
59
- expect(g.nCols).toEqual(2);
60
- expect(g.nRows).toEqual(3);
61
- expect(g.colIndices).toEqual([
62
- [0, 2, 4],
63
- [1, 3],
64
- ]);
65
- expect(g.rowIndices).toEqual([[0, 1], [2, 3], [4]]);
66
- expect(g.getCellIndex(1, 0)).toEqual(1);
67
- expect(g.getCellIndex(0, 1)).toEqual(2);
68
- expect(g.getCellIndex(1, 2)).toBeUndefined();
69
- expect(g.getCellCoords(3)).toEqual([1, 1]);
70
- });
71
- });