@genome-spy/core 0.48.2 → 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 (221) hide show
  1. package/dist/bundle/index.es.js +7226 -6923
  2. package/dist/bundle/index.js +121 -108
  3. package/dist/schema.json +838 -344
  4. package/dist/src/data/collector.test.d.ts +2 -0
  5. package/dist/src/data/collector.test.d.ts.map +1 -0
  6. package/dist/src/data/dataFlow.test.d.ts +2 -0
  7. package/dist/src/data/dataFlow.test.d.ts.map +1 -0
  8. package/dist/src/data/flow.test.d.ts +2 -0
  9. package/dist/src/data/flow.test.d.ts.map +1 -0
  10. package/dist/src/data/flow.test.js +19 -14
  11. package/dist/src/data/flowNode.test.d.ts +2 -0
  12. package/dist/src/data/flowNode.test.d.ts.map +1 -0
  13. package/dist/src/data/flowOptimizer.test.d.ts +2 -0
  14. package/dist/src/data/flowOptimizer.test.d.ts.map +1 -0
  15. package/dist/src/data/flowOptimizer.test.js +9 -10
  16. package/dist/src/data/formats/fasta.test.d.ts +2 -0
  17. package/dist/src/data/formats/fasta.test.d.ts.map +1 -0
  18. package/dist/src/data/sources/inlineSource.test.d.ts +2 -0
  19. package/dist/src/data/sources/inlineSource.test.d.ts.map +1 -0
  20. package/dist/src/data/sources/inlineSource.test.js +23 -16
  21. package/dist/src/data/sources/sequenceSource.test.d.ts +2 -0
  22. package/dist/src/data/sources/sequenceSource.test.d.ts.map +1 -0
  23. package/dist/src/data/sources/sequenceSource.test.js +59 -42
  24. package/dist/src/data/transforms/clone.test.d.ts +2 -0
  25. package/dist/src/data/transforms/clone.test.d.ts.map +1 -0
  26. package/dist/src/data/transforms/coverage.test.d.ts +2 -0
  27. package/dist/src/data/transforms/coverage.test.d.ts.map +1 -0
  28. package/dist/src/data/transforms/coverage.test.js +1 -1
  29. package/dist/src/data/transforms/filter.d.ts +10 -0
  30. package/dist/src/data/transforms/filter.d.ts.map +1 -1
  31. package/dist/src/data/transforms/filter.js +30 -1
  32. package/dist/src/data/transforms/filter.test.d.ts +2 -0
  33. package/dist/src/data/transforms/filter.test.d.ts.map +1 -0
  34. package/dist/src/data/transforms/flatten.test.d.ts +2 -0
  35. package/dist/src/data/transforms/flatten.test.d.ts.map +1 -0
  36. package/dist/src/data/transforms/flatten.test.js +10 -7
  37. package/dist/src/data/transforms/flattenDelimited.test.d.ts +2 -0
  38. package/dist/src/data/transforms/flattenDelimited.test.d.ts.map +1 -0
  39. package/dist/src/data/transforms/flattenDelimited.test.js +16 -13
  40. package/dist/src/data/transforms/flattenSequence.test.d.ts +2 -0
  41. package/dist/src/data/transforms/flattenSequence.test.d.ts.map +1 -0
  42. package/dist/src/data/transforms/flattenSequence.test.js +1 -1
  43. package/dist/src/data/transforms/formula.test.d.ts +2 -0
  44. package/dist/src/data/transforms/formula.test.d.ts.map +1 -0
  45. package/dist/src/data/transforms/formula.test.js +1 -1
  46. package/dist/src/data/transforms/identifier.test.d.ts +2 -0
  47. package/dist/src/data/transforms/identifier.test.d.ts.map +1 -0
  48. package/dist/src/data/transforms/pileup.test.d.ts +2 -0
  49. package/dist/src/data/transforms/pileup.test.d.ts.map +1 -0
  50. package/dist/src/data/transforms/project.test.d.ts +2 -0
  51. package/dist/src/data/transforms/project.test.d.ts.map +1 -0
  52. package/dist/src/data/transforms/project.test.js +1 -1
  53. package/dist/src/data/transforms/regexExtract.test.d.ts +2 -0
  54. package/dist/src/data/transforms/regexExtract.test.d.ts.map +1 -0
  55. package/dist/src/data/transforms/regexExtract.test.js +6 -3
  56. package/dist/src/data/transforms/regexFold.test.d.ts +2 -0
  57. package/dist/src/data/transforms/regexFold.test.d.ts.map +1 -0
  58. package/dist/src/data/transforms/sample.test.d.ts +2 -0
  59. package/dist/src/data/transforms/sample.test.d.ts.map +1 -0
  60. package/dist/src/data/transforms/stack.test.d.ts +2 -0
  61. package/dist/src/data/transforms/stack.test.d.ts.map +1 -0
  62. package/dist/src/data/transforms/stack.test.js +8 -8
  63. package/dist/src/encoder/accessor.d.ts +17 -14
  64. package/dist/src/encoder/accessor.d.ts.map +1 -1
  65. package/dist/src/encoder/accessor.js +127 -56
  66. package/dist/src/encoder/accessor.test.d.ts +2 -0
  67. package/dist/src/encoder/accessor.test.d.ts.map +1 -0
  68. package/dist/src/encoder/accessor.test.js +145 -31
  69. package/dist/src/encoder/encoder.d.ts +26 -13
  70. package/dist/src/encoder/encoder.d.ts.map +1 -1
  71. package/dist/src/encoder/encoder.js +98 -114
  72. package/dist/src/encoder/encoder.test.d.ts +2 -0
  73. package/dist/src/encoder/encoder.test.d.ts.map +1 -0
  74. package/dist/src/encoder/encoder.test.js +85 -82
  75. package/dist/src/fonts/bmFontManager.d.ts.map +1 -1
  76. package/dist/src/fonts/bmFontManager.js +10 -4
  77. package/dist/src/genome/genome.test.d.ts +2 -0
  78. package/dist/src/genome/genome.test.d.ts.map +1 -0
  79. package/dist/src/genome/scaleIndex.test.d.ts +2 -0
  80. package/dist/src/genome/scaleIndex.test.d.ts.map +1 -0
  81. package/dist/src/genome/scaleLocus.test.d.ts +2 -0
  82. package/dist/src/genome/scaleLocus.test.d.ts.map +1 -0
  83. package/dist/src/genomeSpy.d.ts +3 -2
  84. package/dist/src/genomeSpy.d.ts.map +1 -1
  85. package/dist/src/genomeSpy.js +15 -6
  86. package/dist/src/gl/dataToVertices.d.ts +6 -8
  87. package/dist/src/gl/dataToVertices.d.ts.map +1 -1
  88. package/dist/src/gl/dataToVertices.js +42 -33
  89. package/dist/src/gl/glslScaleGenerator.d.ts +84 -15
  90. package/dist/src/gl/glslScaleGenerator.d.ts.map +1 -1
  91. package/dist/src/gl/glslScaleGenerator.js +260 -73
  92. package/dist/src/marks/link.common.glsl.js +1 -1
  93. package/dist/src/marks/link.d.ts.map +1 -1
  94. package/dist/src/marks/link.js +10 -0
  95. package/dist/src/marks/link.vertex.glsl.js +1 -1
  96. package/dist/src/marks/mark.d.ts +6 -9
  97. package/dist/src/marks/mark.d.ts.map +1 -1
  98. package/dist/src/marks/mark.js +212 -95
  99. package/dist/src/marks/point.d.ts.map +1 -1
  100. package/dist/src/marks/point.js +5 -1
  101. package/dist/src/marks/rect.d.ts.map +1 -1
  102. package/dist/src/marks/rect.js +9 -4
  103. package/dist/src/marks/rule.d.ts.map +1 -1
  104. package/dist/src/marks/rule.js +4 -0
  105. package/dist/src/marks/text.d.ts.map +1 -1
  106. package/dist/src/marks/text.js +5 -1
  107. package/dist/src/scale/scale.test.d.ts +2 -0
  108. package/dist/src/scale/scale.test.d.ts.map +1 -0
  109. package/dist/src/scale/scale.test.js +2 -0
  110. package/dist/src/scale/ticks.test.d.ts +2 -0
  111. package/dist/src/scale/ticks.test.d.ts.map +1 -0
  112. package/dist/src/scale/ticks.test.js +6 -0
  113. package/dist/src/selection/selection.d.ts +39 -0
  114. package/dist/src/selection/selection.d.ts.map +1 -0
  115. package/dist/src/selection/selection.js +78 -0
  116. package/dist/src/spec/channel.d.ts +137 -83
  117. package/dist/src/spec/mark.d.ts +9 -0
  118. package/dist/src/spec/parameter.d.ts +112 -3
  119. package/dist/src/spec/root.d.ts +0 -1
  120. package/dist/src/spec/transform.d.ts +19 -1
  121. package/dist/src/spec/view.d.ts +3 -3
  122. package/dist/src/tooltip/dataTooltipHandler.js +1 -1
  123. package/dist/src/types/encoder.d.ts +80 -26
  124. package/dist/src/types/rendering.d.ts +1 -0
  125. package/dist/src/types/selectionTypes.d.ts +44 -0
  126. package/dist/src/types/viewContext.d.ts +1 -4
  127. package/dist/src/utils/addBaseUrl.test.d.ts +2 -0
  128. package/dist/src/utils/addBaseUrl.test.d.ts.map +1 -0
  129. package/dist/src/utils/binnedIndex.test.d.ts +2 -0
  130. package/dist/src/utils/binnedIndex.test.d.ts.map +1 -0
  131. package/dist/src/utils/cloner.test.d.ts +2 -0
  132. package/dist/src/utils/cloner.test.d.ts.map +1 -0
  133. package/dist/src/utils/coalesce.test.d.ts +2 -0
  134. package/dist/src/utils/coalesce.test.d.ts.map +1 -0
  135. package/dist/src/utils/concatIterables.test.d.ts +2 -0
  136. package/dist/src/utils/concatIterables.test.d.ts.map +1 -0
  137. package/dist/src/utils/domainArray.test.d.ts +2 -0
  138. package/dist/src/utils/domainArray.test.d.ts.map +1 -0
  139. package/dist/src/utils/expression.d.ts +2 -2
  140. package/dist/src/utils/expression.d.ts.map +1 -1
  141. package/dist/src/utils/expression.js +11 -2
  142. package/dist/src/utils/indexer.test.d.ts +2 -0
  143. package/dist/src/utils/indexer.test.d.ts.map +1 -0
  144. package/dist/src/utils/inputBinding.d.ts.map +1 -1
  145. package/dist/src/utils/inputBinding.js +4 -0
  146. package/dist/src/utils/iterateNestedMaps.test.d.ts +2 -0
  147. package/dist/src/utils/iterateNestedMaps.test.d.ts.map +1 -0
  148. package/dist/src/utils/kWayMerge.test.d.ts +2 -0
  149. package/dist/src/utils/kWayMerge.test.d.ts.map +1 -0
  150. package/dist/src/utils/mergeObjects.test.d.ts +2 -0
  151. package/dist/src/utils/mergeObjects.test.d.ts.map +1 -0
  152. package/dist/src/utils/numberExtractor.test.d.ts +2 -0
  153. package/dist/src/utils/numberExtractor.test.d.ts.map +1 -0
  154. package/dist/src/utils/propertyCacher.test.d.ts +2 -0
  155. package/dist/src/utils/propertyCacher.test.d.ts.map +1 -0
  156. package/dist/src/utils/propertyCoalescer.test.d.ts +2 -0
  157. package/dist/src/utils/propertyCoalescer.test.d.ts.map +1 -0
  158. package/dist/src/utils/propertyCoalescer.test.js +3 -0
  159. package/dist/src/utils/radixSort.test.d.ts +2 -0
  160. package/dist/src/utils/radixSort.test.d.ts.map +1 -0
  161. package/dist/src/utils/reservationMap.test.d.ts +2 -0
  162. package/dist/src/utils/reservationMap.test.d.ts.map +1 -0
  163. package/dist/src/utils/ringBuffer.test.d.ts +2 -0
  164. package/dist/src/utils/ringBuffer.test.d.ts.map +1 -0
  165. package/dist/src/utils/topK.test.d.ts +2 -0
  166. package/dist/src/utils/topK.test.d.ts.map +1 -0
  167. package/dist/src/utils/trees.test.d.ts +2 -0
  168. package/dist/src/utils/trees.test.d.ts.map +1 -0
  169. package/dist/src/utils/trees.test.js +8 -3
  170. package/dist/src/utils/variableTools.test.d.ts +2 -0
  171. package/dist/src/utils/variableTools.test.d.ts.map +1 -0
  172. package/dist/src/view/axisResolution.d.ts +19 -6
  173. package/dist/src/view/axisResolution.d.ts.map +1 -1
  174. package/dist/src/view/axisResolution.js +16 -7
  175. package/dist/src/view/axisResolution.test.d.ts +2 -0
  176. package/dist/src/view/axisResolution.test.d.ts.map +1 -0
  177. package/dist/src/view/axisResolution.test.js +16 -11
  178. package/dist/src/view/facetView.d.ts +1 -1
  179. package/dist/src/view/facetView.d.ts.map +1 -1
  180. package/dist/src/view/flowBuilder.d.ts +1 -1
  181. package/dist/src/view/flowBuilder.d.ts.map +1 -1
  182. package/dist/src/view/flowBuilder.js +34 -5
  183. package/dist/src/view/flowBuilder.test.d.ts +2 -0
  184. package/dist/src/view/flowBuilder.test.d.ts.map +1 -0
  185. package/dist/src/view/gridView.d.ts +0 -6
  186. package/dist/src/view/gridView.d.ts.map +1 -1
  187. package/dist/src/view/layerView.d.ts +0 -6
  188. package/dist/src/view/layerView.d.ts.map +1 -1
  189. package/dist/src/view/layout/flexLayout.test.d.ts +2 -0
  190. package/dist/src/view/layout/flexLayout.test.d.ts.map +1 -0
  191. package/dist/src/view/layout/grid.test.d.ts +2 -0
  192. package/dist/src/view/layout/grid.test.d.ts.map +1 -0
  193. package/dist/src/view/layout/rectangle.test.d.ts +2 -0
  194. package/dist/src/view/layout/rectangle.test.d.ts.map +1 -0
  195. package/dist/src/view/paramMediator.d.ts +32 -5
  196. package/dist/src/view/paramMediator.d.ts.map +1 -1
  197. package/dist/src/view/paramMediator.js +97 -9
  198. package/dist/src/view/paramMediator.test.d.ts +2 -0
  199. package/dist/src/view/paramMediator.test.d.ts.map +1 -0
  200. package/dist/src/view/paramMediator.test.js +17 -1
  201. package/dist/src/view/scaleResolution.d.ts +17 -9
  202. package/dist/src/view/scaleResolution.d.ts.map +1 -1
  203. package/dist/src/view/scaleResolution.js +51 -34
  204. package/dist/src/view/scaleResolution.test.d.ts +2 -0
  205. package/dist/src/view/scaleResolution.test.d.ts.map +1 -0
  206. package/dist/src/view/scaleResolution.test.js +2 -0
  207. package/dist/src/view/testUtils.d.ts.map +1 -1
  208. package/dist/src/view/testUtils.js +15 -3
  209. package/dist/src/view/unitView.d.ts +5 -15
  210. package/dist/src/view/unitView.d.ts.map +1 -1
  211. package/dist/src/view/unitView.js +81 -101
  212. package/dist/src/view/view.d.ts +1 -1
  213. package/dist/src/view/view.d.ts.map +1 -1
  214. package/dist/src/view/view.test.d.ts +2 -0
  215. package/dist/src/view/view.test.d.ts.map +1 -0
  216. package/dist/src/view/view.test.js +73 -55
  217. package/dist/src/view/viewFactory.test.d.ts +2 -0
  218. package/dist/src/view/viewFactory.test.d.ts.map +1 -0
  219. package/dist/src/view/viewFactory.test.js +2 -2
  220. package/dist/src/view/zoom.js +2 -2
  221. package/package.json +5 -2
