@jbrowse/render-core 4.3.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 (164) hide show
  1. package/LICENSE +201 -0
  2. package/esm/OverlayCanvas.d.ts +29 -0
  3. package/esm/OverlayCanvas.js +43 -0
  4. package/esm/RenderCanvas.d.ts +76 -0
  5. package/esm/RenderCanvas.js +38 -0
  6. package/esm/RenderLifecycleMixin.d.ts +180 -0
  7. package/esm/RenderLifecycleMixin.js +279 -0
  8. package/esm/ScrollLockedOverlay.d.ts +28 -0
  9. package/esm/ScrollLockedOverlay.js +42 -0
  10. package/esm/blockClipUtils.d.ts +27 -0
  11. package/esm/blockClipUtils.js +101 -0
  12. package/esm/canvas2dUtils.d.ts +372 -0
  13. package/esm/canvas2dUtils.js +564 -0
  14. package/esm/canvasContext.d.ts +68 -0
  15. package/esm/canvasContext.js +74 -0
  16. package/esm/colorRampLut.d.ts +17 -0
  17. package/esm/colorRampLut.js +25 -0
  18. package/esm/coverageBand.d.ts +107 -0
  19. package/esm/coverageBand.js +109 -0
  20. package/esm/coverageBandBuffers.d.ts +30 -0
  21. package/esm/coverageBandBuffers.js +13 -0
  22. package/esm/createRenderingBackend.d.ts +52 -0
  23. package/esm/createRenderingBackend.js +58 -0
  24. package/esm/displayPhase.d.ts +155 -0
  25. package/esm/displayPhase.js +97 -0
  26. package/esm/globalRenderingBackend.d.ts +90 -0
  27. package/esm/globalRenderingBackend.js +53 -0
  28. package/esm/gpuDevice.d.ts +91 -0
  29. package/esm/gpuDevice.js +277 -0
  30. package/esm/graphicsCapabilities.d.ts +98 -0
  31. package/esm/graphicsCapabilities.js +165 -0
  32. package/esm/hal/createHal.d.ts +22 -0
  33. package/esm/hal/createHal.js +91 -0
  34. package/esm/hal/deviceGpuCache.d.ts +36 -0
  35. package/esm/hal/deviceGpuCache.js +120 -0
  36. package/esm/hal/gpuHalBase.d.ts +55 -0
  37. package/esm/hal/gpuHalBase.js +81 -0
  38. package/esm/hal/index.d.ts +7 -0
  39. package/esm/hal/index.js +5 -0
  40. package/esm/hal/mockHal.d.ts +153 -0
  41. package/esm/hal/mockHal.js +297 -0
  42. package/esm/hal/oomReporter.d.ts +15 -0
  43. package/esm/hal/oomReporter.js +22 -0
  44. package/esm/hal/passIds.d.ts +22 -0
  45. package/esm/hal/passIds.js +36 -0
  46. package/esm/hal/regionRegistry.d.ts +11 -0
  47. package/esm/hal/regionRegistry.js +66 -0
  48. package/esm/hal/types.d.ts +116 -0
  49. package/esm/hal/types.js +1 -0
  50. package/esm/hal/webgl2Hal.d.ts +47 -0
  51. package/esm/hal/webgl2Hal.js +490 -0
  52. package/esm/hal/webgpuHal.d.ts +169 -0
  53. package/esm/hal/webgpuHal.js +722 -0
  54. package/esm/installUpload.d.ts +91 -0
  55. package/esm/installUpload.js +94 -0
  56. package/esm/instanceCache.d.ts +43 -0
  57. package/esm/instanceCache.js +53 -0
  58. package/esm/instancePass.d.ts +50 -0
  59. package/esm/instancePass.js +34 -0
  60. package/esm/keyedRenderingBackend.d.ts +41 -0
  61. package/esm/keyedRenderingBackend.js +19 -0
  62. package/esm/mapUploadSync.d.ts +31 -0
  63. package/esm/mapUploadSync.js +45 -0
  64. package/esm/namedReactions.d.ts +29 -0
  65. package/esm/namedReactions.js +62 -0
  66. package/esm/perRegionRenderingBackend.d.ts +114 -0
  67. package/esm/perRegionRenderingBackend.js +93 -0
  68. package/esm/recoveryBudget.d.ts +40 -0
  69. package/esm/recoveryBudget.js +56 -0
  70. package/esm/regionDataMap.d.ts +60 -0
  71. package/esm/regionDataMap.js +98 -0
  72. package/esm/renderBlock.d.ts +25 -0
  73. package/esm/renderBlock.js +10 -0
  74. package/esm/renderingBackendBase.d.ts +71 -0
  75. package/esm/renderingBackendBase.js +50 -0
  76. package/esm/shaders/antialias.js.generated.d.ts +4 -0
  77. package/esm/shaders/antialias.js.generated.js +25 -0
  78. package/esm/shaders/capsule.generated.d.ts +1 -0
  79. package/esm/shaders/capsule.generated.js +3 -0
  80. package/esm/shaders/colorRampLut.generated.d.ts +1 -0
  81. package/esm/shaders/colorRampLut.generated.js +3 -0
  82. package/esm/shaders/coverageBand.generated.d.ts +2 -0
  83. package/esm/shaders/coverageBand.generated.js +4 -0
  84. package/esm/shaders/coverageBar.generated.d.ts +4 -0
  85. package/esm/shaders/coverageBar.generated.js +6 -0
  86. package/esm/shaders/coverageBar.iface.generated.d.ts +85 -0
  87. package/esm/shaders/coverageBar.iface.generated.js +114 -0
  88. package/esm/shaders/coverageIndicator.generated.d.ts +4 -0
  89. package/esm/shaders/coverageIndicator.generated.js +6 -0
  90. package/esm/shaders/coverageIndicator.iface.generated.d.ts +85 -0
  91. package/esm/shaders/coverageIndicator.iface.generated.js +114 -0
  92. package/esm/shaders/coverageInterbase.generated.d.ts +4 -0
  93. package/esm/shaders/coverageInterbase.generated.js +6 -0
  94. package/esm/shaders/coverageInterbase.iface.generated.d.ts +93 -0
  95. package/esm/shaders/coverageInterbase.iface.generated.js +134 -0
  96. package/esm/shaders/coverageMod.generated.d.ts +4 -0
  97. package/esm/shaders/coverageMod.generated.js +6 -0
  98. package/esm/shaders/coverageMod.iface.generated.d.ts +97 -0
  99. package/esm/shaders/coverageMod.iface.generated.js +144 -0
  100. package/esm/shaders/coverageSnp.generated.d.ts +4 -0
  101. package/esm/shaders/coverageSnp.generated.js +6 -0
  102. package/esm/shaders/coverageSnp.iface.generated.d.ts +97 -0
  103. package/esm/shaders/coverageSnp.iface.generated.js +144 -0
  104. package/esm/shaders/hpmath.js.generated.d.ts +3 -0
  105. package/esm/shaders/hpmath.js.generated.js +48 -0
  106. package/esm/shaders/pointGlyph.generated.d.ts +1 -0
  107. package/esm/shaders/pointGlyph.generated.js +3 -0
  108. package/esm/shaders/pointGlyph.js.generated.d.ts +1 -0
  109. package/esm/shaders/pointGlyph.js.generated.js +7 -0
  110. package/esm/shaders/rowRect.generated.d.ts +3 -0
  111. package/esm/shaders/rowRect.generated.js +5 -0
  112. package/esm/shaders/rowRect.js.generated.d.ts +2 -0
  113. package/esm/shaders/rowRect.js.generated.js +13 -0
  114. package/esm/shaders/scoreScale.js.generated.d.ts +1 -0
  115. package/esm/shaders/scoreScale.js.generated.js +46 -0
  116. package/esm/slangPass.d.ts +49 -0
  117. package/esm/slangPass.js +22 -0
  118. package/esm/useEventCallback.d.ts +1 -0
  119. package/esm/useEventCallback.js +19 -0
  120. package/esm/useGraphicsCapabilities.d.ts +17 -0
  121. package/esm/useGraphicsCapabilities.js +38 -0
  122. package/esm/useRenderingBackend.d.ts +83 -0
  123. package/esm/useRenderingBackend.js +422 -0
  124. package/esm/useTabVisibilityRerender.d.ts +13 -0
  125. package/esm/useTabVisibilityRerender.js +39 -0
  126. package/esm/webgpuUtils.d.ts +23 -0
  127. package/esm/webgpuUtils.js +76 -0
  128. package/package.json +91 -0
  129. package/src/shaders/antialias.js.generated.ts +33 -0
  130. package/src/shaders/antialias.slang +112 -0
  131. package/src/shaders/capsule.generated.ts +4 -0
  132. package/src/shaders/capsule.slang +62 -0
  133. package/src/shaders/colorPack.slang +26 -0
  134. package/src/shaders/colorRampLut.generated.ts +4 -0
  135. package/src/shaders/colorRampLut.slang +51 -0
  136. package/src/shaders/coverageBand.generated.ts +6 -0
  137. package/src/shaders/coverageBand.slang +276 -0
  138. package/src/shaders/coverageBar.generated.ts +10 -0
  139. package/src/shaders/coverageBar.iface.generated.ts +172 -0
  140. package/src/shaders/coverageBar.slang +37 -0
  141. package/src/shaders/coverageIndicator.generated.ts +10 -0
  142. package/src/shaders/coverageIndicator.iface.generated.ts +172 -0
  143. package/src/shaders/coverageIndicator.slang +61 -0
  144. package/src/shaders/coverageInterbase.generated.ts +10 -0
  145. package/src/shaders/coverageInterbase.iface.generated.ts +198 -0
  146. package/src/shaders/coverageInterbase.slang +63 -0
  147. package/src/shaders/coverageMod.generated.ts +10 -0
  148. package/src/shaders/coverageMod.iface.generated.ts +211 -0
  149. package/src/shaders/coverageMod.slang +36 -0
  150. package/src/shaders/coverageSnp.generated.ts +10 -0
  151. package/src/shaders/coverageSnp.iface.generated.ts +211 -0
  152. package/src/shaders/coverageSnp.slang +52 -0
  153. package/src/shaders/diagonalGrid.slang +25 -0
  154. package/src/shaders/glyphEdgeAlpha.test.ts +241 -0
  155. package/src/shaders/hpmath.js.generated.ts +47 -0
  156. package/src/shaders/hpmath.slang +226 -0
  157. package/src/shaders/pointGlyph.generated.ts +4 -0
  158. package/src/shaders/pointGlyph.js.generated.ts +9 -0
  159. package/src/shaders/pointGlyph.slang +93 -0
  160. package/src/shaders/rowRect.generated.ts +8 -0
  161. package/src/shaders/rowRect.js.generated.ts +17 -0
  162. package/src/shaders/rowRect.slang +160 -0
  163. package/src/shaders/scoreScale.js.generated.ts +51 -0
  164. package/src/shaders/scoreScale.slang +68 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2020] [Evolutionary Software Foundation]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * An absolutely-positioned, non-interactive Canvas2D layer that composites over
