@genome-spy/core 0.48.1 → 0.49.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 (241) hide show
  1. package/dist/bundle/index.es.js +7485 -7097
  2. package/dist/bundle/index.js +124 -111
  3. package/dist/schema.json +838 -344
  4. package/dist/src/data/collector.d.ts +10 -8
  5. package/dist/src/data/collector.d.ts.map +1 -1
  6. package/dist/src/data/collector.js +131 -33
  7. package/dist/src/data/collector.test.d.ts +2 -0
  8. package/dist/src/data/collector.test.d.ts.map +1 -0
  9. package/dist/src/data/collector.test.js +55 -1
  10. package/dist/src/data/dataFlow.test.d.ts +2 -0
  11. package/dist/src/data/dataFlow.test.d.ts.map +1 -0
  12. package/dist/src/data/flow.test.d.ts +2 -0
  13. package/dist/src/data/flow.test.d.ts.map +1 -0
  14. package/dist/src/data/flow.test.js +19 -14
  15. package/dist/src/data/flowNode.test.d.ts +2 -0
  16. package/dist/src/data/flowNode.test.d.ts.map +1 -0
  17. package/dist/src/data/flowOptimizer.test.d.ts +2 -0
  18. package/dist/src/data/flowOptimizer.test.d.ts.map +1 -0
  19. package/dist/src/data/flowOptimizer.test.js +9 -10
  20. package/dist/src/data/formats/fasta.test.d.ts +2 -0
  21. package/dist/src/data/formats/fasta.test.d.ts.map +1 -0
  22. package/dist/src/data/sources/inlineSource.test.d.ts +2 -0
  23. package/dist/src/data/sources/inlineSource.test.d.ts.map +1 -0
  24. package/dist/src/data/sources/inlineSource.test.js +23 -16
  25. package/dist/src/data/sources/sequenceSource.test.d.ts +2 -0
  26. package/dist/src/data/sources/sequenceSource.test.d.ts.map +1 -0
  27. package/dist/src/data/sources/sequenceSource.test.js +59 -42
  28. package/dist/src/data/transforms/clone.test.d.ts +2 -0
  29. package/dist/src/data/transforms/clone.test.d.ts.map +1 -0
  30. package/dist/src/data/transforms/coverage.test.d.ts +2 -0
  31. package/dist/src/data/transforms/coverage.test.d.ts.map +1 -0
  32. package/dist/src/data/transforms/coverage.test.js +1 -1
  33. package/dist/src/data/transforms/filter.d.ts +10 -0
  34. package/dist/src/data/transforms/filter.d.ts.map +1 -1
  35. package/dist/src/data/transforms/filter.js +30 -1
  36. package/dist/src/data/transforms/filter.test.d.ts +2 -0
  37. package/dist/src/data/transforms/filter.test.d.ts.map +1 -0
  38. package/dist/src/data/transforms/flatten.test.d.ts +2 -0
  39. package/dist/src/data/transforms/flatten.test.d.ts.map +1 -0
  40. package/dist/src/data/transforms/flatten.test.js +10 -7
  41. package/dist/src/data/transforms/flattenDelimited.test.d.ts +2 -0
  42. package/dist/src/data/transforms/flattenDelimited.test.d.ts.map +1 -0
  43. package/dist/src/data/transforms/flattenDelimited.test.js +16 -13
  44. package/dist/src/data/transforms/flattenSequence.test.d.ts +2 -0
  45. package/dist/src/data/transforms/flattenSequence.test.d.ts.map +1 -0
  46. package/dist/src/data/transforms/flattenSequence.test.js +1 -1
  47. package/dist/src/data/transforms/formula.test.d.ts +2 -0
  48. package/dist/src/data/transforms/formula.test.d.ts.map +1 -0
  49. package/dist/src/data/transforms/formula.test.js +1 -1
  50. package/dist/src/data/transforms/identifier.d.ts +1 -1
  51. package/dist/src/data/transforms/identifier.d.ts.map +1 -1
  52. package/dist/src/data/transforms/identifier.js +2 -2
  53. package/dist/src/data/transforms/identifier.test.d.ts +2 -0
  54. package/dist/src/data/transforms/identifier.test.d.ts.map +1 -0
  55. package/dist/src/data/transforms/identifier.test.js +23 -14
  56. package/dist/src/data/transforms/pileup.test.d.ts +2 -0
  57. package/dist/src/data/transforms/pileup.test.d.ts.map +1 -0
  58. package/dist/src/data/transforms/project.test.d.ts +2 -0
  59. package/dist/src/data/transforms/project.test.d.ts.map +1 -0
  60. package/dist/src/data/transforms/project.test.js +1 -1
  61. package/dist/src/data/transforms/regexExtract.test.d.ts +2 -0
  62. package/dist/src/data/transforms/regexExtract.test.d.ts.map +1 -0
  63. package/dist/src/data/transforms/regexExtract.test.js +6 -3
  64. package/dist/src/data/transforms/regexFold.test.d.ts +2 -0
  65. package/dist/src/data/transforms/regexFold.test.d.ts.map +1 -0
  66. package/dist/src/data/transforms/sample.test.d.ts +2 -0
  67. package/dist/src/data/transforms/sample.test.d.ts.map +1 -0
  68. package/dist/src/data/transforms/stack.test.d.ts +2 -0
  69. package/dist/src/data/transforms/stack.test.d.ts.map +1 -0
  70. package/dist/src/data/transforms/stack.test.js +8 -8
  71. package/dist/src/encoder/accessor.d.ts +17 -14
  72. package/dist/src/encoder/accessor.d.ts.map +1 -1
  73. package/dist/src/encoder/accessor.js +127 -56
  74. package/dist/src/encoder/accessor.test.d.ts +2 -0
  75. package/dist/src/encoder/accessor.test.d.ts.map +1 -0
  76. package/dist/src/encoder/accessor.test.js +145 -31
  77. package/dist/src/encoder/encoder.d.ts +26 -13
  78. package/dist/src/encoder/encoder.d.ts.map +1 -1
  79. package/dist/src/encoder/encoder.js +98 -114
  80. package/dist/src/encoder/encoder.test.d.ts +2 -0
  81. package/dist/src/encoder/encoder.test.d.ts.map +1 -0
  82. package/dist/src/encoder/encoder.test.js +85 -82
  83. package/dist/src/fonts/bmFontManager.d.ts.map +1 -1
  84. package/dist/src/fonts/bmFontManager.js +10 -4
  85. package/dist/src/genome/genome.test.d.ts +2 -0
  86. package/dist/src/genome/genome.test.d.ts.map +1 -0
  87. package/dist/src/genome/scaleIndex.test.d.ts +2 -0
  88. package/dist/src/genome/scaleIndex.test.d.ts.map +1 -0
  89. package/dist/src/genome/scaleLocus.test.d.ts +2 -0
  90. package/dist/src/genome/scaleLocus.test.d.ts.map +1 -0
  91. package/dist/src/genomeSpy.d.ts +3 -2
  92. package/dist/src/genomeSpy.d.ts.map +1 -1
  93. package/dist/src/genomeSpy.js +29 -21
  94. package/dist/src/gl/dataToVertices.d.ts +5 -7
  95. package/dist/src/gl/dataToVertices.d.ts.map +1 -1
  96. package/dist/src/gl/dataToVertices.js +42 -30
  97. package/dist/src/gl/glslScaleGenerator.d.ts +84 -15
  98. package/dist/src/gl/glslScaleGenerator.d.ts.map +1 -1
  99. package/dist/src/gl/glslScaleGenerator.js +260 -73
  100. package/dist/src/gl/includes/picking.vertex.glsl.js +1 -1
  101. package/dist/src/marks/link.common.glsl.js +1 -1
  102. package/dist/src/marks/link.d.ts.map +1 -1
  103. package/dist/src/marks/link.js +10 -0
  104. package/dist/src/marks/link.vertex.glsl.js +1 -1
  105. package/dist/src/marks/mark.d.ts +6 -9
  106. package/dist/src/marks/mark.d.ts.map +1 -1
  107. package/dist/src/marks/mark.js +212 -95
  108. package/dist/src/marks/point.d.ts.map +1 -1
  109. package/dist/src/marks/point.js +5 -1
  110. package/dist/src/marks/rect.d.ts.map +1 -1
  111. package/dist/src/marks/rect.js +9 -4
  112. package/dist/src/marks/rule.d.ts.map +1 -1
  113. package/dist/src/marks/rule.js +4 -0
  114. package/dist/src/marks/text.d.ts.map +1 -1
  115. package/dist/src/marks/text.js +5 -1
  116. package/dist/src/scale/scale.test.d.ts +2 -0
  117. package/dist/src/scale/scale.test.d.ts.map +1 -0
  118. package/dist/src/scale/scale.test.js +2 -0
  119. package/dist/src/scale/ticks.test.d.ts +2 -0
  120. package/dist/src/scale/ticks.test.d.ts.map +1 -0
  121. package/dist/src/scale/ticks.test.js +6 -0
  122. package/dist/src/selection/selection.d.ts +39 -0
  123. package/dist/src/selection/selection.d.ts.map +1 -0
  124. package/dist/src/selection/selection.js +78 -0
  125. package/dist/src/spec/channel.d.ts +137 -83
  126. package/dist/src/spec/mark.d.ts +9 -0
  127. package/dist/src/spec/parameter.d.ts +112 -3
  128. package/dist/src/spec/root.d.ts +0 -1
  129. package/dist/src/spec/transform.d.ts +19 -1
  130. package/dist/src/spec/view.d.ts +3 -3
  131. package/dist/src/tooltip/dataTooltipHandler.js +1 -1
  132. package/dist/src/types/encoder.d.ts +80 -26
  133. package/dist/src/types/rendering.d.ts +1 -0
  134. package/dist/src/types/selectionTypes.d.ts +44 -0
  135. package/dist/src/types/viewContext.d.ts +1 -4
  136. package/dist/src/utils/addBaseUrl.test.d.ts +2 -0
  137. package/dist/src/utils/addBaseUrl.test.d.ts.map +1 -0
  138. package/dist/src/utils/animator.d.ts.map +1 -1
  139. package/dist/src/utils/animator.js +3 -1
  140. package/dist/src/utils/binnedIndex.test.d.ts +2 -0
  141. package/dist/src/utils/binnedIndex.test.d.ts.map +1 -0
  142. package/dist/src/utils/cloner.test.d.ts +2 -0
  143. package/dist/src/utils/cloner.test.d.ts.map +1 -0
  144. package/dist/src/utils/coalesce.test.d.ts +2 -0
  145. package/dist/src/utils/coalesce.test.d.ts.map +1 -0
  146. package/dist/src/utils/concatIterables.test.d.ts +2 -0
  147. package/dist/src/utils/concatIterables.test.d.ts.map +1 -0
  148. package/dist/src/utils/domainArray.test.d.ts +2 -0
  149. package/dist/src/utils/domainArray.test.d.ts.map +1 -0
  150. package/dist/src/utils/expression.d.ts +2 -2
  151. package/dist/src/utils/expression.d.ts.map +1 -1
  152. package/dist/src/utils/expression.js +11 -2
  153. package/dist/src/utils/indexer.test.d.ts +2 -0
  154. package/dist/src/utils/indexer.test.d.ts.map +1 -0
  155. package/dist/src/utils/inertia.d.ts.map +1 -1
  156. package/dist/src/utils/inertia.js +4 -0
  157. package/dist/src/utils/inputBinding.d.ts.map +1 -1
  158. package/dist/src/utils/inputBinding.js +4 -0
  159. package/dist/src/utils/iterateNestedMaps.d.ts +4 -3
  160. package/dist/src/utils/iterateNestedMaps.d.ts.map +1 -1
  161. package/dist/src/utils/iterateNestedMaps.js +3 -2
  162. package/dist/src/utils/iterateNestedMaps.test.d.ts +2 -0
  163. package/dist/src/utils/iterateNestedMaps.test.d.ts.map +1 -0
  164. package/dist/src/utils/kWayMerge.test.d.ts +2 -0
  165. package/dist/src/utils/kWayMerge.test.d.ts.map +1 -0
  166. package/dist/src/utils/mergeObjects.test.d.ts +2 -0
  167. package/dist/src/utils/mergeObjects.test.d.ts.map +1 -0
  168. package/dist/src/utils/numberExtractor.test.d.ts +2 -0
  169. package/dist/src/utils/numberExtractor.test.d.ts.map +1 -0
  170. package/dist/src/utils/propertyCacher.test.d.ts +2 -0
  171. package/dist/src/utils/propertyCacher.test.d.ts.map +1 -0
  172. package/dist/src/utils/propertyCoalescer.test.d.ts +2 -0
  173. package/dist/src/utils/propertyCoalescer.test.d.ts.map +1 -0
  174. package/dist/src/utils/propertyCoalescer.test.js +3 -0
  175. package/dist/src/utils/radixSort.d.ts +9 -0
  176. package/dist/src/utils/radixSort.d.ts.map +1 -0
  177. package/dist/src/utils/radixSort.js +130 -0
  178. package/dist/src/utils/radixSort.test.d.ts +2 -0
  179. package/dist/src/utils/radixSort.test.d.ts.map +1 -0
  180. package/dist/src/utils/radixSort.test.js +51 -0
  181. package/dist/src/utils/reservationMap.test.d.ts +2 -0
  182. package/dist/src/utils/reservationMap.test.d.ts.map +1 -0
  183. package/dist/src/utils/ringBuffer.test.d.ts +2 -0
  184. package/dist/src/utils/ringBuffer.test.d.ts.map +1 -0
  185. package/dist/src/utils/topK.test.d.ts +2 -0
  186. package/dist/src/utils/topK.test.d.ts.map +1 -0
  187. package/dist/src/utils/trees.test.d.ts +2 -0
  188. package/dist/src/utils/trees.test.d.ts.map +1 -0
  189. package/dist/src/utils/trees.test.js +8 -3
  190. package/dist/src/utils/variableTools.test.d.ts +2 -0
  191. package/dist/src/utils/variableTools.test.d.ts.map +1 -0
  192. package/dist/src/view/axisResolution.d.ts +19 -6
  193. package/dist/src/view/axisResolution.d.ts.map +1 -1
  194. package/dist/src/view/axisResolution.js +16 -7
  195. package/dist/src/view/axisResolution.test.d.ts +2 -0
  196. package/dist/src/view/axisResolution.test.d.ts.map +1 -0
  197. package/dist/src/view/axisResolution.test.js +16 -11
  198. package/dist/src/view/facetView.d.ts +1 -1
  199. package/dist/src/view/facetView.d.ts.map +1 -1
  200. package/dist/src/view/flowBuilder.d.ts +1 -1
  201. package/dist/src/view/flowBuilder.d.ts.map +1 -1
  202. package/dist/src/view/flowBuilder.js +34 -5
  203. package/dist/src/view/flowBuilder.test.d.ts +2 -0
  204. package/dist/src/view/flowBuilder.test.d.ts.map +1 -0
  205. package/dist/src/view/gridView.d.ts +0 -6
  206. package/dist/src/view/gridView.d.ts.map +1 -1
  207. package/dist/src/view/layerView.d.ts +0 -6
  208. package/dist/src/view/layerView.d.ts.map +1 -1
  209. package/dist/src/view/layout/flexLayout.test.d.ts +2 -0
  210. package/dist/src/view/layout/flexLayout.test.d.ts.map +1 -0
  211. package/dist/src/view/layout/grid.test.d.ts +2 -0
  212. package/dist/src/view/layout/grid.test.d.ts.map +1 -0
  213. package/dist/src/view/layout/rectangle.test.d.ts +2 -0
  214. package/dist/src/view/layout/rectangle.test.d.ts.map +1 -0
  215. package/dist/src/view/paramMediator.d.ts +32 -5
  216. package/dist/src/view/paramMediator.d.ts.map +1 -1
  217. package/dist/src/view/paramMediator.js +97 -9
  218. package/dist/src/view/paramMediator.test.d.ts +2 -0
  219. package/dist/src/view/paramMediator.test.d.ts.map +1 -0
  220. package/dist/src/view/paramMediator.test.js +17 -1
  221. package/dist/src/view/scaleResolution.d.ts +17 -9
  222. package/dist/src/view/scaleResolution.d.ts.map +1 -1
  223. package/dist/src/view/scaleResolution.js +51 -34
  224. package/dist/src/view/scaleResolution.test.d.ts +2 -0
  225. package/dist/src/view/scaleResolution.test.d.ts.map +1 -0
  226. package/dist/src/view/scaleResolution.test.js +2 -0
  227. package/dist/src/view/testUtils.d.ts.map +1 -1
  228. package/dist/src/view/testUtils.js +15 -3
  229. package/dist/src/view/unitView.d.ts +5 -15
  230. package/dist/src/view/unitView.d.ts.map +1 -1
  231. package/dist/src/view/unitView.js +81 -101
  232. package/dist/src/view/view.d.ts +1 -1
  233. package/dist/src/view/view.d.ts.map +1 -1
  234. package/dist/src/view/view.test.d.ts +2 -0
  235. package/dist/src/view/view.test.d.ts.map +1 -0
  236. package/dist/src/view/view.test.js +73 -55
  237. package/dist/src/view/viewFactory.test.d.ts +2 -0
  238. package/dist/src/view/viewFactory.test.d.ts.map +1 -0
  239. package/dist/src/view/viewFactory.test.js +2 -2
  240. package/dist/src/view/zoom.js +2 -2
  241. package/package.json +5 -2