@@ -0,0 +1,78 @@
1
+ import { UNIQUE_ID_KEY } from "../data/transforms/identifier.js";
2
+ import { validateParameterName } from "../view/paramMediator.js";
3
+
4
+ /**
5
+ * @param {import("../data/flowNode.js").Datum} datum
6
+ * @returns {import("../types/selectionTypes.js").SinglePointSelection}
7
+ */
8
+ export function createSinglePointSelection(datum) {
9
+ return {
10
+ type: "single",
11
+ datum,
12
+ uniqueId: datum?.[UNIQUE_ID_KEY],
13
+ };
14
+ }
15
+
16
+ /**
17
+ * @param {import("../types/selectionTypes.js").Selection} selection
18
+ * @param {import("../data/flowNode.js").Datum} datum
19
+ * @param {boolean} [empty] evaluate to true if the selection is empty
20
+ */
21
+ export function selectionTest(selection, datum, empty = true) {
22
+ if (!selection || !datum) {
23
+ return false;
24
+ }
25
+
26
+ if (isSinglePointSelection(selection)) {
27
+ return selection.uniqueId == null
28
+ ? empty
29
+ : selection.uniqueId === datum[UNIQUE_ID_KEY];
30
+ } else if (isMultiPointSelection(selection)) {
31
+ return selection.uniqueIds.size == 0
32
+ ? empty
33
+ : selection.uniqueIds.has(datum[UNIQUE_ID_KEY]);
34
+ } else {
35
+ throw new Error("Not a selection: " + JSON.stringify(selection));
36
+ }
37
+ }
38
+
39
+ /**
40
+ * @param {{param: string, empty?: boolean}} params
41
+ */
42
+ export function makeSelectionTestExpression(params) {
43
+ return `selectionTest(${validateParameterName(params.param)}, datum, ${!!(
44
+ params.empty ?? true
45
+ )})`;
46
+ }
47
+
48
+ /**
49
+ * @param {import("../types/selectionTypes.js").Selection} selection
50
+ * @returns {selection is import("../types/selectionTypes.js").RangeSelection}
51
+ */
52
+ export function isRangeSelection(selection) {
53
+ return selection.type === "range";
54
+ }
55
+
56
+ /**
57
+ * @param {import("../types/selectionTypes.js").Selection} selection
58
+ * @returns {selection is import("../types/selectionTypes.js").SinglePointSelection}
59
+ */
60
+ export function isSinglePointSelection(selection) {
61
+ return selection.type === "single";
62
+ }
63
+
64
+ /**
65
+ * @param {import("../types/selectionTypes.js").Selection} selection
66
+ * @returns {selection is import("../types/selectionTypes.js").MultiPointSelection}
67
+ */
68
+ export function isMultiPointSelection(selection) {
69
+ return selection.type === "multi";
70
+ }
71
+
72
+ /**
73
+ * @param {import("../types/selectionTypes.js").Selection} selection
74
+ * @returns {selection is import("../types/selectionTypes.js").ProjectedSelection}
75
+ */
76
+ export function isProjectedSelection(selection) {
77
+ return selection.type === "projected";
78
+ }
@@ -12,6 +12,7 @@ import { ExprRef } from "./parameter.js";
12
12
  import { Scale } from "./scale.js";
