loom-browser 0.0.9 → 0.0.11

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 (99) hide show
  1. package/dist/loom-react.esm.js +3810 -3099
  2. package/dist/loom-react.esm.min.js +1 -1
  3. package/dist/loom-react.esm.min.js.map +1 -1
  4. package/dist/loom-worker.js +191 -137
  5. package/dist/loom-worker.min.js +1 -1
  6. package/dist/loom-worker.min.js.map +1 -1
  7. package/dist/loom.esm.js +3641 -2883
  8. package/dist/loom.esm.min.js +1 -1
  9. package/dist/loom.esm.min.js.map +1 -1
  10. package/dist/loom.js +3652 -2886
  11. package/dist/loom.min.js +1 -1
  12. package/dist/loom.min.js.map +1 -1
  13. package/dist/tsconfig.src.tsbuildinfo +1 -1
  14. package/dist/types/browser/dom/browserExport.d.ts +32 -0
  15. package/dist/types/browser/dom/contextMenu.d.ts +64 -0
  16. package/dist/types/browser/dom/contextMenuManager.d.ts +49 -0
  17. package/dist/types/browser/dom/defaultProviders.d.ts +23 -0
  18. package/dist/types/browser/dom/genomeBrowser.d.ts +171 -0
  19. package/dist/types/browser/dom/pointerEventManager.d.ts +109 -0
  20. package/dist/types/browser/dom/roiOverlayManager.d.ts +38 -0
  21. package/dist/types/browser/dom/svgFeatureOverlay.d.ts +27 -0
  22. package/dist/types/browser/headless/errors.d.ts +10 -0
  23. package/dist/types/browser/headless/headlessGenomeBrowser.d.ts +391 -0
  24. package/dist/types/browser/headless/roiManager.d.ts +47 -0
  25. package/dist/types/browser/headless/session.d.ts +45 -0
  26. package/dist/types/browser/headless/trackDataManager.d.ts +53 -0
  27. package/dist/types/browser/headless/trackFactories.d.ts +145 -0
  28. package/dist/types/browser/index.d.ts +24 -0
  29. package/dist/types/browserExport.d.ts +32 -0
  30. package/dist/types/commandDispatcher.d.ts +1 -1
  31. package/dist/types/contextMenuManager.d.ts +49 -0
  32. package/dist/types/data/searchService.d.ts +24 -0
  33. package/dist/types/dataSourceWorkerProvider.d.ts +3 -3
  34. package/dist/types/dataSources/bigWigDataSource.d.ts +2 -2
  35. package/dist/types/dataSources/config.d.ts +40 -0
  36. package/dist/types/dataSources/configureDataSource.d.ts +17 -0
  37. package/dist/types/dataSources/createDataSource.d.ts +14 -0
  38. package/dist/types/dataSources/geneDataSource.d.ts +4 -3
  39. package/dist/types/dataSources/gtxDataSource.d.ts +2 -2
  40. package/dist/types/dataSources/memoryDataSource.d.ts +2 -2
  41. package/dist/types/dataSources/sequenceDataSource.d.ts +4 -1
  42. package/dist/types/dataSources/textFeatureSource.d.ts +4 -2
  43. package/dist/types/dataSources/wholeGenomeUtils.d.ts +37 -0
  44. package/dist/types/defaultProviders.d.ts +23 -0
  45. package/dist/types/errors.d.ts +10 -0
  46. package/dist/types/formats/featureParser.d.ts +1 -1
  47. package/dist/types/genomeBrowser.d.ts +18 -91
  48. package/dist/types/headlessGenomeBrowser.d.ts +88 -225
  49. package/dist/types/index.d.ts +21 -14
  50. package/dist/types/io/binaryParser.d.ts +0 -1
  51. package/dist/types/logger.d.ts +20 -0
  52. package/dist/types/pointerEventManager.d.ts +109 -0
  53. package/dist/types/react/GenomeBrowserContext.d.ts +1 -1
  54. package/dist/types/react/LoomBrowser.d.ts +4 -4
  55. package/dist/types/react/hooks/useBrowserEvent.d.ts +1 -1
  56. package/dist/types/react/hooks/useGenomeBrowser.d.ts +1 -1
  57. package/dist/types/react/hooks/useTrackManager.d.ts +1 -1
  58. package/dist/types/react/tracks/BedTrack.d.ts +7 -7
  59. package/dist/types/react/ui/ChromosomeSelect.d.ts +1 -1
  60. package/dist/types/react/ui/ExportControls.d.ts +1 -1
  61. package/dist/types/react/ui/LocusInput.d.ts +1 -1
  62. package/dist/types/react/ui/Navbar.d.ts +1 -1
  63. package/dist/types/react/ui/WindowSize.d.ts +1 -1
  64. package/dist/types/react/ui/ZoomControls.d.ts +1 -1
  65. package/dist/types/remoteProtocol.d.ts +1 -1
  66. package/dist/types/roiManager.d.ts +47 -0
  67. package/dist/types/roiOverlayManager.d.ts +38 -0
  68. package/dist/types/stateProjection.d.ts +1 -1
  69. package/dist/types/trackDataManager.d.ts +48 -0
  70. package/dist/types/trackFactories.d.ts +140 -0
  71. package/dist/types/trackSelector.d.ts +1 -1
  72. package/dist/types/tracks/annotation/annotationTrackCanvas.d.ts +0 -1
  73. package/dist/types/tracks/annotation/config.d.ts +61 -0
  74. package/dist/types/tracks/baseTrackCanvas.d.ts +10 -0
  75. package/dist/types/tracks/configDiff.d.ts +14 -0
  76. package/dist/types/tracks/interaction/config.d.ts +40 -0
  77. package/dist/types/tracks/ruler/config.d.ts +24 -0
  78. package/dist/types/tracks/sequence/config.d.ts +56 -0
  79. package/dist/types/tracks/sequence/sequenceTrackCanvas.d.ts +3 -0
  80. package/dist/types/tracks/wig/config.d.ts +77 -0
  81. package/dist/types/types/igvCompat.d.ts +36 -0
  82. package/dist/types/types.d.ts +48 -284
  83. package/dist/types/ui/components/LoomBrowserShell.d.ts +2 -2
  84. package/dist/types/ui/components/LoomChromosomeSelect.d.ts +1 -1
  85. package/dist/types/ui/components/LoomContextMenu.d.ts +1 -0
  86. package/dist/types/ui/components/LoomExportControls.d.ts +1 -1
  87. package/dist/types/ui/components/LoomLocusInput.d.ts +1 -1
  88. package/dist/types/ui/components/LoomNavbar.d.ts +1 -1
  89. package/dist/types/ui/components/LoomWindowSize.d.ts +1 -1
  90. package/dist/types/ui/components/LoomZoomControls.d.ts +1 -1
  91. package/dist/types/undoManager.d.ts +49 -0
  92. package/dist/types/worker/dataSourceRegistry.d.ts +2 -2
  93. package/dist/types/worker/serializedError.d.ts +16 -0
  94. package/dist/types/worker/taskTimeout.d.ts +21 -0
  95. package/dist/types/worker/webWorkerPool.d.ts +5 -2
  96. package/dist/types/worker/webWorkerProvider.d.ts +3 -0
  97. package/dist/types/workerDataSource.d.ts +2 -2
  98. package/dist/types/workerProvider.d.ts +2 -2
  99. package/package.json +1 -1