@@ -1,6 +1,7 @@
1
- import { expect, test } from "vitest";
1
+ import { describe, expect, test } from "vitest";
2
2
  import Collector from "../collector.js";
3
3
  import SequenceSource from "./sequenceSource.js";
4
+ import { makeParamMediatorProvider } from "../flowTestUtils.js";
4
5
 
5
6
  /**
6
7
  * @param {SequenceSource} source
@@ -14,51 +15,67 @@ async function collectSource(source) {
14
15
  return [...collector.getData()];
15
16
  }
16
17
 
17
- const viewStub = {
18
- paramMediator: {
19
- registerParam: () => {},
20
- allocateSetter: () => {},
21
- createExpression: () => {},
22
- },
23
- };
18
+ describe("SequenceSource", () => {
19
+ /** @type {import("../../view/view.js").default} */
20
+ const viewStub = /** @type {any} */ (makeParamMediatorProvider());
24
21
 
25
- test("SequenceSource generates a sequence", async () => {
26
- expect(
27
- await collectSource(
28
- new SequenceSource({ sequence: { start: 0, stop: 3 } }, viewStub)
29
- )
30
- ).toEqual([{ data: 0 }, { data: 1 }, { data: 2 }]);
31
- });
22
+ test("generates a sequence", () =>
23
+ expect(
24
+ collectSource(
25
+ new SequenceSource(
26
+ { sequence: { start: 0, stop: 3 } },
27
+ viewStub
28
+ )
29
+ )
30
+ ).resolves.toEqual([{ data: 0 }, { data: 1 }, { data: 2 }]));
32
31
 