13
13
  import { GenomeAxis } from "./axis.js";
14
14
 
15
+ // TODO: Rename Scalar to PrimitiveValue
15
16
  export type Scalar = string | number | boolean;
16
17
  export type Value = Scalar | ExprRef | null;
17
18
 
@@ -39,8 +40,7 @@ export type ChannelWithScale =
39
40
  | "shape"
40
41
  | "angle"
41
42
  | "dx"
42
- | "dy"
43
- | "sample"; // Needed for collecting sample ids (domain) from multiple views
43
+ | "dy";
44
44
 
45
45
  export type ChannelWithoutScale =
46
46
  | "uniqueId"
@@ -48,7 +48,8 @@ export type ChannelWithoutScale =
48
48
  | "text"
49
49
  | "facetIndex"
50
50
  | "semanticScore"
51
- | "uniqueId";
51
+ | "uniqueId"
52
+ | "sample"; // Needed for collecting sample ids (domain) from multiple views
52
53
 
53
54
  export type Channel = ChannelWithScale | ChannelWithoutScale;
54
55
 
@@ -96,7 +97,7 @@ export interface TypeMixins<T extends Type> {
96
97
  type: T;
97
98
  }
98
99
 
99
- export interface FieldDefBase<F> {
100
+ export interface FieldDefBase {
100
101
  /**
101
102
  * __Required.__ A string defining the name of the field from which to pull a data value
102
103
  * or an object defining iterated values from the [`repeat`](https://vega.github.io/vega-lite/docs/repeat.html) operator.
@@ -109,22 +110,20 @@ export interface FieldDefBase<F> {
109
110
  * See more details about escaping in the [field documentation](https://vega.github.io/vega-lite/docs/field.html).
110
111
  * 2) `field` is not required if `aggregate` is `count`.
111
112
  */
112
- field?: F;
113
+ field?: string;
113
114
  }
114
115
 
115
- export type TypedFieldDef<
116
- F extends Field,
117
- T extends Type = any
118
- > = FieldDefBase<F> & TitleMixins & TypeMixins<T>;
116
+ export type FieldDef<T extends Type = Type> =
117
+ | SecondaryFieldDef
118
+ | TypedFieldDef<T>;
119
119
 
120
- export type ScaleFieldDef<F extends Field, T extends Type> = TypedFieldDef<
121
- F,
122
- T
123
- > &
124
- ScaleMixins;
120
+ export type TypedFieldDef<T extends Type = Type> = FieldDefBase &
121
+ TitleMixins &
122
+ TypeMixins<T>;
125
123
 
126
- export type FieldDefWithoutScale<F extends Field> = FieldDefBase<F> &
127
- TitleMixins;
124
+ export type ScaleFieldDef<T extends Type> = TypedFieldDef<T> & ScaleMixins;
125
+
126
+ export type FieldDefWithoutScale = FieldDefBase & TitleMixins;
128
127
 
129
128
  export interface ScaleMixins {
130
129
  /**
@@ -155,27 +154,30 @@ export interface ValueDefBase<V extends Value = Scalar> {
155
154
 
156
155
  export type ValueDef<V extends Value = Scalar> = ValueDefBase<V> & TitleMixins;
157
156
 
158
- export interface DatumDefBase {
157
+ export interface DatumDef<V extends Scalar | ExprRef = Scalar | ExprRef>
158
+ extends Partial<TypeMixins<Type>>,
159
+ BandMixins,
160
+ TitleMixins {
159
161
  /**
160
162
  * A constant value in data domain.
161
163
  */
162
- datum?: Scalar | ExprRef;
164
+ datum?: V;
163
165
  }
164
166
 
165
- export type DatumDef = DatumDefBase & TitleMixins;
166
-
167
- export interface ExprDef {
168
- /** An expression. Properties of the data can be accessed through the `datum` object. */
167
+ export interface ExprDef<>extends Partial<TypeMixins<Type>>,
168
+ BandMixins,
169
+ TitleMixins {
170
+ /**
171
+ * An expression. Properties of the data can be accessed through the `datum` object.
172
+ */
169
173
  expr: string;
170
174
  }
171
175
 
172
176
  /**
173
177
  * Field definition of a mark property, which can contain a legend.
174
178
  */
175
- export type MarkPropFieldDef<
176
- F extends Field,
177
- T extends Type = Type
178
- > = ScaleFieldDef<F, T> & LegendMixins;
179
+ export type MarkPropFieldDef<T extends Type = Type> = ScaleFieldDef<T> &
180
+ LegendMixins;
179
181
 
180
182
  export type MarkPropExprDef<T extends Type = Type> = ExprDef &
181
183
  TypeMixins<T> &
@@ -186,11 +188,6 @@ export type MarkPropDatumDef<T extends Type> = LegendMixins &
186
188
  ScaleDatumDef &
187
189
  TypeMixins<T>;
188
190
 
189
- export type MarkPropFieldOrDatumOrExprDef<
190
- F extends Field,
191
- T extends Type = Type
192
- > = MarkPropFieldDef<F, T> | MarkPropDatumDef<T> | MarkPropExprDef;
193
-
194
191
  export interface LegendMixins {
195
192
  /**
196
193
  * An object defining properties of the legend.
@@ -203,15 +200,83 @@ export interface LegendMixins {
203
200
  // TODO: legend?: Legend<ExprRef | SignalRef> | null;
204
201
  }
205
202
 
206
- export type MarkPropDef<
207
- F extends Field,
208
- V extends Value,
209
- T extends Type = Type
210
- > = MarkPropFieldOrDatumOrExprDef<F, T> | ValueDef<V>;
203
+ export type ConditionalTemplate =
204
+ | FieldDef<any>
205
+ | DatumDef
206
+ | ValueDef<any>
207
+ | ExprRef;
208
+
209
+ export type Conditional<CD extends ConditionalTemplate> =
210
+ ConditionalParameter<CD>;
211
211
 
212
- export type ColorDef<F extends Field> = MarkPropDef<F, string | null>;
212
+ // Source of ParameterPredicate: https://github.com/vega/vega-lite/blob/main/src/predicate.ts
213
+ export interface ParameterPredicate {
214
+ /**
215
+ * Filter using a parameter name.
216
+ */
217
+ param: string;
218
+
219
+ /**
220
+ * For selection parameters, the predicate of empty selections returns true by default.
221
+ * Override this behavior, by setting this property `empty: false`.
222
+ */
223
+ empty?: boolean;
224
+ }
213
225
 
214
- export type SecondaryFieldDef<F extends Field> = FieldDefBase<F> & TitleMixins;
226
+ export type ConditionalParameter<CD extends ConditionalTemplate> =
227
+ ParameterPredicate & CD;
228
+
229
+ export interface ConditionValueDefMixins<V extends Value = Value> {
230
+ /**
231
+ * One or more value definition(s) with [a parameter or a test predicate](https://vega.github.io/vega-lite/docs/condition.html).
232
+ *
233
+ * __Note:__ A field definition's `condition` property can only contain [conditional value definitions](https://vega.github.io/vega-lite/docs/condition.html#value)
234
+ * since Vega-Lite only allows at most one encoded field per encoding channel.
235
+ */
236
+ condition?: Conditional<ValueDef<V>> | Conditional<ValueDef<V>>[];
237
+ }
238
+
239
+ /**
240
+ * A FieldDef with Condition<ValueDef>
241
+ * {
242
+ * condition: {value: ...},
243
+ * field: ...,
244
+ * ...
245
+ * }
246
+ */
247
+ export type FieldOrDatumDefWithCondition<
248
+ F extends FieldDef<any> | DatumDef<any> = FieldDef<any> | DatumDef<any>,
249
+ V extends Value = Value
250
+ > = F & ConditionValueDefMixins<V | ExprRef>;
251
+
252
+ /**
253
+ * @minProperties 1
254
+ */
255
+ export type ValueDefWithCondition<V extends Value = Value> = Partial<
256
+ ValueDef<V | ExprRef>
257
+ > & {
258
+ /**
259
+ * A field definition or one or more value definition(s) with a parameter predicate.
260
+ */
261
+ condition?:
262
+ | Conditional<FieldDef>
263
+ | Conditional<DatumDef>
264
+ | Conditional<ValueDef<V | ExprRef>>;
265
+ };
266
+
267
+ export type MarkPropFieldOrDatumOrExprDef<T extends Type = Type> =
268
+ | MarkPropFieldDef<T>
269
+ | MarkPropDatumDef<T>
270
+ | MarkPropExprDef<T>;
271
+
272
+ export type MarkPropDef<V extends Value, T extends Type = Type> =
273
+ | FieldOrDatumDefWithCondition<MarkPropFieldDef<T>, V>
274
+ | FieldOrDatumDefWithCondition<DatumDef, V>
275
+ | ValueDefWithCondition<V>;
276
+
277
+ export type ColorDef = MarkPropDef<string | null>;
278
+
279
+ export type SecondaryFieldDef = FieldDefBase & TitleMixins;
215
280
 
216
281
  export type NumericValueDef = ValueDef<number>;
217
282
 
@@ -219,8 +284,7 @@ export type ScaleDatumDef = ScaleMixins & DatumDef;
219
284
 
220
285
  export type PositionDatumDefBase = ScaleDatumDef & TypeMixins<Type>;
221
286
 
222
- export type PositionFieldDef<F extends Field> = PositionFieldDefBase<F> &
223
- PositionMixins;
287
+ export type PositionFieldDef = PositionFieldDefBase & PositionMixins;
224
288
 
225
289
  export type PositionDatumDef = PositionDatumDefBase & PositionMixins;
226
290
 
@@ -243,7 +307,7 @@ export interface PositionMixins extends BandMixins {
243
307
  axis?: GenomeAxis | null;
244
308
  }
245
309
 
246
- export type PositionFieldDefBase<F extends Field> = ScaleFieldDef<F, Type>;
310
+ export type PositionFieldDefBase = ScaleFieldDef<Type>;
247
311
 
248
312
  export interface ChromPosDefBase extends BandMixins {
249
313
  /**
@@ -278,39 +342,29 @@ export type ChromPosDef = SecondaryChromPosDef &
278
342
  TypeMixins<"locus"> &
279
343
  ScaleMixins;
280
344
 
281
- export type PositionDef<F extends Field> =
282
- | PositionFieldDef<F>
345
+ export type PositionDef =
346
+ | PositionFieldDef
283
347
  | ChromPosDef
284
348
  | PositionDatumDef
285
349
  | PositionExprDef
286
350
  | PositionValueDef;
287
351
 
288
- export type Position2Def<F extends Field> =
289
- | (SecondaryFieldDef<F> & BandMixins)
352
+ export type Position2Def =
353
+ | (SecondaryFieldDef & BandMixins)
290
354
  | SecondaryChromPosDef
291
355
  | (DatumDef & BandMixins)
292
356
  | (ExprDef & BandMixins)
293
357
  | PositionValueDef;
294
358
 
295
- export type NumericMarkPropDef<F extends Field> = MarkPropDef<F, number>;
359
+ export type NumericMarkPropDef = MarkPropDef<number>;
296
360
 
297
- export type ShapeDef<F extends Field> = MarkPropDef<
298
- F,
299
- string | null,
300
- TypeForShape
301
- >;
361
+ export type ShapeDef = MarkPropDef<string | null, TypeForShape>;
302
362
 
303
- export interface StringFieldDef<F extends Field>
304
- extends FieldDefWithoutScale<F>,
305
- FormatMixins {}
363
+ export interface StringFieldDef extends FieldDefWithoutScale, FormatMixins {}
306
364
 
307
- export type TextDef<F extends Field> =
308
- | StringFieldDef<F>
309
- | StringDatumDef
310
- | ExprDef;
365
+ export type TextDef = StringFieldDef | StringDatumDef | ExprDef; // TODO: Conditions
311
366
 
312
- export type ChannelDef<F extends Field = string> =
313
- Encoding<F>[keyof Encoding<F>];
367
+ export type ChannelDef = Encoding[keyof Encoding];
314
368
 
315
369
  // TODO: Does this make sense?
316
370
  export type ChannelDefWithScale = ScaleMixins & TypeMixins<Type>;
@@ -328,37 +382,37 @@ export interface XIndexDef {
328
382
  buildIndex?: boolean;
329
383
  }
330
384
 
331
- export interface Encoding<F extends Field = string> {
385
+ export interface Encoding {
332
386
  /**
333
387
  * X coordinates of the marks.
334
388
  *
335
389
  * The `value` of this channel can be a number between zero and one.
336
390
  */
337
- x?: PositionDef<F> & XIndexDef;
391
+ x?: PositionDef & XIndexDef;
338
392
 
339
393
  /**
340
394
  * Y coordinates of the marks.
341
395
  *
342
396
  * The `value` of this channel can be a number between zero and one.
343
397
  */
344
- y?: PositionDef<F>;
398
+ y?: PositionDef;
345
399
 
346
400
  /**
347
401
  * X2 coordinates of the marks.
348
402
  *
349
403
  * The `value` of this channel can be a number between zero and one.
350
404
  */
351
- x2?: Position2Def<F>;
405
+ x2?: Position2Def;
352
406
 
353
407
  /**
354
408
  * Y2 coordinates of the marks.
355
409
  *
356
410
  * The `value` of this channel can be a number between zero and one.
357
411
  */
358
- y2?: Position2Def<F>;
412
+ y2?: Position2Def;
359
413
 
360
- dx?: NumericMarkPropDef<F>;
361
- dy?: NumericMarkPropDef<F>;
414
+ dx?: NumericMarkPropDef; // TODO: Not a mark property. Fix types.
415
+ dy?: NumericMarkPropDef;
362
416
 
363
417
  /**
364
418
  * Color of the marks – either fill or stroke color based on the `filled` property of mark definition.
@@ -367,14 +421,14 @@ export interface Encoding<F extends Field = string> {
367
421
  * 1) For fine-grained control over both fill and stroke colors of the marks, please use the `fill` and `stroke` channels. The `fill` or `stroke` encodings have higher precedence than `color`, thus may override the `color` encoding if conflicting encodings are specified.
368
422
  * 2) See the scale documentation for more information about customizing [color scheme](https://vega.github.io/vega-lite/docs/scale.html#scheme).
369
423
  */
370
- color?: ColorDef<F>;
424
+ color?: ColorDef;
371
425
 
372
426
  /**
373
427
  * Fill color of the marks.
374
428
  *
375
429
  * _Note:_ The `fill` encoding has higher precedence than `color`, thus may override the `color` encoding if conflicting encodings are specified.
376
430
  */
377
- fill?: ColorDef<F>;
431
+ fill?: ColorDef;
378
432
 
379
433
  /**
380
434
  * Stroke color of the marks.
@@ -382,39 +436,39 @@ export interface Encoding<F extends Field = string> {
382
436
  * _Note:_ The `stroke` encoding has higher precedence than `color`, thus may override the `color` encoding if conflicting encodings are specified.
383
437
  */
384
438
 
385
- stroke?: ColorDef<F>;
439
+ stroke?: ColorDef;
386
440
 
387
441
  /**
388
442
  * Opacity of the marks.
389
443
  */
390
- opacity?: NumericMarkPropDef<F>;
444
+ opacity?: NumericMarkPropDef;
391
445
 
392
446
  /**
393
447
  * Fill opacity of the marks.
394
448
  */
395
- fillOpacity?: NumericMarkPropDef<F>;
449
+ fillOpacity?: NumericMarkPropDef;
396
450
 
397
451
  /**
398
452
  * Stroke opacity of the marks.
399
453
  */
400
- strokeOpacity?: NumericMarkPropDef<F>;
454
+ strokeOpacity?: NumericMarkPropDef;
401
455
 
402
456
  /**
403
457
  * Stroke width of the marks.
404
458
  */
405
- strokeWidth?: NumericMarkPropDef<F>;
459
+ strokeWidth?: NumericMarkPropDef;
406
460
 
407
461
  /**
408
462
  * Size of the mark.
409
463
  * - For `"point"` – the symbol size, or pixel area of the mark.
410
464
  * - For `"text"` – the text's font size.
411
465
  */
412
- size?: NumericMarkPropDef<F>;
466
+ size?: NumericMarkPropDef;
413
467
 
414
468
  /**
415
469
  * Rotation angle of point and text marks.
416
470
  */
417
- angle?: NumericMarkPropDef<F>;
471
+ angle?: NumericMarkPropDef;
418
472
 
419
473
  /**
420
474
  * Shape of the mark.
@@ -423,32 +477,32 @@ export interface Encoding<F extends Field = string> {
423
477
  * - plotting shapes: `"circle"`, `"square"`, `"cross"`, `"diamond"`, `"triangle-up"`, `"triangle-down"`, `"triangle-right"`, or `"triangle-left"`.
424
478
  * - centered directional shape `"triangle"`
425
479
  */
426
- shape?: ShapeDef<F>;
480
+ shape?: ShapeDef;
427
481
 
428
482
  /**
429
483
  * Text of the `text` mark.
430
484
  */
431
- text?: TextDef<F>;
485
+ text?: TextDef;
432
486
 
433
487
  /**
434
488
  * Facet identifier for interactive filtering, sorting, and grouping in the App.
435
489
  */
436
- sample?: FieldDefWithoutScale<F>;
490
+ sample?: FieldDefWithoutScale;
437
491
 
438
492
  /**
439
493
  * For internal use
440
494
  */
441
495
  // TODO: proper type
442
- uniqueId?: FieldDefWithoutScale<F>;
496
+ uniqueId?: FieldDefWithoutScale;
443
497
 
444
498
  // TODO: proper type
445
- search?: FieldDefWithoutScale<F>;
499
+ search?: FieldDefWithoutScale;
446
500
 
447
501
  /**
448
502
  * For internal use
449
503
  */
450
504
  // TODO: proper type
451
- facetIndex?: FieldDefWithoutScale<F>;
505
+ facetIndex?: FieldDefWithoutScale;
452
506
 
453
- semanticScore?: FieldDefWithoutScale<F>;
507
+ semanticScore?: FieldDefWithoutScale;
454
508
  }
@@ -386,6 +386,15 @@ export interface LinkProps extends SecondaryPositionProps {
386
386
  */
387
387
  arcFadingDistance?: [number, number] | false | ExprRef;
388
388
 
389
+ /**
390
+ * Disables fading of the link when an mark instance is subject to any point selection.
391
+ * As the fading distance is unavailable as a visual channel, this property allows for
392
+ * enhancing the visibility of the selected links.
393
+ *
394
+ * **Default value:** `true`
395
+ */
396
+ noFadingOnPointSelection?: boolean | ExprRef;
397
+
389
398
  /**
390
399
  * The minimum stroke width of the links when pointing with the mouse cursor.
391
400
  * Allows making very thin links easier to point at.
@@ -1,3 +1,5 @@
1
+ import { ChannelWithScale, Scalar } from "./channel.js";
2
+
1
3
  export interface ExprRef {
2
4
  /**
3
5
  * The expression string.
@@ -5,9 +7,7 @@ export interface ExprRef {
5
7
  expr: string;
6
8
  }
7
9
 
8
- // Adapted from: https://github.com/vega/vega-lite/blob/main/src/parameter.ts
9
-
10
- export interface VariableParameter {
10
+ export interface ParameterBase {
11
11
  /**
12
12
  * A unique name for the variable parameter. Parameter names should be valid
13
13
  * JavaScript identifiers: they should contain only alphanumeric characters
@@ -16,6 +16,12 @@ export interface VariableParameter {
16
16
  */
17
17
  name: string;
18
18
 
19
+ push?: "outer";
20
+ }
21
+
22
+ // Adapted from: https://github.com/vega/vega-lite/blob/main/src/parameter.ts
23
+
24
+ export interface VariableParameter extends ParameterBase {
19
25
  /**
20
26
  * The [initial value](http://vega.github.io/vega-lite/docs/value.html) of the parameter.
21
27
  *
@@ -144,3 +150,106 @@ export interface BindDirect {
144
150
  }
145
151
 
146
152
  export type Binding = BindCheckbox | BindRadioSelect | BindRange | BindInput;
153
+
154
+ // ----------------------------------------------------------------------------
155
+ // Adapted from: https://github.com/vega/vega-lite/blob/main/src/selection.ts
156
+
157
+ type Vector2<T> = [T, T];
158
+
159
+ export type SelectionType = "point" | "interval";
160
+ export type SelectionInit = Scalar;
161
+ export type SelectionInitInterval =
162
+ | Vector2<boolean>
163
+ | Vector2<number>
164
+ | Vector2<string>;
165
+
166
+ export type InteractionEventType = "click" | "dblclick" | "mouseover";
167
+
168
+ export interface BaseSelectionConfig<T extends SelectionType = SelectionType> {
169
+ /**
170
+ * Determines the default event processing and data query for the selection. Vega-Lite currently supports two selection types:
171
+ *
172
+ * - `"point"` -- to select multiple discrete data values; the first value is selected on `click` and additional values toggled on shift-click.
173
+ * - `"interval"` -- to select a continuous range of data values on `drag`.
174
+ */
175
+ type: T;
176
+
177
+ /**
178
+ */
179
+ on?: "click" | "mouseover" | "pointerover";
180
+
181
+ /**
182
+ * An array of encoding channels. The corresponding data field values
183
+ * must match for a data tuple to fall within the selection.
184
+ *
185
+ * __See also:__ The [projection with `encodings` and `fields` section](https://vega.github.io/vega-lite/docs/selection.html#project) in the documentation.
186
+ */
187
+ encodings?: ChannelWithScale[];
188
+
189
+ /**
190
+ * An array of field names whose values must match for a data tuple to
191
+ * fall within the selection.
192
+ *
193
+ * __See also:__ The [projection with `encodings` and `fields` section](https://vega.github.io/vega-lite/docs/selection.html#project) in the documentation.
194
+ */
195
+ fields?: string[];
196
+ }
197
+
198
+ export interface PointSelectionConfig extends BaseSelectionConfig<"point"> {
199
+ /**
200
+ * Controls whether data values should be toggled (inserted or removed from a point selection)
201
+ * when clicking with the shift key pressed.
202
+ *
203
+ * - `true` -- additional values can be selected by shift-clicking.
204
+ * - `false` -- only a single value can be selected at a time.
205
+ *
206
+ * __Default value:__ `true`
207
+ */
208
+ // TODO TODO TODO TODO TODO TODO TODO TODO
209
+ //toggle?: boolean;
210
+ /**
211
+ * A set of fields that uniquely identify a tuple. Used for bookmarking point selections
212
+ * in the GenomeSpy App. Still work in progress.
213
+ *
214
+ * TODO: Or maybe use the `key` channel? https://vega.github.io/vega-lite/docs/encoding.html#key
215
+ */
216
+ //keyFields?: string[];
217
+ }
218
+
219
+ export interface IntervalSelectionConfig
220
+ extends BaseSelectionConfig<"interval"> {
221
+ // TODO
222
+ }
223
+
224
+ export interface SelectionParameter<T extends SelectionType = SelectionType>
225
+ extends ParameterBase {
226
+ /**
227
+ * Determines the default event processing and data query for the selection. Vega-Lite currently supports two selection types:
228
+ *
229
+ * - `"point"` -- to select multiple discrete data values; the first value is selected on `click` and additional values toggled on shift-click.
230
+ * - `"interval"` -- to select a continuous range of data values on `drag`.
231
+ */
232
+ select:
233
+ | T
234
+ | (T extends "point"
235
+ ? PointSelectionConfig
236
+ : T extends "interval"
237
+ ? IntervalSelectionConfig
238
+ : never);
239
+
240
+ /*
241
+ * Initialize the selection with a mapping between [projected channels or field names](https://vega.github.io/vega-lite/docs/selection.html#project) and initial values.
242
+ *
243
+ * __See also:__ [`init`](https://vega.github.io/vega-lite/docs/value.html) documentation.
244
+ */
245
+ /*
246
+ // TODO TODO TODO TODO TODO TODO TODO TODO
247
+ value?: T extends "point"
248
+ ? SelectionInit | SelectionInitMapping[]
249
+ : T extends "interval"
250
+ ? SelectionInitIntervalMapping
251
+ : never;
252
+ */
253
+ }
254
+
255
+ export type Parameter = VariableParameter | SelectionParameter;
@@ -1,5 +1,4 @@
1
1
  import { GenomeConfig } from "./genome.js";
2
- import { VariableParameter } from "./parameter.js";
3
2
  import { ViewSpec } from "./view.js";
4
3
 
5
4
  interface RootConfig {