@@ -1,4 +1,15 @@
1
1
  import type { ChromSizes, CumulativeOffsets } from './genome/chromSizes';
2
+ export type { DisplayMode, AnnotationRenderConfig } from './tracks/annotation/config';
3
+ export { defaultAnnotationRenderConfig } from './tracks/annotation/config';
4
+ export type { RulerRenderConfig } from './tracks/ruler/config';
5
+ export { defaultRulerRenderConfig } from './tracks/ruler/config';
6
+ export type { WigGraphType, WigGuideLine, WigColorValue, WigRenderConfig } from './tracks/wig/config';
7
+ export { defaultWigRenderConfig } from './tracks/wig/config';
8
+ export type { SequenceType, SequenceRenderConfig } from './tracks/sequence/config';
9
+ export { defaultSequenceRenderConfig } from './tracks/sequence/config';
10
+ export type { ArcOrientation, ArcDisplayMode, InteractionRenderConfig } from './tracks/interaction/config';
11
+ export { defaultInteractionRenderConfig } from './tracks/interaction/config';
12
+ export type { DataSourceConfig, BigWigDataSourceConfig, GtxDataSourceConfig, UCSCDataSourceConfig, TextDataSourceConfig, MemoryDataSourceConfig, } from './dataSources/config';
2
13
  /** Genomic locus — a chromosome region. */
