@genome-spy/core 0.65.0 → 0.66.1

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 (232) hide show
  1. package/dist/bundle/browser-BRemItdO.js +138 -0
  2. package/dist/bundle/{index-CD7FLu9x.js → index-BatuyGAI.js} +23 -21
  3. package/dist/bundle/{index-C0llXMqm.js → index-ByuE8dvu.js} +140 -88
  4. package/dist/bundle/index-Cq3QFUxX.js +1781 -0
  5. package/dist/bundle/index-D28m8tSW.js +1607 -0
  6. package/dist/bundle/index-DbJ0oeYM.js +631 -0
  7. package/dist/bundle/index.es.js +17587 -16593
  8. package/dist/bundle/index.js +214 -212
  9. package/dist/bundle/{inflate-DRgHi_KK.js → inflate-GtwLkvSP.js} +222 -224
  10. package/dist/bundle/unzip-NywezaRR.js +1492 -0
  11. package/dist/schema.json +13 -3
  12. package/dist/src/config/scaleDefaults.d.ts +8 -0
  13. package/dist/src/config/scaleDefaults.d.ts.map +1 -0
  14. package/dist/src/config/scaleDefaults.js +45 -0
  15. package/dist/src/data/flowInit.js +2 -2
  16. package/dist/src/data/sources/lazy/axisTickSource.js +1 -1
  17. package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts +1 -1
  18. package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts.map +1 -1
  19. package/dist/src/data/sources/lazy/singleAxisLazySource.js +10 -3
  20. package/dist/src/data/sources/lazy/singleAxisWindowedSource.d.ts.map +1 -1
  21. package/dist/src/data/sources/lazy/singleAxisWindowedSource.js +5 -1
  22. package/dist/src/data/transforms/filterScoredLabels.d.ts +1 -1
  23. package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -1
  24. package/dist/src/data/transforms/filterScoredLabels.js +1 -1
  25. package/dist/src/data/transforms/linearizeGenomicCoordinate.d.ts.map +1 -1
  26. package/dist/src/data/transforms/linearizeGenomicCoordinate.js +2 -1
  27. package/dist/src/encoder/encoder.d.ts +1 -1
  28. package/dist/src/encoder/encoder.d.ts.map +1 -1
  29. package/dist/src/encoder/encoder.js +1 -1
  30. package/dist/src/genome/scaleLocus.d.ts +39 -0
  31. package/dist/src/genome/scaleLocus.d.ts.map +1 -1
  32. package/dist/src/genome/scaleLocus.js +76 -0
  33. package/dist/src/genomeSpy/canvasExport.d.ts +19 -0
  34. package/dist/src/genomeSpy/canvasExport.d.ts.map +1 -0
  35. package/dist/src/genomeSpy/canvasExport.js +66 -0
  36. package/dist/src/genomeSpy/containerUi.d.ts +17 -0
  37. package/dist/src/genomeSpy/containerUi.d.ts.map +1 -0
  38. package/dist/src/genomeSpy/containerUi.js +78 -0
  39. package/dist/src/genomeSpy/eventListenerRegistry.d.ts +19 -0
  40. package/dist/src/genomeSpy/eventListenerRegistry.d.ts.map +1 -0
  41. package/dist/src/genomeSpy/eventListenerRegistry.js +38 -0
  42. package/dist/src/genomeSpy/inputBindingManager.d.ts +14 -0
  43. package/dist/src/genomeSpy/inputBindingManager.d.ts.map +1 -0
  44. package/dist/src/genomeSpy/inputBindingManager.js +63 -0
  45. package/dist/src/genomeSpy/interactionController.d.ts +40 -0
  46. package/dist/src/genomeSpy/interactionController.d.ts.map +1 -0
  47. package/dist/src/genomeSpy/interactionController.js +371 -0
  48. package/dist/src/genomeSpy/keyboardListenerManager.d.ts +10 -0
  49. package/dist/src/genomeSpy/keyboardListenerManager.d.ts.map +1 -0
  50. package/dist/src/genomeSpy/keyboardListenerManager.js +31 -0
  51. package/dist/src/genomeSpy/loadingIndicatorManager.d.ts +15 -0
  52. package/dist/src/genomeSpy/loadingIndicatorManager.d.ts.map +1 -0
  53. package/dist/src/genomeSpy/loadingIndicatorManager.js +92 -0
  54. package/dist/src/genomeSpy/renderCoordinator.d.ts +22 -0
  55. package/dist/src/genomeSpy/renderCoordinator.d.ts.map +1 -0
  56. package/dist/src/genomeSpy/renderCoordinator.js +118 -0
  57. package/dist/src/genomeSpy/viewContextFactory.d.ts +18 -0
  58. package/dist/src/genomeSpy/viewContextFactory.d.ts.map +1 -0
  59. package/dist/src/genomeSpy/viewContextFactory.js +79 -0
  60. package/dist/src/genomeSpy/viewDataInit.d.ts +12 -0
  61. package/dist/src/genomeSpy/viewDataInit.d.ts.map +1 -0
  62. package/dist/src/genomeSpy/viewDataInit.js +41 -0
  63. package/dist/src/genomeSpy/viewHierarchyConfig.d.ts +14 -0
  64. package/dist/src/genomeSpy/viewHierarchyConfig.d.ts.map +1 -0
  65. package/dist/src/genomeSpy/viewHierarchyConfig.js +24 -0
  66. package/dist/src/genomeSpy/viewHighlight.d.ts +5 -0
  67. package/dist/src/genomeSpy/viewHighlight.d.ts.map +1 -0
  68. package/dist/src/genomeSpy/viewHighlight.js +30 -0
  69. package/dist/src/genomeSpy.d.ts +16 -71
  70. package/dist/src/genomeSpy.d.ts.map +1 -1
  71. package/dist/src/genomeSpy.js +179 -745
  72. package/dist/src/gl/glslScaleGenerator.d.ts +1 -1
  73. package/dist/src/gl/webGLHelper.d.ts +2 -2
  74. package/dist/src/gl/webGLHelper.d.ts.map +1 -1
  75. package/dist/src/gl/webGLHelper.js +4 -4
  76. package/dist/src/index.d.ts.map +1 -1
  77. package/dist/src/index.js +2 -12
  78. package/dist/src/marks/mark.d.ts.map +1 -1
  79. package/dist/src/marks/mark.js +4 -2
  80. package/dist/src/{view → scales}/axisResolution.d.ts +9 -16
  81. package/dist/src/scales/axisResolution.d.ts.map +1 -0
  82. package/dist/src/{view → scales}/axisResolution.js +29 -18
  83. package/dist/src/scales/axisResolution.test.d.ts.map +1 -0
  84. package/dist/src/scales/scaleDomainAggregator.d.ts +57 -0
  85. package/dist/src/scales/scaleDomainAggregator.d.ts.map +1 -0
  86. package/dist/src/scales/scaleDomainAggregator.js +162 -0
  87. package/dist/src/scales/scaleDomainAggregator.test.d.ts +2 -0
  88. package/dist/src/scales/scaleDomainAggregator.test.d.ts.map +1 -0
  89. package/dist/src/scales/scaleInstanceManager.d.ts +40 -0
  90. package/dist/src/scales/scaleInstanceManager.d.ts.map +1 -0
  91. package/dist/src/scales/scaleInstanceManager.js +313 -0
  92. package/dist/src/scales/scaleInstanceManager.test.d.ts +2 -0
  93. package/dist/src/scales/scaleInstanceManager.test.d.ts.map +1 -0
  94. package/dist/src/scales/scaleInteractionController.d.ts +73 -0
  95. package/dist/src/scales/scaleInteractionController.d.ts.map +1 -0
  96. package/dist/src/scales/scaleInteractionController.js +336 -0
  97. package/dist/src/scales/scaleInteractionController.test.d.ts +2 -0
  98. package/dist/src/scales/scaleInteractionController.test.d.ts.map +1 -0
  99. package/dist/src/scales/scalePropsResolver.d.ts +23 -0
  100. package/dist/src/scales/scalePropsResolver.d.ts.map +1 -0
  101. package/dist/src/scales/scalePropsResolver.js +74 -0
  102. package/dist/src/{view → scales}/scaleResolution.d.ts +52 -35
  103. package/dist/src/scales/scaleResolution.d.ts.map +1 -0
  104. package/dist/src/scales/scaleResolution.js +658 -0
  105. package/dist/src/scales/scaleResolution.test.d.ts.map +1 -0
  106. package/dist/src/scales/scaleResolutionConstants.d.ts +6 -0
  107. package/dist/src/scales/scaleResolutionConstants.d.ts.map +1 -0
  108. package/dist/src/scales/scaleResolutionConstants.js +5 -0
  109. package/dist/src/scales/scaleRules.d.ts +16 -0
  110. package/dist/src/scales/scaleRules.d.ts.map +1 -0
  111. package/dist/src/scales/scaleRules.js +103 -0
  112. package/dist/src/scales/scaleRules.test.d.ts +2 -0
  113. package/dist/src/scales/scaleRules.test.d.ts.map +1 -0
  114. package/dist/src/spec/channel.d.ts +13 -18
  115. package/dist/src/spec/scale.d.ts +6 -0
  116. package/dist/src/types/embedApi.d.ts +5 -0
  117. package/dist/src/types/scaleResolutionApi.d.ts +1 -1
  118. package/dist/src/view/concatView.d.ts +18 -0
  119. package/dist/src/view/concatView.d.ts.map +1 -1
  120. package/dist/src/view/concatView.js +73 -0
  121. package/dist/src/view/concatView.test.d.ts +2 -0
  122. package/dist/src/view/concatView.test.d.ts.map +1 -0
  123. package/dist/src/view/containerMutationHelper.d.ts +74 -0
  124. package/dist/src/view/containerMutationHelper.d.ts.map +1 -0
  125. package/dist/src/view/containerMutationHelper.js +114 -0
  126. package/dist/src/view/containerView.d.ts +0 -7
  127. package/dist/src/view/containerView.d.ts.map +1 -1
  128. package/dist/src/view/containerView.js +0 -10
  129. package/dist/src/view/facetView.d.ts.map +1 -1
  130. package/dist/src/view/facetView.js +0 -15
  131. package/dist/src/view/gridView/gridChild.d.ts +11 -0
  132. package/dist/src/view/gridView/gridChild.d.ts.map +1 -1
  133. package/dist/src/view/gridView/gridChild.js +32 -6
  134. package/dist/src/view/gridView/gridView.d.ts +39 -1
  135. package/dist/src/view/gridView/gridView.d.ts.map +1 -1
  136. package/dist/src/view/gridView/gridView.js +106 -48
  137. package/dist/src/view/gridView/gridView.test.d.ts +2 -0
  138. package/dist/src/view/gridView/gridView.test.d.ts.map +1 -0
  139. package/dist/src/view/gridView/scrollbar.d.ts +39 -8
  140. package/dist/src/view/gridView/scrollbar.d.ts.map +1 -1
  141. package/dist/src/view/gridView/scrollbar.js +184 -69
  142. package/dist/src/view/layerView.d.ts +14 -0
  143. package/dist/src/view/layerView.d.ts.map +1 -1
  144. package/dist/src/view/layerView.js +66 -0
  145. package/dist/src/view/layerView.test.d.ts +2 -0
  146. package/dist/src/view/layerView.test.d.ts.map +1 -0
  147. package/dist/src/view/testUtils.d.ts.map +1 -1
  148. package/dist/src/view/testUtils.js +2 -1
  149. package/dist/src/view/unitView.d.ts.map +1 -1
  150. package/dist/src/view/unitView.js +24 -34
  151. package/dist/src/view/view.d.ts +6 -6
  152. package/dist/src/view/view.d.ts.map +1 -1
  153. package/dist/src/view/view.js +4 -4
  154. package/package.json +2 -2
  155. package/dist/bundle/browser-txUcLy2H.js +0 -123
  156. package/dist/bundle/index-BQpbYrv4.js +0 -1712
  157. package/dist/bundle/index-BhtHKLUo.js +0 -73
  158. package/dist/bundle/index-CCe8rnZz.js +0 -716
  159. package/dist/bundle/index-DhcU-Gk-.js +0 -1487
  160. package/dist/src/data/collector.test.js +0 -138
  161. package/dist/src/data/dataFlow.test.js +0 -38
  162. package/dist/src/data/flow.test.js +0 -81
  163. package/dist/src/data/flowInit.test.js +0 -413
  164. package/dist/src/data/flowNode.test.js +0 -50
  165. package/dist/src/data/flowOptimizer.test.js +0 -209
  166. package/dist/src/data/formats/fasta.test.js +0 -27
  167. package/dist/src/data/sources/inlineSource.test.js +0 -63
  168. package/dist/src/data/sources/sequenceSource.test.js +0 -81
  169. package/dist/src/data/transforms/aggregate.test.js +0 -134
  170. package/dist/src/data/transforms/clone.test.js +0 -11
  171. package/dist/src/data/transforms/coverage.test.js +0 -238
  172. package/dist/src/data/transforms/filter.test.js +0 -20
  173. package/dist/src/data/transforms/flatten.test.js +0 -96
  174. package/dist/src/data/transforms/flattenDelimited.test.js +0 -90
  175. package/dist/src/data/transforms/flattenSequence.test.js +0 -34
  176. package/dist/src/data/transforms/formula.test.js +0 -25
  177. package/dist/src/data/transforms/identifier.test.js +0 -92
  178. package/dist/src/data/transforms/pileup.test.js +0 -70
  179. package/dist/src/data/transforms/project.test.js +0 -32
  180. package/dist/src/data/transforms/regexExtract.test.js +0 -70
  181. package/dist/src/data/transforms/regexFold.test.js +0 -201
  182. package/dist/src/data/transforms/sample.test.js +0 -38
  183. package/dist/src/data/transforms/stack.test.js +0 -91
  184. package/dist/src/encoder/accessor.test.js +0 -162
  185. package/dist/src/encoder/encoder.test.js +0 -105
  186. package/dist/src/genome/genome.test.js +0 -268
  187. package/dist/src/genome/genomes.test.js +0 -8
  188. package/dist/src/genome/scaleIndex.test.js +0 -78
  189. package/dist/src/genome/scaleLocus.test.js +0 -4
  190. package/dist/src/scale/scale.test.js +0 -326
  191. package/dist/src/scale/ticks.test.js +0 -46
  192. package/dist/src/selection/selection.test.js +0 -14
  193. package/dist/src/utils/addBaseUrl.test.js +0 -30
  194. package/dist/src/utils/binnedIndex.test.js +0 -201
  195. package/dist/src/utils/cloner.test.js +0 -35
  196. package/dist/src/utils/coalesce.test.js +0 -16
  197. package/dist/src/utils/concatIterables.test.js +0 -8
  198. package/dist/src/utils/domainArray.test.js +0 -130
  199. package/dist/src/utils/indexer.test.js +0 -49
  200. package/dist/src/utils/interactionEvent.test.js +0 -35
  201. package/dist/src/utils/iterateNestedMaps.test.js +0 -33
  202. package/dist/src/utils/kWayMerge.test.js +0 -30
  203. package/dist/src/utils/mergeObjects.test.js +0 -42
  204. package/dist/src/utils/numberExtractor.test.js +0 -6
  205. package/dist/src/utils/propertyCacher.test.js +0 -89
  206. package/dist/src/utils/propertyCoalescer.test.js +0 -25
  207. package/dist/src/utils/radixSort.test.js +0 -51
  208. package/dist/src/utils/reservationMap.test.js +0 -20
  209. package/dist/src/utils/ringBuffer.test.js +0 -39
  210. package/dist/src/utils/topK.test.js +0 -54
  211. package/dist/src/utils/trees.test.js +0 -135
  212. package/dist/src/utils/url.test.js +0 -28
  213. package/dist/src/utils/variableTools.test.js +0 -13
  214. package/dist/src/view/axisResolution.d.ts.map +0 -1
  215. package/dist/src/view/axisResolution.test.d.ts.map +0 -1
  216. package/dist/src/view/axisResolution.test.js +0 -206
  217. package/dist/src/view/flowBuilder.test.js +0 -125
  218. package/dist/src/view/gridView/selectionRect.test.js +0 -87
  219. package/dist/src/view/layout/flexLayout.test.js +0 -323
  220. package/dist/src/view/layout/grid.test.js +0 -71
  221. package/dist/src/view/layout/rectangle.test.js +0 -192
  222. package/dist/src/view/paramMediator.test.js +0 -282
  223. package/dist/src/view/scaleResolution.d.ts.map +0 -1
  224. package/dist/src/view/scaleResolution.js +0 -1059
  225. package/dist/src/view/scaleResolution.test.d.ts.map +0 -1
  226. package/dist/src/view/scaleResolution.test.js +0 -645
  227. package/dist/src/view/view.test.js +0 -245
  228. package/dist/src/view/viewDispose.test.js +0 -110
  229. package/dist/src/view/viewFactory.test.js +0 -25
  230. package/dist/src/view/viewUtils.test.js +0 -87
  231. /package/dist/src/{view → scales}/axisResolution.test.d.ts +0 -0
  232. /package/dist/src/{view → scales}/scaleResolution.test.d.ts +0 -0
