@genome-spy/core 0.29.0 → 0.30.2

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 (234) hide show
  1. package/dist/index.es.js +16373 -0
  2. package/dist/index.js +43 -43
  3. package/package.json +10 -7
  4. package/src/data/collector.js +0 -183
  5. package/src/data/collector.test.js +0 -84
  6. package/src/data/dataFlow.js +0 -148
  7. package/src/data/dataFlow.test.js +0 -5
  8. package/src/data/facetNode.js +0 -17
  9. package/src/data/flow.test.js +0 -72
  10. package/src/data/flowBatch.d.ts +0 -40
  11. package/src/data/flowNode.js +0 -283
  12. package/src/data/flowNode.test.js +0 -50
  13. package/src/data/flowOptimizer.js +0 -123
  14. package/src/data/flowOptimizer.test.js +0 -193
  15. package/src/data/flowTestUtils.js +0 -63
  16. package/src/data/formats/fasta.js +0 -32
  17. package/src/data/formats/fasta.test.js +0 -27
  18. package/src/data/sources/dataSource.js +0 -22
  19. package/src/data/sources/dataSourceFactory.js +0 -24
  20. package/src/data/sources/dataUtils.js +0 -78
  21. package/src/data/sources/dynamicCallbackSource.js +0 -57
  22. package/src/data/sources/dynamicSource.js +0 -37
  23. package/src/data/sources/inlineSource.js +0 -67
  24. package/src/data/sources/inlineSource.test.js +0 -56
  25. package/src/data/sources/namedSource.js +0 -79
  26. package/src/data/sources/sequenceSource.js +0 -46
  27. package/src/data/sources/sequenceSource.test.js +0 -46
  28. package/src/data/sources/urlSource.js +0 -74
  29. package/src/data/transforms/aggregate.js +0 -70
  30. package/src/data/transforms/clone.js +0 -40
  31. package/src/data/transforms/clone.test.js +0 -11
  32. package/src/data/transforms/coverage.js +0 -187
  33. package/src/data/transforms/coverage.test.js +0 -123
  34. package/src/data/transforms/filter.js +0 -37
  35. package/src/data/transforms/filter.test.js +0 -18
  36. package/src/data/transforms/filterScoredLabels.js +0 -134
  37. package/src/data/transforms/flattenCompressedExons.js +0 -57
  38. package/src/data/transforms/flattenDelimited.js +0 -74
  39. package/src/data/transforms/flattenDelimited.test.js +0 -87
  40. package/src/data/transforms/flattenSequence.js +0 -39
  41. package/src/data/transforms/flattenSequence.test.js +0 -34
  42. package/src/data/transforms/formula.js +0 -39
  43. package/src/data/transforms/formula.test.js +0 -19
  44. package/src/data/transforms/identifier.js +0 -108
  45. package/src/data/transforms/identifier.test.js +0 -83
  46. package/src/data/transforms/linearizeGenomicCoordinate.js +0 -101
  47. package/src/data/transforms/measureText.js +0 -44
  48. package/src/data/transforms/pileup.js +0 -128
  49. package/src/data/transforms/pileup.test.js +0 -70
  50. package/src/data/transforms/project.js +0 -41
  51. package/src/data/transforms/project.test.js +0 -32
  52. package/src/data/transforms/regexExtract.js +0 -61
  53. package/src/data/transforms/regexExtract.test.js +0 -67
  54. package/src/data/transforms/regexFold.js +0 -141
  55. package/src/data/transforms/regexFold.test.js +0 -160
  56. package/src/data/transforms/sample.js +0 -101
  57. package/src/data/transforms/sample.test.js +0 -38
  58. package/src/data/transforms/stack.js +0 -137
  59. package/src/data/transforms/stack.test.js +0 -91
  60. package/src/data/transforms/transformFactory.js +0 -60
  61. package/src/embedApi.d.ts +0 -67
  62. package/src/encoder/accessor.js +0 -82
  63. package/src/encoder/accessor.test.js +0 -47
  64. package/src/encoder/encoder.js +0 -394
  65. package/src/encoder/encoder.test.js +0 -98
  66. package/src/fonts/Lato-Regular.json +0 -1267
  67. package/src/fonts/Lato-Regular.png +0 -0
  68. package/src/fonts/OFL.txt +0 -93
  69. package/src/fonts/README.md +0 -3
  70. package/src/fonts/bmFont.d.ts +0 -58
  71. package/src/fonts/bmFontManager.js +0 -357
  72. package/src/fonts/bmFontMetrics.js +0 -108
  73. package/src/genome/genome.js +0 -317
  74. package/src/genome/genome.test.js +0 -188
  75. package/src/genome/genomeStore.js +0 -54
  76. package/src/genome/locusFormat.js +0 -31
  77. package/src/genome/scaleIndex.d.ts +0 -38
  78. package/src/genome/scaleIndex.js +0 -166
  79. package/src/genome/scaleIndex.test.js +0 -78
  80. package/src/genome/scaleLocus.d.ts +0 -11
  81. package/src/genome/scaleLocus.js +0 -108
  82. package/src/genome/scaleLocus.test.js +0 -4
  83. package/src/genomeSpy.js +0 -784
  84. package/src/gl/arrayBuilder.js +0 -199
  85. package/src/gl/dataToVertices.js +0 -636
  86. package/src/gl/includes/common.glsl +0 -63
  87. package/src/gl/includes/picking.fragment.glsl +0 -1
  88. package/src/gl/includes/picking.vertex.glsl +0 -27
  89. package/src/gl/includes/sampleFacet.glsl +0 -107
  90. package/src/gl/includes/scales.glsl +0 -112
  91. package/src/gl/link.fragment.glsl +0 -18
  92. package/src/gl/link.vertex.glsl +0 -111
  93. package/src/gl/point.fragment.glsl +0 -123
  94. package/src/gl/point.vertex.glsl +0 -129
  95. package/src/gl/rect.fragment.glsl +0 -51
  96. package/src/gl/rect.vertex.glsl +0 -114
  97. package/src/gl/rule.fragment.glsl +0 -52
  98. package/src/gl/rule.vertex.glsl +0 -89
  99. package/src/gl/text.fragment.glsl +0 -31
  100. package/src/gl/text.vertex.glsl +0 -246
  101. package/src/gl/webGLHelper.js +0 -489
  102. package/src/img/bowtie.svg +0 -1
  103. package/src/img/genomespy-favicon.svg +0 -34
  104. package/src/index.html +0 -11
  105. package/src/index.js +0 -128
  106. package/src/marks/link.js +0 -175
  107. package/src/marks/mark.js +0 -975
  108. package/src/marks/markUtils.js +0 -125
  109. package/src/marks/pointMark.js +0 -251
  110. package/src/marks/rectMark.js +0 -241
  111. package/src/marks/rule.js +0 -250
  112. package/src/marks/text.js +0 -278
  113. package/src/node_modules/.vitest/results.json +0 -1
  114. package/src/scale/colorUtils.js +0 -184
  115. package/src/scale/glslScaleGenerator.js +0 -488
  116. package/src/scale/scale.js +0 -451
  117. package/src/scale/scale.test.js +0 -324
  118. package/src/scale/ticks.js +0 -203
  119. package/src/scale/ticks.test.js +0 -40
  120. package/src/singlePageApp.js +0 -13
  121. package/src/spec/axis.d.ts +0 -296
  122. package/src/spec/channel.d.ts +0 -430
  123. package/src/spec/data.d.ts +0 -196
  124. package/src/spec/font.d.ts +0 -15
  125. package/src/spec/genome.d.ts +0 -35
  126. package/src/spec/mark.d.ts +0 -429
  127. package/src/spec/root.d.ts +0 -17
  128. package/src/spec/sampleView.d.ts +0 -180
  129. package/src/spec/scale.d.ts +0 -273
  130. package/src/spec/title.d.ts +0 -102
  131. package/src/spec/tooltip.d.ts +0 -9
  132. package/src/spec/transform.d.ts +0 -479
  133. package/src/spec/view.d.ts +0 -201
  134. package/src/styles/genome-spy.scss +0 -153
  135. package/src/tooltip/dataTooltipHandler.js +0 -64
  136. package/src/tooltip/refseqGeneTooltipHandler.js +0 -78
  137. package/src/tooltip/tooltipHandler.ts +0 -12
  138. package/src/types/filetypes.d.ts +0 -14
  139. package/src/types/flatqueue.d.ts +0 -53
  140. package/src/types/glsl.d.ts +0 -4
  141. package/src/types/internmap.d.ts +0 -22
  142. package/src/types/object.d.ts +0 -21
  143. package/src/types/vega-loader.d.ts +0 -1
  144. package/src/types/vega-scale.d.ts +0 -60
  145. package/src/utils/addBaseUrl.js +0 -19
  146. package/src/utils/addBaseUrl.test.js +0 -22
  147. package/src/utils/animator.js +0 -83
  148. package/src/utils/arrayUtils.js +0 -61
  149. package/src/utils/binnedIndex.js +0 -167
  150. package/src/utils/binnedIndex.test.js +0 -155
  151. package/src/utils/clamp.js +0 -8
  152. package/src/utils/cloner.js +0 -34
  153. package/src/utils/cloner.test.js +0 -24
  154. package/src/utils/coalesce.js +0 -11
  155. package/src/utils/coalesce.test.js +0 -16
  156. package/src/utils/concatIterables.js +0 -26
  157. package/src/utils/concatIterables.test.js +0 -8
  158. package/src/utils/debounce.js +0 -37
  159. package/src/utils/domainArray.js +0 -216
  160. package/src/utils/domainArray.test.js +0 -130
  161. package/src/utils/eerp.js +0 -13
  162. package/src/utils/expression.js +0 -32
  163. package/src/utils/field.js +0 -28
  164. package/src/utils/formatObject.js +0 -31
  165. package/src/utils/indexer.js +0 -43
  166. package/src/utils/indexer.test.js +0 -47
  167. package/src/utils/inertia.js +0 -124
  168. package/src/utils/interactionEvent.js +0 -33
  169. package/src/utils/iterateNestedMaps.js +0 -21
  170. package/src/utils/iterateNestedMaps.test.js +0 -33
  171. package/src/utils/kWayMerge.js +0 -42
  172. package/src/utils/kWayMerge.test.js +0 -26
  173. package/src/utils/layout/flexLayout.js +0 -368
  174. package/src/utils/layout/flexLayout.test.js +0 -311
  175. package/src/utils/layout/grid.js +0 -95
  176. package/src/utils/layout/grid.test.js +0 -71
  177. package/src/utils/layout/padding.js +0 -120
  178. package/src/utils/layout/point.js +0 -23
  179. package/src/utils/layout/rectangle.js +0 -288
  180. package/src/utils/layout/rectangle.test.js +0 -172
  181. package/src/utils/mergeObjects.js +0 -99
  182. package/src/utils/mergeObjects.test.js +0 -42
  183. package/src/utils/numberExtractor.js +0 -24
  184. package/src/utils/numberExtractor.test.js +0 -6
  185. package/src/utils/point.js +0 -14
  186. package/src/utils/propertyCacher.js +0 -70
  187. package/src/utils/propertyCacher.test.js +0 -85
  188. package/src/utils/propertyCoalescer.js +0 -42
  189. package/src/utils/propertyCoalescer.test.js +0 -22
  190. package/src/utils/reservationMap.js +0 -103
  191. package/src/utils/reservationMap.test.js +0 -20
  192. package/src/utils/scaleNull.js +0 -19
  193. package/src/utils/setOperations.js +0 -75
  194. package/src/utils/smoothstep.js +0 -10
  195. package/src/utils/throttle.js +0 -34
  196. package/src/utils/topK.js +0 -76
  197. package/src/utils/topK.test.js +0 -64
  198. package/src/utils/transition.js +0 -74
  199. package/src/utils/ui/tooltip.js +0 -189
  200. package/src/utils/url.js +0 -22
  201. package/src/utils/variableTools.js +0 -24
  202. package/src/utils/variableTools.test.js +0 -13
  203. package/src/view/axisResolution.js +0 -140
  204. package/src/view/axisResolution.test.js +0 -201
  205. package/src/view/axisView.js +0 -747
  206. package/src/view/concatView.js +0 -45
  207. package/src/view/containerView.js +0 -159
  208. package/src/view/facetView.js +0 -491
  209. package/src/view/flowBuilder.js +0 -367
  210. package/src/view/flowBuilder.test.js +0 -125
  211. package/src/view/gridView.js +0 -786
  212. package/src/view/implicitRootView.js +0 -14
  213. package/src/view/importView.js +0 -19
  214. package/src/view/layerView.js +0 -74
  215. package/src/view/rendering.d.ts +0 -44
  216. package/src/view/renderingContext/compositeViewRenderingContext.js +0 -51
  217. package/src/view/renderingContext/deferredViewRenderingContext.js +0 -176
  218. package/src/view/renderingContext/layoutRecorderViewRenderingContext.js +0 -128
  219. package/src/view/renderingContext/simpleViewRenderingContext.js +0 -64
  220. package/src/view/renderingContext/svgViewRenderingContext.js +0 -125
  221. package/src/view/renderingContext/viewRenderingContext.js +0 -41
  222. package/src/view/scaleResolution.js +0 -791
  223. package/src/view/scaleResolution.test.js +0 -572
  224. package/src/view/scaleResolutionApi.d.ts +0 -40
  225. package/src/view/testUtils.js +0 -51
  226. package/src/view/title.js +0 -165
  227. package/src/view/unitView.js +0 -382
  228. package/src/view/view.js +0 -612
  229. package/src/view/view.test.js +0 -214
  230. package/src/view/viewContext.d.ts +0 -62
  231. package/src/view/viewFactory.js +0 -181
  232. package/src/view/viewFactory.test.js +0 -17
  233. package/src/view/viewUtils.js +0 -327
  234. package/src/view/zoom.js +0 -89
