@jbrowse/core 5.0.0-beta.10 → 5.0.0-beta.13

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 (145) hide show
  1. package/README.md +210 -80
  2. package/esm/BaseFeatureWidget/BaseFeatureDetail/ArrayValue.js +0 -2
  3. package/esm/BaseFeatureWidget/BaseFeatureDetail/Attributes.d.ts +3 -0
  4. package/esm/BaseFeatureWidget/BaseFeatureDetail/Attributes.js +14 -1
  5. package/esm/BaseFeatureWidget/BaseFeatureDetail/BasicValue.js +22 -6
  6. package/esm/BaseFeatureWidget/BaseFeatureDetail/jexlFilterActions.js +3 -4
  7. package/esm/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeatureDetails.d.ts +2 -0
  8. package/esm/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeatureDetails.js +5 -5
  9. package/esm/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeaturePanel.js +1 -1
  10. package/esm/BaseFeatureWidget/SequenceFeatureDetails/dialogs/FeatureSequenceDialog.d.ts +3 -1
  11. package/esm/BaseFeatureWidget/SequenceFeatureDetails/dialogs/FeatureSequenceDialog.js +2 -2
  12. package/esm/BaseFeatureWidget/SequenceFeatureDetails/featureTypeUtil.d.ts +2 -1
  13. package/esm/BaseFeatureWidget/SequenceFeatureDetails/featureTypeUtil.js +7 -14
  14. package/esm/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/CDNASequence.js +3 -3
  15. package/esm/BaseFeatureWidget/SequenceFeatureDetails/useSequenceData.js +8 -5
  16. package/esm/BaseFeatureWidget/stateModelFactory.d.ts +7 -0
  17. package/esm/BaseFeatureWidget/stateModelFactory.js +11 -0
  18. package/esm/BaseFeatureWidget/types.d.ts +2 -0
  19. package/esm/CorePlugin.js +32 -1
  20. package/esm/PluginManager.d.ts +6 -3
  21. package/esm/PluginManager.js +6 -3
  22. package/esm/ReExports/coreModules.generated.js +291 -283
  23. package/esm/ReExports/coreWorkerModules.generated.js +288 -281
  24. package/esm/ReExports/list.js +10 -2
  25. package/esm/TextSearch/TextSearchManager.d.ts +3 -3
  26. package/esm/TextSearch/TextSearchManager.js +6 -13
  27. package/esm/configuration/configurationSchema.d.ts +33 -95
  28. package/esm/configuration/configurationSchema.js +50 -218
  29. package/esm/configuration/configurationSlot.d.ts +18 -64
  30. package/esm/configuration/configurationSlot.js +31 -97
  31. package/esm/configuration/formatDetailsConfigSchema.js +2 -0
  32. package/esm/configuration/getConf.d.ts +7 -36
  33. package/esm/configuration/getConf.js +7 -37
  34. package/esm/configuration/index.d.ts +5 -2
  35. package/esm/configuration/index.js +3 -1
  36. package/esm/configuration/partitionAdvanced.d.ts +12 -0
  37. package/esm/configuration/partitionAdvanced.js +42 -0
  38. package/esm/configuration/plot.d.ts +67 -0
  39. package/esm/configuration/plot.js +175 -0
  40. package/esm/configuration/readConfObject.d.ts +15 -17
  41. package/esm/configuration/readConfObject.js +19 -50
  42. package/esm/configuration/schemaTypes.js +5 -1
  43. package/esm/configuration/snapshotPreprocess.js +1 -3
  44. package/esm/configuration/types.d.ts +60 -159
  45. package/esm/pluggableElementTypes/DisplayType.d.ts +14 -0
  46. package/esm/pluggableElementTypes/DisplayType.js +13 -0
  47. package/esm/pluggableElementTypes/RpcMethodType.d.ts +7 -0
  48. package/esm/pluggableElementTypes/RpcMethodType.js +9 -0
  49. package/esm/pluggableElementTypes/WidgetType.d.ts +6 -0
  50. package/esm/pluggableElementTypes/WidgetType.js +6 -0
  51. package/esm/pluggableElementTypes/addMenuItems.d.ts +2 -1
  52. package/esm/pluggableElementTypes/addMenuItems.js +2 -1
  53. package/esm/pluggableElementTypes/index.js +1 -8
  54. package/esm/pluggableElementTypes/models/BaseDisplayModel.d.ts +58 -1
  55. package/esm/pluggableElementTypes/models/BaseDisplayModel.js +84 -2
  56. package/esm/pluggableElementTypes/models/BaseTrackModel.d.ts +2 -4
  57. package/esm/pluggableElementTypes/models/BaseTrackModel.js +2 -4
  58. package/esm/pluggableElementTypes/models/BaseViewModel.d.ts +2 -2
  59. package/esm/pluggableElementTypes/models/BaseViewModel.js +1 -1
  60. package/esm/pluggableElementTypes/models/baseTrackConfig.js +3 -0
  61. package/esm/rpc/RpcRegistry.d.ts +2 -1
  62. package/esm/rpc/byteBudget.d.ts +7 -0
  63. package/esm/rpc/byteBudget.js +10 -0
  64. package/esm/rpc/coreRpcMethods.d.ts +1 -1
  65. package/esm/rpc/coreRpcMethods.js +1 -1
  66. package/esm/rpc/explainTransferError.js +3 -3
  67. package/esm/rpc/methods/CoreLoadTrackCode.d.ts +17 -0
  68. package/esm/rpc/methods/CoreLoadTrackCode.js +24 -0
  69. package/esm/ui/AppLogo.js +43 -3
  70. package/esm/ui/JexlFilterDialog.d.ts +1 -1
  71. package/esm/ui/JexlFilterDialog.js +2 -3
  72. package/esm/ui/buildExtraTrackMenuItems.d.ts +2 -2
  73. package/esm/ui/colors.d.ts +41 -30
  74. package/esm/ui/colors.js +81 -44
  75. package/esm/ui/multiTrackMenuItems.d.ts +2 -2
  76. package/esm/util/TimeTraveller.d.ts +3 -0
  77. package/esm/util/TimeTraveller.js +34 -2
  78. package/esm/util/alignedBytes.d.ts +19 -0
  79. package/esm/util/alignedBytes.js +37 -0
  80. package/esm/util/analytics.d.ts +5 -6
  81. package/esm/util/analytics.js +5 -3
  82. package/esm/util/baseDisplayConfig.d.ts +8 -0
  83. package/esm/util/baseDisplayConfig.js +27 -0
  84. package/esm/util/bezierConnector.js +5 -1
  85. package/esm/util/cachedSetup.d.ts +16 -6
  86. package/esm/util/cachedSetup.js +108 -38
  87. package/esm/util/categoricalField.d.ts +23 -3
  88. package/esm/util/categoricalField.js +36 -3
  89. package/esm/util/cellMatches.d.ts +23 -0
  90. package/esm/util/cellMatches.js +264 -0
  91. package/esm/util/cellsStep.d.ts +27 -0
  92. package/esm/util/cellsStep.js +439 -0
  93. package/esm/util/color-bits/parse.js +22 -11
  94. package/esm/util/colorRamp.js +6 -0
  95. package/esm/util/colorScale.d.ts +9 -2
  96. package/esm/util/colorScale.js +33 -2
  97. package/esm/util/colorSchemes.d.ts +4 -2
  98. package/esm/util/colorSchemes.js +4 -1
  99. package/esm/util/copyToClipboard.js +8 -1
  100. package/esm/util/createAbortRotation.js +3 -3
  101. package/esm/util/featureTransforms.d.ts +7 -6
  102. package/esm/util/featureTransforms.js +131 -479
  103. package/esm/util/fetchPhases.d.ts +1 -1
  104. package/esm/util/formatBytes.js +1 -1
  105. package/esm/util/formatGuessers.d.ts +25 -14
  106. package/esm/util/formatGuessers.js +42 -27
  107. package/esm/util/formatRelativeTime.js +1 -1
  108. package/esm/util/getLocationUri.d.ts +2 -1
  109. package/esm/util/getLocationUri.js +8 -2
  110. package/esm/util/groupKeys.d.ts +4 -5
  111. package/esm/util/groupKeys.js +7 -6
  112. package/esm/util/intervals.js +9 -4
  113. package/esm/util/io/index.js +3 -1
  114. package/esm/util/isoformRank.d.ts +39 -0
  115. package/esm/util/isoformRank.js +118 -0
  116. package/esm/util/jexlFilters.d.ts +31 -49
  117. package/esm/util/jexlFilters.js +29 -39
  118. package/esm/util/locString.js +5 -2
  119. package/esm/util/markEncoding.js +48 -8
  120. package/esm/util/markEncodingTypes.d.ts +11 -2
  121. package/esm/util/quantileExtent.d.ts +22 -0
  122. package/esm/util/quantileExtent.js +24 -1
  123. package/esm/util/springAnimate.js +1 -1
  124. package/esm/util/stepTables.d.ts +14 -0
  125. package/esm/util/stepTables.js +38 -4
  126. package/esm/util/systemColorScheme.d.ts +4 -0
  127. package/esm/util/systemColorScheme.js +21 -0
  128. package/esm/util/tabix.d.ts +7 -3
  129. package/esm/util/tabix.js +3 -3
  130. package/esm/util/temporaryAssembly.d.ts +2 -2
  131. package/esm/util/temporaryAssembly.js +2 -3
  132. package/esm/util/trackConfigDelta.d.ts +1 -1
  133. package/esm/util/tracks.d.ts +28 -45
  134. package/esm/util/tracks.js +71 -82
  135. package/esm/util/types/index.d.ts +15 -7
  136. package/esm/util/types/index.js +21 -2
  137. package/esm/util/unknownSnapshotKeys.d.ts +3 -1
  138. package/esm/util/unknownSnapshotKeys.js +5 -11
  139. package/esm/util/usePanZoom.js +10 -3
  140. package/esm/util/useRafCommit.js +1 -0
  141. package/esm/util/useRowVirtualScroll.d.ts +1 -0
  142. package/esm/util/withFeatureDetails.js +4 -0
  143. package/package.json +13 -9
  144. package/esm/rpc/methods/CoreLoadAdapterCode.d.ts +0 -13
  145. package/esm/rpc/methods/CoreLoadAdapterCode.js +0 -16
