@genome-spy/core 0.48.2 → 0.50.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 (244) hide show
  1. package/dist/bundle/index.es.js +7434 -7107
  2. package/dist/bundle/index.js +116 -103
  3. package/dist/schema.json +3975 -2819
  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/gl/includes/common.glsl.js +1 -1
  93. package/dist/src/marks/link.common.glsl.js +1 -1
  94. package/dist/src/marks/link.d.ts +8 -1
  95. package/dist/src/marks/link.d.ts.map +1 -1
  96. package/dist/src/marks/link.fragment.glsl.js +1 -1
  97. package/dist/src/marks/link.js +47 -31
  98. package/dist/src/marks/link.vertex.glsl.js +1 -1
  99. package/dist/src/marks/mark.d.ts +24 -25
  100. package/dist/src/marks/mark.d.ts.map +1 -1
  101. package/dist/src/marks/mark.js +246 -118
  102. package/dist/src/marks/markUtils.d.ts +25 -0
  103. package/dist/src/marks/markUtils.d.ts.map +1 -1
  104. package/dist/src/marks/markUtils.js +41 -1
  105. package/dist/src/marks/point.common.glsl.js +1 -1
  106. package/dist/src/marks/point.d.ts +8 -1
  107. package/dist/src/marks/point.d.ts.map +1 -1
  108. package/dist/src/marks/point.js +34 -25
  109. package/dist/src/marks/point.vertex.glsl.js +1 -1
  110. package/dist/src/marks/rect.d.ts +8 -1
  111. package/dist/src/marks/rect.d.ts.map +1 -1
  112. package/dist/src/marks/rect.js +28 -23
  113. package/dist/src/marks/rule.d.ts +8 -1
  114. package/dist/src/marks/rule.d.ts.map +1 -1
  115. package/dist/src/marks/rule.js +23 -16
  116. package/dist/src/marks/text.d.ts +10 -1
  117. package/dist/src/marks/text.d.ts.map +1 -1
  118. package/dist/src/marks/text.fragment.glsl.js +1 -1
  119. package/dist/src/marks/text.js +53 -47
  120. package/dist/src/marks/text.vertex.glsl.js +1 -1
  121. package/dist/src/scale/scale.test.d.ts +2 -0
  122. package/dist/src/scale/scale.test.d.ts.map +1 -0
  123. package/dist/src/scale/scale.test.js +2 -0
  124. package/dist/src/scale/ticks.test.d.ts +2 -0
  125. package/dist/src/scale/ticks.test.d.ts.map +1 -0
  126. package/dist/src/scale/ticks.test.js +6 -0
  127. package/dist/src/selection/selection.d.ts +39 -0
  128. package/dist/src/selection/selection.d.ts.map +1 -0
  129. package/dist/src/selection/selection.js +78 -0
  130. package/dist/src/spec/channel.d.ts +150 -83
  131. package/dist/src/spec/mark.d.ts +133 -78
  132. package/dist/src/spec/parameter.d.ts +112 -3
  133. package/dist/src/spec/root.d.ts +0 -1
  134. package/dist/src/spec/transform.d.ts +19 -1
  135. package/dist/src/spec/view.d.ts +5 -10
  136. package/dist/src/tooltip/dataTooltipHandler.d.ts +1 -1
  137. package/dist/src/tooltip/dataTooltipHandler.d.ts.map +1 -1
  138. package/dist/src/tooltip/dataTooltipHandler.js +1 -1
  139. package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts +1 -1
  140. package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts.map +1 -1
  141. package/dist/src/types/encoder.d.ts +80 -26
  142. package/dist/src/types/rendering.d.ts +1 -0
  143. package/dist/src/types/selectionTypes.d.ts +44 -0
  144. package/dist/src/types/viewContext.d.ts +1 -4
  145. package/dist/src/utils/addBaseUrl.test.d.ts +2 -0
  146. package/dist/src/utils/addBaseUrl.test.d.ts.map +1 -0
  147. package/dist/src/utils/binnedIndex.test.d.ts +2 -0
  148. package/dist/src/utils/binnedIndex.test.d.ts.map +1 -0
  149. package/dist/src/utils/cloner.test.d.ts +2 -0
  150. package/dist/src/utils/cloner.test.d.ts.map +1 -0
  151. package/dist/src/utils/coalesce.test.d.ts +2 -0
  152. package/dist/src/utils/coalesce.test.d.ts.map +1 -0
  153. package/dist/src/utils/concatIterables.test.d.ts +2 -0
  154. package/dist/src/utils/concatIterables.test.d.ts.map +1 -0
  155. package/dist/src/utils/domainArray.test.d.ts +2 -0
  156. package/dist/src/utils/domainArray.test.d.ts.map +1 -0
  157. package/dist/src/utils/expression.d.ts +2 -2
  158. package/dist/src/utils/expression.d.ts.map +1 -1
  159. package/dist/src/utils/expression.js +11 -2
  160. package/dist/src/utils/indexer.test.d.ts +2 -0
  161. package/dist/src/utils/indexer.test.d.ts.map +1 -0
  162. package/dist/src/utils/inputBinding.d.ts.map +1 -1
  163. package/dist/src/utils/inputBinding.js +4 -0
  164. package/dist/src/utils/iterateNestedMaps.test.d.ts +2 -0
  165. package/dist/src/utils/iterateNestedMaps.test.d.ts.map +1 -0
  166. package/dist/src/utils/kWayMerge.test.d.ts +2 -0
  167. package/dist/src/utils/kWayMerge.test.d.ts.map +1 -0
  168. package/dist/src/utils/mergeObjects.test.d.ts +2 -0
  169. package/dist/src/utils/mergeObjects.test.d.ts.map +1 -0
  170. package/dist/src/utils/numberExtractor.test.d.ts +2 -0
  171. package/dist/src/utils/numberExtractor.test.d.ts.map +1 -0
  172. package/dist/src/utils/propertyCacher.test.d.ts +2 -0
  173. package/dist/src/utils/propertyCacher.test.d.ts.map +1 -0
  174. package/dist/src/utils/propertyCoalescer.test.d.ts +2 -0
  175. package/dist/src/utils/propertyCoalescer.test.d.ts.map +1 -0
  176. package/dist/src/utils/propertyCoalescer.test.js +3 -0
  177. package/dist/src/utils/radixSort.test.d.ts +2 -0
  178. package/dist/src/utils/radixSort.test.d.ts.map +1 -0
  179. package/dist/src/utils/reservationMap.test.d.ts +2 -0
  180. package/dist/src/utils/reservationMap.test.d.ts.map +1 -0
  181. package/dist/src/utils/ringBuffer.test.d.ts +2 -0
  182. package/dist/src/utils/ringBuffer.test.d.ts.map +1 -0
  183. package/dist/src/utils/topK.test.d.ts +2 -0
  184. package/dist/src/utils/topK.test.d.ts.map +1 -0
  185. package/dist/src/utils/trees.test.d.ts +2 -0
  186. package/dist/src/utils/trees.test.d.ts.map +1 -0
  187. package/dist/src/utils/trees.test.js +8 -3
  188. package/dist/src/utils/variableTools.test.d.ts +2 -0
  189. package/dist/src/utils/variableTools.test.d.ts.map +1 -0
  190. package/dist/src/view/axisResolution.d.ts +19 -6
  191. package/dist/src/view/axisResolution.d.ts.map +1 -1
  192. package/dist/src/view/axisResolution.js +16 -7
  193. package/dist/src/view/axisResolution.test.d.ts +2 -0
  194. package/dist/src/view/axisResolution.test.d.ts.map +1 -0
  195. package/dist/src/view/axisResolution.test.js +16 -11
  196. package/dist/src/view/axisView.js +2 -2
  197. package/dist/src/view/facetView.d.ts +1 -1
  198. package/dist/src/view/facetView.d.ts.map +1 -1
  199. package/dist/src/view/flowBuilder.d.ts +1 -1
  200. package/dist/src/view/flowBuilder.d.ts.map +1 -1
  201. package/dist/src/view/flowBuilder.js +34 -5
  202. package/dist/src/view/flowBuilder.test.d.ts +2 -0
  203. package/dist/src/view/flowBuilder.test.d.ts.map +1 -0
  204. package/dist/src/view/flowBuilder.test.js +1 -1
  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/gridView.js +1 -1
  208. package/dist/src/view/layerView.d.ts +0 -6
  209. package/dist/src/view/layerView.d.ts.map +1 -1
  210. package/dist/src/view/layout/flexLayout.test.d.ts +2 -0
  211. package/dist/src/view/layout/flexLayout.test.d.ts.map +1 -0
  212. package/dist/src/view/layout/grid.test.d.ts +2 -0
  213. package/dist/src/view/layout/grid.test.d.ts.map +1 -0
  214. package/dist/src/view/layout/rectangle.test.d.ts +2 -0
  215. package/dist/src/view/layout/rectangle.test.d.ts.map +1 -0
  216. package/dist/src/view/paramMediator.d.ts +39 -5
  217. package/dist/src/view/paramMediator.d.ts.map +1 -1
  218. package/dist/src/view/paramMediator.js +120 -9
  219. package/dist/src/view/paramMediator.test.d.ts +2 -0
  220. package/dist/src/view/paramMediator.test.d.ts.map +1 -0
  221. package/dist/src/view/paramMediator.test.js +37 -1
  222. package/dist/src/view/scaleResolution.d.ts +17 -15
  223. package/dist/src/view/scaleResolution.d.ts.map +1 -1
  224. package/dist/src/view/scaleResolution.js +70 -68
  225. package/dist/src/view/scaleResolution.test.d.ts +2 -0
  226. package/dist/src/view/scaleResolution.test.d.ts.map +1 -0
  227. package/dist/src/view/scaleResolution.test.js +2 -0
  228. package/dist/src/view/testUtils.d.ts.map +1 -1
  229. package/dist/src/view/testUtils.js +15 -3
  230. package/dist/src/view/unitView.d.ts +8 -20
  231. package/dist/src/view/unitView.d.ts.map +1 -1
  232. package/dist/src/view/unitView.js +100 -102
  233. package/dist/src/view/view.d.ts +1 -1
  234. package/dist/src/view/view.d.ts.map +1 -1
  235. package/dist/src/view/view.test.d.ts +2 -0
  236. package/dist/src/view/view.test.d.ts.map +1 -0
  237. package/dist/src/view/view.test.js +73 -55
  238. package/dist/src/view/viewFactory.test.d.ts +2 -0
  239. package/dist/src/view/viewFactory.test.d.ts.map +1 -0
  240. package/dist/src/view/viewFactory.test.js +2 -2
  241. package/dist/src/view/viewUtils.d.ts +1 -1
  242. package/dist/src/view/viewUtils.d.ts.map +1 -1
  243. package/dist/src/view/zoom.js +2 -2
  244. 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
  /**
@@ -142,8 +141,19 @@ export interface ScaleMixins {
142
141
  * An alternative channel for scale resolution.
143
142
  *
144
143
  * This is mainly for internal use and allows using `color` channel to resolve `fill` and `stroke` channels under certain circumstances.
144
+ *
145
+ * @internal
145
146
  */
