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
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Track convenience factories — create and wire tracks with data sources.
3
+ *
4
+ * Extracted from HeadlessGenomeBrowser to isolate repetitive track creation
5
+ * boilerplate. Each factory:
6
+ * 1. Creates a canvas via CanvasProvider
7
+ * 2. Creates a TrackCanvas instance
8
+ * 3. Builds a DataSourceConfig
9
+ * 4. Creates a worker proxy or direct data source
10
+ * 5. Wires chromosome alias resolution + cumulative offsets
11
+ * 6. Returns the track + data source + config for the browser to register
12
+ *
13
+ * Layer 3 (Headless): no DOM dependencies.
14
+ */
15
+ import type { Locus, DataSource, DataSourceConfig, WindowFunction, WigFeature, BedFeature, WigRenderConfig, AnnotationRenderConfig, RulerRenderConfig, SequenceRenderConfig, InteractionRenderConfig, TextFileFormat, SequenceProvider, Genome } from '../../types';
16
+ import type { CanvasProvider } from '../../canvasProvider';
17
+ import type { DataSourceWorkerProvider } from '../../dataSourceWorkerProvider';
18
+ import type { RenderTheme } from '../../themes/renderTheme';
19
+ import type { ChromSizes, CumulativeOffsets } from '../../genome/chromSizes';
20
+ import { WorkerDataSource } from '../../workerDataSource';
21
+ import { RulerTrackCanvas } from '../../tracks/ruler/rulerTrackCanvas';
22
+ import { WigTrackCanvas } from '../../tracks/wig/wigTrackCanvas';
23
+ import { AnnotationTrackCanvas } from '../../tracks/annotation/annotationTrackCanvas';
24
+ import { InteractionTrackCanvas } from '../../tracks/interaction/interactionTrackCanvas';
25
+ export interface AddRulerOptions {
26
+ config?: Partial<RulerRenderConfig>;
27
+ maxTrackHeight?: number;
28
+ }
29
+ export interface AddWigTrackOptions {
30
+ config?: Partial<WigRenderConfig>;
31
+ height?: number;
32
+ background?: string;
33
+ windowFunction?: WindowFunction;
34
+ maxTrackHeight?: number;
35
+ name?: string;
36
+ metadata?: Record<string, string>;
37
+ }
38
+ export interface AddGtxTrackOptions {
39
+ experimentId: string;
40
+ config?: Partial<WigRenderConfig>;
41
+ height?: number;
42
+ background?: string;
43
+ windowFunction?: WindowFunction;
44
+ maxTrackHeight?: number;
45
+ name?: string;
46
+ metadata?: Record<string, string>;
47
+ }
48
+ export interface AddSequenceTrackOptions {
49
+ config?: Partial<SequenceRenderConfig>;
50
+ maxTrackHeight?: number;
51
+ }
52
+ export interface AddBedTrackOptions {
53
+ config?: Partial<AnnotationRenderConfig>;
54
+ height?: number;
55
+ background?: string;
56
+ format?: TextFileFormat;
57
+ indexURL?: string;
58
+ indexed?: boolean;
59
+ maxTrackHeight?: number;
60
+ name?: string;
61
+ metadata?: Record<string, string>;
62
+ }
63
+ export interface AddInteractionTrackOptions {
64
+ config?: Partial<InteractionRenderConfig>;
65
+ background?: string;
66
+ format?: TextFileFormat;
67
+ indexURL?: string;
68
+ indexed?: boolean;
69
+ name?: string;
70
+ metadata?: Record<string, string>;
71
+ }
72
+ export interface AddAnnotationTrackOptions {
73
+ config?: Partial<AnnotationRenderConfig>;
74
+ height?: number;
75
+ background?: string;
76
+ genome?: string;
77
+ track?: string;
78
+ maxTrackHeight?: number;
79
+ name?: string;
80
+ metadata?: Record<string, string>;
81
+ }
82
+ export interface AddWigTrackWithFeaturesOptions {
83
+ config?: Partial<WigRenderConfig>;
84
+ height?: number;
85
+ background?: string;
86
+ maxTrackHeight?: number;
87
+ name?: string;
88
+ metadata?: Record<string, string>;
89
+ }
90
+ export interface AddBedTrackWithFeaturesOptions {
91
+ config?: Partial<AnnotationRenderConfig>;
92
+ height?: number;
93
+ background?: string;
94
+ maxTrackHeight?: number;
95
+ name?: string;
96
+ metadata?: Record<string, string>;
97
+ }
98
+ /** Context needed by all factories — passed from HeadlessGenomeBrowser. */
99
+ export interface TrackFactoryContext {
100
+ locus: Locus;
101
+ canvasProvider: CanvasProvider;
102
+ theme: RenderTheme;
103
+ genome?: Genome;
104
+ chromSizes?: ChromSizes;
105
+ cumulativeOffsets?: CumulativeOffsets;
106
+ sequenceProvider?: SequenceProvider;
107
+ dataSourceWorkerProvider?: DataSourceWorkerProvider;
108
+ }
109
+ /** Result of a factory — the browser registers this via addTrack(). */
110
+ export interface FactoryResult<T> {
111
+ track: T;
112
+ dataSource?: DataSource;
113
+ dataSourceConfig?: DataSourceConfig;
114
+ maxTrackHeight?: number;
115
+ metadata?: Record<string, string>;
116
+ order?: number;
117
+ /** Post-registration callback (e.g., wiring onWindowFunctionChange). */
118
+ onRegistered?: (findMT: () => {
119
+ cache: null | unknown;
120
+ dataSourceConfig: DataSourceConfig | null;
121
+ }) => void;
122
+ }
123
+ /**
124
+ * Create a WorkerDataSource proxy for worker-eligible configs, or return null
125
+ * if dataSourceWorkerProvider is not set. Handles create + chrom alias + offsets wiring.
126
+ */
127
+ export declare function createWorkerDataSource<F>(config: DataSourceConfig, ctx: Pick<TrackFactoryContext, 'dataSourceWorkerProvider' | 'genome' | 'cumulativeOffsets'>): WorkerDataSource<F> | null;
128
+ /**
129
+ * Wire chromosome alias resolution and cumulative offsets on a direct (non-worker) data source.
130
+ * Consolidates the pattern repeated 7+ times in the old HeadlessGenomeBrowser.
131
+ */
132
+ export declare function wireDataSource(ds: DataSource, ctx: Pick<TrackFactoryContext, 'genome' | 'cumulativeOffsets'>): void;
133
+ /**
134
+ * Wire a WigTrackCanvas's window function change callback to trigger a data reload.
135
+ * Wraps the existing callback (set by the factory) so the original still fires.
136
+ */
137
+ export declare function wireWindowFunctionReload(track: WigTrackCanvas, reloadFn: () => void): void;
138
+ export declare function createRuler(ctx: TrackFactoryContext, options?: AddRulerOptions): FactoryResult<RulerTrackCanvas>;
139
+ export declare function createWigTrack(ctx: TrackFactoryContext, url: string, options?: AddWigTrackOptions): FactoryResult<WigTrackCanvas>;
140
+ export declare function createGtxTrack(ctx: TrackFactoryContext, url: string, options: AddGtxTrackOptions): FactoryResult<WigTrackCanvas>;
141
+ export declare function createGeneTrack(ctx: TrackFactoryContext, options?: AddAnnotationTrackOptions): FactoryResult<AnnotationTrackCanvas>;
142
+ export declare function createBedTrack(ctx: TrackFactoryContext, url: string, options?: AddBedTrackOptions): FactoryResult<AnnotationTrackCanvas>;
143
+ export declare function createInteractionTrack(ctx: TrackFactoryContext, url: string, options?: AddInteractionTrackOptions): FactoryResult<InteractionTrackCanvas>;
144
+ export declare function createWigTrackWithFeatures(ctx: TrackFactoryContext, features: WigFeature[], options?: AddWigTrackWithFeaturesOptions): FactoryResult<WigTrackCanvas>;
145
+ export declare function createBedTrackWithFeatures(ctx: TrackFactoryContext, features: BedFeature[], options?: AddBedTrackWithFeaturesOptions): FactoryResult<AnnotationTrackCanvas>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Browser module barrel exports.
3
+ *
4
+ * Re-exports from headless/ (Layer 3, no DOM) and dom/ (Layer 4, DOM shell).
5
+ */
6
+ export { HeadlessGenomeBrowser, BrowserEvent } from './headless/headlessGenomeBrowser';
7
+ export type { HeadlessGenomeBrowserOptions, ManagedTrack, AddRulerOptions, AddWigTrackOptions, AddGtxTrackOptions, AddBedTrackOptions, AddAnnotationTrackOptions, AddInteractionTrackOptions, AddSequenceTrackOptions, AddWigTrackWithFeaturesOptions, AddBedTrackWithFeaturesOptions, } from './headless/headlessGenomeBrowser';
8
+ export { ROIManager } from './headless/roiManager';
9
+ export type { ROIEventCallbacks } from './headless/roiManager';
10
+ export { TrackDataManager } from './headless/trackDataManager';
11
+ export type { DataEventCallbacks } from './headless/trackDataManager';
12
+ export { isAbortError, normalizeError } from './headless/errors';
13
+ export { SESSION_VERSION, createTrackFromSession, fromIgvSession, toIgvSession, } from './headless/session';
14
+ export type { CreateTrackFromSessionOptions } from './headless/session';
15
+ export { GenomeBrowser } from './dom/genomeBrowser';
16
+ export type { GenomeBrowserOptions, BrowserEvents } from './dom/genomeBrowser';
17
+ export { PointerEventManager } from './dom/pointerEventManager';
18
+ export type { PointerBrowserAccess } from './dom/pointerEventManager';
19
+ export { ROIOverlayManager } from './dom/roiOverlayManager';
20
+ export type { ROIOverlayCallbacks } from './dom/roiOverlayManager';
21
+ export { ContextMenuManager } from './dom/contextMenuManager';
22
+ export type { ContextMenuManagerCallbacks } from './dom/contextMenuManager';
23
+ export { createDefaultContextMenuProvider, createDefaultPopupProvider } from './dom/defaultProviders';
24
+ export { renderDOMBrowserSVG, svgToPNG, triggerDownload } from './dom/browserExport';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Browser export utilities — SVG and PNG export for the DOM GenomeBrowser.
3
+ *
4
+ * Pure functions that render the multi-track browser state to SVG/PNG,
5
+ * including axis columns and ROI overlays.
6
+ *
7
+ * Extracted from GenomeBrowser to isolate export logic.
8
+ *
9
+ * Layer 4 (DOM): requires DOM APIs (for PNG rendering via Image/Canvas).
10
+ */
11
+ import type { Locus, ROI } from './types';
12
+ import type { ManagedTrack } from './headlessGenomeBrowser';
13
+ import type { RenderTheme } from './themes/renderTheme';
14
+ /**
15
+ * Render the DOM browser view as an SVG string, including axis columns.
16
+ *
17
+ * Pure function — takes all needed state as parameters.
18
+ * Matches igv.js Browser.toSVG() which calls renderSVGAxis() for each TrackView.
19
+ */
20
+ export declare function renderDOMBrowserSVG(managedTracks: readonly ManagedTrack[], locus: Locus, theme: RenderTheme, visibleROIs: ROI[], axisColumnWidth: number, options?: {
21
+ width?: number;
22
+ containerWidth?: number;
23
+ backdropColor?: string;
24
+ }): string;
25
+ /**
26
+ * Convert an SVG string to a PNG data URL.
27
+ *
28
+ * Pipeline: SVG string → Blob → object URL → Image → Canvas (DPR-scaled) → toDataURL.
29
+ */
30
+ export declare function svgToPNG(svgString: string, width: number, height: number, dpr: number): Promise<string>;
31
+ /** Trigger a file download via a temporary anchor element. */
32
+ export declare function triggerDownload(filename: string, url: string): void;
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Follows the discriminated-union + result-map pattern from workerProvider.ts.
9
9
  */
