@genome-spy/core 0.63.0 → 0.65.0

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 (138) hide show
  1. package/dist/bundle/{index-CCJIjehY.js → AbortablePromiseCache-CcuMrnn7.js} +22 -91
  2. package/dist/bundle/browser-txUcLy2H.js +123 -0
  3. package/dist/bundle/index-BQpbYrv4.js +1712 -0
  4. package/dist/bundle/index-BhtHKLUo.js +73 -0
  5. package/dist/bundle/index-C0llXMqm.js +280 -0
  6. package/dist/bundle/index-CCe8rnZz.js +716 -0
  7. package/dist/bundle/index-CD7FLu9x.js +269 -0
  8. package/dist/bundle/{index-C08YCM2T.js → index-D-w7Mmt9.js} +246 -126
  9. package/dist/bundle/index-D74H8TTz.js +508 -0
  10. package/dist/bundle/index-DhcU-Gk-.js +1487 -0
  11. package/dist/bundle/index.es.js +5394 -4989
  12. package/dist/bundle/index.js +420 -362
  13. package/dist/bundle/inflate-DRgHi_KK.js +1050 -0
  14. package/dist/schema.json +93 -13
  15. package/dist/src/data/collector.d.ts +7 -2
  16. package/dist/src/data/collector.d.ts.map +1 -1
  17. package/dist/src/data/collector.js +13 -2
  18. package/dist/src/data/dataFlow.d.ts +20 -42
  19. package/dist/src/data/dataFlow.d.ts.map +1 -1
  20. package/dist/src/data/dataFlow.js +57 -80
  21. package/dist/src/data/dataFlow.test.js +35 -2
  22. package/dist/src/data/flowHandle.d.ts +15 -0
  23. package/dist/src/data/flowHandle.d.ts.map +1 -0
  24. package/dist/src/data/flowHandle.js +13 -0
  25. package/dist/src/data/flowInit.d.ts +85 -0
  26. package/dist/src/data/flowInit.d.ts.map +1 -0
  27. package/dist/src/data/flowInit.js +238 -0
  28. package/dist/src/data/flowInit.test.d.ts +2 -0
  29. package/dist/src/data/flowInit.test.d.ts.map +1 -0
  30. package/dist/src/data/flowInit.test.js +413 -0
  31. package/dist/src/data/flowOptimizer.d.ts +6 -4
  32. package/dist/src/data/flowOptimizer.d.ts.map +1 -1
  33. package/dist/src/data/flowOptimizer.js +29 -14
  34. package/dist/src/data/flowOptimizer.test.js +20 -15
  35. package/dist/src/data/sources/lazy/bamSource.js +1 -1
  36. package/dist/src/data/sources/lazy/bigBedSource.js +1 -1
  37. package/dist/src/data/sources/lazy/bigWigSource.js +1 -1
  38. package/dist/src/data/sources/lazy/gff3Source.d.ts +2 -6
  39. package/dist/src/data/sources/lazy/gff3Source.d.ts.map +1 -1
  40. package/dist/src/data/sources/lazy/gff3Source.js +4 -8
  41. package/dist/src/data/sources/lazy/indexedFastaSource.d.ts.map +1 -1
  42. package/dist/src/data/sources/lazy/indexedFastaSource.js +17 -17
  43. package/dist/src/data/sources/lazy/tabixSource.js +1 -1
  44. package/dist/src/genomeSpy.d.ts +1 -1
  45. package/dist/src/genomeSpy.d.ts.map +1 -1
  46. package/dist/src/genomeSpy.js +18 -61
  47. package/dist/src/gl/webGLHelper.d.ts.map +1 -1
  48. package/dist/src/gl/webGLHelper.js +8 -0
  49. package/dist/src/marks/link.fragment.glsl.js +1 -1
  50. package/dist/src/marks/link.vertex.glsl.js +1 -1
  51. package/dist/src/marks/mark.d.ts +1 -0
  52. package/dist/src/marks/mark.d.ts.map +1 -1
  53. package/dist/src/marks/mark.js +22 -1
  54. package/dist/src/marks/point.fragment.glsl.js +1 -1
  55. package/dist/src/marks/point.vertex.glsl.js +1 -1
  56. package/dist/src/marks/rect.fragment.glsl.js +1 -1
  57. package/dist/src/marks/rect.vertex.glsl.js +1 -1
  58. package/dist/src/marks/rule.fragment.glsl.js +1 -1
  59. package/dist/src/marks/rule.vertex.glsl.js +1 -1
  60. package/dist/src/marks/text.fragment.glsl.js +1 -1
  61. package/dist/src/marks/text.vertex.glsl.js +1 -1
  62. package/dist/src/selection/selection.d.ts +5 -0
  63. package/dist/src/selection/selection.d.ts.map +1 -1
  64. package/dist/src/selection/selection.js +43 -6
  65. package/dist/src/selection/selection.test.d.ts +2 -0
  66. package/dist/src/selection/selection.test.d.ts.map +1 -0
  67. package/dist/src/selection/selection.test.js +14 -0
  68. package/dist/src/spec/parameter.d.ts +28 -2
  69. package/dist/src/spec/sampleView.d.ts +3 -2
  70. package/dist/src/styles/{genome-spy.scss → genome-spy.css} +25 -21
  71. package/dist/src/styles/genome-spy.css.d.ts +1 -1
  72. package/dist/src/styles/genome-spy.css.d.ts.map +1 -1
  73. package/dist/src/styles/genome-spy.css.js +264 -195
  74. package/dist/src/styles/update.sh +14 -4
  75. package/dist/src/types/viewContext.d.ts +1 -1
  76. package/dist/src/utils/expression.d.ts +5 -0
  77. package/dist/src/utils/expression.d.ts.map +1 -1
  78. package/dist/src/utils/expression.js +37 -0
  79. package/dist/src/utils/interactionEvent.d.ts +18 -1
  80. package/dist/src/utils/interactionEvent.d.ts.map +1 -1
  81. package/dist/src/utils/interactionEvent.js +101 -1
  82. package/dist/src/utils/interactionEvent.test.d.ts +2 -0
  83. package/dist/src/utils/interactionEvent.test.d.ts.map +1 -0
  84. package/dist/src/utils/interactionEvent.test.js +35 -0
  85. package/dist/src/view/axisResolution.d.ts +5 -0
  86. package/dist/src/view/axisResolution.d.ts.map +1 -1
  87. package/dist/src/view/axisResolution.js +16 -1
  88. package/dist/src/view/facetView.d.ts +1 -1
  89. package/dist/src/view/facetView.d.ts.map +1 -1
  90. package/dist/src/view/facetView.js +1 -0
  91. package/dist/src/view/flowBuilder.d.ts +2 -2
  92. package/dist/src/view/flowBuilder.d.ts.map +1 -1
  93. package/dist/src/view/flowBuilder.js +21 -4
  94. package/dist/src/view/gridView/gridView.d.ts.map +1 -1
  95. package/dist/src/view/gridView/gridView.js +13 -0
  96. package/dist/src/view/gridView/selectionRect.d.ts +8 -4
  97. package/dist/src/view/gridView/selectionRect.d.ts.map +1 -1
  98. package/dist/src/view/gridView/selectionRect.js +28 -3
  99. package/dist/src/view/gridView/selectionRect.test.d.ts +2 -0
  100. package/dist/src/view/gridView/selectionRect.test.d.ts.map +1 -0
  101. package/dist/src/view/gridView/selectionRect.test.js +87 -0
  102. package/dist/src/view/paramMediator.d.ts +2 -1
  103. package/dist/src/view/paramMediator.d.ts.map +1 -1
  104. package/dist/src/view/paramMediator.js +13 -1
  105. package/dist/src/view/paramMediator.test.js +22 -0
  106. package/dist/src/view/scaleResolution.d.ts +5 -0
  107. package/dist/src/view/scaleResolution.d.ts.map +1 -1
  108. package/dist/src/view/scaleResolution.js +10 -0
  109. package/dist/src/view/testUtils.d.ts.map +1 -1
  110. package/dist/src/view/testUtils.js +16 -4
  111. package/dist/src/view/unitView.d.ts.map +1 -1
  112. package/dist/src/view/unitView.js +103 -10
  113. package/dist/src/view/view.d.ts +17 -1
  114. package/dist/src/view/view.d.ts.map +1 -1
  115. package/dist/src/view/view.js +57 -1
  116. package/dist/src/view/viewDispose.test.d.ts +2 -0
  117. package/dist/src/view/viewDispose.test.d.ts.map +1 -0
  118. package/dist/src/view/viewDispose.test.js +110 -0
  119. package/dist/src/view/viewUtils.d.ts +4 -4
  120. package/dist/src/view/viewUtils.d.ts.map +1 -1
  121. package/dist/src/view/viewUtils.js +19 -15
  122. package/dist/src/view/viewUtils.test.d.ts +2 -0
  123. package/dist/src/view/viewUtils.test.d.ts.map +1 -0
  124. package/dist/src/view/viewUtils.test.js +87 -0
  125. package/package.json +16 -16
  126. package/dist/bundle/__vite-browser-external-C--ziKoh.js +0 -8
  127. package/dist/bundle/_commonjsHelpers-DjF3Plf2.js +0 -26
  128. package/dist/bundle/index-5ajWdKly.js +0 -1319
  129. package/dist/bundle/index-B03-Om4z.js +0 -274
  130. package/dist/bundle/index-BftNdA0O.js +0 -27
  131. package/dist/bundle/index-Bg7C4Xat.js +0 -2750
  132. package/dist/bundle/index-C3QR8Lv6.js +0 -2131
  133. package/dist/bundle/index-DTcHjAHp.js +0 -505
  134. package/dist/bundle/index-DnIkxb0L.js +0 -1025
  135. package/dist/bundle/index-Ww3TAo6_.js +0 -71
  136. package/dist/bundle/index-g8iXgW0W.js +0 -651
  137. package/dist/bundle/long-B-FASCSo.js +0 -2387
  138. package/dist/bundle/remoteFile-BuaqFGWk.js +0 -94
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Synchronize flow handles after data flow optimization.
3
+ *
4
+ * @param {import("../view/view.js").default} root
5
+ * @param {Map<import("./sources/dataSource.js").default, import("./sources/dataSource.js").default>} canonicalBySource
6
+ */
7
+ export function syncFlowHandles(root: import("../view/view.js").default, canonicalBySource: Map<import("./sources/dataSource.js").default, import("./sources/dataSource.js").default>): void;
8
+ /**
9
+ * Initializes data flow and mark wiring for a subtree without rebuilding the
10
+ * entire view hierarchy. This is the primary entry point for dynamic view
11
+ * insertion: build the subtree fully, call this, then attach the subtree to
12
+ * the live hierarchy.
13
+ *
14
+ * What it does:
15
+ * - builds/extends the dataflow graph for the subtree
16
+ * - runs flow optimization and syncs flow handles to canonical data sources
17
+ * - discovers the nearest data sources for views in the subtree
18
+ * - initializes dataflow nodes (initialize) for those sources
19
+ * - initializes mark encoders for unit views
20
+ * - queues graphics initialization (if a GL context exists)
21
+ * - wires collector observers so marks update on data arrival
22
+ *
23
+ * How to use it:
24
+ * - call after the subtree is fully constructed (post-order build)
25
+ * - do not attach the subtree to the live hierarchy until after this call
26
+ * - dispose the old subtree before replacing it to prevent observer leaks
27
+ * - follow up with finalizeSubtreeGraphics(...) once graphics promises resolve
28
+ * - reconfigure scales for the subtree when data loads complete
29
+ *
30
+ * Considerations:
31
+ * - this does not trigger data loading; callers decide when to load
32
+ * - data sources are derived by walking to the nearest ancestor source; nested
33
+ * sources should be treated as boundaries (do not walk past them)
34
+ * - only call updateGraphicsData when graphics are initialized or a GL context
35
+ * is available; headless/test contexts must avoid WebGL usage
36
+ * - loadViewSubtreeData emits a subtree-scoped "subtreeDataReady" broadcast
37
+ *
38
+ * TODO:
39
+ * - promote in-flight load caching to a persistent load-state per source
40
+ * - replace global dataLoaded usage with subtree-scoped readiness
41
+ * - integrate with async font readiness for text marks
42
+ * - unify observer wiring via a disposable registry across view types
43
+ *
44
+ * @param {import("../view/view.js").default} subtreeRoot
45
+ * @param {import("./dataFlow.js").default} flow
46
+ * @returns {{
47
+ * dataFlow: import("./dataFlow.js").default,
48
+ * unitViews: UnitView[],
49
+ * dataSources: Set<import("./sources/dataSource.js").default>,
50
+ * graphicsPromises: Promise<import("../marks/mark.js").default>[]
51
+ * }}
52
+ */
53
+ export function initializeViewSubtree(subtreeRoot: import("../view/view.js").default, flow: import("./dataFlow.js").default): {
54
+ dataFlow: import("./dataFlow.js").default;
55
+ unitViews: UnitView[];
56
+ dataSources: Set<import("./sources/dataSource.js").default>;
57
+ graphicsPromises: Promise<import("../marks/mark.js").default>[];
58
+ };
59
+ /**
60
+ * Collects data sources needed to initialize all views in the subtree.
61
+ * This includes sources that are overridden deeper in the hierarchy.
62
+ *
63
+ * @param {import("../view/view.js").default | import("../view/view.js").default[]} subtreeRoot
64
+ * @returns {Set<import("./sources/dataSource.js").default>}
65
+ */
66
+ export function collectViewSubtreeDataSources(subtreeRoot: import("../view/view.js").default | import("../view/view.js").default[]): Set<import("./sources/dataSource.js").default>;
67
+ /**
68
+ * Collects the nearest data sources under a subtree root.
69
+ * These sources define data-ready boundaries for subtree-level loading.
70
+ *
71
+ * @param {import("../view/view.js").default} subtreeRoot
72
+ * @returns {Set<import("./sources/dataSource.js").default>}
73
+ */
74
+ export function collectNearestViewSubtreeDataSources(subtreeRoot: import("../view/view.js").default): Set<import("./sources/dataSource.js").default>;
75
+ /**
76
+ * Loads the nearest data sources for a subtree.
77
+ * Use the returned promise as a subtree-level "data ready" signal.
78
+ *
79
+ * @param {import("../view/view.js").default} subtreeRoot
80
+ * @param {Set<import("./sources/dataSource.js").default>} [dataSources]
81
+ * @returns {Promise<void[]>}
82
+ */
83
+ export function loadViewSubtreeData(subtreeRoot: import("../view/view.js").default, dataSources?: Set<import("./sources/dataSource.js").default>): Promise<void[]>;
84
+ import UnitView from "../view/unitView.js";
85
+ //# sourceMappingURL=flowInit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowInit.d.ts","sourceRoot":"","sources":["../../../src/data/flowInit.js"],"names":[],"mappings":"AAoCA;;;;;GAKG;AACH,sCAHW,OAAO,iBAAiB,EAAE,OAAO,qBACjC,GAAG,CAAC,OAAO,yBAAyB,EAAE,OAAO,EAAE,OAAO,yBAAyB,EAAE,OAAO,CAAC,QAcnG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,mDATW,OAAO,iBAAiB,EAAE,OAAO,QACjC,OAAO,eAAe,EAAE,OAAO,GAC7B;IACN,QAAQ,EAAE,OAAO,eAAe,EAAE,OAAO,CAAC;IAC1C,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,WAAW,EAAE,GAAG,CAAC,OAAO,yBAAyB,EAAE,OAAO,CAAC,CAAC;IAC5D,gBAAgB,EAAE,OAAO,CAAC,OAAO,kBAAkB,EAAE,OAAO,CAAC,EAAE,CAAA;CAClE,CAsDH;AAED;;;;;;GAMG;AACH,2DAHW,OAAO,iBAAiB,EAAE,OAAO,GAAG,OAAO,iBAAiB,EAAE,OAAO,EAAE,GACrE,GAAG,CAAC,OAAO,yBAAyB,EAAE,OAAO,CAAC,CAmB1D;AAED;;;;;;GAMG;AACH,kEAHW,OAAO,iBAAiB,EAAE,OAAO,GAC/B,GAAG,CAAC,OAAO,yBAAyB,EAAE,OAAO,CAAC,CAY1D;AAED;;;;;;;GAOG;AACH,iDAJW,OAAO,iBAAiB,EAAE,OAAO,gBACjC,GAAG,CAAC,OAAO,yBAAyB,EAAE,OAAO,CAAC,GAC5C,OAAO,CAAC,IAAI,EAAE,CAAC,CAe3B;qBA7NoB,qBAAqB"}
@@ -0,0 +1,238 @@
1
+ import UnitView from "../view/unitView.js";
2
+ import { buildDataFlow } from "../view/flowBuilder.js";
3
+ import { optimizeDataFlow } from "./flowOptimizer.js";
4
+ import { VISIT_SKIP } from "../view/view.js";
5
+ import { reconfigureScales } from "../view/scaleResolution.js";
6
+
7
+ /** @type {WeakMap<import("./sources/dataSource.js").default, Promise<void>>} */
8
+ const inFlightLoads = new WeakMap();
9
+
10
+ /**
11
+ * Deduplicate concurrent loads for shared sources without changing propagation.
12
+ *
13
+ * Data sources still propagate rows immediately during `load()`/`loadSynchronously`
14
+ * and do not retain data. This helper only prevents overlapping `load()` calls
15
+ * from running twice; collectors remain the sole in-memory cache. Once the load
16
+ * promise settles, the source may be loaded again later as usual.
17
+ *
18
+ * @param {import("./sources/dataSource.js").default} dataSource
19
+ * @returns {Promise<void>}
20
+ */
21
+ function loadDataSourceOnce(dataSource) {
22
+ const existing = inFlightLoads.get(dataSource);
23
+ if (existing) {
24
+ return existing;
25
+ }
26
+
27
+ const loadPromise = Promise.resolve()
28
+ .then(() => dataSource.load())
29
+ .finally(() => {
30
+ inFlightLoads.delete(dataSource);
31
+ });
32
+
33
+ inFlightLoads.set(dataSource, loadPromise);
34
+ return loadPromise;
35
+ }
36
+
37
+ /**
38
+ * Synchronize flow handles after data flow optimization.
39
+ *
40
+ * @param {import("../view/view.js").default} root
41
+ * @param {Map<import("./sources/dataSource.js").default, import("./sources/dataSource.js").default>} canonicalBySource
42
+ */
43
+ export function syncFlowHandles(root, canonicalBySource) {
44
+ for (const view of root.getDescendants()) {
45
+ const handle = view.flowHandle;
46
+ if (!handle) {
47
+ continue;
48
+ }
49
+
50
+ const dataSource = handle.dataSource;
51
+ if (dataSource) {
52
+ handle.dataSource = canonicalBySource.get(dataSource) ?? dataSource;
53
+ }
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Initializes data flow and mark wiring for a subtree without rebuilding the
59
+ * entire view hierarchy. This is the primary entry point for dynamic view
60
+ * insertion: build the subtree fully, call this, then attach the subtree to
61
+ * the live hierarchy.
62
+ *
63
+ * What it does:
64
+ * - builds/extends the dataflow graph for the subtree
65
+ * - runs flow optimization and syncs flow handles to canonical data sources
66
+ * - discovers the nearest data sources for views in the subtree
67
+ * - initializes dataflow nodes (initialize) for those sources
68
+ * - initializes mark encoders for unit views
69
+ * - queues graphics initialization (if a GL context exists)
70
+ * - wires collector observers so marks update on data arrival
71
+ *
72
+ * How to use it:
73
+ * - call after the subtree is fully constructed (post-order build)
74
+ * - do not attach the subtree to the live hierarchy until after this call
75
+ * - dispose the old subtree before replacing it to prevent observer leaks
76
+ * - follow up with finalizeSubtreeGraphics(...) once graphics promises resolve
77
+ * - reconfigure scales for the subtree when data loads complete
78
+ *
79
+ * Considerations:
80
+ * - this does not trigger data loading; callers decide when to load
81
+ * - data sources are derived by walking to the nearest ancestor source; nested
82
+ * sources should be treated as boundaries (do not walk past them)
83
+ * - only call updateGraphicsData when graphics are initialized or a GL context
84
+ * is available; headless/test contexts must avoid WebGL usage
85
+ * - loadViewSubtreeData emits a subtree-scoped "subtreeDataReady" broadcast
86
+ *
87
+ * TODO:
88
+ * - promote in-flight load caching to a persistent load-state per source
89
+ * - replace global dataLoaded usage with subtree-scoped readiness
90
+ * - integrate with async font readiness for text marks
91
+ * - unify observer wiring via a disposable registry across view types
92
+ *
93
+ * @param {import("../view/view.js").default} subtreeRoot
94
+ * @param {import("./dataFlow.js").default} flow
95
+ * @returns {{
96
+ * dataFlow: import("./dataFlow.js").default,
97
+ * unitViews: UnitView[],
98
+ * dataSources: Set<import("./sources/dataSource.js").default>,
99
+ * graphicsPromises: Promise<import("../marks/mark.js").default>[]
100
+ * }}
101
+ */
102
+ export function initializeViewSubtree(subtreeRoot, flow) {
103
+ const dataFlow = buildDataFlow(subtreeRoot, flow);
104
+ const canonicalBySource = optimizeDataFlow(dataFlow);
105
+ syncFlowHandles(subtreeRoot, canonicalBySource);
106
+ const subtreeViews = subtreeRoot.getDescendants();
107
+ const dataSources = collectViewSubtreeDataSources(subtreeViews);
108
+
109
+ // Initialize flow nodes for the sources that belong to this subtree.
110
+ for (const dataSource of dataSources) {
111
+ dataSource.visit((node) => node.initialize());
112
+ }
113
+
114
+ /** @type {UnitView[]} */
115
+ const unitViews = subtreeViews.filter((view) => view instanceof UnitView);
116
+
117
+ /** @type {Promise<import("../marks/mark.js").default>[]} */
118
+ const graphicsPromises = [];
119
+
120
+ const canInitializeGraphics = !!subtreeRoot.context.glHelper;
121
+
122
+ for (const view of unitViews) {
123
+ const mark = view.mark;
124
+ // Encoders can be initialized immediately; graphics need a GL context.
125
+ mark.initializeEncoders();
126
+ if (canInitializeGraphics) {
127
+ graphicsPromises.push(mark.initializeGraphics().then(() => mark));
128
+ }
129
+
130
+ // Wire collector completion to mark data/graphics updates.
131
+ const observer = (
132
+ /** @type {import("./collector.js").default} */ _collector
133
+ ) => {
134
+ mark.initializeData(); // does faceting
135
+ if (canInitializeGraphics) {
136
+ try {
137
+ mark.updateGraphicsData();
138
+ } catch (e) {
139
+ e.view = view;
140
+ throw e;
141
+ }
142
+ }
143
+ view.context.animator.requestRender();
144
+ };
145
+ view.registerDisposer(view.flowHandle.collector.observe(observer));
146
+ }
147
+
148
+ return {
149
+ dataFlow,
150
+ unitViews,
151
+ dataSources,
152
+ graphicsPromises,
153
+ };
154
+ }
155
+
156
+ /**
157
+ * Collects data sources needed to initialize all views in the subtree.
158
+ * This includes sources that are overridden deeper in the hierarchy.
159
+ *
160
+ * @param {import("../view/view.js").default | import("../view/view.js").default[]} subtreeRoot
161
+ * @returns {Set<import("./sources/dataSource.js").default>}
162
+ */
163
+ export function collectViewSubtreeDataSources(subtreeRoot) {
164
+ const subtreeViews = Array.isArray(subtreeRoot)
165
+ ? subtreeRoot
166
+ : subtreeRoot.getDescendants();
167
+ /** @type {Set<import("./sources/dataSource.js").default>} */
168
+ const dataSources = new Set();
169
+ for (const view of subtreeViews) {
170
+ // Walk up to the nearest view that owns a data source.
171
+ let current = view;
172
+ while (current && !current.flowHandle?.dataSource) {
173
+ current = current.dataParent;
174
+ }
175
+ if (current?.flowHandle?.dataSource) {
176
+ dataSources.add(current.flowHandle.dataSource);
177
+ }
178
+ }
179
+ return dataSources;
180
+ }
181
+
182
+ /**
183
+ * Collects the nearest data sources under a subtree root.
184
+ * These sources define data-ready boundaries for subtree-level loading.
185
+ *
186
+ * @param {import("../view/view.js").default} subtreeRoot
187
+ * @returns {Set<import("./sources/dataSource.js").default>}
188
+ */
189
+ export function collectNearestViewSubtreeDataSources(subtreeRoot) {
190
+ /** @type {Set<import("./sources/dataSource.js").default>} */
191
+ const dataSources = new Set();
192
+ subtreeRoot.visit((view) => {
193
+ if (view.flowHandle?.dataSource) {
194
+ dataSources.add(view.flowHandle.dataSource);
195
+ return VISIT_SKIP;
196
+ }
197
+ });
198
+ return dataSources;
199
+ }
200
+
201
+ /**
202
+ * Loads the nearest data sources for a subtree.
203
+ * Use the returned promise as a subtree-level "data ready" signal.
204
+ *
205
+ * @param {import("../view/view.js").default} subtreeRoot
206
+ * @param {Set<import("./sources/dataSource.js").default>} [dataSources]
207
+ * @returns {Promise<void[]>}
208
+ */
209
+ export function loadViewSubtreeData(
210
+ subtreeRoot,
211
+ dataSources = collectNearestViewSubtreeDataSources(subtreeRoot)
212
+ ) {
213
+ return Promise.all(
214
+ Array.from(dataSources).map((dataSource) =>
215
+ loadDataSourceOnce(dataSource)
216
+ )
217
+ ).then((results) => {
218
+ reconfigureScales(subtreeRoot);
219
+ broadcastSubtreeDataReady(subtreeRoot);
220
+ return results;
221
+ });
222
+ }
223
+
224
+ /**
225
+ * Broadcasts a subtree-scoped data-ready event to views within the subtree.
226
+ *
227
+ * @param {import("../view/view.js").default} subtreeRoot
228
+ */
229
+ function broadcastSubtreeDataReady(subtreeRoot) {
230
+ /** @type {import("../view/view.js").BroadcastMessage} */
231
+ const message = {
232
+ type: /** @type {import("../genomeSpy.js").BroadcastEventType} */ (
233
+ "subtreeDataReady"
234
+ ),
235
+ payload: { subtreeRoot },
236
+ };
237
+ subtreeRoot.visit((view) => view.handleBroadcast(message));
238
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=flowInit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowInit.test.d.ts","sourceRoot":"","sources":["../../../src/data/flowInit.test.js"],"names":[],"mappings":""}