146
147
  resolutionChannel?: ChannelWithScale;
148
+
149
+ /**
150
+ * Whether the field or evaluated expr should be included in the scale's domain.
151
+ *
152
+ * **Default value:** `true`
153
+ *
154
+ * @internal
155
+ */
156
+ contributesToScaleDomain?: boolean;
147
157
  }
148
158
 
149
159
  export interface ValueDefBase<V extends Value = Scalar> {
@@ -155,27 +165,31 @@ export interface ValueDefBase<V extends Value = Scalar> {
155
165
 
156
166
  export type ValueDef<V extends Value = Scalar> = ValueDefBase<V> & TitleMixins;
157
167
 
158
- export interface DatumDefBase {
168
+ export interface DatumDef<V extends Scalar | ExprRef = Scalar | ExprRef>
169
+ extends Partial<TypeMixins<Type>>,
170
+ BandMixins,
171
+ ScaleMixins,
172
+ TitleMixins {
159
173
  /**
160
174
  * A constant value in data domain.
161
175
  */
162
- datum?: Scalar | ExprRef;
176
+ datum?: V;
163
177
  }
164
178
 
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. */
179
+ export interface ExprDef<>extends Partial<TypeMixins<Type>>,
180
+ BandMixins,
181
+ TitleMixins {
182
+ /**
183
+ * An expression. Properties of the data can be accessed through the `datum` object.
184
+ */
169
185
  expr: string;
170
186
  }
171
187
 
172
188
  /**
173
189
  * Field definition of a mark property, which can contain a legend.
174
190
  */
175
- export type MarkPropFieldDef<
176
- F extends Field,
177
- T extends Type = Type
178
- > = ScaleFieldDef<F, T> & LegendMixins;
191
+ export type MarkPropFieldDef<T extends Type = Type> = ScaleFieldDef<T> &
192
+ LegendMixins;
179
193
 
180
194
  export type MarkPropExprDef<T extends Type = Type> = ExprDef &
181
195
  TypeMixins<T> &
@@ -186,11 +200,6 @@ export type MarkPropDatumDef<T extends Type> = LegendMixins &
186
200
  ScaleDatumDef &
187
201
  TypeMixins<T>;
188
202
 
189
- export type MarkPropFieldOrDatumOrExprDef<
190
- F extends Field,
191
- T extends Type = Type
192
- > = MarkPropFieldDef<F, T> | MarkPropDatumDef<T> | MarkPropExprDef;
193
-
194
203
  export interface LegendMixins {
195
204
  /**
196
205
  * An object defining properties of the legend.
@@ -203,15 +212,84 @@ export interface LegendMixins {
203
212
  // TODO: legend?: Legend<ExprRef | SignalRef> | null;
204
213
  }
205
214
 
206
- export type MarkPropDef<
207
- F extends Field,
208
- V extends Value,
209
- T extends Type = Type
210
- > = MarkPropFieldOrDatumOrExprDef<F, T> | ValueDef<V>;
215
+ export type ConditionalTemplate =
216
+ | FieldDef<any>
217
+ | DatumDef
218
+ | ValueDef<any>
219
+ | ExprRef;
211
220
 
212
- export type ColorDef<F extends Field> = MarkPropDef<F, string | null>;
221
+ export type Conditional<CD extends ConditionalTemplate> =
222
+ ConditionalParameter<CD>;
213
223
 
214
- export type SecondaryFieldDef<F extends Field> = FieldDefBase<F> & TitleMixins;
224
+ // Source of ParameterPredicate: https://github.com/vega/vega-lite/blob/main/src/predicate.ts
225
+ export interface ParameterPredicate {
226
+ /**
227
+ * Filter using a parameter name.
228
+ */
229
+ param: string;
230
+
231
+ /**
232
+ * For selection parameters, the predicate of empty selections returns true by default.
233
+ * Override this behavior, by setting this property `empty: false`.
234
+ */
235
+ empty?: boolean;
236
+ }
237
+
238
+ export type ConditionalParameter<CD extends ConditionalTemplate> =
239
+ ParameterPredicate & CD;
240
+
241
+ export interface ConditionValueDefMixins<V extends Value = Value> {
242
+ /**
243
+ * One or more value definition(s) with [a parameter or a test predicate](https://vega.github.io/vega-lite/docs/condition.html).
244
+ *
245
+ * __Note:__ A field definition's `condition` property can only contain [conditional value definitions](https://vega.github.io/vega-lite/docs/condition.html#value)
246
+ * since Vega-Lite only allows at most one encoded field per encoding channel.
247
+ */
248
+ condition?: Conditional<ValueDef<V>> | Conditional<ValueDef<V>>[];
249
+ }
250
+
251
+ /**
252
+ * A FieldDef with Condition<ValueDef>
253
+ * {
254
+ * condition: {value: ...},
255
+ * field: ...,
256
+ * ...
257
+ * }
258
+ */
259
+ export type FieldOrDatumDefWithCondition<
260
+ F extends FieldDef<any> | DatumDef<any> = FieldDef<any> | DatumDef<any>,
261
+ V extends Value = Value
262
+ > = F & ConditionValueDefMixins<V | ExprRef>;
263
+
264
+ /**
265
+ * @minProperties 1
266
+ */
267
+ export type ValueDefWithCondition<V extends Value = Value> = Partial<
268
+ ValueDef<V | ExprRef>
269
+ > & {
270
+ /**
271
+ * A field definition or one or more value definition(s) with a parameter predicate.
272
+ */
273
+ condition?:
274
+ | Conditional<FieldDef>
275
+ | Conditional<DatumDef>
276
+ | Conditional<ValueDef<V | ExprRef>>
277
+ | Conditional<ValueDef<V | ExprRef>>[];
278
+ };
279
+
280
+ export type MarkPropFieldOrDatumOrExprDef<T extends Type = Type> =
281
+ | MarkPropFieldDef<T>
282
+ | MarkPropDatumDef<T>
283
+ | MarkPropExprDef<T>;
284
+
285
+ export type MarkPropDef<V extends Value, T extends Type = Type> =
286
+ | FieldOrDatumDefWithCondition<MarkPropFieldDef<T>, V>
287
+ | FieldOrDatumDefWithCondition<DatumDef, V>
288
+ | ValueDefWithCondition<V>;
289
+
290
+ export type ColorDef = MarkPropDef<string | null>;
291
+
292
+ export type SecondaryFieldDef = FieldDefBase & TitleMixins;
215
293
 
216
294
  export type NumericValueDef = ValueDef<number>;
217
295
 
@@ -219,8 +297,7 @@ export type ScaleDatumDef = ScaleMixins & DatumDef;
219
297
 
220
298
  export type PositionDatumDefBase = ScaleDatumDef & TypeMixins<Type>;
221
299
 
222
- export type PositionFieldDef<F extends Field> = PositionFieldDefBase<F> &
223
- PositionMixins;
300
+ export type PositionFieldDef = PositionFieldDefBase & PositionMixins;
224
301
 
225
302
  export type PositionDatumDef = PositionDatumDefBase & PositionMixins;
226
303
 
@@ -243,7 +320,7 @@ export interface PositionMixins extends BandMixins {
243
320
  axis?: GenomeAxis | null;
244
321
  }
245
322
 
246
- export type PositionFieldDefBase<F extends Field> = ScaleFieldDef<F, Type>;
323
+ export type PositionFieldDefBase = ScaleFieldDef<Type>;
247
324
 
248
325
  export interface ChromPosDefBase extends BandMixins {
249
326
  /**
@@ -278,39 +355,29 @@ export type ChromPosDef = SecondaryChromPosDef &
278
355
  TypeMixins<"locus"> &
279
356
  ScaleMixins;
280
357
 
281
- export type PositionDef<F extends Field> =
282
- | PositionFieldDef<F>
358
+ export type PositionDef =
359
+ | PositionFieldDef
283
360
  | ChromPosDef
284
361
  | PositionDatumDef
285
362
  | PositionExprDef
286
363
  | PositionValueDef;
287
364
 
288
- export type Position2Def<F extends Field> =
289
- | (SecondaryFieldDef<F> & BandMixins)
365
+ export type Position2Def =
366
+ | (SecondaryFieldDef & BandMixins)
290
367
  | SecondaryChromPosDef
291
368
  | (DatumDef & BandMixins)
292
369
  | (ExprDef & BandMixins)
293
370
  | PositionValueDef;
294
371
 
295
- export type NumericMarkPropDef<F extends Field> = MarkPropDef<F, number>;
372
+ export type NumericMarkPropDef = MarkPropDef<number>;
296
373
 
297
- export type ShapeDef<F extends Field> = MarkPropDef<
298
- F,
299
- string | null,
300
- TypeForShape
301
- >;
374
+ export type ShapeDef = MarkPropDef<string | null, TypeForShape>;
302
375
 
303
- export interface StringFieldDef<F extends Field>
304
- extends FieldDefWithoutScale<F>,
305
- FormatMixins {}
376
+ export interface StringFieldDef extends FieldDefWithoutScale, FormatMixins {}
306
377
 
307
- export type TextDef<F extends Field> =
308
- | StringFieldDef<F>
309
- | StringDatumDef
310
- | ExprDef;
378
+ export type TextDef = StringFieldDef | StringDatumDef | ExprDef; // TODO: Conditions
311
379
 
312
- export type ChannelDef<F extends Field = string> =
313
- Encoding<F>[keyof Encoding<F>];
380
+ export type ChannelDef = Encoding[keyof Encoding];
314
381
 
315
382
  // TODO: Does this make sense?
316
383
  export type ChannelDefWithScale = ScaleMixins & TypeMixins<Type>;
@@ -328,37 +395,37 @@ export interface XIndexDef {
328
395
  buildIndex?: boolean;
329
396
  }
330
397
 
331
- export interface Encoding<F extends Field = string> {
398
+ export interface Encoding {
332
399
  /**
333
400
  * X coordinates of the marks.
334
401
  *
335
402
  * The `value` of this channel can be a number between zero and one.
336
403
  */
337
- x?: PositionDef<F> & XIndexDef;
404
+ x?: PositionDef & XIndexDef;
338
405
 
339
406
  /**
340
407
  * Y coordinates of the marks.
341
408
  *
342
409
  * The `value` of this channel can be a number between zero and one.
343
410
  */
344
- y?: PositionDef<F>;
411
+ y?: PositionDef;
345
412
 
346
413
  /**
347
414
  * X2 coordinates of the marks.
348
415
  *
349
416
  * The `value` of this channel can be a number between zero and one.
350
417
  */
351
- x2?: Position2Def<F>;
418
+ x2?: Position2Def;
352
419
 
353
420
  /**
354
421
  * Y2 coordinates of the marks.
355
422
  *
356
423
  * The `value` of this channel can be a number between zero and one.
357
424
  */
358
- y2?: Position2Def<F>;
425
+ y2?: Position2Def;
359
426
 
360
- dx?: NumericMarkPropDef<F>;
361
- dy?: NumericMarkPropDef<F>;
427
+ dx?: NumericMarkPropDef; // TODO: Not a mark property. Fix types.
428
+ dy?: NumericMarkPropDef;
362
429
 
363
430
  /**
364
431
  * Color of the marks – either fill or stroke color based on the `filled` property of mark definition.
@@ -367,14 +434,14 @@ export interface Encoding<F extends Field = string> {
367
434
  * 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
435
  * 2) See the scale documentation for more information about customizing [color scheme](https://vega.github.io/vega-lite/docs/scale.html#scheme).
369
436
  */
370
- color?: ColorDef<F>;
437
+ color?: ColorDef;
371
438
 
372
439
  /**
373
440
  * Fill color of the marks.
374
441
  *
375
442
  * _Note:_ The `fill` encoding has higher precedence than `color`, thus may override the `color` encoding if conflicting encodings are specified.
376
443
  */
377
- fill?: ColorDef<F>;
444
+ fill?: ColorDef;
378
445
 
379
446
  /**
380
447
  * Stroke color of the marks.
@@ -382,39 +449,39 @@ export interface Encoding<F extends Field = string> {
382
449
  * _Note:_ The `stroke` encoding has higher precedence than `color`, thus may override the `color` encoding if conflicting encodings are specified.
383
450
  */
384
451
 
385
- stroke?: ColorDef<F>;
452
+ stroke?: ColorDef;
386
453
 
387
454
  /**
388
455
  * Opacity of the marks.
389
456
  */
390
- opacity?: NumericMarkPropDef<F>;
457
+ opacity?: NumericMarkPropDef;
391
458
 
392
459
  /**
393
460
  * Fill opacity of the marks.
394
461
  */
395
- fillOpacity?: NumericMarkPropDef<F>;
462
+ fillOpacity?: NumericMarkPropDef;
396
463
 
397
464
  /**
398
465
  * Stroke opacity of the marks.
399
466
  */
400
- strokeOpacity?: NumericMarkPropDef<F>;
467
+ strokeOpacity?: NumericMarkPropDef;
401
468
 
402
469
  /**
403
470
  * Stroke width of the marks.
404
471
  */
405
- strokeWidth?: NumericMarkPropDef<F>;
472
+ strokeWidth?: NumericMarkPropDef;
406
473
 
407
474
  /**
408
475
  * Size of the mark.
409
476
  * - For `"point"` – the symbol size, or pixel area of the mark.
410
477
  * - For `"text"` – the text's font size.
411
478
  */
412
- size?: NumericMarkPropDef<F>;
479
+ size?: NumericMarkPropDef;
413
480
 
414
481
  /**
415
482
  * Rotation angle of point and text marks.
416
483
  */
417
- angle?: NumericMarkPropDef<F>;
484
+ angle?: NumericMarkPropDef;
418
485
 
419
486
  /**
420
487
  * Shape of the mark.
@@ -423,32 +490,32 @@ export interface Encoding<F extends Field = string> {
423
490
  * - plotting shapes: `"circle"`, `"square"`, `"cross"`, `"diamond"`, `"triangle-up"`, `"triangle-down"`, `"triangle-right"`, or `"triangle-left"`.
424
491
  * - centered directional shape `"triangle"`
425
492
  */
426
- shape?: ShapeDef<F>;
493
+ shape?: ShapeDef;
427
494
 
428
495
  /**
429
496
  * Text of the `text` mark.
430
497
  */
431
- text?: TextDef<F>;
498
+ text?: TextDef;
432
499
 
433
500
  /**
434
501
  * Facet identifier for interactive filtering, sorting, and grouping in the App.
435
502
  */
436
- sample?: FieldDefWithoutScale<F>;
503
+ sample?: FieldDefWithoutScale;
437
504
 
438
505
  /**
439
506
  * For internal use
440
507
  */
441
508
  // TODO: proper type
442
- uniqueId?: FieldDefWithoutScale<F>;
509
+ uniqueId?: FieldDefWithoutScale;
443
510
 
444
511
  // TODO: proper type
445
- search?: FieldDefWithoutScale<F>;
512
+ search?: FieldDefWithoutScale;
446
513
 
447
514
  /**
448
515
  * For internal use
449
516
  */
450
517
  // TODO: proper type
451
- facetIndex?: FieldDefWithoutScale<F>;
518
+ facetIndex?: FieldDefWithoutScale;
452
519
 
453
- semanticScore?: FieldDefWithoutScale<F>;
520
+ semanticScore?: FieldDefWithoutScale;
454
521
  }