10
- import type { HeadlessGenomeBrowser } from './headlessGenomeBrowser';
10
+ import type { HeadlessGenomeBrowser } from './browser/headless/headlessGenomeBrowser';
11
11
  import type { ROI, ROISetConfig, TrackSessionConfig, SessionConfig } from './types';
12
12
  import type { TrackSelector } from './trackSelector';
13
13
  import type { ProjectedState, TrackSummary } from './stateProjection';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * ContextMenuManager — handles right-click context menus for tracks and ROIs.
3
+ *
4
+ * Manages the contextmenu event listener, lazy input dialog creation,
5
+ * track-specific and common menu item assembly, and ROI context menus.
6
+ *
7
+ * Extracted from GenomeBrowser to isolate context menu lifecycle.
8
+ *
9
+ * Layer 4 (DOM): requires DOM APIs.
10
+ */
11
+ import type { Track, TrackContextMenuEvent, ROI, Locus } from './types';
12
+ import type { ContextMenuProvider } from './contextMenuProvider';
13
+ import type { PopupProvider } from './popupProvider';
14
+ /** Callback interface for context menu actions that require browser-level coordination. */
15
+ export interface ContextMenuManagerCallbacks {
16
+ findTrackForTarget(target: EventTarget | null): Track | null;
17
+ getLocus(): Locus;
18
+ getViewportWidth(): number;
19
+ removeTrack(track: Track): void;
20
+ onAxisUpdate(track: Track): void;
21
+ updateROI(roiId: string, changes: Partial<Omit<ROI, 'id'>>): ROI | undefined;
22
+ removeROI(roiId: string): boolean;
23
+ setLocus(locus: Locus): void;
24
+ emitTrackContextMenu(event: TrackContextMenuEvent): void;
25
+ emitROIContextMenu(event: {
26
+ roi: ROI;
27
+ genomicLocation: number;
28
+ x: number;
29
+ y: number;
30
+ }): void;
31
+ }
32
+ export declare class ContextMenuManager {
33
+ private container;
34
+ private axisColumnWidth;
35
+ private contextMenuProvider;
36
+ private popupProvider;
37
+ private callbacks;
38
+ private handleContextMenu;
39
+ private inputDialog;
40
+ constructor(container: HTMLElement, axisColumnWidth: number, contextMenuProvider: ContextMenuProvider | undefined, popupProvider: PopupProvider | undefined, callbacks: ContextMenuManagerCallbacks);
41
+ /** Attach the contextmenu event listener to the container. */
42
+ setup(): void;
43
+ /** Show context menu for an ROI region. */
44
+ showROIContextMenu(roi: ROI, e: MouseEvent): void;
45
+ /** Remove context menu listener and dispose of input dialog. */
46
+ dispose(): void;
47
+ /** Lazy-create the input dialog element. Consolidates duplicated creation logic. */
48
+ private ensureInputDialog;
49
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Gene/feature name lookup via the igv.org locus web service.
3
+ *
4
+ * Ports js/searchFeatures.ts: searchWebService() + parseSearchResults().
5
+ * Layer 1 — no DOM dependencies.
6
+ */
7
+ /** Result from a gene/feature name search. */
8
+ export interface SearchResult {
9
+ chr: string;
10
+ start: number;
11
+ end: number;
12
+ name: string;
13
+ }
14
+ /**
15
+ * Look up a gene/feature name via the igv.org locus web service.
16
+ * Returns the first matching result, or undefined if not found.
17
+ */
18
+ export declare function searchWebService(featureName: string, genomeId: string, signal?: AbortSignal): Promise<SearchResult | undefined>;
19
+ /**
20
+ * Parse tab-delimited search results from igv.org locus.php.
21
+ * Format per line: GENENAME\tchr:start-end\tdescription
22
+ * Returns the first valid result, or undefined.
23
+ */
24
+ export declare function parseSearchResults(data: string): SearchResult | undefined;
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * Layer 1 (Data + Layout): no DOM.
11
11
  */
12
- import type { DataSourceConfig, Locus } from './types';
12
+ import type { DataSourceConfig, DataSourceConfigMethod, Locus } from './types';
13
13
  /** Main thread → Worker messages. */
14
14
  export type DataSourceWorkerRequest = {
15
15
  type: 'create';
@@ -24,7 +24,7 @@ export type DataSourceWorkerRequest = {
24
24
  } | {
25
25
  type: 'configure';
26
26
  instanceId: string;
27
- method: string;
27
+ method: DataSourceConfigMethod;
28
28
  args: unknown[];
29
29
  } | {
30
30
  type: 'cancel';
@@ -67,7 +67,7 @@ export interface DataSourceWorkerProvider {
67
67
  * Send a configuration update to a worker-resident DataSource.
68
68
  * Used for serializable setter calls like setCumulativeOffsets, setWindowFunction.
69
69
  */
70
- configure(instanceId: string, method: string, ...args: unknown[]): void;
70
+ configure(instanceId: string, method: DataSourceConfigMethod, ...args: unknown[]): void;
71
71
  /**
72
72
  * Destroy a worker-resident DataSource instance.
73
73
  */
@@ -1,6 +1,6 @@
1
- import type { DataSource, Locus, WigFeature, WindowFunction } from '../types';
1
+ import type { DataSource, ConfigurableDataSource, Locus, WigFeature, WindowFunction } from '../types';
2
2
  import type { CumulativeOffsets } from '../genome/chromSizes';
3
- export declare class BigWigDataSource implements DataSource<WigFeature> {
3
+ export declare class BigWigDataSource implements DataSource<WigFeature>, ConfigurableDataSource {
4
4
  private url;
5
5
  private _windowFunction;
6
6
  private _cumulativeOffsets?;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Data source configuration types.
3
+ *
4
+ * Discriminated union for serializable data source reconstruction.
5
+ * Used by session serialization, track factories, and worker infrastructure.
6
+ *
7
+ * Layer 1 (Data): no DOM, no canvas.
8
+ */
9
+ import type { WindowFunction, TextFileFormat } from '../types';
10
+ /** Discriminated union for data source reconstruction. */
11
+ export type DataSourceConfig = BigWigDataSourceConfig | GtxDataSourceConfig | UCSCDataSourceConfig | TextDataSourceConfig | MemoryDataSourceConfig;
12
+ export interface BigWigDataSourceConfig {
13
+ type: 'bigwig';
14
+ url: string;
15
+ windowFunction?: WindowFunction;
16
+ }
17
+ export interface GtxDataSourceConfig {
18
+ type: 'gtx';
19
+ url: string;
20
+ experimentId: string;
21
+ windowFunction?: WindowFunction;
22
+ }
23
+ export interface UCSCDataSourceConfig {
24
+ type: 'ucsc';
25
+ genome?: string;
26
+ track?: string;
27
+ }
28
+ export interface TextDataSourceConfig {
29
+ type: 'text';
30
+ url: string;
31
+ /** Explicit format override. When absent, inferred from URL. */
32
+ format?: TextFileFormat;
33
+ /** Index URL override. Defaults to url + '.tbi'. */
34
+ indexURL?: string;
35
+ /** Whether the file is indexed (tabix). When absent, auto-detected from indexURL presence. */
36
+ indexed?: boolean;
37
+ }
38
+ export interface MemoryDataSourceConfig {
39
+ type: 'memory';
40
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Type-safe method dispatch for DataSource configuration.
3
+ *
4
+ * Centralizes setter calls by name (e.g., setCumulativeOffsets, setWindowFunction)
5
+ * on DataSource instances that may or may not implement ConfigurableDataSource.
6
+ *
7
+ * Previously used unsafe `Record<string, unknown>` casts — now constrained to
8
+ * known method names via `DataSourceConfigMethod`.
9
+ *
10
+ * Layer 1 (Data): no DOM, no canvas.
11
+ */
12
+ import type { DataSource, ConfigurableDataSource, DataSourceConfigMethod } from '../types';
13
+ /**
14
+ * Call a named configuration setter on a DataSource if it exists.
15
+ * The method name is constrained to known ConfigurableDataSource methods.
16
+ */
17
+ export declare function configureDataSource(ds: DataSource & Partial<ConfigurableDataSource>, method: DataSourceConfigMethod, ...args: unknown[]): void;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Factory: create a DataSource from a serializable DataSourceConfig.
3
+ *
4
+ * Shared by MainThreadProvider and DataSourceRegistry (worker-side) to
5
+ * avoid duplicating the config → DataSource mapping logic.
6
+ *
7
+ * Does NOT handle 'memory' or 'sequence' configs — those require
8
+ * non-serializable inputs (in-memory features, SequenceProvider function)
9
+ * and must stay on the main thread.
10
+ *
11
+ * Layer 1 (Data): no DOM, no canvas.
12
+ */
13
+ import type { DataSource, DataSourceConfig } from '../types';
14
+ export declare function createDataSource(config: DataSourceConfig): DataSource;
@@ -1,10 +1,11 @@
1
- import type { DataSource, Locus, AnnotationFeature } from '../types';
1
+ import type { DataSource, ConfigurableDataSource, Locus, AnnotationFeature } from '../types';
2
2
  import type { CumulativeOffsets } from '../genome/chromSizes';
3
3
  import type { FetchGenesOptions } from '../data/ucscApi';
4
- export declare class GeneDataSource implements DataSource<AnnotationFeature> {
4
+ export declare class GeneDataSource implements DataSource<AnnotationFeature>, ConfigurableDataSource {
5
5
  private options;
6
6
  private _cumulativeOffsets?;
7
- constructor(options?: FetchGenesOptions);
7
+ private maxWgFeatures;
8
+ constructor(options?: FetchGenesOptions, maxWgFeatures?: number);
8
9
  /** Set cumulative offsets for whole genome view coordinate transformation. */
9
10
  setCumulativeOffsets(offsets: CumulativeOffsets): void;
10
11
  fetch(locus: Locus, _bpPerPixel: number, signal: AbortSignal): Promise<AnnotationFeature[]>;
@@ -15,9 +15,9 @@
15
15
  *
16
16
  * Layer 1 (Data + Layout): no DOM, no canvas.
17
17
  */
18
- import type { DataSource, Locus, WigFeature, WindowFunction } from '../types';
18
+ import type { DataSource, ConfigurableDataSource, Locus, WigFeature, WindowFunction } from '../types';
19
19
  import type { CumulativeOffsets } from '../genome/chromSizes';
20
- export declare class GtxDataSource implements DataSource<WigFeature> {
20
+ export declare class GtxDataSource implements DataSource<WigFeature>, ConfigurableDataSource {
21
21
  private url;
22
22
  private experimentId;
23
23
  private _windowFunction;
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Layer 1 (Data + Layout): no DOM, no canvas.
9
9
  */
10
- import type { DataSource, Locus } from '../types';
10
+ import type { DataSource, ConfigurableDataSource, Locus } from '../types';
11
11
  import type { CacheableFeature } from '../featureCache';
12
12
  import type { CumulativeOffsets } from '../genome/chromSizes';
13
13
  /**
@@ -16,7 +16,7 @@ import type { CumulativeOffsets } from '../genome/chromSizes';
16
16
  * Features are indexed in a FeatureCache on construction for efficient
17
17
  * spatial queries. Calling `setFeatures()` replaces the cache entirely.
18
18
  */
19
- export declare class MemoryDataSource<F extends CacheableFeature = CacheableFeature> implements DataSource<F> {
19
+ export declare class MemoryDataSource<F extends CacheableFeature = CacheableFeature> implements DataSource<F>, ConfigurableDataSource {
20
20
  private cache;
21
21
  private _resolveChromName?;
22
22
  private _cumulativeOffsets?;
@@ -1,5 +1,7 @@
1
1
  import type { DataSource, Locus, SequenceProvider } from '../types';
2
2
  import type { SequenceFeature } from '../tracks/sequence/sequenceRenderer';
3
+ /** Default bpPerPixel threshold above which sequence data is not loaded. Matches igv.js bppSequenceThreshold = 10. */
4
+ export declare const DEFAULT_BPP_SEQUENCE_THRESHOLD = 10;
3
5
  /**
4
6
  * DataSource for sequence tracks — wraps a SequenceProvider to conform
5
7
  * to the standard DataSource<SequenceFeature> interface.
@@ -10,6 +12,7 @@ import type { SequenceFeature } from '../tracks/sequence/sequenceRenderer';
10
12
  */
11
13
  export declare class SequenceDataSource implements DataSource<SequenceFeature> {
12
14
  private sequenceProvider;
13
- constructor(sequenceProvider: SequenceProvider);
15
+ private bppThreshold;
16
+ constructor(sequenceProvider: SequenceProvider, bppThreshold?: number);
14
17
  fetch(locus: Locus, bpPerPixel: number, signal: AbortSignal): Promise<SequenceFeature[]>;
15
18
  }
@@ -10,7 +10,7 @@
10
10
  * Port of js/feature/textFeatureSource.ts and js/feature/featureFileReader.ts.
11
11
  * Layer 1 (Data + Layout): no DOM.
12
12
  */
13
- import type { DataSource, Locus, TextFileFormat } from '../types';
13
+ import type { DataSource, ConfigurableDataSource, Locus, TextFileFormat } from '../types';
14
14
  import type { CacheableFeature } from '../featureCache';
15
15
  import type { CumulativeOffsets } from '../genome/chromSizes';
16
16
  export interface TextFeatureSourceConfig {
@@ -31,7 +31,7 @@ export interface TextFeatureSourceConfig {
31
31
  * For indexed files: uses TabixReader to query by region, parses lines on each fetch.
32
32
  * For non-indexed files: loads entire file on first fetch, caches in FeatureCache.
33
33
  */
34
- export declare class TextFeatureSource<F extends CacheableFeature = CacheableFeature> implements DataSource<F> {
34
+ export declare class TextFeatureSource<F extends CacheableFeature = CacheableFeature> implements DataSource<F>, ConfigurableDataSource {
35
35
  private readonly url;
36
36
  private readonly format;
37
37
  private readonly assembleGFF;
@@ -56,4 +56,6 @@ export declare class TextFeatureSource<F extends CacheableFeature = CacheableFea
56
56
  private fetchNonIndexed;
57
57
  private loadAllFeatures;
58
58
  private fetchWG;
59
+ /** Release resources (TabixReader, feature cache). */
60
+ dispose(): void;
59
61
  }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Whole-genome coordinate transform utilities.
3
+ *
4
+ * Shared logic for converting per-chromosome features to genome-wide
5
+ * coordinates using CumulativeOffsets. Used by all DataSource implementations
6
+ * that support whole-genome view.
7
+ *
8
+ * Layer 1 (Data): no DOM, no canvas.
9
+ */
10
+ import type { CumulativeOffsets } from '../genome/chromSizes';
11
+ /** Minimal feature shape required for whole-genome coordinate transform. */
12
+ interface GenomicFeature {
13
+ chr?: string;
14
+ start: number;
15
+ end: number;
16
+ }
17
+ /**
18
+ * Transform per-chromosome features to genome-wide coordinates.
19
+ *
20
+ * For each feature, replaces `chr` with `'all'` and shifts `start`/`end`
21
+ * by the chromosome's cumulative offset. Features on unknown chromosomes
22
+ * are silently dropped. Results are sorted by start position.
23
+ */
24
+ /**
25
+ * Fetch features for all chromosomes in parallel, tolerating individual failures.
26
+ *
27
+ * Uses `Promise.allSettled` so a single chromosome failure doesn't abort the
28
+ * entire whole-genome view. If ALL chromosomes fail, the first error is re-thrown.
29
+ *
30
+ * @param chrNames - Chromosome names to fetch
31
+ * @param fetchChrom - Per-chromosome fetch function
32
+ * @param signal - AbortSignal for cancellation
33
+ * @returns Flattened array of features from all successful chromosome fetches
34
+ */
35
+ export declare function fetchAllChromosomes<F>(chrNames: string[], fetchChrom: (chr: string) => Promise<F[]>, signal?: AbortSignal): Promise<F[]>;
36
+ export declare function transformToWholeGenome<F extends GenomicFeature>(features: F[], offsets: CumulativeOffsets): F[];
37
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Default provider factories for GenomeBrowser.
3
+ *
4
+ * Creates lazy-loaded Web Component-based providers for popups and context menus.
5
+ * Separated to keep GenomeBrowser focused on browser orchestration.
6
+ *
7
+ * Layer 4 (DOM): requires DOM APIs.
8
+ */
9
+ import type { ContextMenuProvider } from './contextMenuProvider';
10
+ import type { PopupProvider } from './popupProvider';
11
+ /**
12
+ * Create a default ContextMenuProvider using <loom-context-menu>.
13
+ * This avoids statically importing the Web Component class (which extends
14
+ * HTMLElement and breaks SSR). The custom element self-registers on first
15
+ * import of ui/components/LoomContextMenu, but GenomeBrowser is always
16
+ * DOM-attached so we can safely trigger registration here.
17
+ */
18
+ export declare function createDefaultContextMenuProvider(): ContextMenuProvider;
19
+ /**
20
+ * Create a default PopupProvider using <loom-popup>.
21
+ * Same lazy/SSR-safe pattern as createDefaultContextMenuProvider.
22
+ */
23
+ export declare function createDefaultPopupProvider(): PopupProvider;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shared error utilities for the Loom genome browser.
3
+ *
4
+ * Consolidates error classification and normalization patterns
5
+ * previously scattered across multiple modules.
6
+ */
7
+ /** Check if an error is an AbortError (from fetch abort, signal abort, or worker abort). */
8
+ export declare function isAbortError(err: unknown): boolean;
9
+ /** Normalize an unknown thrown value into an Error instance. */
10
+ export declare function normalizeError(err: unknown): Error;
@@ -40,7 +40,7 @@ interface DecoderInfo {
40
40
  /** Whether parsed features need GFF transcript assembly. */
41
41
  requiresAssembly: boolean;
42
42
  /** Optional post-processing of all decoded features (e.g., BEDPE fixup). */
43
- postProcess?: (features: any[]) => void;
43
+ postProcess?: (features: unknown[]) => void;
44
44
  }
45
45
  /**
46
46
  * Get the appropriate decoder function and delimiter for a format string.