3
+ * a display's main canvas. Callers pass a `draw` closure capturing their
4
+ * current data; the effect re-runs whenever that closure or the size changes.
5
+ *
6
+ * Wrap the caller in `observer` (mobx-react memoizes it) so the component
7
+ * re-renders exactly when its own inputs change — `draw`'s identity then
8
+ * changes exactly when those inputs do, and an unrelated parent re-render
9
+ * (hover, scroll) costs no redraw.
10
+ *
11
+ * Lives here rather than in a plugin because the marker-overlay pattern is the
12
+ * Canvas2D counterpart of a GPU pass: every display that draws positioned marks
13
+ * over a rendering backend needs the same absolutely-positioned,
14
+ * `pointerEvents: 'none'`, dpr-prepared canvas. MAF has seven such overlays;
15
+ * alignments and canvas each had a hand-rolled copy.
16
+ *
17
+ * **The explicit CSS `width`/`height` are the load-bearing part.** A canvas is a
18
+ * replaced element, so `inset: 0` does not stretch it the way it stretches a
19
+ * div: with no CSS size it takes its INTRINSIC size, which `prepareCanvas` has
20
+ * just set to the DPR-scaled backing store. A hand-rolled copy that reached for
21
+ * `inset: 0` therefore drew everything at twice its x on a retina display and
22
+ * dropped the right half off the edge, while looking entirely plausible.
23
+ */
24
+ export default function OverlayCanvas({ width, height, draw, 'data-testid': testId, }: {
25
+ width: number;
26
+ height: number;
27
+ draw: (ctx: CanvasRenderingContext2D) => void;
28
+ 'data-testid'?: string;
29
+ }): import("react").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from 'react';
3
+ import { getPreparedCanvas2D } from './canvas2dUtils.js';
4
+ /**
5
+ * An absolutely-positioned, non-interactive Canvas2D layer that composites over
6
+ * a display's main canvas. Callers pass a `draw` closure capturing their
7
+ * current data; the effect re-runs whenever that closure or the size changes.
8
+ *
9
+ * Wrap the caller in `observer` (mobx-react memoizes it) so the component
10
+ * re-renders exactly when its own inputs change — `draw`'s identity then
11
+ * changes exactly when those inputs do, and an unrelated parent re-render
12
+ * (hover, scroll) costs no redraw.
13
+ *
14
+ * Lives here rather than in a plugin because the marker-overlay pattern is the
15
+ * Canvas2D counterpart of a GPU pass: every display that draws positioned marks
16
+ * over a rendering backend needs the same absolutely-positioned,
17
+ * `pointerEvents: 'none'`, dpr-prepared canvas. MAF has seven such overlays;
18
+ * alignments and canvas each had a hand-rolled copy.
19
+ *
20
+ * **The explicit CSS `width`/`height` are the load-bearing part.** A canvas is a
21
+ * replaced element, so `inset: 0` does not stretch it the way it stretches a
22
+ * div: with no CSS size it takes its INTRINSIC size, which `prepareCanvas` has
23
+ * just set to the DPR-scaled backing store. A hand-rolled copy that reached for
24
+ * `inset: 0` therefore drew everything at twice its x on a retina display and
25
+ * dropped the right half off the edge, while looking entirely plausible.
26
+ */
27
+ export default function OverlayCanvas({ width, height, draw, 'data-testid': testId, }) {
28
+ const canvasRef = useRef(null);
29
+ useEffect(() => {
30
+ const ctx = getPreparedCanvas2D(canvasRef.current, width, height);
31
+ if (ctx) {
32
+ draw(ctx);
33
+ }
34
+ }, [draw, width, height]);
35
+ return (_jsx("canvas", { ref: canvasRef, "data-testid": testId, style: {
36
+ position: 'absolute',
37
+ top: 0,
38
+ left: 0,
39
+ width,
40
+ height,
41
+ pointerEvents: 'none',
42
+ } }));
43
+ }
@@ -0,0 +1,76 @@
1
+ import type { DisplayStatusPhase } from './displayPhase.ts';
2
+ import type { ComponentPropsWithoutRef } from 'react';
3
+ /**
4
+ * The two fields of `useRenderingBackend`'s return value this needs, duck-typed
5
+ * so the hook's generic backend parameter doesn't have to be threaded here.
6
+ */
7
+ export interface RenderCanvasHandle {
8
+ canvasRef: (node: HTMLCanvasElement | null) => void;
9
+ canvasKey: number;
10
+ }
11
+ /**
12
+ * The `<canvas>` for a rendering backend owned **outside** `DisplayChrome` — the
13
+ * sanctioned drop-to-primitive path for the non-LGV views (dotplot, the synteny
14
+ * level), which have no `ChromeModel` contract and render their own banners.
15
+ *
16
+ * It exists for one invariant that was previously carried by prose:
17
+ * **`key={canvasKey}`**. Every backend re-init needs a canvas element that never
18
+ * held a context — `getContext('webgl2')` hands back the *same lost* context,
19
+ * and `getContext('2d')` returns **null** on any element that once had WebGL, so
20
+ * reusing the element turns a recoverable context loss into a permanent "Canvas
21
+ * 2D context not available" — and more generally a canvas's context kind is
22
+ * permanent, so a re-init whose HAL ladder lands on a different rung than last
23
+ * time cannot bind at all. These consumers keep their canvas mounted through an
24
+ * error by design (ADR-025), so they must key it; `DisplayChromeBase` keys its
25
+ * render-prop body on the same value for the displays on the chrome, which it
26
+ * does *not* get for free from the `renderError` unmount (that covers only a
27
+ * reported loss — see the `canvasKey` note in useRenderingBackend.ts).
28
+ * GPU_RENDERING.md said so and ended with "any new consumer rendering its own
29
+ * banner must too" — a rule enforced by remembering to read the doc. Rendering
30
+ * the element here makes it structural instead: there is no way to mount this
31
+ * canvas without the key.
32
+ *
33
+ * It owns the key and **nothing else** — everything (sizing, class, mouse
34
+ * handlers, `data-testid`) is forwarded.
35
+ *
36
+ * There used to be a readiness convention to fold in here and there is not any
37
+ * more: these two views spelled it `synteny_canvas_done` /
38
+ * `dotplot_webgl_canvas_done`, with an **underscore**, against `DisplayChrome`'s
39
+ * `-done`, and ADR-065 deleted both in favour of the `data-display-drawn` this
40
+ * component already publishes. Their readiness flag is still `settled` rather
41
+ * than `canvasDrawn`, which is a real distinction and not a naming one — a
42
+ * shared canvas repaints unconditionally, so `canvasDrawn` says nothing
43
+ * (ADR-009's scope clause) — so `drawn` is passed at the call site.
44
+ */
45
+ export default function RenderCanvas({ handle, drawn, phase, ...canvasProps }: {
46
+ handle: RenderCanvasHandle;
47
+ /**
48
+ * Whether this canvas holds finished content — each view's own `settled`, the
49
+ * same flag its `*_canvas_done` testid is built from. Published as
50
+ * `data-display-drawn`, which is what `PENDING_DISPLAYS`
51
+ * (`@jbrowse/browser-test-utils`) selects on, so these views answer "has
52
+ * everything painted?" with the same attribute every LGV display does.
53
+ *
54
+ * Required, and that is the point: `PENDING_DISPLAYS` used to name
55
+ * `synteny_canvas` explicitly and simply **forgot dotplot**, so an unpainted
56
+ * dotplot counted as finished and a capture could land on it blank. A new
57
+ * drop-to-primitive view would have been forgotten the same way.
58
+ */
59
+ drawn: boolean;
60
+ /**
61
+ * The surface's own mutually-exclusive state, published as
62
+ * `data-display-phase` — the same attribute `DisplayStatusChrome` gives every
63
+ * LGV display, and the same split of meaning: `drawn` above is FINISHED
64
+ * CONTENT, this is still WORKING, and an error separates them.
65
+ *
66
+ * Required for the reason `drawn` is. Every DOM-level doneness wait
67
+ * (`waitForDisplayPhases`, the busy selector, `Instrumentation.displayPhase`)
68
+ * keys on `[data-display-phase]`, and a view that published none turned each
69
+ * of them into an assertion about an absent selector — satisfied by a canvas
70
+ * that had not begun to draw. That was true of both of these views.
71
+ *
72
+ * A shared canvas carries the ranking over its displays rather than one
73
+ * display's phase; `comparativeSurfacePhase` is where that ranking lives.
74
+ */
75
+ phase: DisplayStatusPhase;
76
+ } & Omit<ComponentPropsWithoutRef<'canvas'>, 'ref'>): import("react").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * The `<canvas>` for a rendering backend owned **outside** `DisplayChrome` — the
4
+ * sanctioned drop-to-primitive path for the non-LGV views (dotplot, the synteny
5
+ * level), which have no `ChromeModel` contract and render their own banners.
6
+ *
7
+ * It exists for one invariant that was previously carried by prose:
8
+ * **`key={canvasKey}`**. Every backend re-init needs a canvas element that never
9
+ * held a context — `getContext('webgl2')` hands back the *same lost* context,
10
+ * and `getContext('2d')` returns **null** on any element that once had WebGL, so
11
+ * reusing the element turns a recoverable context loss into a permanent "Canvas
12
+ * 2D context not available" — and more generally a canvas's context kind is
13
+ * permanent, so a re-init whose HAL ladder lands on a different rung than last
14
+ * time cannot bind at all. These consumers keep their canvas mounted through an
15
+ * error by design (ADR-025), so they must key it; `DisplayChromeBase` keys its
16
+ * render-prop body on the same value for the displays on the chrome, which it
17
+ * does *not* get for free from the `renderError` unmount (that covers only a
18
+ * reported loss — see the `canvasKey` note in useRenderingBackend.ts).
19
+ * GPU_RENDERING.md said so and ended with "any new consumer rendering its own
20
+ * banner must too" — a rule enforced by remembering to read the doc. Rendering
21
+ * the element here makes it structural instead: there is no way to mount this
22
+ * canvas without the key.
23
+ *
24
+ * It owns the key and **nothing else** — everything (sizing, class, mouse
25
+ * handlers, `data-testid`) is forwarded.
26
+ *
27
+ * There used to be a readiness convention to fold in here and there is not any
28
+ * more: these two views spelled it `synteny_canvas_done` /
29
+ * `dotplot_webgl_canvas_done`, with an **underscore**, against `DisplayChrome`'s
30
+ * `-done`, and ADR-065 deleted both in favour of the `data-display-drawn` this
31
+ * component already publishes. Their readiness flag is still `settled` rather
32
+ * than `canvasDrawn`, which is a real distinction and not a naming one — a
33
+ * shared canvas repaints unconditionally, so `canvasDrawn` says nothing
34
+ * (ADR-009's scope clause) — so `drawn` is passed at the call site.
35
+ */
36
+ export default function RenderCanvas({ handle, drawn, phase, ...canvasProps }) {
37
+ return (_jsx("canvas", { "data-display-drawn": drawn, "data-display-phase": phase, ref: handle.canvasRef, ...canvasProps }, handle.canvasKey));
38
+ }
@@ -0,0 +1,180 @@
1
+ import type { IStateTreeNode } from '@jbrowse/mobx-state-tree';
2
+ /**
3
+ * The slice of a display an installer needs. Every display that paints composes
4
+ * {@link RenderLifecycleMixin} (directly or through `MultiRegionDisplayMixin` /
5
+ * `GlobalFetchMixin`), so this is satisfied by construction; it exists so
6
+ * the installers can take `self` without importing a plugin's model type.
7
+ */
8
+ export interface LifecycleHost extends IStateTreeNode {
9
+ attachRenderingBackend: <B>(b: B, setup: () => RenderingBackendCallbacks<B>) => void;
10
+ }
11
+ export interface RenderingBackendCallbacks<B> {
12
+ /**
13
+ * Push bytes for the current data and say whether anything reached the
14
+ * backend. `true` forces a redraw, which a first arrival needs when the
15
+ * render callback's own dependencies are identity-stable across it; the
16
+ * map-diffing installers answer `false` for a run that uploaded nothing.
17
+ */
18
+ upload: (backend: B) => boolean;
19
+ /**
20
+ * Issue draw calls for the current frame. Return `true` if something was
21
+ * actually drawn (flips `canvasDrawn`), `false` to skip this tick
22
+ * (e.g. `renderState` not yet computed). Returning `true` without
23
+ * having drawn — or forgetting a return branch — will flip the
24
+ * `canvasDrawn` flag spuriously, which test selectors and overlay UI
25
+ * depend on.
26
+ */
27
+ render: (backend: B) => boolean;
28
+ }
29
+ /**
30
+ * Owns the GPU draw lifecycle for any display that paints to a canvas.
31
+ *
32
+ * Plugins compose this mixin (directly or via `MultiRegionDisplayMixin` /
33
+ * `GlobalFetchMixin`) and call
34
+ * `self.attachRenderingBackend(backend, () => ({ upload, render }))` from their
35
+ * own `startRenderingBackend(backend)` action. **The second argument is a thunk
36
+ * because it runs exactly once**, on the first attach: `startRenderingBackend`
37
+ * fires again on every context-loss recovery, and the autoruns keep the
38
+ * callbacks they were given first. Anything the callbacks close over — an
39
+ * upload sync's memo of what it last sent — is built inside it, so it lives as
40
+ * long as the callbacks that read it rather than being allocated per recovery
41
+ * and discarded. The mixin owns:
42
+ *
43
+ * - `canvasDrawn` — observable flag read by test-selector `data-testid` attributes to detect first paint.
44
+ * - `currentRenderingBackend` — the backend reference, updated on context-loss
45
+ * recovery. Autoruns read it each tick so they re-fire against the new
46
+ * one without being reinstalled.
47
+ * - `renderTick` — counter the render autorun observes; bumped by
48
+ * `renderNow()` (tab-visibility restore) and after every upload
49
+ * (ensures render re-fires when an upload happens but renderState
50
+ * identity stays stable).
51
+ * - `autorunsInstalled` — guards `attachRenderingBackend` so the autorun
52
+ * pair is spawned once per model instance, not once per backend
53
+ * assignment.
54
+ *
55
+ * The `upload` callback runs in one autorun, `render` in another. Inside
56
+ * each, every observable read is auto-tracked by MobX — no getter-layer
57
+ * indirection, no multi-entry config. `render` returns `true` when the
58
+ * backend actually painted content (flips `canvasDrawn`), `false` to skip
59
+ * this tick (e.g. `renderState` not yet computed or no regions loaded).
60
+ *
61
+ * #stateModel RenderLifecycleMixin
62
+ * #category display
63
+ * @see RenderLifecycleMixin.test.ts for the upload/render autorun behavior
64
+ */
65
+ export declare function RenderLifecycleMixin(): import("@jbrowse/mobx-state-tree").IModelType<{}, {
66
+ canvasDrawn: boolean;
67
+ currentRenderingBackend: unknown;
68
+ renderTick: number;
69
+ autorunsInstalled: boolean;
70
+ renderError: unknown;
71
+ } & {
72
+ /**
73
+ * #getter
74
+ * Overridable precondition (default true): both lifecycle autoruns skip
75
+ * their callback entirely while this is false, so a display never has to
76
+ * open its own `upload`/`render` with a readiness check.
77
+ *
78
+ * The LGV mixins override it with `view.initialized`, because before the
79
+ * view is measured its geometry throws by design (`view.width`, and so
80
+ * `visibleRegions` / `trackWidthPx` with it) and a throw in either callback
81
+ * is routed to `renderError` — surfacing "not measured yet" as the GPU
82
+ * render-error banner. Because it's an observable read inside the autoruns,
83
+ * the pair re-fires the moment it flips. This is the *precondition* axis
84
+ * only: whether any data has arrived stays the render callback's own gate
85
+ * (return `false` to skip a tick), which is why `renderState` getters can
86
+ * be plain resolved values.
87
+ */
88
+ readonly canRender: boolean;
89
+ /**
90
+ * #getter
91
+ * Overridable hook (default true): whether this display paints a canvas
92
+ * in its **current** configuration, as opposed to a deliberate static
93
+ * placeholder (LD with the triangle off, sequence past base resolution —
94
+ * both render a message where the `<canvas>` would go, so `canvasRef` is
95
+ * never called and `canvasDrawn` can never flip).
96
+ *
97
+ * Lives here, beside `canvasDrawn`, because every consumer of "has this
98
+ * display painted" needs the pair — and until 2026-08 each family
99
+ * declared its own copy (per-region hard-coded `true`, global carried the
100
+ * hook for LD), so a display could express the state only to whichever
101
+ * family it happened to compose. See `painted` below for the reader that
102
+ * was missed.
103
+ */
104
+ readonly rendersCanvas: boolean;
105
+ /**
106
+ * #getter
107
+ * Overridable hook (default false): the display has reached a state it
108
+ * will not paint its way out of, so `painted` below should answer
109
+ * *finished* rather than *pending*. Both LGV fetch families fill it with
110
+ * `!!error` — a fetch that failed before first paint keeps its canvas
111
+ * mounted, since the error bar is an overlay rather than a subtree
112
+ * replacement, so nothing ever draws into it. Named for `fetchInert` on
113
+ * the comparative side.
114
+ *
115
+ * A hook rather than a read of `error` here, for two reasons that both
116
+ * bite: this package is a leaf and `error` belongs to the fetch mixins,
117
+ * and declaring that name here would *collide* with `FetchMixin`'s
118
+ * volatile — `types.compose` gives the collision to its later argument,
119
+ * and the two families compose the two mixins in opposite orders.
120
+ */
121
+ readonly paintInert: boolean;
122
+ } & {
123
+ /**
124
+ * #getter
125
+ * **The first-paint answer every consumer outside the display should
126
+ * read**, `canvasDrawn` being only the raw flag: a display that is
127
+ * deliberately not painting a canvas has finished, and saying otherwise
128
+ * is a lie that never resolves.
129
+ *
130
+ * The two `rendersCanvas: false` states each had three of their four
131
+ * consumers wired by hand — the loading scrim (`rendersCanvas` /
132
+ * `fetchInert`) and the SVG export (`fetchInert`) —
133
+ * while the fourth, `data-display-drawn`, went on publishing `"false"`
134
+ * forever off the raw flag. That attribute is what `PENDING_DISPLAYS`
135
+ * (`@jbrowse/browser-test-utils`) selects on, so a zoomed-out reference
136
+ * sequence track made every `waitForDisplaysDone` on the page burn its
137
+ * full timeout — silently, since that wait swallows its own. Same shape
138
+ * as `fetchInert` on the comparative side: the reader you forget is the
139
+ * one outside the display, so the display has to publish one name for it.
140
+ *
141
+ * `paintInert` is the third term and the same argument once more, for the
142
+ * state where a display *would* paint a canvas and never gets to — a fetch
143
+ * that failed before first paint. See that hook.
144
+ */
145
+ readonly painted: boolean;
146
+ } & {
147
+ /**
148
+ * #action
149
+ */
150
+ markCanvasDrawn(): void;
151
+ /**
152
+ * #action
153
+ */
154
+ resetCanvasDrawn(): void;
155
+ /**
156
+ * #action
157
+ */
158
+ stopRenderingBackend(): void;
159
+ /**
160
+ * #action
161
+ */
162
+ renderNow(): void;
163
+ /**
164
+ * #action
165
+ * set/clear the render-backend error. Called by `useRenderingBackend`:
166
+ * with the error when the canvas factory rejects (or context-loss
167
+ * re-init fails), and with `undefined` on successful (re)init and on
168
+ * retry.
169
+ */
170
+ setRenderError(error: unknown): void;
171
+ } & {
172
+ /**
173
+ * #action
174
+ * attach a GPU/Canvas2D backend and install the upload + render autorun
175
+ * pair. Idempotent: re-calling swaps the backend and does not run `setup`
176
+ * again, so the callbacks and everything they close over are the first
177
+ * call's.
178
+ */
179
+ attachRenderingBackend<B>(backend: B, setup: () => RenderingBackendCallbacks<B>): void;
180
+ }, import("@jbrowse/mobx-state-tree")._NotCustomized, import("@jbrowse/mobx-state-tree")._NotCustomized>;