33
- test("SequenceSource generates a sequence with a custom step", async () => {
34
- expect(
35
- await collectSource(
36
- new SequenceSource(
37
- { sequence: { start: 0, stop: 5, step: 2 } },
38
- viewStub
32
+ test("generates a sequence with a custom step", () =>
33
+ expect(
34
+ collectSource(
35
+ new SequenceSource(
36
+ { sequence: { start: 0, stop: 5, step: 2 } },
37
+ viewStub
38
+ )
39
39
  )
40
- )
41
- ).toEqual([{ data: 0 }, { data: 2 }, { data: 4 }]);
42
- });
40
+ ).resolves.toEqual([{ data: 0 }, { data: 2 }, { data: 4 }]));
43
41
 
44
- test("SequenceSource generates a sequence with a custom field name", async () => {
45
- expect(
46
- await collectSource(
47
- new SequenceSource(
48
- { sequence: { start: 0, stop: 3, as: "x" } },
49
- viewStub
42
+ test("generates a sequence with a custom field name", () =>
43
+ expect(
44
+ collectSource(
45
+ new SequenceSource(
46
+ { sequence: { start: 0, stop: 3, as: "x" } },
47
+ viewStub
48
+ )
50
49
  )
51
- )
52
- ).toEqual([{ x: 0 }, { x: 1 }, { x: 2 }]);
53
- });
50
+ ).resolves.toEqual([{ x: 0 }, { x: 1 }, { x: 2 }]));
54
51
 
55
- test("SequenceSource throws on missing 'start' parameter", () => {
56
- expect(
57
- () => new SequenceSource({ sequence: { stop: 3 } }, viewStub)
58
- ).toThrow();
59
- });
60
- test("SequenceSource throws on missing 'stop' parameter", () => {
61
- expect(
62
- () => new SequenceSource({ sequence: { start: 0 } }, viewStub)
63
- ).toThrow();
52
+ test("accepts ExprRef parameters", async () =>
53
+ expect(
54
+ collectSource(
55
+ new SequenceSource(
56
+ {
57
+ sequence: {
58
+ start: { expr: "0" },
59
+ stop: { expr: "1 + 2" },
60
+ step: { expr: "1" },
61
+ as: "x",
62
+ },
63
+ },
64
+ viewStub
65
+ )
66
+ )
67
+ // TODO: Test that the sequence is regenerated when the parameters change
68
+ ).resolves.toEqual([{ x: 0 }, { x: 1 }, { x: 2 }]));
69
+
70
+ test("throws on missing 'start' parameter", () =>
71
+ expect(
72
+ // @ts-expect-error
73
+ () => new SequenceSource({ sequence: { stop: 3 } }, viewStub)
74
+ ).toThrow());
75
+
76
+ test("throws on missing 'stop' parameter", () =>
77
+ expect(
78
+ // @ts-expect-error
79
+ () => new SequenceSource({ sequence: { start: 0 } }, viewStub)
80
+ ).toThrow());
64
81
  });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=clone.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/clone.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type CoverageParams = import("../../spec/transform.js").CoverageParams;
2
+ //# sourceMappingURL=coverage.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/coverage.test.js"],"names":[],"mappings":"6BAKa,OAAO,yBAAyB,EAAE,cAAc"}
@@ -48,7 +48,7 @@ function testSimpleCoverage(reads, coverageSegments) {
48
48
  /**
49
49
  *
50
50
  * @param {[number, number, number][]} reads Start, end, weight
51
- * @param {[number, number, number][]} coverageSemgments Start, end, coverage
51
+ * @param {[number, number, number][]} coverageSegments Start, end, coverage
52
52
  */
53
53
  function testWeightedCoverage(reads, coverageSegments) {
54
54
  /** @type {CoverageParams} */
@@ -1,3 +1,13 @@
1
+ /**
2
+ * @param {import("../../spec/transform.js").FilterParams} params
3
+ * @returns {params is import("../../spec/transform.js").ExprFilterParams}
4
+ */
5
+ export function isExprFilterParams(params: import("../../spec/transform.js").FilterParams): params is import("../../spec/transform.js").ExprFilterParams;
6
+ /**
7
+ * @param {import("../../spec/transform.js").FilterParams} params
8
+ * @returns {params is import("../../spec/transform.js").SelectionFilterParams}
9
+ */
10
+ export function isSelectionFilterParams(params: import("../../spec/transform.js").FilterParams): params is import("../../spec/transform.js").SelectionFilterParams;
1
11
  export default class FilterTransform extends FlowNode {
2
12
  /**
3
13
  *
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/filter.js"],"names":[],"mappings":"AAEA;IACI;;;;OAIG;IACH,oBAHW,OAAO,yBAAyB,EAAE,YAAY,yBAC9C,OAAO,gBAAgB,EAAE,qBAAqB,EASxD;IAJG,uDAAoB;IAEpB,oEAAoE;IACpE,WADW,OAAO,6BAA6B,EAAE,eAAe,CACtC;CAiBjC;qBA/BoB,gBAAgB"}
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/filter.js"],"names":[],"mappings":"AA8CA;;;GAGG;AACH,2CAHW,OAAO,yBAAyB,EAAE,YAAY,gEAKxD;AAED;;;GAGG;AACH,gDAHW,OAAO,yBAAyB,EAAE,YAAY,qEAKxD;AAzDD;IACI;;;;OAIG;IACH,oBAHW,OAAO,yBAAyB,EAAE,YAAY,yBAC9C,OAAO,gBAAgB,EAAE,qBAAqB,EASxD;IAJG,uDAAoB;IAEpB,oEAAoE;IACpE,WADW,OAAO,6BAA6B,EAAE,eAAe,CACtC;CA6BjC;qBA3CoB,gBAAgB"}
@@ -1,3 +1,4 @@
1
+ import { makeSelectionTestExpression } from "../../selection/selection.js";
1
2
  import FlowNode from "../flowNode.js";
2
3
 
3
4
  export default class FilterTransform extends FlowNode {
@@ -16,7 +17,19 @@ export default class FilterTransform extends FlowNode {
16
17
  }
17
18
 
18
19
  initialize() {
19
- this.predicate = this.paramMediator.createExpression(this.params.expr);
20
+ let expression = "";
21
+
22
+ if (isExprFilterParams(this.params)) {
23
+ expression = this.params.expr;
24
+ } else if (isSelectionFilterParams(this.params)) {
25
+ expression = makeSelectionTestExpression(this.params);
26
+ } else {
27
+ throw new Error(
28
+ "Invalid filter params: " + JSON.stringify(this.params)
29
+ );
30
+ }
31
+
32
+ this.predicate = this.paramMediator.createExpression(expression);
20
33
  this.predicate.addListener(() => this.repropagate());
21
34
  }
22
35
 
@@ -30,3 +43,19 @@ export default class FilterTransform extends FlowNode {
30
43
  }
31
44
  }
32
45
  }
46
+
47
+ /**
48
+ * @param {import("../../spec/transform.js").FilterParams} params
49
+ * @returns {params is import("../../spec/transform.js").ExprFilterParams}
50
+ */
51
+ export function isExprFilterParams(params) {
52
+ return "expr" in params;
53
+ }
54
+
55
+ /**
56
+ * @param {import("../../spec/transform.js").FilterParams} params
57
+ * @returns {params is import("../../spec/transform.js").SelectionFilterParams}
58
+ */
59
+ export function isSelectionFilterParams(params) {
60
+ return "param" in params;
61
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=filter.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/filter.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=flatten.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/flatten.test.js"],"names":[],"mappings":""}
@@ -3,7 +3,7 @@ import { processData } from "../flowTestUtils.js";
3
3
  import FlattenTransform from "./flatten.js";
4
4
 
5
5
  /**
6
- * @param {import("./flatten.js").FlattenParams} params
6
+ * @param {import("../../spec/transform.js").FlattenParams} params
7
7
  * @param {any[]} data
8
8
  */
9
9
  function transform(params, data) {
@@ -11,8 +11,11 @@ function transform(params, data) {
11
11
  }
12
12
 
13
13
  describe("Flatten transform", () => {
14
+ /**
15
+ * @typedef {import("../../spec/transform.js").FlattenParams} FlattenParams
16
+ */
14
17
  test("With a single field", () => {
15
- /** @type {import("./flattenDelimited.js").FlattenParams} */
18
+ /** @type {FlattenParams} */
16
19
  const params = { type: "flatten", fields: ["foo"] };
17
20
 
18
21
  const input = [
@@ -30,7 +33,7 @@ describe("Flatten transform", () => {
30
33
  });
31
34
 
32
35
  test("With an index field", () => {
33
- /** @type {import("./flattenDelimited.js").FlattenParams} */
36
+ /** @type {FlattenParams} */
34
37
  const params = { type: "flatten", fields: ["foo"], index: "idx" };
35
38
 
36
39
  const input = [
@@ -48,7 +51,7 @@ describe("Flatten transform", () => {
48
51
  });
49
52
 
50
53
  test("With multiple fields", () => {
51
- /** @type {import("./flattenDelimited.js").FlattenParams} */
54
+ /** @type {FlattenParams} */
52
55
  const params = { type: "flatten", fields: ["foo", "bar"] };
53
56
 
54
57
  const input = [
@@ -66,18 +69,18 @@ describe("Flatten transform", () => {
66
69
  });
67
70
 
68
71
  test("Throws on mismatching spec lengths", () => {
69
- /** @type {import("./flattenDelimited.js").FlattenParams} */
72
+ /** @type {FlattenParams} */
70
73
  const params = {
71
74
  type: "flatten",
72
75
  fields: ["a", "b"],
73
76
  as: ["a"],
74
77
  };
75
78
 
76
- expect(() => transform(params, sampleData)).toThrow();
79
+ expect(() => transform(params, [])).toThrow();
77
80
  });
78
81
 
79
82
  test("Missing fields property treats the input object as an array", () => {
80
- /** @type {import("./flattenDelimited.js").FlattenParams} */
83
+ /** @type {FlattenParams} */
81
84
  const params = {
82
85
  type: "flatten",
83
86
  };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=flattenDelimited.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flattenDelimited.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/flattenDelimited.test.js"],"names":[],"mappings":""}
@@ -9,7 +9,7 @@ const sampleData = [
9
9
  ];
10
10
 
11
11
  /**
12
- * @param {import("./flattenDelimited.js").FlattenDelimitedParams} params
12
+ * @param {import("../../spec/transform.js").FlattenDelimitedParams} params
13
13
  * @param {any[]} data
14
14
  */
15
15
  function transform(params, data) {
@@ -17,15 +17,18 @@ function transform(params, data) {
17
17
  }
18
18
 
19
19
  describe("FlattenDelimited transform", () => {
20
+ /**
21
+ * @typedef {import("../../spec/transform.js").FlattenDelimitedParams} FlattenDelimitedParams
22
+ */
20
23
  test("With a single field", () => {
21
- /** @type {import("./flattenDelimited.js").FlattenDelimitedParams} */
22
- const config = {
24
+ /** @type {FlattenDelimitedParams} */
25
+ const params = {
23
26
  type: "flattenDelimited",
24
27
  field: "a",
25
28
  separator: ", ",
26
29
  };
27
30
 
28
- expect(transform(config, sampleData)).toEqual([
31
+ expect(transform(params, sampleData)).toEqual([
29
32
  { id: 1, a: "q", b: "a-s-d" },
30
33
  { id: 1, a: "w", b: "a-s-d" },
31
34
  { id: 1, a: "e", b: "a-s-d" },
@@ -37,15 +40,15 @@ describe("FlattenDelimited transform", () => {
37
40
  });
38
41
 
39
42
  test("With two fields", () => {
40
- /** @type {import("./flattenDelimited.js").FlattenDelimitedParams} */
41
- const config = {
43
+ /** @type {FlattenDelimitedParams} */
44
+ const params = {
42
45
  type: "flattenDelimited",
43
46
  field: ["a", "b"],
44
47
  as: ["a", "c"],
45
48
  separator: [", ", "-"],
46
49
  };
47
50
 
48
- expect(transform(config, sampleData)).toEqual([
51
+ expect(transform(params, sampleData)).toEqual([
49
52
  { id: 1, a: "q", b: "a-s-d", c: "a" },
50
53
  { id: 1, a: "w", b: "a-s-d", c: "s" },
51
54
  { id: 1, a: "e", b: "a-s-d", c: "d" },
@@ -64,24 +67,24 @@ describe("FlattenDelimited transform", () => {
64
67
  },
65
68
  ];
66
69
 
67
- /** @type {import("./flattenDelimited.js").FlattenDelimitedParams} */
68
- const config = {
70
+ /** @type {FlattenDelimitedParams} */
71
+ const params = {
69
72
  type: "flattenDelimited",
70
73
  field: ["a", "b"],
71
74
  separator: ["-", "-"],
72
75
  };
73
76
 
74
- expect(() => transform(config, data)).toThrow();
77
+ expect(() => transform(params, data)).toThrow();
75
78
  });
76
79
 
77
80
  test("Throws on mismatching spec lengths", () => {
78
- /** @type {import("./flattenDelimited.js").FlattenDelimitedParams} */
79
- const config = {
81
+ /** @type {FlattenDelimitedParams} */
82
+ const params = {
80
83
  type: "flattenDelimited",
81
84
  field: ["a", "b"],
82
85
  separator: ["a"],
83
86
  };
84
87
 
85
- expect(() => transform(config, sampleData)).toThrow();
88
+ expect(() => transform(params, sampleData)).toThrow();
86
89
  });
87
90
  });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=flattenSequence.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flattenSequence.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/flattenSequence.test.js"],"names":[],"mappings":""}
@@ -3,7 +3,7 @@ import { processData } from "../flowTestUtils.js";
3
3
  import FlattenSequenceTransform from "./flattenSequence.js";
4
4
 
5
5
  /**
6
- * @param {import("./flattenSequence.js").FlattenSequenceParams} params
6
+ * @param {import("../../spec/transform.js").FlattenSequenceParams} params
7
7
  * @param {any[]} data
8
8
  */
9
9
  function transform(params, data) {
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=formula.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/formula.test.js"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { expect, test, test } from "vitest";
1
+ import { expect, test } from "vitest";
2
2
  import { makeParamMediatorProvider, processData } from "../flowTestUtils.js";
3
3
  import FormulaTransform from "./formula.js";
4
4
 
@@ -1,4 +1,4 @@
1
- export const DEFAULT_AS: "_uniqueId";
1
+ export const UNIQUE_ID_KEY: "_uniqueId";
2
2
  export const BLOCK_SIZE: 10000;
3
3
  /**
4
4
  * Assigns unique identifiers for tuples that pass through this transform.
@@ -1 +1 @@
1
- {"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/identifier.js"],"names":[],"mappings":"AAEA,qCAAsC;AAEtC,+BAAgC;AAehC;;;;;;;GAOG;AACH;IAKI;;;OAGG;IACH,oBAFW,OAAO,yBAAyB,EAAE,gBAAgB,EAuB5D;IAnBG,2DAAoB;IAEpB,WAAiC;IAEjC;;;OAGG;IACH,SAFU,MAAM,EAAE,CAED;IAEjB;;OAEG;IACH,oBAAoB;IAEpB;;OAEG;IACH,YAAa;IAuBjB;;OAEG;IACH,WAFa,MAAM,CAOlB;IAED,oBAMC;IAED,wBAOC;CACJ;qBAzG2C,gBAAgB"}
1
+ {"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/identifier.js"],"names":[],"mappings":"AAEA,wCAAyC;AAEzC,+BAAgC;AAehC;;;;;;;GAOG;AACH;IAKI;;;OAGG;IACH,oBAFW,OAAO,yBAAyB,EAAE,gBAAgB,EAuB5D;IAnBG,2DAAoB;IAEpB,WAAoC;IAEpC;;;OAGG;IACH,SAFU,MAAM,EAAE,CAED;IAEjB;;OAEG;IACH,oBAAoB;IAEpB;;OAEG;IACH,YAAa;IAuBjB;;OAEG;IACH,WAFa,MAAM,CAOlB;IAED,oBAMC;IAED,wBAOC;CACJ;qBAzG2C,gBAAgB"}
@@ -1,6 +1,6 @@
1
1
  import FlowNode, { BEHAVIOR_MODIFIES } from "../flowNode.js";
2
2
 
3
- export const DEFAULT_AS = "_uniqueId";
3
+ export const UNIQUE_ID_KEY = "_uniqueId";
4
4
 
5
5
  export const BLOCK_SIZE = 10000;
6
6
 
@@ -38,7 +38,7 @@ export default class IdentifierTransform extends FlowNode {
38
38
  super();
39
39
  this.params = params;
40
40
 
41
- this.as = params.as ?? DEFAULT_AS;
41
+ this.as = params.as ?? UNIQUE_ID_KEY;
42
42
 
43
43
  /**
44
44
  * The block indexes reserved by this transform instance.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=identifier.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identifier.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/identifier.test.js"],"names":[],"mappings":""}
@@ -1,7 +1,10 @@
1
1
  import { expect, test } from "vitest";
2
2
  import { range } from "d3-array";
3
3
  import { processData } from "../flowTestUtils.js";
4
- import IdentifierTransform, { BLOCK_SIZE, DEFAULT_AS } from "./identifier.js";
4
+ import IdentifierTransform, {
5
+ BLOCK_SIZE,
6
+ UNIQUE_ID_KEY,
7
+ } from "./identifier.js";
5
8
 
6
9
  test("An IdentifierTransform adds identifiers correctly", () => {
7
10
  const data = range(BLOCK_SIZE * 2).map((x) => ({ data: x }));
@@ -14,15 +17,18 @@ test("An IdentifierTransform adds identifiers correctly", () => {
14
17
  // The fist block is skipped
15
18
  const firstId = BLOCK_SIZE;
16
19
 
17
- expect(identifiedData[0]).toEqual({ data: 0, [DEFAULT_AS]: firstId });
18
- expect(identifiedData[1]).toEqual({ data: 1, [DEFAULT_AS]: firstId + 1 });
20
+ expect(identifiedData[0]).toEqual({ data: 0, [UNIQUE_ID_KEY]: firstId });
21
+ expect(identifiedData[1]).toEqual({
22
+ data: 1,
23
+ [UNIQUE_ID_KEY]: firstId + 1,
24
+ });
19
25
  expect(identifiedData[BLOCK_SIZE]).toEqual({
20
26
  data: BLOCK_SIZE,
21
- [DEFAULT_AS]: firstId + BLOCK_SIZE,
27
+ [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE,
22
28
  });
23
29
  expect(identifiedData[BLOCK_SIZE + 1]).toEqual({
24
30
  data: BLOCK_SIZE + 1,
25
- [DEFAULT_AS]: firstId + BLOCK_SIZE + 1,
31
+ [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE + 1,
26
32
  });
27
33
  });
28
34
 
@@ -37,15 +43,18 @@ test("Another transform instance adds identifiers correctly", () => {
37
43
  // The fist block was skipped and the previous test case consumed two blocks
38
44
  const firstId = BLOCK_SIZE * 3;
39
45
 
40
- expect(identifiedData[0]).toEqual({ data: 0, [DEFAULT_AS]: firstId });
41
- expect(identifiedData[1]).toEqual({ data: 1, [DEFAULT_AS]: firstId + 1 });
46
+ expect(identifiedData[0]).toEqual({ data: 0, [UNIQUE_ID_KEY]: firstId });
47
+ expect(identifiedData[1]).toEqual({
48
+ data: 1,
49
+ [UNIQUE_ID_KEY]: firstId + 1,
50
+ });
42
51
  expect(identifiedData[BLOCK_SIZE]).toEqual({
43
52
  data: BLOCK_SIZE,
44
- [DEFAULT_AS]: firstId + BLOCK_SIZE,
53
+ [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE,
45
54
  });
46
55
  expect(identifiedData[BLOCK_SIZE + 1]).toEqual({
47
56
  data: BLOCK_SIZE + 1,
48
- [DEFAULT_AS]: firstId + BLOCK_SIZE + 1,
57
+ [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE + 1,
49
58
  });
50
59
  });
51
60
 
@@ -57,10 +66,10 @@ test("IdentifierTransform recycles allocated blocks", () => {
57
66
 
58
67
  let firstId = BLOCK_SIZE * 5;
59
68
 
60
- expect(identifiedData[0]).toEqual({ data: 0, [DEFAULT_AS]: firstId });
69
+ expect(identifiedData[0]).toEqual({ data: 0, [UNIQUE_ID_KEY]: firstId });
61
70
  expect(identifiedData[BLOCK_SIZE]).toEqual({
62
71
  data: BLOCK_SIZE,
63
- [DEFAULT_AS]: firstId + BLOCK_SIZE,
72
+ [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE,
64
73
  });
65
74
 
66
75
  data = range(BLOCK_SIZE * 3).map((x) => ({ data: x }));
@@ -69,15 +78,15 @@ test("IdentifierTransform recycles allocated blocks", () => {
69
78
  transform.reset();
70
79
  identifiedData = processData(transform, data);
71
80
 
72
- expect(identifiedData[0]).toEqual({ data: 0, [DEFAULT_AS]: firstId });
81
+ expect(identifiedData[0]).toEqual({ data: 0, [UNIQUE_ID_KEY]: firstId });
73
82
  expect(identifiedData[BLOCK_SIZE]).toEqual({
74
83
  data: BLOCK_SIZE,
75
- [DEFAULT_AS]: firstId + BLOCK_SIZE,
84
+ [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE,
76
85
  });
77
86
 
78
87
  // ... and reserve one extra
79
88
  expect(identifiedData[BLOCK_SIZE * 2]).toEqual({
80
89
  data: BLOCK_SIZE * 2,
81
- [DEFAULT_AS]: firstId + BLOCK_SIZE * 2,
90
+ [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE * 2,
82
91
  });
83
92
  });
@@ -0,0 +1,2 @@
1
+ export type PileupParams = import("../../spec/transform.js").PileupParams;
2
+ //# sourceMappingURL=pileup.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pileup.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/pileup.test.js"],"names":[],"mappings":"2BAOa,OAAO,yBAAyB,EAAE,YAAY"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=project.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/project.test.js"],"names":[],"mappings":""}
@@ -11,7 +11,7 @@ test("Project", () => {
11
11
  },
12
12
  ];
13
13
 
14
- /** @param {import("./project.js").ProjectParams} params */
14
+ /** @param {import("../../spec/transform.js").ProjectParams} params */
15
15
  const p = (params) => processData(new ProjectTransform(params), data);
16
16
 
17
17
  expect(p({ type: "project", fields: ["bar"] })).toEqual([{ bar: "BAR" }]);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=regexExtract.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regexExtract.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/regexExtract.test.js"],"names":[],"mappings":""}
@@ -4,7 +4,7 @@ import { processData } from "../flowTestUtils.js";
4
4
  import RegexExtractTransform from "./regexExtract.js";
5
5
 
6
6
  /**
7
- * @param {import("./regexExtract.js").RegexExtractParams} params
7
+ * @param {import("../../spec/transform.js").RegexExtractParams} params
8
8
  * @param {any[]} data
9
9
  */
10
10
  function transform(params, data) {
@@ -12,9 +12,12 @@ function transform(params, data) {
12
12
  }
13
13
 
14
14
  describe("RegexExtractTransform", () => {
15
+ /**
16
+ * @typedef {import("../../spec/transform.js").RegexExtractParams} RegexExtractParams
17
+ */
15
18
  const rows = [{ a: "12-34" }, { a: "23-45" }];
16
19
 
17
- /** @type {import("./regexExtract.js").RegexExtractParams} */
20
+ /** @type {RegexExtractParams} */
18
21
  const params = {
19
22
  type: "regexExtract",
20
23
  regex: "^(\\d+)-(\\d+)$",
@@ -30,7 +33,7 @@ describe("RegexExtractTransform", () => {
30
33
  });
31
34
 
32
35
  test("Invalid config", () => {
33
- /** @type {import("./regexExtract.js").RegexExtractParams} */
36
+ /** @type {RegexExtractParams} */
34
37
  const config2 = {
35
38
  type: "regexExtract",
36
39
  regex: "^(\\d+)-(\\d+)$",
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=regexFold.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regexFold.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/regexFold.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sample.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/sample.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=stack.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.test.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/stack.test.js"],"names":[],"mappings":""}