@@ -1,153 +0,0 @@
1
- @use "sass:math";
2
-
3
- $basic-spacing: 10px;
4
-
5
- $font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif,
6
- "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
7
-
8
- .genome-spy {
9
- font-family: $font-family;
10
-
11
- position: relative;
12
-
13
- canvas {
14
- transform: scale(1, 1);
15
- opacity: 1;
16
- transition: transform 0.6s, opacity 0.6s;
17
- }
18
-
19
- .loading-message {
20
- position: absolute;
21
- top: 0;
22
- bottom: 0;
23
- left: 0;
24
- right: 0;
25
- display: flex;
26
-
27
- align-items: center;
28
- justify-content: center;
29
-
30
- .message {
31
- color: #666;
32
- opacity: 0;
33
- transition: opacity 0.7s;
34
- }
35
- }
36
-
37
- &.loading {
38
- canvas {
39
- transform: scale(0.95, 0.95);
40
- opacity: 0;
41
- }
42
-
43
- .loading-message .message {
44
- opacity: 1;
45
- }
46
-
47
- .ellipsis {
48
- animation: blinker 1s linear infinite;
49
- }
50
-
51
- @keyframes blinker {
52
- 50% {
53
- opacity: 0;
54
- }
55
- }
56
- }
57
-
58
- .tooltip {
59
- position: absolute;
60
-
61
- max-width: 450px;
62
- overflow: hidden;
63
-
64
- $background-color: #f6f6f6;
65
- background: $background-color;
66
- padding: $basic-spacing;
67
- font-size: 13px;
68
-
69
- box-shadow: 0px 3px 15px 0px rgba(0, 0, 0, 0.21);
70
-
71
- pointer-events: none;
72
- z-index: 100;
73
-
74
- > :last-child {
75
- margin-bottom: 0;
76
- }
77
-
78
- > .title {
79
- padding-bottom: math.div($basic-spacing, 2);
80
- margin-bottom: math.div($basic-spacing, 2);
81
- border-bottom: 1px dashed darken($background-color, 25%);
82
- }
83
-
84
- .summary {
85
- font-size: 12px;
86
- }
87
-
88
- table {
89
- &:first-child {
90
- margin-top: 0;
91
- }
92
-
93
- border-collapse: collapse;
94
-
95
- th,
96
- td {
97
- padding: 2px 0.4em;
98
- vertical-align: top;
99
-
100
- &:first-child {
101
- padding-left: 0;
102
- }
103
- }
104
-
105
- th {
106
- text-align: left;
107
- font-weight: bold;
108
- }
109
- }
110
-
111
- .color-legend {
112
- display: inline-block;
113
- width: 0.8em;
114
- height: 0.8em;
115
- margin-left: 0.4em;
116
- box-shadow: 0px 0px 3px 1px white;
117
- }
118
-
119
- .attributes {
120
- .hovered {
121
- background-color: #e0e0e0;
122
- }
123
- }
124
-
125
- .na {
126
- color: #aaa;
127
- font-style: italic;
128
- font-size: 80%;
129
- }
130
- }
131
-
132
- .gene-track-tooltip {
133
- .summary {
134
- font-size: 90%;
135
- }
136
- }
137
-
138
- .message-box {
139
- display: flex;
140
- align-items: center;
141
- justify-content: center;
142
- position: absolute;
143
- top: 0;
144
- height: 100%;
145
- width: 100%;
146
-
147
- > div {
148
- border: 1px solid red;
149
- padding: 10px;
150
- background: #fff0f0;
151
- }
152
- }
153
- }
@@ -1,64 +0,0 @@
1
- import { html } from "lit-html";
2
- import formatObject from "../utils/formatObject";
3
-
4
- /**
5
- * @type {import("./tooltipHandler").TooltipHandler}
6
- */
7
- export default async function dataTooltipHandler(datum, mark, params) {
8
- /**
9
- * @param {string} key
10
- * @param {object} datum
11
- */
12
- const legend = (key, datum) => {
13
- for (const [channel, encoder] of Object.entries(mark.encoders)) {
14
- if (encoder?.accessor?.fields.includes(key)) {
15
- switch (channel) {
16
- case "color":
17
- case "fill":
18
- case "stroke":
19
- return html`
20
- <span
21
- class="color-legend"
22
- style=${`background-color: ${encoder(datum)}`}
23
- ></span>
24
- `;
25
- default:
26
- }
27
- }
28
- }
29
-
30
- return "";
31
- };
32
-
33
- const strippedEntries = Object.entries(datum).filter(
34
- ([key, _value]) => !key.startsWith("_")
35
- );
36
-
37
- if (strippedEntries.length === 0) {
38
- return;
39
- }
40
-
41
- const table = html`
42
- <table class="attributes">
43
- ${strippedEntries.map(
44
- ([key, value]) => html`
45
- <tr>
46
- <th>${key}</th>
47
- <td>${formatObject(value)} ${legend(key, datum)}</td>
48
- </tr>
49
- `
50
- )}
51
- </table>
52
- `;
53
-
54
- const titleText = mark.unitView.getTitleText();
55
- const title = titleText
56
- ? html`
57
- <div class="title">
58
- <strong>${titleText}</strong>
59
- </div>
60
- `
61
- : "";
62
-
63
- return html`${title}${table}`;
64
- }
@@ -1,78 +0,0 @@
1
- import { debounce } from "../utils/debounce";
2
- import { html } from "lit-html";
3
-
4
- /*
5
- * https://www.ncbi.nlm.nih.gov/books/NBK25500/
6
- *
7
- * TODO: Implement tool & email parameters: https://www.ncbi.nlm.nih.gov/books/NBK25497/
8
- */
9
-
10
- // TODO: Replace with an LRU-cache
11
- const symbolSummaryCache = new Map();
12
-
13
- /**
14
- * @type {import("./tooltipHandler").TooltipHandler}
15
- */
16
- export default async function refseqGeneTooltipHandler(datum, mark, params) {
17
- const symbol = datum.symbol;
18
-
19
- let summary =
20
- symbolSummaryCache.get(symbol) ??
21
- (await debouncedFetchGeneSummary(datum.symbol));
22
-
23
- if (summary) {
24
- symbolSummaryCache.set(symbol, summary);
25
- return html`
26
- <div class="title">
27
- <strong>${summary.name}</strong>
28
- ${summary.description}
29
- </div>
30
- <p class="summary">${summary.summary}</p>
31
- <p class="source">Source: NCBI RefSeq Gene</p>
32
- `;
33
- } else {
34
- return null;
35
- }
36
- }
37
-
38
- /**
39
- * @param {string} symbol
40
- */
41
- async function fetchGeneSummary(symbol) {
42
- // TODO: Add more search terms to ensure that we really find genes specific to the current genome
43
-
44
- console.log("Searching: " + symbol);
45
-
46
- /** @type {RequestInit} */
47
- const opts = { mode: "cors" };
48
-
49
- const searchResult = await fetch(
50
- `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=gene&term=${symbol}[GENE]&sort=relevance&retmode=json`,
51
- opts
52
- ).then((res) => res.json());
53
-
54
- // TODO: Handle failed searchs
55
- const id = searchResult.esearchresult.idlist[0];
56
-
57
- if (id) {
58
- const summaryResult = await fetch(
59
- `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&id=${id}&retmode=json`,
60
- opts
61
- ).then((res) => res.json());
62
-
63
- const summary = summaryResult.result[id];
64
- return summary;
65
- } else {
66
- return null;
67
- }
68
- }
69
-
70
- const debounced = debounce(fetchGeneSummary, 500);
71
-
72
- /**
73
- *
74
- * @param {string} symbol
75
- */
76
- function debouncedFetchGeneSummary(symbol) {
77
- return debounced(symbol);
78
- }
@@ -1,12 +0,0 @@
1
- import { TemplateResult } from "lit-html";
2
- import Mark from "../marks/mark";
3
-
4
- /**
5
- * Converts a datum to tooltip (HTMLElement or lit's TemplateResult).
6
- */
7
- export type TooltipHandler = (
8
- datum: Record<string, any>,
9
- mark: Mark,
10
- /** Optional parameters from the view specification */
11
- params?: Record<string, any>
12
- ) => Promise<string | TemplateResult | HTMLElement>;
@@ -1,14 +0,0 @@
1
- declare module "*.svg" {
2
- const content: string;
3
- export default content;
4
- }
5
-
6
- declare module "*.txt" {
7
- const content: string;
8
- export default content;
9
- }
10
-
11
- declare module "*.png" {
12
- const value: any;
13
- export = value;
14
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * Adapted from: https://github.com/mourner/flatqueue/blob/master/index.d.ts
3
- *
4
- * A version with typings is yet be released...
5
- */
6
- declare module "flatqueue" {
7
- export default class FlatQueue<T> {
8
- /**
9
- * Number of items in the queue.
10
- */
11
- readonly length: number;
12
-
13
- constructor();
14
-
15
- /**
16
- * Removes all items from the queue.
17
- */
18
- clear(): void;
19
-
20
- /**
21
- * Adds `item` to the queue with the specified `priority`.
22
- *
23
- * `priority` must be a number. Items are sorted and returned from low to
24
- * high priority. Multiple items with the same priority value can be added
25
- * to the queue, but there is no guaranteed order between these items.
26
- */
27
- push(item: T, priority: number): void;
28
-
29
- /**
30
- * Removes and returns the item from the head of this queue, which is one of
31
- * the items with the lowest priority. If this queue is empty, returns
32
- * `undefined`.
33
- */
34
- pop(): T | undefined;
35
-
36
- /**
37
- * Returns the item from the head of this queue without removing it. If this
38
- * queue is empty, returns `undefined`.
39
- */
40
- peek(): T | undefined;
41
-
42
- /**
43
- * Returns the priority value of the item at the head of this queue without
44
- * removing it. If this queue is empty, returns `undefined`.
45
- */
46
- peekValue(): number | undefined;
47
-
48
- /**
49
- * Shrinks the internal arrays to `this.length`.
50
- */
51
- shrink(): void;
52
- }
53
- }
@@ -1,4 +0,0 @@
1
- declare module "*.glsl" {
2
- const glsl: string;
3
- export default glsl;
4
- }
@@ -1,22 +0,0 @@
1
- // Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/d3-array/index.d.ts
2
-
3
- declare module "internmap" {
4
- /**
5
- * The InternMap class extends the native JavaScript Map class, allowing Dates and other non-primitive keys by bypassing the SameValueZero algorithm when determining key equality.
6
- */
7
- export class InternMap<K = any, V = any> extends Map<K, V> {
8
- constructor(
9
- entries?: readonly (readonly [K, V])[] | null,
10
- keyFunction?: KeyFunction
11
- );
12
- }
13
-
14
- /**
15
- * The InternSet class extends the native JavaScript Set class, allowing Dates and other non-primitive keys by bypassing the SameValueZero algorithm when determining key equality.
16
- */
17
- export class InternSet<T = any> extends Set<T> {
18
- constructor(values?: readonly T[] | null, keyFunction?: KeyFunction);
19
- }
20
- }
21
-
22
- type KeyFunction = (key: any) => string | number | bigint | boolean | symbol;
@@ -1,21 +0,0 @@
1
- type ObjectKeys<T> = T extends object
2
- ? (keyof T)[]
3
- : T extends number
4
- ? []
5
- : T extends Array<any> | string
6
- ? string[]
7
- : never;
8
-
9
- interface ObjectConstructor {
10
- // Source: https://fettblog.eu/typescript-better-object-keys/
11
- keys<T>(o: T): ObjectKeys<T>;
12
-
13
- // Source: https://github.com/microsoft/TypeScript/issues/35101
14
- entries<T>(
15
- o: T
16
- ): T extends ArrayLike<infer U>
17
- ? [string, U][]
18
- : { [K in keyof T]: [K, T[K]] }[keyof T][];
19
-
20
- values<T>(o: T): T extends ArrayLike<infer U> ? U[] : T[keyof T][];
21
- }
@@ -1 +0,0 @@
1
- declare module "vega-loader";
@@ -1,60 +0,0 @@
1
- type MetaDatum =
2
- | "continuous"
3
- | "discrete"
4
- | "discretizing"
5
- | "interpolating"
6
- | "log"
7
- | "temporal";
8
-
9
- type Color = string;
10
- type Interpolator<T> = (t: number) => T;
11
- type ColorInterpolator = Interpolator<Color>;
12
-
13
- declare module "vega-scale" {
14
- // TODO: Correct return type
15
- export function scale(
16
- type: string,
17
- scale: () => any,
18
- metadata: MetaDatum | MetaDatum[]
19
- ): any;
20
-
21
- export function scheme(
22
- name: string,
23
- scheme: string[] | ColorInterpolator
24
- ): void;
25
- export function scheme(name: string): ColorInterpolator;
26
-
27
- // TODO: Correct return type
28
- export function interpolate(name: string, gamma?: number): any;
29
-
30
- export function interpolateColors(
31
- colors: Color[],
32
- type?: string,
33
- gamma?: number
34
- ): ColorInterpolator;
35
-
36
- export function interpolateRange<T>(
37
- interpolator: Interpolator<T>,
38
- range: number[]
39
- ): Interpolator<T>;
40
-
41
- export function quantizeInterpolator<T>(
42
- interpolator: Interpolator<T>,
43
- count: number
44
- ): T[];
45
-
46
- export function isValidScaleType(type: string): boolean;
47
- export function isContinuous(key: string): boolean;
48
- export function isDiscrete(key: string): boolean;
49
- export function isDiscretizing(key: string): boolean;
50
- export function isLogarithmic(key: string): boolean;
51
- export function isTemporal(key: string): boolean;
52
- export function isInterpolating(key: string): boolean;
53
- export function isQuantile(key: string): boolean;
54
-
55
- export function bandSpace(
56
- count: number,
57
- paddingInner: number,
58
- paddingOuter: number
59
- ): number;
60
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * @param {string} url
3
- * @param {string} baseUrl
4
- */
5
- export default function addBaseUrl(url, baseUrl) {
6
- // Regex copied from vega-loader
7
- if (!baseUrl || /^(data:|([A-Za-z]+:)?\/\/)/.test(url)) {
8
- return url;
9
- }
10
-
11
- if (!url.startsWith("/")) {
12
- if (!baseUrl.endsWith("/")) {
13
- baseUrl += "/";
14
- }
15
- return baseUrl + url;
16
- }
17
-
18
- return url;
19
- }
@@ -1,22 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import addBaseUrl from "./addBaseUrl";
3
-
4
- test("addBaseUrl adds baseUrl when needed", () => {
5
- expect(addBaseUrl("foo.html", "https://site.com/")).toEqual(
6
- "https://site.com/foo.html"
7
- );
8
- expect(addBaseUrl("foo.html", "https://site.com")).toEqual(
9
- "https://site.com/foo.html"
10
- );
11
- expect(addBaseUrl("bar/foo.html", "https://site.com/")).toEqual(
12
- "https://site.com/bar/foo.html"
13
- );
14
- expect(addBaseUrl("../foo.html", "https://site.com/bar/")).toEqual(
15
- "https://site.com/bar/../foo.html"
16
- );
17
- });
18
-
19
- test("addBaseUrl doesn't add baseUrl when not needed", () => {
20
- expect(addBaseUrl("/foo.html", "https://site.com/")).toEqual("/foo.html");
21
- expect(addBaseUrl("foo.html", undefined)).toEqual("foo.html");
22
- });
@@ -1,83 +0,0 @@
1
- import doTransition from "./transition";
2
-
3
- export default class Animator {
4
- /**
5
- *
6
- * @param {function(number):void} renderCallback
7
- */
8
- constructor(renderCallback) {
9
- this._renderCallback = renderCallback;
10
- this._renderRequested = false;
11
- this._warn = false;
12
-
13
- /** @type {(function(number):void)[]} */
14
- this.transitions = [];
15
- }
16
-
17
- /**
18
- * Schedules a "transition" to be called before the actual rendering
19
- * is preformed. The transition could adjust the layout, for example.
20
- * This method also requests rendering to be performed.
21
- *
22
- * If the callback has already been requested (compared by identity),
23
- * it is removed from the queue and added to the end.
24
- *
25
- * @param {function(number):void} callback
26
- */
27
- requestTransition(callback) {
28
- this.cancelTransition(callback);
29
- this.transitions.push(callback);
30
- this.requestRender();
31
- }
32
-
33
- /**
34
- * @param {function(number):void} callback
35
- */
36
- cancelTransition(callback) {
37
- const existingIndex = this.transitions.indexOf(callback);
38
- if (existingIndex >= 0) {
39
- this.transitions.splice(existingIndex, 1);
40
- }
41
- }
42
-
43
- /**
44
- * Requests the request transitions and rendering callback to be called
45
- * during the next animation frame. Redundant calls to this method are safe,
46
- * they have no effect.
47
- */
48
- requestRender() {
49
- if (!this._renderRequested) {
50
- this._renderRequested = true;
51
- window.requestAnimationFrame((timestamp) => {
52
- this._renderRequested = false;
53
-
54
- const transitions = this.transitions;
55
- this.transitions = [];
56
-
57
- /** @type {function} */
58
- let transitionCallback;
59
- while ((transitionCallback = transitions.shift())) {
60
- transitionCallback(timestamp);
61
- }
62
-
63
- this._renderCallback(timestamp);
64
- });
65
- } else if (this._warn) {
66
- console.warn("Render already requested!");
67
- }
68
- }
69
-
70
- /**
71
- * Initiates a transition with a `requestAnimationFrame` that is synced
72
- * with this Animator instance.
73
- *
74
- * @param {import("./transition").TransitionOptions} options
75
- */
76
- transition(options) {
77
- return doTransition({
78
- requestAnimationFrame: (callback) =>
79
- this.requestTransition(callback),
80
- ...options,
81
- });
82
- }
83
- }
@@ -1,61 +0,0 @@
1
- /**
2
- * @param {T[]} a
3
- * @param {T[]} b
4
- * @template T
5
- */
6
- export function shallowArrayEquals(a, b) {
7
- return a.length == b.length && a.every((s, i) => a[i] === b[i]);
8
- }
9
-
10
- /**
11
- * @param {A[]} a
12
- * @param {B[]} b
13
- * @param {function(A):T} aAccessor
14
- * @param {function(B):T} bAccessor
15
- * @template A, B, T
16
- */
17
- export function shallowArrayEqualsWithAccessors(a, b, aAccessor, bAccessor) {
18
- return (
19
- a.length == b.length &&
20
- a.every((s, i) => aAccessor(a[i]) === bAccessor(b[i]))
21
- );
22
- }
23
-
24
- /**
25
- *
26
- * @param {any[]} a
27
- */
28
- export function isHomogeneous(a) {
29
- if (a.length <= 1) {
30
- return true;
31
- }
32
-
33
- const first = a[0];
34
- return a.every((x) => x === first);
35
- }
36
-
37
- /**
38
- * @param {T[] | T} obj
39
- * @returns {T[]}
40
- * @template T
41
- */
42
- export function asArray(obj) {
43
- if (Array.isArray(obj)) {
44
- return obj;
45
- } else if (typeof obj != "undefined") {
46
- return [obj];
47
- } else {
48
- return [];
49
- }
50
- }
51
-
52
- /**
53
- * Returns the last element of an array.
54
- * Like vega-util's peek but with stricter typings
55
- *
56
- * @param {T[]} arr
57
- * @template T
58
- */
59
- export function peek(arr) {
60
- return arr[arr.length - 1];
61
- }