3
14
  export interface Locus {
4
15
  chr: string;
@@ -78,6 +89,16 @@ export interface Track {
78
89
  setError(error: Error | null): void;
79
90
  /** Apply a new render theme and re-render. Replaces all theme-derived config values. */
80
91
  setTheme(theme: import('./themes/renderTheme').RenderTheme): void;
92
+ /**
93
+ * Callback invoked just before config changes (e.g. setConfig()).
94
+ * The browser registers this to snapshot state for undo (capturing pre-mutation state).
95
+ */
96
+ onBeforeConfigChange?: (() => void) | undefined;
97
+ /**
98
+ * Callback invoked after config changes (e.g. setConfig()).
99
+ * The browser registers this to emit TrackConfigChanged.
100
+ */
101
+ onConfigChanged?: (() => void) | undefined;
81
102
  /**
82
103
  * Hit-test at canvas-relative pixel coordinates.
83
104
  * Returns features at that point with pre-formatted popup data.
@@ -127,6 +148,12 @@ export interface Track {
127
148
  renderToContext?(ctx: CanvasRenderingContext2D, width: number, height: number): void;
128
149
  visibilityWindow?: number;
129
150
  }
151
+ /** Track that supports zoom-level awareness (shows "zoom in" notice when zoomed out). */
152
+ export interface ZoomAwareTrack extends Track {
153
+ setZoomedOut(zoomed: boolean): void;
154
+ }
155
+ /** Type guard for tracks that implement setZoomedOut(). */
156
+ export declare function isZoomAware(track: Track): track is ZoomAwareTrack;
130
157
  /** A single exon within a gene feature. */
131
158
  export interface Exon {
132
159
  start: number;
@@ -169,58 +196,6 @@ export interface AnnotationFeature {
169
196
  /** Assigned by pack() — the row this feature is placed in. */
170
197
  row?: number;
171
198
  }
172
- /** Display mode for gene features. */
173
- export type DisplayMode = 'COLLAPSED' | 'SQUISHED' | 'EXPANDED';
174
- /** Configuration controlling how annotation features (gene, BED, GFF, peaks) are rendered. */
175
- export interface AnnotationRenderConfig {
176
- displayMode: DisplayMode;
177
- featureHeight: number;
178
- margin: number;
179
- /** Row height in EXPANDED mode (featureHeight + label space + padding). */
180
- expandedRowHeight: number;
181
- /** Row height in SQUISHED mode. */
182
- squishedRowHeight: number;
183
- /** Pixel spacing between strand-direction arrows. */
184
- arrowSpacing: number;
185
- /** Default fill color for CDS exons. */
186
- color: string;
187
- /** Color for features on the opposite strand (if desired). */
188
- altColor?: string;
189
- /** Which feature property to use as the label. */
190
- labelField: string;
191
- /** CSS font string for labels, e.g. "10px sans-serif". */
192
- font: string;
193
- /** Whether to draw labels. */
194
- drawLabels: boolean;
195
- /** Label display mode — "SLANT" rotates labels 45°. */
196
- labelDisplayMode?: 'SLANT';
197
- /** UTR fill color. Defaults to main color. */
198
- utrColor?: string;
199
- /** Alt UTR color (for - strand when altColor is set). */
200
- altUtrColor?: string;
201
- /** Exon stroke outline color. No outline when undefined. */
202
- borderColor?: string;
203
- /** Exon outline width. Default: 0 (no outline). */
204
- borderWidth?: number;
205
- /** Rounded corner radius for exon rects. Default: 0 (square). */
206
- borderRadius?: number;
207
- /** Intron line color. Defaults to main color. */
208
- intronColor?: string;
209
- /** Intron line width. Default: 1. */
210
- intronLineWidth?: number;
211
- /** Dash pattern for intron lines, e.g. [3, 3]. Default: [] (solid). */
212
- intronDash?: number[];
213
- /** Strand arrow color on intron lines. Defaults to current stroke color. */
214
- arrowColor?: string;
215
- /** Strand arrow color inside exons. Default: 'white'. */
216
- arrowInExonColor?: string;
217
- /** Label text color. Defaults to feature color. */
218
- labelColor?: string;
219
- /** Background color behind labels. When set, fills behind labels instead of clearing to transparent. */
220
- labelBackground?: string;
221
- /** Separate CSS font string for labels. Defaults to `font`. */
222
- labelFont?: string;
223
- }
224
199
  /** Rendering context — describes the viewport being drawn into. */
225
200
  export interface RenderContext {
226
201
  /** Total pixel width of the canvas. */
@@ -232,23 +207,6 @@ export interface RenderContext {
232
207
  /** Visible viewport width (may be less than pixelWidth for overscanning). */
233
208
  viewportWidth: number;
234
209
  }
235
- /** Returns sensible defaults for annotation feature rendering. */
236
- export declare function defaultAnnotationRenderConfig(): AnnotationRenderConfig;
237
- /** Configuration for ruler track rendering. */
238
- export interface RulerRenderConfig {
239
- /** Total height in CSS pixels. Default: 40. */
240
- height: number;
241
- /** Font for tick labels. Default: 'bold 10px sans-serif'. */
242
- font: string;
243
- /** Tick line color. Default: 'rgb(150, 150, 150)'. */
244
- tickColor: string;
245
- /** Label text color. Default: 'rgb(0, 0, 0)'. */
246
- labelColor: string;
247
- /** Baseline (bottom rule) color. Default: 'rgb(150, 150, 150)'. */
248
- baselineColor: string;
249
- /** Background color. Default: 'white'. */
250
- background: string;
251
- }
252
210
  /** A single wig data point: a chromosome region with a numeric value. */
253
211
  export interface WigFeature {
254
212
  chr: string;
@@ -260,8 +218,6 @@ export interface WigFeature {
260
218
  /** DNA sequence for this region (populated for dynseq rendering). */
261
219
  sequence?: string;
262
220
  }
263
- /** Graph type for wig track rendering. */
264
- export type WigGraphType = 'bar' | 'line' | 'points' | 'dynseq';
265
221
  /** A function that fetches DNA sequence for a genomic region. */
266
222
  export type SequenceProvider = (locus: Locus, signal?: AbortSignal) => Promise<string>;
267
223
  /**
@@ -348,122 +304,6 @@ export interface GenomeConfig {
348
304
  }
349
305
  /** Aggregation function for resolution-aware data summarization. */
350
306
  export type WindowFunction = 'mean' | 'min' | 'max' | 'none';
351
- /** A horizontal guide line drawn at a specific data value. */
352
- export interface WigGuideLine {
353
- /** The data value at which to draw the line. */
354
- y: number;
355
- /** Line color. */
356
- color: string;
357
- /** Whether to draw a dashed line. */
358
- dotted: boolean;
359
- }
360
- /** Color value for wig features: a static CSS color string or a function mapping value → color. */
361
- export type WigColorValue = string | ((value: number) => string);
362
- /** Configuration controlling how wig features are rendered. */
363
- export interface WigRenderConfig {
364
- /** Track height in CSS pixels. Default: 50. */
365
- height: number;
366
- /** Graph rendering style. Default: 'bar'. */
367
- graphType: WigGraphType;
368
- /** Data aggregation when zoomed out. Default: 'mean'. */
369
- windowFunction: WindowFunction;
370
- /** Y-axis data range. Features are scaled to this range. */
371
- dataRange: {
372
- min: number;
373
- max: number;
374
- };
375
- /** Whether to auto-compute dataRange from features. Default: true. */
376
- autoscale: boolean;
377
- /** Fill/stroke color for positive values. String or (value) => color function. Default: 'rgb(150, 150, 150)'. */
378
- color: WigColorValue;
379
- /** Fill/stroke color for negative values. String or (value) => color function. Uses `color` when undefined. */
380
- altColor?: WigColorValue;
381
- /** Alpha transparency for feature colors (0–1). Applied on top of resolved color. Default: undefined (fully opaque). */
382
- alpha?: number;
383
- /** Flip the y-axis (values grow downward). Default: false. */
384
- flipAxis: boolean;
385
- /** Use logarithmic scale for the y-axis. Default: false. */
386
- logScale: boolean;
387
- /** Color for the zero-line baseline. Default: 'lightGray'. */
388
- baselineColor: string;
389
- /** Color for out-of-range value indicators. Default: 'rgb(255, 32, 255)'. */
390
- overflowColor: string;
391
- /** Point diameter in pixels (for 'points' graphType). Default: 3. */
392
- pointSize: number;
393
- /** Background color. Default: '#ffffff'. */
394
- background: string;
395
- /** Optional horizontal guide lines. */
396
- guideLines?: WigGuideLine[];
397
- /** Nucleotide colors for dynseq rendering. Keys: A, C, G, T, N. */
398
- nucleotideColors?: Record<string, string>;
399
- /** Multiply all feature values by this factor before rendering. Default: undefined (no scaling). */
400
- scaleFactor?: number;
401
- /**
402
- * Normalization factor applied to all feature values (e.g. reads-per-million from TDF).
403
- * When set, all values are multiplied by this factor before scaleFactor is applied.
404
- * Typically provided by the data source rather than set manually.
405
- */
406
- normalizationFactor?: number;
407
- /** Whether to draw min/max data range labels on the track. Default: true. */
408
- showDataRange: boolean;
409
- /** Color for data range label text. Default: palette.foreground. */
410
- labelColor: string;
411
- /** Font for data range labels. Default: 'bold 9px sans-serif'. */
412
- labelFont: string;
413
- /** Track name to display as an overlay label (igv.js style, top-left). */
414
- trackName?: string;
415
- }
416
- /** Sequence type for the sequence track. */
417
- export type SequenceType = 'dna' | 'rna' | 'prot';
418
- /** Configuration controlling how sequence features are rendered. */
419
- export interface SequenceRenderConfig {
420
- /** Sequence type (affects coloring). Default: 'dna'. */
421
- sequenceType: SequenceType;
422
- /** Show reverse complement. Default: false. */
423
- reversed: boolean;
424
- /** Show three-frame amino acid translation. Default: false. */
425
- frameTranslate: boolean;
426
- /** Override color for all bases. When set, ignores nucleotide color map. */
427
- color?: string;
428
- /** Background color. Default: '#ffffff'. */
429
- background: string;
430
- /** Nucleotide color mapping (A, C, G, T, N). Used when sequenceType is 'dna'. */
431
- nucleotideColors: Record<string, string>;
432
- /** Default color for RNA/protein bases. Default: 'rgb(0, 0, 150)'. */
433
- nonDnaColor: string;
434
- /** Track height without translation frames. Default: 25. */
435
- defaultHeight: number;
436
- /** Track height with translation frames. Default: 115. */
437
- translatedHeight: number;
438
- /** Height of the sequence row. Default: 15. */
439
- sequenceHeight: number;
440
- /** Height of each translation frame row. Default: 25. */
441
- frameHeight: number;
442
- /** Border/padding between elements. Default: 5. */
443
- frameBorder: number;
444
- /** Alternating background color 1 for translation frames. Default: 'rgb(160,160,160)'. */
445
- frameColor1: string;
446
- /** Alternating background color 2 for translation frames. Default: 'rgb(224,224,224)'. */
447
- frameColor2: string;
448
- /** Stop codon highlight color. Default: 'rgb(255, 0, 0)'. */
449
- stopCodonColor: string;
450
- /** Start codon (M) highlight color. Default: 'rgb(0, 153, 0)'. */
451
- startCodonColor: string;
452
- /** Use fillText instead of strokeText for base and amino acid labels. Default: false (strokeText, matching igv.js). */
453
- useFillText: boolean;
454
- /** Color for amino acid labels in translation frames. Default: '#000000'. */
455
- frameLabelColor: string;
456
- /** Color for amino acid labels on start/stop codon backgrounds. Default: same as frameLabelColor. */
457
- codonLabelColor?: string;
458
- /** Font for amino acid labels in translation frames. Default: 'bold 10px sans-serif'. */
459
- frameFont: string;
460
- /** Border radius for start/stop codon highlights (roundRect). 0 = sharp rectangles. Default: 0. */
461
- codonBorderRadius: number;
462
- }
463
- /** Returns sensible defaults for sequence rendering. */
464
- export declare function defaultSequenceRenderConfig(): SequenceRenderConfig;
465
- /** Returns sensible defaults for wig rendering. */
466
- export declare function defaultWigRenderConfig(): WigRenderConfig;
467
307
  /** An interaction feature representing a pairwise genomic contact (Hi-C, ChIA-PET, etc.). */
468
308
  export interface InteractionFeature {
469
309
  /** Bounding chromosome (same as chr1 for intra-chr; set per-copy for inter-chr). */
@@ -496,39 +336,6 @@ export interface InteractionFeature {
496
336
  /** True if this is a duplicated copy of an inter-chr feature (for the other chromosome). */
497
337
  dup?: boolean;
498
338
  }
499
- /** Arc orientation: arcs open upward or downward. */
500
- export type ArcOrientation = 'UP' | 'DOWN';
501
- /** Display mode for interaction arcs. */
502
- export type ArcDisplayMode = 'nested' | 'proportional';
503
- /** Configuration controlling how interaction features are rendered as arcs. */
504
- export interface InteractionRenderConfig {
505
- /** Track height in CSS pixels. Default: 250. */
506
- height: number;
507
- /** Arc direction. Default: 'UP'. */
508
- arcOrientation: ArcOrientation;
509
- /** Display mode. Default: 'nested'. */
510
- displayMode: ArcDisplayMode;
511
- /** Show small rectangles at feature endpoints. Default: true. */
512
- showBlocks: boolean;
513
- /** Height of endpoint rectangles in pixels. Default: 3. */
514
- blockHeight: number;
515
- /** Arc stroke width in pixels. Default: 1. */
516
- thickness: number;
517
- /** Default arc color. Default: 'rgb(180,25,137)'. */
518
- color: string;
519
- /** Fill alpha for arcs. Default: 0.02. */
520
- alpha: number;
521
- /** Use log scale for proportional arc heights. Default: true. */
522
- logScale: boolean;
523
- /** Background color. Default: '#ffffff'. */
524
- background: string;
525
- /** Font for inter-chromosome labels. Default: '8px sans-serif'. */
526
- font: string;
527
- /** Whether to use score-based shading. Default: false. */
528
- useScore: boolean;
529
- }
530
- /** Returns sensible defaults for interaction rendering. */
531
- export declare function defaultInteractionRenderConfig(): InteractionRenderConfig;
532
339
  /** A single item in a feature popup (key-value pair). */
533
340
  export interface PopupDataItem {
534
341
  name: string;
@@ -652,7 +459,22 @@ export interface DataSource<F = unknown> {
652
459
  * @param signal - AbortSignal for cancellation of stale requests
653
460
  */
654
461
  fetch(locus: Locus, bpPerPixel: number, signal: AbortSignal): Promise<F[]>;
462
+ /** Optional cleanup — release file handles, caches, or other resources. */
463
+ dispose?(): void;
655
464
  }
465
+ /**
466
+ * Optional configuration methods that DataSource implementations may support.
467
+ *
468
+ * Used by `configureDataSource()` to safely dispatch setter calls by name.
469
+ * Implementations should declare `implements ConfigurableDataSource` to opt in.
470
+ */
471
+ export interface ConfigurableDataSource {
472
+ setCumulativeOffsets?(offsets: CumulativeOffsets): void;
473
+ setChromNameResolver?(resolver: (chr: string) => string): void;
474
+ setWindowFunction?(wf: WindowFunction): void;
475
+ }
476
+ /** Known setter method names on ConfigurableDataSource. */
477
+ export type DataSourceConfigMethod = keyof ConfigurableDataSource;
656
478
  /** Cached features for a track, stored and managed by GenomeBrowser. */
657
479
  export interface FeatureCacheEntry<F = unknown> {
658
480
  locus: Locus;
@@ -663,8 +485,6 @@ export interface FeatureCacheEntry<F = unknown> {
663
485
  export interface DataDrivenTrack<F = unknown> extends Track {
664
486
  setFeatures(features: F[]): void;
665
487
  }
666
- /** Returns sensible defaults for ruler rendering. */
667
- export declare function defaultRulerRenderConfig(): RulerRenderConfig;
668
488
  /** Base for all track feature summaries. */
669
489
  interface FeatureSummaryBase {
670
490
  /** Number of features in the current view. */
@@ -695,6 +515,12 @@ export interface InteractionFeatureSummary extends FeatureSummaryBase {
695
515
  }
696
516
  /** Union of all track feature summaries. */
697
517
  export type TrackFeatureSummary = WigFeatureSummary | AnnotationFeatureSummary | InteractionFeatureSummary;
518
+ import type { AnnotationRenderConfig } from './tracks/annotation/config';
519
+ import type { RulerRenderConfig } from './tracks/ruler/config';
520
+ import type { WigRenderConfig } from './tracks/wig/config';
521
+ import type { SequenceRenderConfig } from './tracks/sequence/config';
522
+ import type { InteractionRenderConfig } from './tracks/interaction/config';
523
+ import type { DataSourceConfig } from './dataSources/config';
698
524
  /** First-party session config — fully typed, JSON-serializable browser state. */
699
525
  export interface SessionConfig {
700
526
  version: string;
@@ -753,37 +579,6 @@ export type RulerSessionOverrides = Partial<RulerRenderConfig>;
753
579
  export type SequenceSessionOverrides = Partial<SequenceRenderConfig>;
754
580
  /** Serializable subset of InteractionRenderConfig (all fields are already serializable). */
755
581
  export type InteractionSessionOverrides = Partial<InteractionRenderConfig>;
756
- /** Discriminated union for data source reconstruction. */
757
- export type DataSourceConfig = BigWigDataSourceConfig | GtxDataSourceConfig | UCSCDataSourceConfig | TextDataSourceConfig | MemoryDataSourceConfig;
758
- export interface BigWigDataSourceConfig {
759
- type: 'bigwig';
760
- url: string;
761
- windowFunction?: WindowFunction;
762
- }
763
- export interface GtxDataSourceConfig {
764
- type: 'gtx';
765
- url: string;
766
- experimentId: string;
767
- windowFunction?: WindowFunction;
768
- }
769
- export interface UCSCDataSourceConfig {
770
- type: 'ucsc';
771
- genome?: string;
772
- track?: string;
773
- }
774
- export interface TextDataSourceConfig {
775
- type: 'text';
776
- url: string;
777
- /** Explicit format override. When absent, inferred from URL. */
778
- format?: TextFileFormat;
779
- /** Index URL override. Defaults to url + '.tbi'. */
780
- indexURL?: string;
781
- /** Whether the file is indexed (tabix). When absent, auto-detected from indexURL presence. */
782
- indexed?: boolean;
783
- }
784
- export interface MemoryDataSourceConfig {
785
- type: 'memory';
786
- }
787
582
  /** Strand value for genomic features. */
788
583
  export type Strand = '+' | '-' | '.';
789
584
  /** Known text genomic file formats supported by the format detection system. */
@@ -875,34 +670,3 @@ export interface GFFFeature {
875
670
  }
876
671
  /** Union of all feature types produced by text format decoders. */
877
672
  export type TextFeature = BedFeature | PeakFeature | BedGraphFeature | GFFFeature;
878
- /** Minimal igv.js session shape — just enough to parse/produce sessions. */
879
- export interface IgvSessionObject {
880
- version?: string;
881
- reference?: IgvReferenceConfig;
882
- genome?: string;
883
- locus?: string | string[];
884
- tracks?: IgvTrackConfig[];
885
- }
886
- export interface IgvReferenceConfig {
887
- id?: string;
888
- fastaURL?: string;
889
- indexURL?: string;
890
- }
891
- export interface IgvTrackConfig {
892
- type?: string;
893
- format?: string;
894
- url?: string;
895
- indexURL?: string;
896
- name?: string;
897
- color?: string;
898
- altColor?: string;
899
- height?: number;
900
- min?: number;
901
- max?: number;
902
- autoscale?: boolean;
903
- displayMode?: string;
904
- order?: number;
905
- visibilityWindow?: number;
906
- windowFunction?: string;
907
- }
908
- export {};
@@ -12,8 +12,8 @@
12
12
  * Or use the createShell() helper:
13
13
  * const shell = createShell(container, { locus, theme: 'modern' })
14
14
  */
15
- import { GenomeBrowser } from '../../genomeBrowser';
16
- import type { GenomeBrowserOptions, BrowserEvents } from '../../genomeBrowser';
15
+ import { GenomeBrowser } from '../../browser/dom/genomeBrowser';
16
+ import type { GenomeBrowserOptions, BrowserEvents } from '../../browser/dom/genomeBrowser';
17
17
  import type { Locus, Track } from '../../types';
18
18
  import type { ShellTheme } from '../themes';
19
19
  export declare class LoomBrowserShell extends HTMLElement {
@@ -4,7 +4,7 @@
4
4
  * Lists main chromosomes (chr1-22, X, Y, M) plus "All" for whole genome view.
5
5
  * Updates automatically when the browser locus changes.
6
6
  */
7
- import type { GenomeBrowser } from '../../genomeBrowser';
7
+ import type { GenomeBrowser } from '../../browser/dom/genomeBrowser';
8
8
  export declare class LoomChromosomeSelect extends HTMLElement {
9
9
  private select;
10
10
  private unsubscribe;
@@ -17,6 +17,7 @@ export declare class LoomContextMenu extends HTMLElement {
17
17
  private menuDiv;
18
18
  constructor();
19
19
  connectedCallback(): void;
20
+ disconnectedCallback(): void;
20
21
  /** Populate the menu from typed ContextMenuItem data. */
21
22
  setItems(items: ContextMenuItem[]): void;
22
23
  private buildItems;
@@ -4,7 +4,7 @@
4
4
  * Adds "Save SVG" and "Save PNG" buttons to the shell navbar.
5
5
  * Calls GenomeBrowser.saveSVGtoFile() and savePNGtoFile() respectively.
6
6
  */
7
- import type { GenomeBrowser } from '../../genomeBrowser';
7
+ import type { GenomeBrowser } from '../../browser/dom/genomeBrowser';
8
8
  export declare class LoomExportControls extends HTMLElement {
9
9
  private _browser;
10
10
  constructor();
@@ -4,7 +4,7 @@
4
4
  * Shows the current locus as a formatted string. User can type a new locus
5
5
  * and press Enter to navigate. Updates automatically on locuschange events.
6
6
  */
7
- import type { GenomeBrowser } from '../../genomeBrowser';
7
+ import type { GenomeBrowser } from '../../browser/dom/genomeBrowser';
8
8
  export declare class LoomLocusInput extends HTMLElement {
9
9
  private input;
10
10
  private unsubscribe;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * <loom-navbar> — Horizontal navigation bar composing locus input, window size, and zoom controls.
3
3
  */
4
- import type { GenomeBrowser } from '../../genomeBrowser';
4
+ import type { GenomeBrowser } from '../../browser/dom/genomeBrowser';
5
5
  export declare class LoomNavbar extends HTMLElement {
6
6
  private chromSelect;
7
7
  private locusInput;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * <loom-window-size> — Read-only display of current viewport bp range.
3
3
  */
4
- import type { GenomeBrowser } from '../../genomeBrowser';
4
+ import type { GenomeBrowser } from '../../browser/dom/genomeBrowser';
5
5
  export declare class LoomWindowSize extends HTMLElement {
6
6
  private label;
7
7
  private unsubscribe;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * <loom-zoom-controls> — Zoom in/out buttons.
3
3
  */
4
- import type { GenomeBrowser } from '../../genomeBrowser';
4
+ import type { GenomeBrowser } from '../../browser/dom/genomeBrowser';
5
5
  export declare class LoomZoomControls extends HTMLElement {
6
6
  private _browser;
7
7
  constructor();
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Undo/redo manager for HeadlessGenomeBrowser.
3
+ *
4
+ * Maintains two stacks of tagged session snapshots. Each entry records the
5
+ * mutation type so consumers can filter (e.g., skip navigation-only entries).
6
+ *
7
+ * Decoupled from the browser — operates purely on SessionConfig objects.
8
+ */
9
+ import type { SessionConfig } from './types';
10
+ /** Category of mutation that produced an undo entry. */
11
+ export type UndoEntryType = 'navigation' | 'track-add' | 'track-remove' | 'track-reorder' | 'track-config' | 'roi' | 'theme' | 'session-load';
12
+ /** A single undo/redo stack entry. */
13
+ export interface UndoEntry {
14
+ type: UndoEntryType;
15
+ session: SessionConfig;
16
+ }
17
+ export declare class UndoManager {
18
+ readonly maxHistory: number;
19
+ private undoStack;
20
+ private redoStack;
21
+ private _paused;
22
+ constructor(maxHistory?: number);
23
+ /** Whether snapshot calls are currently suppressed. */
24
+ get paused(): boolean;
25
+ /** Suppress snapshot calls (e.g., during loadSession restoration). */
26
+ pause(): void;
27
+ /** Resume snapshot calls. */
28
+ resume(): void;
29
+ /** Push the current state before a mutation. Clears the redo stack. */
30
+ snapshot(type: UndoEntryType, session: SessionConfig): void;
31
+ /**
32
+ * Undo: pop from undo stack, push currentSession to redo, return the entry to restore.
33
+ * Optionally skip entries matching a predicate (they are discarded).
34
+ */
35
+ undo(currentSession: SessionConfig, skip?: (e: UndoEntry) => boolean): UndoEntry | undefined;
36
+ /**
37
+ * Redo: pop from redo stack, push currentSession to undo, return the entry to restore.
38
+ * Optionally skip entries matching a predicate (they are discarded).
39
+ */
40
+ redo(currentSession: SessionConfig, skip?: (e: UndoEntry) => boolean): UndoEntry | undefined;
41
+ canUndo(skip?: (e: UndoEntry) => boolean): boolean;
42
+ canRedo(skip?: (e: UndoEntry) => boolean): boolean;
43
+ /** Number of entries in the undo stack. */
44
+ get undoSize(): number;
45
+ /** Number of entries in the redo stack. */
46
+ get redoSize(): number;
47
+ /** Clear all history. */
48
+ clear(): void;
49
+ }
@@ -7,7 +7,7 @@
7
7
  * Runs inside a web worker or Node worker_threads context.
8
8
  * Layer 1 (Data + Layout): no DOM.
9
9
  */
10
- import type { DataSourceConfig, Locus } from '../types';
10
+ import type { DataSourceConfig, DataSourceConfigMethod, Locus } from '../types';
11
11
  export declare class DataSourceRegistry {
12
12
  private readonly instances;
13
13
  private readonly inflightAborts;
@@ -27,7 +27,7 @@ export declare class DataSourceRegistry {
27
27
  * Call a setter method on a registered DataSource.
28
28
  * Used for serializable configuration updates (setCumulativeOffsets, setWindowFunction, etc.).
29
29
  */
30
- configure(instanceId: string, method: string, args: unknown[]): void;
30
+ configure(instanceId: string, method: DataSourceConfigMethod, args: unknown[]): void;
31
31
  /** Destroy a DataSource instance and clean up. */
32
32
  destroy(instanceId: string): void;
33
33
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Serialized error for cross-worker-boundary error propagation.
3
+ *
4
+ * Workers can't transfer Error objects via postMessage. This type carries
5
+ * the error message, name, and stack trace across the boundary so the
6
+ * receiving side can reconstruct a meaningful Error.
7
+ */
8
+ export interface SerializedError {
9
+ message: string;
10
+ name: string;
11
+ stack?: string;
12
+ }
13
+ /** Extract serializable fields from an error. */
14
+ export declare function serializeError(err: unknown): SerializedError;
15
+ /** Reconstruct an Error from serialized fields (preserves name and stack). */
16
+ export declare function deserializeError(se: SerializedError): Error;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Timeout utility for worker task execution.
3
+ *
4
+ * Wraps a promise with a configurable timeout. If the promise doesn't settle
5
+ * within the timeout, it rejects with a TaskTimeoutError.
6
+ *
7
+ * Layer 1 (Data): no DOM, no canvas.
8
+ */
9
+ /** Default timeout for worker tasks (30 seconds). */
10
+ export declare const DEFAULT_TASK_TIMEOUT_MS = 30000;
11
+ /** Error thrown when a worker task exceeds its timeout. */
12
+ export declare class TaskTimeoutError extends Error {
13
+ constructor(taskName: string, ms: number);
14
+ }
15
+ /**
16
+ * Race a promise against a timeout. Returns the promise result if it settles
17
+ * first, or rejects with TaskTimeoutError if the timeout fires first.
18
+ *
19
+ * Pass `ms <= 0` to disable the timeout (returns the promise as-is).
20
+ */
21
+ export declare function withTimeout<T>(promise: Promise<T>, ms: number, taskName: string): Promise<T>;
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import type { WorkerProvider, WorkerTask, WorkerTaskResultMap } from '../workerProvider';
21
21
  import type { DataSourceWorkerProvider } from '../dataSourceWorkerProvider';
22
- import type { DataSourceConfig, Locus } from '../types';
22
+ import type { DataSourceConfig, DataSourceConfigMethod, Locus } from '../types';
23
23
  export interface WebWorkerPoolOptions {
24
24
  /**
25
25
  * URL to the worker pool script.
@@ -37,10 +37,13 @@ export interface WebWorkerPoolOptions {
37
37
  * Number of workers in the pool. Default: 1.
38
38
  */
39
39
  poolSize?: number;
40
+ /** Task timeout in ms. Default: 30000. Set to 0 to disable. */
41
+ taskTimeoutMs?: number;
40
42
  }
41
43
  export declare class WebWorkerPool implements WorkerProvider, DataSourceWorkerProvider {
42
44
  private workers;
43
45
  private readyPromises;
46
+ private readonly taskTimeoutMs;
44
47
  private nextId;
45
48
  private nextWorker;
46
49
  private pending;
@@ -53,7 +56,7 @@ export declare class WebWorkerPool implements WorkerProvider, DataSourceWorkerPr
53
56
  execute<T extends WorkerTask>(task: T, transfer?: Transferable[]): Promise<WorkerTaskResultMap[T['task']]>;
54
57
  create(instanceId: string, config: DataSourceConfig): void;
55
58
  fetch<F>(instanceId: string, locus: Locus, bpPerPixel: number, signal: AbortSignal): Promise<F[]>;
56
- configure(instanceId: string, method: string, ...args: unknown[]): void;
59
+ configure(instanceId: string, method: DataSourceConfigMethod, ...args: unknown[]): void;
57
60
  destroy(instanceId: string): void;
58
61
  dispose(): void;
59
62
  /**
@@ -33,12 +33,15 @@ export interface WebWorkerProviderOptions {
33
33
  * Default: 1.
34
34
  */
35
35
  poolSize?: number;
36
+ /** Task timeout in ms. Default: 30000. Set to 0 to disable. */
37
+ taskTimeoutMs?: number;
36
38
  }
37
39
  export declare class WebWorkerProvider implements WorkerProvider {
38
40
  private workers;
39
41
  private nextId;
40
42
  private nextWorker;
41
43
  private pending;
44
+ private readonly taskTimeoutMs;
42
45
  /**
43
46
  * @param optionsOrUrl - Options object with workerUrl and poolSize,
44
47
  * or a URL string/URL for backward compatibility (single worker).
@@ -10,11 +10,11 @@
10
10
  *
11
11
  * Layer 1 (Data + Layout): no DOM.
12
12
  */
13
- import type { DataSource, Locus } from './types';
13
+ import type { DataSource, ConfigurableDataSource, Locus } from './types';
14
14
  import type { CumulativeOffsets } from './genome/chromSizes';
15
15
  import type { DataSourceWorkerProvider } from './dataSourceWorkerProvider';
16
16
  import type { WindowFunction } from './types';
17
- export declare class WorkerDataSource<F = unknown> implements DataSource<F> {
17
+ export declare class WorkerDataSource<F = unknown> implements DataSource<F>, ConfigurableDataSource {
18
18
  private readonly provider;
19
19
  readonly instanceId: string;
20
20
  private resolver?;