@@ -36,12 +36,12 @@ export function parseLocStringOneBased(locString, isValidRefName) {
36
36
  throw new Error('no location string provided, could not parse');
37
37
  }
38
38
  // handle reverse strand notation e.g. "chr1:1-100[rev]"
39
+ locString = locString.replaceAll(/\s/g, '');
39
40
  let reversed = false;
40
41
  if (locString.endsWith('[rev]')) {
41
42
  reversed = true;
42
43
  locString = locString.slice(0, -5);
43
44
  }
44
- locString = locString.replaceAll(/\s/g, '');
45
45
  // extract optional assembly name in braces e.g. "{hg19}chr1:1-100"
46
46
  const assemblyMatch = ASSEMBLY_REGEX.exec(locString);
47
47
  if (!assemblyMatch) {
@@ -174,7 +174,10 @@ function assembleLocStringWith(region, cb = (n) => n) {
174
174
  }
175
175
  let endString;
176
176
  if (end !== undefined) {
177
- endString = start !== undefined && start + 1 === end ? '' : `..${cb(end)}`;
177
+ endString =
178
+ start !== undefined && (start + 1 === end || start === end)
179
+ ? ''
180
+ : `..${cb(end)}`;
178
181
  }
179
182
  else {
180
183
  endString = start !== undefined ? '..' : '';
@@ -51,6 +51,22 @@ function channelReader(table, ref, jexl) {
51
51
  const read = fieldReader(ref, jexl);
52
52
  return i => read(table.row(i));
53
53
  }
54
+ // A text channel's reader, printing a float32 lane's value at the digits the
55
+ // lane holds rather than the double it widens to: 0.3865, not 0.3865000009.
56
+ function textChannelReader(table, ref, jexl) {
57
+ const read = channelReader(table, ref, jexl);
58
+ const column = typeof ref !== 'function' && isPlainFieldRef(ref)
59
+ ? table.column(ref)
60
+ : undefined;
61
+ return column?.kind === 'number' && column.values instanceof Float32Array
62
+ ? i => {
63
+ const v = read(i);
64
+ return typeof v === 'number' && !Number.isInteger(v)
65
+ ? String(Number(v.toPrecision(7)))
66
+ : valueText(v);
67
+ }
68
+ : i => valueText(read(i));
69
+ }
54
70
  function numberChannelReader(table, ref, jexl) {
55
71
  if (typeof ref !== 'function' && isPlainFieldRef(ref)) {
56
72
  return numberReaderOf(table.column(ref));
@@ -457,10 +473,10 @@ export function encodeFeatures(input, encoding, lanes, ctx = {}) {
457
473
  text.fill('');
458
474
  }
459
475
  else {
460
- const read = channelReader(table, textEncoding, jexl);
476
+ const read = textChannelReader(table, textEncoding, jexl);
461
477
  for (let k = 0; k < count; k++) {
462
478
  report?.(k);
463
- text[k] = valueText(read(rowAt(k)));
479
+ text[k] = read(rowAt(k));
464
480
  }
465
481
  }
466
482
  }
@@ -519,30 +535,47 @@ export function encodeFeatures(input, encoding, lanes, ctx = {}) {
519
535
  ? y
520
536
  : new Float32Array(count)
521
537
  : undefined;
522
- const paintsColor = has('color') && !colorValue;
538
+ const colorKey = declaredScale?.scale === 'categorical' && has('colorKey')
539
+ ? new Uint32Array(count)
540
+ : undefined;
541
+ const paintsColor = has('color') && !colorValue && !colorKey;
523
542
  const unscaled = paintsColor && declaredScale?.scale !== 'categorical' && !quantitative
524
543
  ? unscaledColor(table, colorEncoding, jexl)
525
544
  : undefined;
526
545
  const color = paintsColor && typeof unscaled !== 'number'
527
546
  ? new Uint32Array(count)
528
547
  : undefined;
529
- const scaled = paintsColor || colorValue ? declaredScale : undefined;
548
+ const scaled = paintsColor || colorValue || colorKey ? declaredScale : undefined;
549
+ const categoryLane = colorKey ?? color;
530
550
  let scale;
531
551
  let missingMet = false;
532
552
  let notNumberMet = false;
533
- if (scaled?.scale === 'categorical' && color) {
553
+ if (scaled?.scale === 'categorical' && categoryLane) {
534
554
  const colorField = categoricalField(scaled.field, {
535
555
  domain: scaled.domain?.map(String),
536
556
  range: scaled.range,
537
557
  });
538
- const entries = paintCategories(table, scaled.field, jexl, colorField, { kept, count, report }, color, key => cssColorToABGR(colorField.color(key)), abgr => abgr);
558
+ let resolved = 0;
559
+ const entries = paintCategories(table, scaled.field, jexl, colorField, { kept, count, report }, categoryLane, key => ({
560
+ color: cssColorToABGR(colorField.color(key)),
561
+ order: resolved++,
562
+ }), entry => (colorKey ? entry.order : entry.color));
563
+ if (colorKey) {
564
+ const position = new Uint32Array(resolved);
565
+ for (const [i, e] of entries.entries()) {
566
+ position[e.entry.order] = i;
567
+ }
568
+ for (let k = 0; k < count; k++) {
569
+ colorKey[k] = position[colorKey[k]];
570
+ }
571
+ }
539
572
  scale = {
540
573
  kind: 'categorical',
541
574
  field: scaled.field,
542
575
  domain: [...colorField.domain],
543
576
  ...(scaled.range ? { range: [...scaled.range] } : {}),
544
577
  ...(keysAreNumeric(entries) ? { numericKeys: true } : {}),
545
- entries: entries.map(e => ({ value: e.value, color: e.entry })),
578
+ entries: entries.map(e => ({ value: e.value, color: e.entry.color })),
546
579
  };
547
580
  }
548
581
  else if (scaled && quantitative) {
@@ -570,10 +603,13 @@ export function encodeFeatures(input, encoding, lanes, ctx = {}) {
570
603
  const cuts = thresholdCuts(thresholdEncoding.domain ?? []);
571
604
  if (color) {
572
605
  const binColors = Uint32Array.from(thresholdPalette(cuts.length + 1, thresholdEncoding.range), c => cssColorToABGR(c));
606
+ // in float32 on both sides, as the shader and the key compare, so a
607
+ // value off a float32 lane sits at a cut like 0.7 rather than under it
608
+ const cuts32 = cuts.map(cut => Math.fround(cut));
573
609
  for (let k = 0; k < count; k++) {
574
610
  report?.(k);
575
611
  const v = read(rowAt(k));
576
- const bin = thresholdIndex(v, cuts);
612
+ const bin = thresholdIndex(Math.fround(numericValue(v)), cuts32);
577
613
  if (bin >= 0) {
578
614
  color[k] = binColors[bin];
579
615
  }
@@ -656,6 +692,9 @@ export function encodeFeatures(input, encoding, lanes, ctx = {}) {
656
692
  // the y view itself where the colour reads y, so a reader can tell
657
693
  encoded.colorValue = colorValue;
658
694
  }
695
+ if (colorKey) {
696
+ encoded.colorKey = colorKey;
697
+ }
659
698
  if (glyph) {
660
699
  encoded.glyph = glyph;
661
700
  }
@@ -830,6 +869,7 @@ export function encodedChannelTransferables(c) {
830
869
  c.row,
831
870
  typeof c.color === 'number' ? undefined : c.color,
832
871
  c.colorValue,
872
+ c.colorKey,
833
873
  c.glyph,
834
874
  c.size,
835
875
  c.x2Ref,
@@ -149,7 +149,7 @@ export interface MarkEncoding {
149
149
  * allocated nor transferred, and a caller that never hovers declines the
150
150
  * index, which is most of the encoder's cost after the walk.
151
151
  */
152
- export type LaneName = 'y' | 'color' | 'colorValue' | 'glyph' | 'row' | 'text' | 'size' | 'x2Ref' | 'index';
152
+ export type LaneName = 'y' | 'color' | 'colorValue' | 'colorKey' | 'glyph' | 'row' | 'text' | 'size' | 'x2Ref' | 'index';
153
153
  /**
154
154
  * #api
155
155
  * The scale a colour channel was resolved through, as the legend reads it —
@@ -318,6 +318,13 @@ export interface EncodedChannels {
318
318
  * colour reads the field `y` plots, this IS the `y` array, not a copy.
319
319
  */
320
320
  colorValue?: Float32Array;
321
+ /**
322
+ * Each instance's index into `scale.entries` under a categorical colour, for
323
+ * a caller that named the `colorKey` lane in place of `color`: the display
324
+ * then paints each key through its own `domain` and `range`, which never
325
+ * reach the worker.
326
+ */
327
+ colorKey?: Uint32Array;
321
328
  /** The point painter's code for each feature's `shape`. */
322
329
  glyph?: Uint8Array;
323
330
  row?: Uint32Array;
@@ -456,7 +463,9 @@ export interface AggregateStep {
456
463
  * #api
457
464
  * Replace the features with runs of constant depth: how many of them overlap
458
465
  * each stretch of the region, in a field `as` (`coverage` by default), with
459
- * the stretches nothing overlaps left out.
466
+ * the stretches nothing overlaps left out. A read counts across its whole
467
+ * span, deletions and introns included; gap-aware depth stays the alignments
468
+ * display's (ADR-118).
460
469
  */
461
470
  export interface CoverageStep {
462
471
  type: 'coverage';
@@ -1,5 +1,7 @@
1
1
  /** The quantile "Clip outliers" clips at on a scale whose own default is the extremes. */
2
2
  export declare const DEFAULT_CLIP_QUANTILE = 0.99;
3
+ /** The lowest `domainQuantile` a scale reads, where its two ends meet; one below reads as this. */
4
+ export declare const MIN_DOMAIN_QUANTILE = 0.5;
3
5
  /**
4
6
  * #api
5
7
  * The quantile a clip toggle writes: a scale's declared default where that
@@ -37,8 +39,28 @@ export declare function quantileOf(a: Float32Array, n: number, quantile: number)
37
39
  * where the ends meet rather than cross. `scales.y.domainQuantile` and a
38
40
  * colour's `domainQuantile` both name it. `[Infinity, -Infinity]` where
39
41
  * nothing is finite.
42
+ *
43
+ * Nearest rank keeps ties: where one value holds the rank, as on a segmented
44
+ * copy-number track, a ramp clipped below 1 paints nearly every value one
45
+ * colour. A value axis fences instead ({@link fenceOutliers}); a ramp takes
46
+ * the same fence once a colour default below 1 meets tied data.
40
47
  */
41
48
  export declare function quantileExtent(values: ArrayLike<number>, count: number, quantile?: number): [number, number];
49
+ /**
50
+ * #api
51
+ * Where a value axis's open ends stand below a `domainQuantile` of 1: at the
52
+ * `extremes`, unless one would stretch the axis past twice the span the
53
+ * {@link quantileExtent} ends `quantiles` draw, 0 included where the axis
54
+ * reaches it (`zero`); that end stops at the fence. So a plot with no spike
55
+ * shows every value and cuts none, and a spike leaves the values under it at
56
+ * least half the axis. Quantiles that meet span their own size, as a flat
57
+ * domain widens in `getNiceDomain`.
58
+ */
59
+ export declare function fenceOutliers({ extremes, quantiles, zero, }: {
60
+ extremes: readonly [number, number];
61
+ quantiles: readonly [number, number];
62
+ zero: boolean;
63
+ }): [number, number];
42
64
  /**
43
65
  * #api
44
66
  * {@link quantileExtent} as a scale's open ends read it: over every finite
@@ -1,5 +1,7 @@
1
1
  /** The quantile "Clip outliers" clips at on a scale whose own default is the extremes. */
2
2
  export const DEFAULT_CLIP_QUANTILE = 0.99;
3
+ /** The lowest `domainQuantile` a scale reads, where its two ends meet; one below reads as this. */
4
+ export const MIN_DOMAIN_QUANTILE = 0.5;
3
5
  /**
4
6
  * #api
5
7
  * The quantile a clip toggle writes: a scale's declared default where that
@@ -111,12 +113,17 @@ function lowQuantileOf(a, n, quantile) {
111
113
  * where the ends meet rather than cross. `scales.y.domainQuantile` and a
112
114
  * colour's `domainQuantile` both name it. `[Infinity, -Infinity]` where
113
115
  * nothing is finite.
116
+ *
117
+ * Nearest rank keeps ties: where one value holds the rank, as on a segmented
118
+ * copy-number track, a ramp clipped below 1 paints nearly every value one
119
+ * colour. A value axis fences instead ({@link fenceOutliers}); a ramp takes
120
+ * the same fence once a colour default below 1 meets tied data.
114
121
  */
115
122
  export function quantileExtent(values, count, quantile = 1) {
116
123
  if (!(quantile < 1)) {
117
124
  return finiteExtremes(values, count);
118
125
  }
119
- const q = Math.max(0.5, quantile);
126
+ const q = Math.max(MIN_DOMAIN_QUANTILE, quantile);
120
127
  const positive = new Float32Array(count);
121
128
  const negative = new Float32Array(count);
122
129
  let np = 0;
@@ -139,6 +146,22 @@ export function quantileExtent(values, count, quantile = 1) {
139
146
  const high = np > 0 ? quantileOf(positive, np, q) : quantileOf(negative, nn, q);
140
147
  return [Math.min(low, high), high];
141
148
  }
149
+ /**
150
+ * #api
151
+ * Where a value axis's open ends stand below a `domainQuantile` of 1: at the
152
+ * `extremes`, unless one would stretch the axis past twice the span the
153
+ * {@link quantileExtent} ends `quantiles` draw, 0 included where the axis
154
+ * reaches it (`zero`); that end stops at the fence. So a plot with no spike
155
+ * shows every value and cuts none, and a spike leaves the values under it at
156
+ * least half the axis. Quantiles that meet span their own size, as a flat
157
+ * domain widens in `getNiceDomain`.
158
+ */
159
+ export function fenceOutliers({ extremes, quantiles, zero, }) {
160
+ const lo = zero ? Math.min(0, quantiles[0]) : quantiles[0];
161
+ const hi = zero ? Math.max(0, quantiles[1]) : quantiles[1];
162
+ const span = hi - lo || Math.abs(hi) || 1;
163
+ return [Math.max(extremes[0], lo - span), Math.min(extremes[1], hi + span)];
164
+ }
142
165
  /**
143
166
  * #api
144
167
  * {@link quantileExtent} as a scale's open ends read it: over every finite
@@ -61,7 +61,7 @@ export function springAnimate({ from, to, write, read, onFinish = () => { }, pre
61
61
  animationFrameId = requestAnimationFrame(() => {
62
62
  update({
63
63
  lastPosition: position,
64
- lastTime: time,
64
+ lastTime: lastTime + numSteps,
65
65
  lastVelocity: velocity,
66
66
  });
67
67
  });
@@ -1,3 +1,4 @@
1
+ import { DerivedTable } from './featureTable.ts';
1
2
  import type { Column, FeatureTable, MadeRows } from './featureTable.ts';
2
3
  import type { AggregateOp, AggregateStep, BinStep } from './markEncodingTypes.ts';
3
4
  import type { Feature, SimpleFeatureSerialized } from './simpleFeature.ts';
@@ -15,6 +16,19 @@ export interface Staged {
15
16
  table: FeatureTable;
16
17
  bounds: Bounds;
17
18
  }
19
+ export declare function boundsThrough(bounds: Bounds, parentRow: Uint32Array): Bounds;
20
+ /**
21
+ * The entries a `flatten` fanned out, one row each over the container row it
22
+ * came from. A container kept with nothing to fan out is a row of its own
23
+ * that reads everything off itself.
24
+ */
25
+ export declare abstract class FannedTable extends DerivedTable {
26
+ get madeFrom(): boolean;
27
+ /** A container kept with nothing to fan out: the row is the container. */
28
+ abstract isKept(i: number): boolean;
29
+ abstract get hasKept(): boolean;
30
+ row(i: number): Feature;
31
+ }
18
32
  export declare function stepReader(table: FeatureTable, ref: string, step: string): (i: number) => unknown;
19
33
  export declare function stepNumberReader(table: FeatureTable, ref: string, step: string): (i: number) => number;
20
34
  export declare function groupKey(value: unknown): unknown;
@@ -1,14 +1,48 @@
1
- // The pieces of the transform steps that the fused bin-and-aggregate kernel
2
- // shares with the steps themselves. Imported by relative path only, so none
3
- // of it is a package subpath or part of the plugin ABI.
1
+ // The pieces of the transform steps that the fused kernels share with the
2
+ // steps themselves. Imported by relative path only, so none of it is a
3
+ // package subpath or part of the plugin ABI.
4
4
  import { aggregateFieldName } from './aggregateFieldName.js';
5
- import { NO_COLUMN, TableRow, numberReaderOf, readerOf, valueAt, } from './featureTable.js';
5
+ import { DerivedTable, NO_COLUMN, TableRow, numberReaderOf, readerOf, valueAt, } from './featureTable.js';
6
6
  import { fieldReader, isPlainFieldRef } from './fieldReader.js';
7
7
  import { isJexl } from './jexlStrings.js';
8
8
  import { numericValue } from './numericValue.js';
9
9
  export const DEFAULT_BIN_AS = ['start', 'end'];
10
10
  /** What a `bin` over `fields` writes on each piece: the bases of its interval inside its bin. */
11
11
  export const BIN_OVERLAP_FIELD = 'overlap';
12
+ // Section starts through a step whose rows came from its input's in order:
13
+ // each section starts at the first row whose parent row is in it.
14
+ export function boundsThrough(bounds, parentRow) {
15
+ const out = new Uint32Array(bounds.length);
16
+ let lo = 0;
17
+ for (let s = 0; s < bounds.length; s++) {
18
+ const edge = bounds[s];
19
+ let hi = parentRow.length;
20
+ while (lo < hi) {
21
+ const mid = (lo + hi) >>> 1;
22
+ if (parentRow[mid] < edge) {
23
+ lo = mid + 1;
24
+ }
25
+ else {
26
+ hi = mid;
27
+ }
28
+ }
29
+ out[s] = lo;
30
+ }
31
+ return out;
32
+ }
33
+ /**
34
+ * The entries a `flatten` fanned out, one row each over the container row it
35
+ * came from. A container kept with nothing to fan out is a row of its own
36
+ * that reads everything off itself.
37
+ */
38
+ export class FannedTable extends DerivedTable {
39
+ get madeFrom() {
40
+ return true;
41
+ }
42
+ row(i) {
43
+ return this.isKept(i) ? this.parent.row(this.parentOf(i)) : super.row(i);
44
+ }
45
+ }
12
46
  // A step reads a name or a dotted path. A plain name reads the table's column;
13
47
  // a path walks each row, chosen once per step. A computed field is a `formula`
14
48
  // step's to make.
@@ -10,3 +10,7 @@ export declare function prefersDarkColorScheme(): boolean;
10
10
  * one preference, and a second spelling of the query is a second answer.
11
11
  */
12
12
  export declare function onColorSchemeChange(listener: () => void): () => void;
13
+ /** Whether Dark Reader darkens the page around canvases it leaves light. */
14
+ export declare function darkReaderIsDark(): boolean;
15
+ /** Call `listener` whenever Dark Reader's scheme mark changes, and return the unsubscribe. */
16
+ export declare function onDarkReaderChange(listener: () => void): () => void;
@@ -25,3 +25,24 @@ export function onColorSchemeChange(listener) {
25
25
  media?.removeEventListener('change', listener);
26
26
  };
27
27
  }
28
+ const DARK_READER_ATTRIBUTE = 'data-darkreader-scheme';
29
+ /** Whether Dark Reader darkens the page around canvases it leaves light. */
30
+ export function darkReaderIsDark() {
31
+ return (typeof document !== 'undefined' &&
32
+ document.documentElement.getAttribute(DARK_READER_ATTRIBUTE) === 'dark');
33
+ }
34
+ /** Call `listener` whenever Dark Reader's scheme mark changes, and return the unsubscribe. */
35
+ export function onDarkReaderChange(listener) {
36
+ if (typeof MutationObserver !== 'function' ||
37
+ typeof document === 'undefined') {
38
+ return () => { };
39
+ }
40
+ const observer = new MutationObserver(listener);
41
+ observer.observe(document.documentElement, {
42
+ attributes: true,
43
+ attributeFilter: [DARK_READER_ATTRIBUTE],
44
+ });
45
+ return () => {
46
+ observer.disconnect();
47
+ };
48
+ }
@@ -90,7 +90,9 @@ export declare function readTabixLinesRedispatched(file: TabixLineSource, query:
90
90
  * structural for the same reason as {@link TabixLineSource}.
91
91
  */
92
92
  interface TabixHeaderSource {
93
- getHeaderLines(): Promise<string[]>;
93
+ getHeaderLines(opts?: {
94
+ signal?: AbortSignal;
95
+ }): Promise<string[]>;
94
96
  }
95
97
  /**
96
98
  * The header lines of a tabix-indexed file, however that file kept them.
@@ -111,7 +113,7 @@ interface TabixHeaderSource {
111
113
  * An adapter that stops at `getHeader()` therefore cannot tell "this file has
112
114
  * no header" from "this file's header is not commented", and quietly falls back
113
115
  * to an assumed column layout. That has cost real information more than once: a
114
- * PLINK LD file lost its D' column, so `ldMetric: 'dprime'` silently served r²,
116
+ * PLINK LD file lost its D' column, so `color.field: 'dprime'` silently served r²,
115
117
  * and a bedGraph loses the names of its value columns. Nothing errors, because
116
118
  * the assumed layout parses.
117
119
  *
@@ -121,5 +123,7 @@ interface TabixHeaderSource {
121
123
  * commented block and then the counted rows used to fetch and decompress the
122
124
  * same bytes twice, which every bare-header file did on every call.
123
125
  */
124
- export declare function readTabixHeaderLines(file: TabixHeaderSource): Promise<string[]>;
126
+ export declare function readTabixHeaderLines(file: TabixHeaderSource, opts?: {
127
+ signal?: AbortSignal;
128
+ }): Promise<string[]>;
125
129
  export {};
package/esm/util/tabix.js CHANGED
@@ -133,7 +133,7 @@ function mergeTabixLines(...groups) {
133
133
  * An adapter that stops at `getHeader()` therefore cannot tell "this file has
134
134
  * no header" from "this file's header is not commented", and quietly falls back
135
135
  * to an assumed column layout. That has cost real information more than once: a
136
- * PLINK LD file lost its D' column, so `ldMetric: 'dprime'` silently served r²,
136
+ * PLINK LD file lost its D' column, so `color.field: 'dprime'` silently served r²,
137
137
  * and a bedGraph loses the names of its value columns. Nothing errors, because
138
138
  * the assumed layout parses.
139
139
  *
@@ -143,6 +143,6 @@ function mergeTabixLines(...groups) {
143
143
  * commented block and then the counted rows used to fetch and decompress the
144
144
  * same bytes twice, which every bare-header file did on every call.
145
145
  */
146
- export function readTabixHeaderLines(file) {
147
- return file.getHeaderLines();
146
+ export function readTabixHeaderLines(file, opts) {
147
+ return file.getHeaderLines(opts);
148
148
  }
@@ -1,4 +1,4 @@
1
- import type { AnyConfigurationModel } from '../configuration/index.ts';
1
+ import type { AnyConfiguration } from '../configuration/index.ts';
2
2
  /**
3
3
  * Whether a track config names an assembly the session holds as **temporary** —
4
4
  * the read-vs-ref pair a comparative view synthesizes, which goes away when that
@@ -18,4 +18,4 @@ import type { AnyConfigurationModel } from '../configuration/index.ts';
18
18
  * answer is yes. A second copy of the predicate is the thing to avoid — a copied
19
19
  * guard is where the escape clause gets added to only one of them.
20
20
  */
21
- export declare function namesTemporaryAssembly(session: unknown, trackConf: AnyConfigurationModel | Record<string, unknown>): boolean;
21
+ export declare function namesTemporaryAssembly(session: unknown, trackConf: AnyConfiguration): boolean;
@@ -1,4 +1,4 @@
1
- import { readConfObject } from '../configuration/index.js';
1
+ import { getConfAssemblyNamesOrNone } from './tracks.js';
2
2
  /**
3
3
  * Whether a track config names an assembly the session holds as **temporary** —
4
4
  * the read-vs-ref pair a comparative view synthesizes, which goes away when that
@@ -24,6 +24,5 @@ export function namesTemporaryAssembly(session, trackConf) {
24
24
  if (!temporary?.length) {
25
25
  return false;
26
26
  }
27
- const names = readConfObject(trackConf, 'assemblyNames');
28
- return !!names?.some(name => temporary.some(a => a.name === name));
27
+ return getConfAssemblyNamesOrNone(trackConf).some(name => temporary.some(a => a.name === name));
29
28
  }
@@ -53,7 +53,7 @@ export declare function diffTrackConfig(base: Record<string, unknown>, edited: R
53
53
  * longer has is dropped, so no `null` member reaches the config a track
54
54
  * hydrates from.
55
55
  */
56
- export declare function mergeTrackConfig(base: Record<string, unknown>, delta: Record<string, unknown>): Record<string, unknown>;
56
+ export declare function mergeTrackConfig<BASE extends Record<string, unknown>>(base: BASE, delta: Record<string, unknown>): BASE;
57
57
  /**
58
58
  * A single overridden slot: the dotted `path`, its base `from` and edited `to`,
59
59
  * which is `undefined` for a reset.
@@ -1,7 +1,10 @@
1
1
  export { getFileName } from './getFileName.ts';
2
2
  export { getRpcSessionId } from './parentWalk.ts';
3
+ export { makeIndex } from './formatGuessers.ts';
4
+ export { isLooseTrackConfig, type LooseTrackInput, } from '@jbrowse/add-track-core';
5
+ import { type LooseTrackInput } from '@jbrowse/add-track-core';
3
6
  import type PluginManager from '../PluginManager.ts';
4
- import type { AnyConfigurationModel } from '../configuration/index.ts';
7
+ import type { AnyConfiguration, AnyConfigurationModel, AnyTrackConfig, TrackConfigEntry } from '../configuration/index.ts';
5
8
  import type { BlobLocation, FileHandleLocation, FileLocation, PreFileLocation } from './types/data.ts';
6
9
  import type { AbstractViewContainer } from './types/index.ts';
7
10
  import type { IAnyStateTreeNode, IAnyType, IStateTreeNode, Instance, types } from '@jbrowse/mobx-state-tree';
@@ -65,7 +68,7 @@ export declare function canonicalAssemblyNames(names: string[], assemblyManager:
65
68
  * to compare equal to themselves.
66
69
  */
67
70
  export declare function isSameAssemblyName(a: string | undefined, b: string | undefined, assemblyManager: AssemblyNameResolver): boolean;
68
- export declare function getConfAssemblyNames(conf: AnyConfigurationModel): string[];
71
+ export declare function getConfAssemblyNames(conf: AnyConfiguration): string[];
69
72
  /**
70
73
  * {@link getConfAssemblyNames} for a caller that cannot afford its throw — a
71
74
  * config answering neither way leaves the question unanswered instead.
@@ -77,7 +80,12 @@ export declare function getConfAssemblyNames(conf: AnyConfigurationModel): strin
77
80
  * answers `[]` for a ReferenceSequenceTrack whose assembly this already knows
78
81
  * how to name.
79
82
  */
80
- export declare function getConfAssemblyNamesOrNone(conf: AnyConfigurationModel): string[];
83
+ export declare function getConfAssemblyNamesOrNone(conf: AnyConfiguration): string[];
84
+ /**
85
+ * A track config as a frozen entry: `conf` itself, or a live node's snapshot.
86
+ * Either way a slot at its default is absent, so a read supplies the default.
87
+ */
88
+ export declare function toTrackConfigEntry(conf: AnyTrackConfig): TrackConfigEntry;
81
89
  /**
82
90
  * The RPC session id a track's own requests go out under, from its config:
83
91
  * what `BaseTrackModel.rpcSessionId` computes, for a caller holding no model.
@@ -132,23 +140,6 @@ export declare function restoreFileHandlesFromSnapshot(sessionSnapshot: unknown,
132
140
  success: false;
133
141
  error: unknown;
134
142
  })[]>;
135
- /**
136
- * creates a new location from the provided location including the appropriate
137
- * suffix and location type
138
- *
139
- * @param location - the FileLocation
140
- * @param suffix - the file suffix (e.g. .bam)
141
- * @returns the constructed location object from the provided parameters
142
- */
143
- export declare function makeIndex(location: FileLocation, suffix: string): BlobLocation | FileHandleLocation | {
144
- uri: string;
145
- locationType: string;
146
- baseUri?: string | undefined;
147
- localPath?: undefined;
148
- } | {
149
- localPath: string;
150
- locationType: string;
151
- };
152
143
  /**
153
144
  * constructs a potential index file (with suffix) from the provided file name
154
145
  *
@@ -227,12 +218,6 @@ export declare function addTrackTypeGuesser(pluginManager: PluginManager, guess:
227
218
  export declare function stripFileExtension(name: string): string;
228
219
  export declare function guessAdapter(file: FileLocation, index: FileLocation | undefined, adapterHint?: string, model?: IAnyStateTreeNode): AdapterConfig;
229
220
  export declare function guessTrackType(adapterType: string, model?: IAnyStateTreeNode, file?: FileLocation): string;
230
- export interface LooseTrackInput {
231
- uri: string;
232
- index?: string;
233
- baseUri?: string;
234
- [key: string]: unknown;
235
- }
236
221
  /**
237
222
  * Expand a loose track description — a bare data-file URI, or an object with
238
223
  * `uri` (and optional `index`) plus any extra config keys — into a full track
@@ -268,13 +253,6 @@ export declare function guessTrackConfForLocation(file: FileLocation, index: Fil
268
253
  assemblyNames: string[];
269
254
  adapter: AdapterConfig;
270
255
  };
271
- /**
272
- * Whether a track snapshot is the loose `{ uri, ... }` form — a data file with
273
- * no `adapter` — that {@link expandLooseTrackConfig} expands.
274
- */
275
- export declare function isLooseTrackConfig(snap: unknown): snap is LooseTrackInput & {
276
- trackId?: string;
277
- };
278
256
  /**
279
257
  * Expand a loose track config into a full one and leave any other snapshot
280
258
  * untouched, so it can sit on every path a track snapshot enters the tree by:
@@ -304,11 +282,7 @@ export declare function generateUnknownTrackConf(trackName: string, trackUrl: st
304
282
  category: string[] | undefined;
305
283
  trackId: string;
306
284
  };
307
- export declare function getTrackName(conf: AnyConfigurationModel | {
308
- name?: string;
309
- type?: string;
310
- trackId?: string;
311
- }, session: {
285
+ export declare function getTrackName(conf: AnyConfiguration, session: {
312
286
  assemblies: AnyConfigurationModel[];
313
287
  }): string;
314
288
  type MSTArray<T extends IAnyType> = Instance<ReturnType<typeof types.array<T>>>;
@@ -374,22 +348,22 @@ export declare function viewCanDisplayTrack(pluginManager: PluginManager, viewDi
374
348
  * and every other picker that opens a track into a view read this one answer,
375
349
  * or one of them offers a track the next hides.
376
350
  */
377
- export declare function filterTracks(tracks: AnyConfigurationModel[], self: {
351
+ export declare function filterTracks<T extends AnyTrackConfig>(tracks: T[], self: {
378
352
  view?: IStateTreeNode & {
379
353
  type: string;
380
354
  };
381
355
  assemblyNames: string[];
382
- }): AnyConfigurationModel[];
356
+ }): T[];
383
357
  /**
384
358
  * Every track config a view can be offered, each assembly's sequence track
385
359
  * first and then {@link filterTracks} over the list handed in.
386
360
  */
387
- export declare function offeredTracks(tracks: AnyConfigurationModel[], self: {
361
+ export declare function offeredTracks(tracks: AnyTrackConfig[], self: {
388
362
  view?: IStateTreeNode & {
389
363
  type: string;
390
364
  };
391
365
  assemblyNames: string[];
392
- }): AnyConfigurationModel[];
366
+ }): AnyTrackConfig[];
393
367
  /**
394
368
  * Which display a track opens with in a given view, and the declared entry
395
369
  * that configures it: `{ type, conf }`, or undefined when the view draws none
@@ -435,6 +409,15 @@ export declare function normalizeTrackInit(t: TrackInit): {
435
409
  [x: string]: unknown;
436
410
  };
437
411
  };
412
+ /**
413
+ * The display type a view of `viewType` opens the track `rawConf` as, the one
414
+ * `showTrack` picks, or undefined when the view draws none of the track's
415
+ * displays. For a caller that needs to know the display before the view exists,
416
+ * such as a CLI choosing which settings to write.
417
+ */
418
+ export declare function trackDisplayType(pluginManager: PluginManager, rawConf: {
419
+ type: string;
420
+ }, viewType: string, requested?: string): string | undefined;
438
421
  export declare function showTrackGeneric(self: GenericView, trackId: string, initialSnapshot?: object, displayInitialSnapshot?: DisplayInitialSnapshot, inlineConf?: Record<string, unknown>): any;
439
422
  export interface DisplaySnapshot {
440
423
  id: string;
@@ -473,11 +456,11 @@ export declare function launchToggleTrackGeneric(self: GenericView, trackId: str
473
456
  * yields every session track twice.
474
457
  */
475
458
  export declare function allSessionTracks(session: {
476
- tracks: AnyConfigurationModel[];
459
+ tracks: TrackConfigEntry[];
477
460
  connectionInstances?: {
478
461
  tracks: AnyConfigurationModel[];
479
462
  }[];
480
- }): AnyConfigurationModel[];
463
+ }): AnyTrackConfig[];
481
464
  /**
482
465
  * The session's annotation for `assemblyName`, as trackIds: what a view opened
483
466
  * on another genome starts with. Only FeatureTracks, not everything configured
@@ -486,7 +469,7 @@ export declare function allSessionTracks(session: {
486
469
  * range query.
487
470
  */
488
471
  export declare function annotationTrackIds(session: {
489
- tracks: AnyConfigurationModel[];
472
+ tracks: TrackConfigEntry[];
490
473
  connectionInstances?: {
491
474
  tracks: AnyConfigurationModel[];
492
475
  }[];