@@ -1,192 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import Rectangle from "./rectangle.js";
3
- import Padding from "./padding.js";
4
-
5
- test("Rectangle creation", () => {
6
- const r = Rectangle.create(1, 2, 3, 4);
7
- expect(r.x).toEqual(1);
8
- expect(r.y).toEqual(2);
9
- expect(r.width).toEqual(3);
10
- expect(r.height).toEqual(4);
11
- });
12
-
13
- test("equals", () => {
14
- const r = Rectangle.create(1, 2, 3, 4);
15
- expect(r.equals(r)).toBeTruthy();
16
- expect(r.equals(Rectangle.create(1, 2, 3, 4))).toBeTruthy();
17
- expect(r.equals(undefined)).toBeFalsy();
18
- });
19
-
20
- test("x2 and y2 calculation", () => {
21
- const r = Rectangle.create(1, 2, 3, 4);
22
- expect(r.x2).toEqual(4);
23
- expect(r.y2).toEqual(6);
24
- });
25
-
26
- test("translate", () => {
27
- const r = Rectangle.create(1, 2, 3, 4).translate(2, 3);
28
- expect(r.x).toEqual(3);
29
- expect(r.y).toEqual(5);
30
- expect(r.width).toEqual(3);
31
- expect(r.height).toEqual(4);
32
- });
33
-
34
- test("Dynamic translate", () => {
35
- let tx = 0;
36
- let ty = 0;
37
-
38
- const r = Rectangle.create(1, 2, 3, 4)
39
- .translate(
40
- () => tx,
41
- () => ty
42
- )
43
- .translate(2, 3);
44
-
45
- expect(r.x).toEqual(3);
46
- expect(r.y).toEqual(5);
47
- expect(r.width).toEqual(3);
48
- expect(r.height).toEqual(4);
49
-
50
- tx = 1;
51
- ty = 2;
52
-
53
- expect(r.x).toEqual(4);
54
- expect(r.y).toEqual(7);
55
- expect(r.width).toEqual(3);
56
- expect(r.height).toEqual(4);
57
- });
58
-
59
- test("expand", () => {
60
- const r = Rectangle.create(1, 2, 3, 4).expand(
61
- Padding.createFromRecord({ top: 2, right: 3, bottom: 4, left: 5 })
62
- );
63
-
64
- expect(r.x).toEqual(-4);
65
- expect(r.width).toEqual(11);
66
- expect(r.y).toEqual(0);
67
- expect(r.height).toEqual(10);
68
- });
69
-
70
- test("shrink", () => {
71
- const r = Rectangle.create(1, 2, 3, 4).shrink(
72
- Padding.createUniformPadding(1)
73
- );
74
-
75
- expect(r.x).toEqual(2);
76
- expect(r.width).toEqual(1);
77
- expect(r.y).toEqual(3);
78
- expect(r.height).toEqual(2);
79
- });
80
-
81
- test("modify", () => {
82
- const r = Rectangle.create(1, 2, 3, 4);
83
- const m = r.modify({ x: 5 });
84
-
85
- expect(m.equals(r)).toBeFalsy();
86
- expect(m.equals(Rectangle.create(5, 2, 3, 4))).toBeTruthy();
87
- });
88
-
89
- test("Dynamic modify", () => {
90
- let x = 1;
91
- const r = Rectangle.create(1, 2, 3, 4);
92
- const m = r.modify({ x: () => x });
93
-
94
- expect(m.equals(r)).toBeTruthy();
95
- expect(m.equals(Rectangle.create(1, 2, 3, 4))).toBeTruthy();
96
-
97
- x = 5;
98
-
99
- expect(m.equals(r)).toBeFalsy();
100
- expect(m.equals(Rectangle.create(5, 2, 3, 4))).toBeTruthy();
101
- });
102
-
103
- test("intersect", () => {
104
- const a = Rectangle.create(1, 1, 6, 3);
105
- const b = Rectangle.create(5, 2, 3, 4);
106
- const c = Rectangle.create(5, 2, 2, 2);
107
-
108
- expect(a.intersect(b).equals(c)).toBeTruthy();
109
- expect(a.intersect(b).isDefined()).toBeTruthy();
110
-
111
- const x = Rectangle.create(1, 1, 1, 1);
112
- const y = Rectangle.create(3, 3, 1, 1);
113
-
114
- expect(x.intersect(y).isDefined()).toBeFalsy();
115
- });
116
-
117
- test("union", () => {
118
- const a = Rectangle.create(1, 1, 6, 3);
119
- const b = Rectangle.create(5, 2, 3, 4);
120
- const c = Rectangle.create(1, 1, 7, 5);
121
-
122
- expect(a.union(b).equals(c)).toBeTruthy();
123
- });
124
-
125
- test("isDefined", () => {
126
- expect(Rectangle.create(0, 0, 1, 1).isDefined()).toBeTruthy();
127
- expect(Rectangle.create(0, 0, 0, 0).isDefined()).toBeTruthy();
128
-
129
- expect(Rectangle.create(0, 0, -1, 0).isDefined()).toBeFalsy();
130
- expect(Rectangle.create(0, 0, 0, -1).isDefined()).toBeFalsy();
131
- });
132
-
133
- test("flatten", () => {
134
- let tx = 0;
135
- let ty = 0;
136
-
137
- const r = Rectangle.create(1, 2, 3, 4).translate(
138
- () => tx,
139
- () => ty
140
- );
141
-
142
- const flattened = r.flatten();
143
-
144
- tx = -1;
145
- ty = -2;
146
-
147
- expect(r.equals(Rectangle.create(0, 0, 3, 4)));
148
- expect(flattened.equals(Rectangle.create(1, 2, 3, 4)));
149
- });
150
-
151
- test("containsPoint", () => {
152
- const r = Rectangle.create(1, 2, 3, 4);
153
-
154
- expect(r.containsPoint(0, 0)).toBeFalsy();
155
- expect(r.containsPoint(0, 10)).toBeFalsy();
156
- expect(r.containsPoint(10, 0)).toBeFalsy();
157
- expect(r.containsPoint(10, 10)).toBeFalsy();
158
-
159
- expect(r.containsPoint(2, 0)).toBeFalsy();
160
- expect(r.containsPoint(2, 10)).toBeFalsy();
161
- expect(r.containsPoint(0, 3)).toBeFalsy();
162
- expect(r.containsPoint(10, 3)).toBeFalsy();
163
-
164
- // Inclusive corner
165
- expect(r.containsPoint(1, 2)).toBeTruthy();
166
-
167
- // Inside
168
- expect(r.containsPoint(2, 3)).toBeTruthy();
169
-
170
- // Exclusive corner
171
- expect(r.containsPoint(4, 6)).toBeFalsy();
172
- });
173
-
174
- test("normalizePoint", () => {
175
- const r = Rectangle.create(1, 2, 6, 4);
176
-
177
- expect(r.normalizePoint(1, 2)).toEqual({ x: 0, y: 0 });
178
- expect(r.normalizePoint(7, 2)).toEqual({ x: 1, y: 0 });
179
- expect(r.normalizePoint(4, 4)).toEqual({ x: 0.5, y: 0.5 });
180
-
181
- expect(r.normalizePoint(1, 6, true)).toEqual({ x: 0, y: 0 });
182
- });
183
-
184
- test("denormalizePoint", () => {
185
- const r = Rectangle.create(1, 2, 6, 4);
186
-
187
- expect(r.denormalizePoint(0, 0)).toEqual({ x: 1, y: 2 });
188
- expect(r.denormalizePoint(1, 0)).toEqual({ x: 7, y: 2 });
189
- expect(r.denormalizePoint(0.5, 0.5)).toEqual({ x: 4, y: 4 });
190
-
191
- expect(r.denormalizePoint(0, 0, true)).toEqual({ x: 1, y: 6 });
192
- });
@@ -1,282 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import ParamMediator, { activateExprRefProps } from "./paramMediator.js";
3
-
4
- describe("Single-level ParamMediator", () => {
5
- test("Trivial case", () => {
6
- const pm = new ParamMediator();
7
- pm.registerParam({ name: "foo", value: 42 });
8
- expect(pm.getValue("foo")).toBe(42);
9
- });
10
-
11
- test("Setter", () => {
12
- const pm = new ParamMediator();
13
- const setter = pm.allocateSetter("foo", 42);
14
- expect(pm.getValue("foo")).toBe(42);
15
-
16
- setter(43);
17
- expect(pm.getValue("foo")).toBe(43);
18
- });
19
-
20
- test("Expressions have access to parameters", () => {
21
- const pm = new ParamMediator();
22
- pm.registerParam({ name: "foo", value: 42 });
23
- const expr = pm.createExpression("foo + 1");
24
- expect(expr()).toBe(43);
25
- });
26
-
27
- test("Throws on an unknown parameter", () => {
28
- const pm = new ParamMediator();
29
- expect(() => pm.createExpression("foo")).toThrow();
30
- });
31
-
32
- test("Listener on an expression gets called (only) when a parameter changes", () => {
33
- const pm = new ParamMediator();
34
- const setter = pm.allocateSetter("foo", 42);
35
- const expr = pm.createExpression("foo + 1");
36
-
37
- let result;
38
- let calls = 0;
39
-
40
- expr.addListener(() => {
41
- result = expr();
42
- calls++;
43
- });
44
-
45
- setter(50);
46
- expect(result).toBe(51);
47
- expect(calls).toBe(1);
48
-
49
- setter(60);
50
- expect(result).toBe(61);
51
- expect(calls).toBe(2);
52
-
53
- setter(60);
54
- expect(result).toBe(61);
55
- expect(calls).toBe(2);
56
- });
57
-
58
- test("Passive parameter does not trigger listeners", () => {
59
- const pm = new ParamMediator();
60
- const setter = pm.allocateSetter("foo", 42, true);
61
- const expr = pm.createExpression("foo");
62
-
63
- let result = expr();
64
-
65
- expr.addListener(() => (result = expr()));
66
-
67
- setter(50);
68
- expect(result).toBe(42);
69
- });
70
-
71
- test("Expression invalidation", () => {
72
- const pm = new ParamMediator();
73
- const setter = pm.allocateSetter("foo", 42);
74
- const expr = pm.createExpression("foo + 1");
75
-
76
- let result = expr();
77
- expect(result).toBe(43);
78
-
79
- expr.addListener(() => (result = expr()));
80
-
81
- setter(50);
82
- expect(result).toBe(51);
83
-
84
- expr.invalidate();
85
- // Listeners should be invalidated now: the result must remain the same.
86
- setter(60);
87
- expect(result).toBe(51);
88
- });
89
-
90
- test("Expression removeListener detaches a listener", () => {
91
- const pm = new ParamMediator();
92
- const setter = pm.allocateSetter("foo", 42);
93
- const expr = pm.createExpression("foo + 1");
94
-
95
- let calls = 0;
96
-
97
- const listener = () => {
98
- calls++;
99
- };
100
-
101
- expr.addListener(listener);
102
-
103
- setter(50);
104
- expect(calls).toBe(1);
105
-
106
- expr.removeListener(listener);
107
-
108
- setter(60);
109
- expect(calls).toBe(1);
110
- });
111
-
112
- test("Expression parameter handles dependencies", () => {
113
- const pm = new ParamMediator();
114
- const setter = pm.registerParam({ name: "foo", value: 42 });
115
- pm.registerParam({ name: "bar", expr: "foo + 1" });
116
- pm.registerParam({ name: "baz", expr: "bar + 2" });
117
-
118
- const expr = pm.createExpression("baz");
119
-
120
- let result = expr();
121
- expect(result).toBe(45);
122
-
123
- expr.addListener(() => (result = expr()));
124
-
125
- setter(52);
126
- expect(result).toBe(55);
127
- });
128
-
129
- test("Throws if both value and expr are provided", () => {
130
- const pm = new ParamMediator();
131
- expect(() =>
132
- pm.registerParam({ name: "foo", value: 42, expr: "bar" })
133
- ).toThrow();
134
- });
135
- });
136
-
137
- describe("Nested ParamMediators", () => {
138
- test("Value in parent", () => {
139
- const parent = new ParamMediator();
140
- const child = new ParamMediator(() => parent);
141
-
142
- parent.registerParam({ name: "foo", value: 42 });
143
- expect(parent.findValue("foo")).toBe(42);
144
- expect(child.findValue("foo")).toBe(42);
145
- });
146
-
147
- test("Value in child", () => {
148
- const parent = new ParamMediator();
149
- const child = new ParamMediator(() => parent);
150
-
151
- child.registerParam({ name: "foo", value: 42 });
152
- expect(parent.findValue("foo")).toBeUndefined();
153
- expect(child.findValue("foo")).toBe(42);
154
- });
155
-
156
- test("Child overrides parent", () => {
157
- const parent = new ParamMediator();
158
- const child = new ParamMediator(() => parent);
159
-
160
- parent.registerParam({ name: "foo", value: 1 });
161
- child.registerParam({ name: "foo", value: 2 });
162
-
163
- expect(parent.findValue("foo")).toBe(1);
164
- expect(child.findValue("foo")).toBe(2);
165
- });
166
-
167
- test("Expression", () => {
168
- const parent = new ParamMediator();
169
- const child = new ParamMediator(() => parent);
170
-
171
- parent.registerParam({ name: "foo", value: 1 });
172
- child.registerParam({ name: "bar", value: 2 });
173
-
174
- const expr = child.createExpression("foo + bar");
175
- expect(expr()).toBe(3);
176
- });
177
-
178
- test("Listener on an expression", () => {
179
- const parent = new ParamMediator();
180
- const child = new ParamMediator(() => parent);
181
-
182
- const parentSetter = parent.allocateSetter("foo", 1);
183
- const childSetter = parent.allocateSetter("bar", 2);
184
-
185
- const expr = child.createExpression("foo + bar");
186
-
187
- let result = expr();
188
- expr.addListener(() => (result = expr()));
189
-
190
- expect(result).toBe(3);
191
-
192
- parentSetter(10);
193
- expect(result).toBe(12);
194
-
195
- childSetter(20);
196
- expect(result).toBe(30);
197
- });
198
-
199
- test("Pushing to outer parameter", () => {
200
- const parent = new ParamMediator();
201
- const child = new ParamMediator(() => parent);
202
-
203
- parent.registerParam({ name: "foo", value: 1 });
204
- const childSetter = child.registerParam({ name: "foo", push: "outer" });
205
-
206
- expect(parent.findValue("foo")).toBe(1);
207
- expect(child.findValue("foo")).toBe(1);
208
-
209
- childSetter(2);
210
-
211
- expect(parent.findValue("foo")).toBe(2);
212
- expect(child.findValue("foo")).toBe(2);
213
- });
214
- });
215
-
216
- test("activateExprRefProps", async () => {
217
- const pm = new ParamMediator();
218
-
219
- const fooSetter = pm.registerParam({ name: "foo", value: 7 });
220
- const barSetter = pm.registerParam({ name: "bar", value: 11 });
221
-
222
- /** @type {Record<string, any | import("../spec/parameter.js").ExprRef>} */
223
- const props = {
224
- a: 42,
225
- b: { expr: "foo" },
226
- c: { expr: "bar" },
227
- };
228
-
229
- /** @type {string[]} */
230
- let altered = [];
231
-
232
- const activatedProps = activateExprRefProps(pm, props, (props) => {
233
- altered = props;
234
- });
235
-
236
- expect(activatedProps).toEqual({
237
- a: 42,
238
- b: 7,
239
- c: 11,
240
- });
241
-
242
- fooSetter(8);
243
-
244
- // Let the scheduled microtask call the listener
245
- await Promise.resolve();
246
-
247
- expect(altered).toEqual(["b"]);
248
-
249
- fooSetter(1);
250
- barSetter(2);
251
-
252
- // Let the scheduled microtask call the listener
253
- await Promise.resolve();
254
-
255
- expect(altered).toEqual(["b", "c"]);
256
-
257
- expect(activatedProps).toEqual({
258
- a: 42,
259
- b: 1,
260
- c: 2,
261
- });
262
- });
263
-
264
- describe("hasPointSelections()", () => {
265
- test("false if there are no point selections", () => {
266
- const pm = new ParamMediator();
267
- pm.registerParam({ name: "foo", value: 42 });
268
- expect(pm.hasPointSelections()).toBe(false);
269
- });
270
-
271
- test("true if there are point selections (1/2)", () => {
272
- const pm = new ParamMediator();
273
- pm.registerParam({ name: "foo", select: "point" });
274
- expect(pm.hasPointSelections()).toBe(true);
275
- });
276
-
277
- test("true if there are point selections (2/2)", () => {
278
- const pm = new ParamMediator();
279
- pm.registerParam({ name: "foo", select: { type: "point" } });
280
- expect(pm.hasPointSelections()).toBe(true);
281
- });
282
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"scaleResolution.d.ts","sourceRoot":"","sources":["../../../src/view/scaleResolution.js"],"names":[],"mappings":"AA6/BA;;;;;;;;;;GAUG;AACH,6CAFW,OAAO,WAAW,EAAE,OAAO,GAAG,OAAO,WAAW,EAAE,OAAO,EAAE,QA4BrE;AAr/BD,2BAA4B,cAAc,CAAC;AAC3C,sBAAuB,SAAS,CAAC;AACjC,sBAAuB,SAAS,CAAC;AACjC,oBAAqB,OAAO,CAAC;AAC7B,oBAAqB,OAAO,CAAC;AAE7B;;;;;;;;GAQG;AACH;;;;;;;GAOG;AACH;IA4CI;;OAEG;IACH,2DASC;IARG,8CAAsB;IACtB,yDAAyD;IACzD,SADW,qBAAqB,EAAE,CACjB;IACjB,0FAA0F;IAC1F,MADW,OAAO,oBAAoB,EAAE,IAAI,CAC5B;IAEhB,iEAAiE;IACjE,MADW,MAAM,CACI;IAWzB,2BAMC;IAED;;;;;;;OAOG;IACH,4KAEC;IAED;;;OAGG;IACH,+KAEC;IAcD;;;;;OAKG;IACH,qBAFW,qBAAqB,QAqD/B;IAED;;;OAGG;IACH,4DAFa,OAAO,CAMnB;IA8MD;;;;OAIG;IACH,+DAOC;IAED;;OAEG;IACH,oBA6CC;IAED;;OAEG;IACH;eA9akC,OAAO,kBAAkB,EAAE,KAAK;MAsdjE;IAED,mBAEC;IAED;;OAEG;IACH,oBAFa,mFAA6B,CAOzC;IAED;;;;OAIG;IACH,oBAKC;IAED;;OAEG;IACH,sBAGC;IAUD;;;;;;;OAOG;IACH,kBALW,MAAM,eACN,MAAM,OACN,MAAM,GACJ,OAAO,CAmEnB;IAED;;;;;;OAMG;IACH,eAJW,mFAA6B,aAC7B,OAAO,GAAG,MAAM,iBA0D1B;IAED;;;;OAIG;IACH,qBAcC;IAED;;;;;OAKG;IACH,uBAOC;IAED;;;;;;;OAOG;IACH,wBAoBC;IAiED;;;OAGG;IACH,aAFa,OAAO,qBAAqB,EAAE,OAAO,CAajD;IAID;;;;;OAKG;IACH,uBAFW,MAAM,yDAUhB;IAED;;OAEG;IACH,iBAFW,MAAM,yDAKhB;IAED;;;OAGG;IACH,qBAHW,MAAM,+CAAmB,GACvB,MAAM,CAQlB;IAED;;;OAGG;IACH,8BAHW,kFAA4B,GAC1B,MAAM,EAAE,CAOpB;;CACJ;kCA/2B+B,CAAC,SAApB,6CAAkB;;;;UAGrB,OAAO,eAAe,EAAE,OAAO;aAC/B,CAAC;gBACD,OAAO,oBAAoB,EAAE,mBAAmB;sBAChD,CAAC,OAAO,+CAAkB,EAAE,IAAI,EAAE,OAAO,oBAAoB,EAAE,IAAI,kDAAgB"}