@jbrowse/core 1.7.11 → 2.1.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 (204) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +20 -4
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +313 -558
  3. package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -473
  4. package/BaseFeatureWidget/index.d.ts +2 -2
  5. package/BaseFeatureWidget/index.js +88 -124
  6. package/BaseFeatureWidget/types.d.ts +1 -0
  7. package/BaseFeatureWidget/types.js +1 -4
  8. package/BaseFeatureWidget/util.js +40 -75
  9. package/CorePlugin.js +55 -94
  10. package/Plugin.js +9 -34
  11. package/PluginLoader.js +153 -422
  12. package/PluginManager.d.ts +84 -117
  13. package/PluginManager.js +377 -666
  14. package/ReExports/Attributes.d.ts +2 -0
  15. package/ReExports/Attributes.js +5 -0
  16. package/ReExports/BaseCard.d.ts +2 -0
  17. package/ReExports/BaseCard.js +5 -0
  18. package/ReExports/DataGrid.d.ts +2 -0
  19. package/ReExports/DataGrid.js +6 -0
  20. package/ReExports/FeatureDetails.d.ts +2 -0
  21. package/ReExports/FeatureDetails.js +5 -0
  22. package/ReExports/index.js +6 -12
  23. package/ReExports/list.d.ts +5 -0
  24. package/ReExports/list.js +271 -7
  25. package/ReExports/material-ui-colors.d.ts +1 -19
  26. package/ReExports/material-ui-colors.js +16 -158
  27. package/ReExports/modules.d.ts +68 -109
  28. package/ReExports/modules.js +455 -244
  29. package/TextSearch/BaseResults.js +51 -123
  30. package/TextSearch/TextSearchManager.d.ts +3 -1
  31. package/TextSearch/TextSearchManager.js +66 -144
  32. package/assemblyManager/assembly.js +280 -554
  33. package/assemblyManager/assemblyConfigSchema.js +47 -64
  34. package/assemblyManager/assemblyManager.d.ts +12 -10
  35. package/assemblyManager/assemblyManager.js +126 -270
  36. package/assemblyManager/index.js +9 -22
  37. package/configuration/configurationSchema.js +167 -203
  38. package/configuration/configurationSlot.js +248 -326
  39. package/configuration/index.js +19 -35
  40. package/configuration/util.d.ts +1 -1
  41. package/configuration/util.js +131 -173
  42. package/data_adapters/BaseAdapter.d.ts +2 -2
  43. package/data_adapters/BaseAdapter.js +132 -521
  44. package/data_adapters/CytobandAdapter.js +40 -126
  45. package/data_adapters/dataAdapterCache.js +77 -158
  46. package/package.json +16 -18
  47. package/pluggableElementTypes/AdapterType.js +24 -79
  48. package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
  49. package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
  50. package/pluggableElementTypes/ConnectionType.js +22 -65
  51. package/pluggableElementTypes/DisplayType.js +35 -82
  52. package/pluggableElementTypes/InternetAccountType.js +23 -64
  53. package/pluggableElementTypes/PluggableElementBase.js +8 -20
  54. package/pluggableElementTypes/RpcMethodType.js +85 -427
  55. package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
  56. package/pluggableElementTypes/TrackType.js +26 -70
  57. package/pluggableElementTypes/ViewType.js +21 -63
  58. package/pluggableElementTypes/WidgetType.js +21 -64
  59. package/pluggableElementTypes/index.d.ts +4 -3
  60. package/pluggableElementTypes/index.js +42 -125
  61. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
  62. package/pluggableElementTypes/models/BaseDisplayModel.d.ts +10 -10
  63. package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
  64. package/pluggableElementTypes/models/BaseTrackModel.d.ts +1 -1
  65. package/pluggableElementTypes/models/BaseTrackModel.js +139 -200
  66. package/pluggableElementTypes/models/BaseViewModel.js +24 -40
  67. package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
  68. package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
  69. package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
  70. package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
  71. package/pluggableElementTypes/models/index.js +21 -70
  72. package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
  73. package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
  74. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
  75. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
  76. package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -255
  77. package/pluggableElementTypes/renderers/RendererType.js +31 -105
  78. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
  79. package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +2 -2
  80. package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
  81. package/pluggableElementTypes/renderers/index.js +19 -62
  82. package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
  83. package/rpc/BaseRpcDriver.js +169 -405
  84. package/rpc/MainThreadRpcDriver.js +27 -150
  85. package/rpc/RpcManager.js +58 -159
  86. package/rpc/WebWorkerRpcDriver.js +54 -171
  87. package/rpc/configSchema.js +25 -49
  88. package/rpc/coreRpcMethods.d.ts +1 -3
  89. package/rpc/coreRpcMethods.js +221 -959
  90. package/rpc/remoteAbortSignals.js +46 -70
  91. package/tsconfig.build.tsbuildinfo +1 -1
  92. package/ui/AboutDialog.js +107 -158
  93. package/ui/App.js +157 -261
  94. package/ui/AssemblySelector.d.ts +1 -1
  95. package/ui/AssemblySelector.js +59 -115
  96. package/ui/CascadingMenu.js +100 -199
  97. package/ui/ColorPicker.d.ts +16 -0
  98. package/ui/ColorPicker.js +97 -0
  99. package/ui/Drawer.js +28 -58
  100. package/ui/DrawerWidget.js +109 -209
  101. package/ui/DropDownMenu.d.ts +0 -8
  102. package/ui/DropDownMenu.js +60 -97
  103. package/ui/EditableTypography.d.ts +1 -1
  104. package/ui/EditableTypography.js +87 -155
  105. package/ui/ErrorMessage.js +41 -66
  106. package/ui/FactoryResetDialog.js +24 -57
  107. package/ui/FatalErrorDialog.js +59 -91
  108. package/ui/FileSelector/FileSelector.js +123 -189
  109. package/ui/FileSelector/LocalFileChooser.js +44 -71
  110. package/ui/FileSelector/UrlChooser.js +17 -38
  111. package/ui/FileSelector/index.js +6 -12
  112. package/ui/Icons.d.ts +1 -1
  113. package/ui/Icons.js +45 -69
  114. package/ui/Logo.js +57 -110
  115. package/ui/Menu.d.ts +1 -1
  116. package/ui/Menu.js +232 -355
  117. package/ui/PrerenderedCanvas.js +63 -78
  118. package/ui/ResizeHandle.js +87 -114
  119. package/ui/ReturnToImportFormDialog.js +32 -59
  120. package/ui/SanitizedHTML.js +63 -52
  121. package/ui/Snackbar.js +74 -99
  122. package/ui/SnackbarModel.js +37 -51
  123. package/ui/Tooltip.d.ts +3 -1
  124. package/ui/Tooltip.js +49 -74
  125. package/ui/ViewContainer.js +113 -183
  126. package/ui/colors.d.ts +10 -0
  127. package/ui/colors.js +78 -0
  128. package/ui/index.js +51 -181
  129. package/ui/react-colorful.d.ts +17 -0
  130. package/ui/react-colorful.js +455 -0
  131. package/ui/theme.d.ts +279 -131
  132. package/ui/theme.js +197 -225
  133. package/util/Base1DUtils.d.ts +32 -0
  134. package/util/Base1DUtils.js +174 -0
  135. package/util/Base1DViewModel.d.ts +16 -37
  136. package/util/Base1DViewModel.js +116 -295
  137. package/util/QuickLRU.js +84 -332
  138. package/util/TimeTraveller.d.ts +19 -0
  139. package/util/TimeTraveller.js +86 -0
  140. package/util/aborting.js +49 -127
  141. package/util/analytics.js +91 -154
  142. package/util/blockTypes.js +106 -240
  143. package/util/calculateDynamicBlocks.js +98 -128
  144. package/util/calculateStaticBlocks.js +105 -125
  145. package/util/color/cssColorsLevel4.js +156 -160
  146. package/util/color/index.js +33 -55
  147. package/util/compositeMap.js +49 -333
  148. package/util/formatFastaStrings.js +9 -14
  149. package/util/idMaker.js +18 -31
  150. package/util/index.d.ts +18 -39
  151. package/util/index.js +743 -1236
  152. package/util/io/RemoteFileWithRangeCache.js +88 -257
  153. package/util/io/index.js +95 -169
  154. package/util/jexl.js +60 -115
  155. package/util/jexlStrings.js +24 -29
  156. package/util/layouts/BaseLayout.js +1 -4
  157. package/util/layouts/GranularRectLayout.js +388 -557
  158. package/util/layouts/MultiLayout.js +41 -109
  159. package/util/layouts/PrecomputedLayout.js +56 -114
  160. package/util/layouts/PrecomputedMultiLayout.js +22 -59
  161. package/util/layouts/SceneGraph.js +127 -197
  162. package/util/layouts/index.js +29 -66
  163. package/util/mst-reflection.js +55 -71
  164. package/util/offscreenCanvasPonyfill.js +66 -134
  165. package/util/offscreenCanvasUtils.d.ts +2 -7
  166. package/util/offscreenCanvasUtils.js +49 -146
  167. package/util/range.js +29 -40
  168. package/util/rxjs.js +20 -27
  169. package/util/simpleFeature.js +88 -152
  170. package/util/stats.js +91 -151
  171. package/util/tracks.js +130 -171
  172. package/util/types/index.d.ts +3 -3
  173. package/util/types/index.js +110 -179
  174. package/util/types/mst.d.ts +3 -3
  175. package/util/types/mst.js +91 -142
  176. package/util/types/util.js +1 -4
  177. package/util/when.js +54 -101
  178. package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
  179. package/BaseFeatureWidget/index.test.js +0 -51
  180. package/TextSearch/BaseResults.test.js +0 -42
  181. package/configuration/configurationSchema.test.js +0 -266
  182. package/configuration/configurationSlot.test.js +0 -69
  183. package/configuration/util.test.js +0 -39
  184. package/data_adapters/BaseAdapter.test.js +0 -200
  185. package/declare.d.js +0 -1
  186. package/pluggableElementTypes/RpcMethodType.test.js +0 -118
  187. package/pluggableElementTypes/renderers/declare.d.js +0 -1
  188. package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
  189. package/rpc/BaseRpcDriver.test.js +0 -540
  190. package/rpc/declaration.d.js +0 -1
  191. package/ui/FatalErrorDialog.test.js +0 -82
  192. package/ui/SanitizedHTML.test.js +0 -36
  193. package/ui/theme.test.js +0 -111
  194. package/util/Base1DViewModel.test.js +0 -130
  195. package/util/calculateDynamicBlocks.test.js +0 -74
  196. package/util/calculateStaticBlocks.test.js +0 -297
  197. package/util/declare.d.js +0 -1
  198. package/util/formatFastaStrings.test.js +0 -40
  199. package/util/index.test.js +0 -213
  200. package/util/jexlStrings.test.js +0 -48
  201. package/util/layouts/GranularRectLayout.test.js +0 -99
  202. package/util/range.test.js +0 -64
  203. package/util/simpleFeature.test.js +0 -34
  204. package/util/stats.test.js +0 -172
@@ -1,28 +1,5 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
-
18
- var _index = require("../index");
19
-
20
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
21
-
22
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
-
24
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
25
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
26
3
  /**
27
4
  * Rectangle-layout manager that lays out rectangles using bitmaps at
28
5
  * resolution that, for efficiency, may be somewhat lower than that of
@@ -31,573 +8,427 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
31
8
  * bitmap resolution.
32
9
  */
33
10
  // minimum excess size of the array at which we garbage collect
34
- var minSizeToBotherWith = 10000;
35
- var maxFeaturePitchWidth = 20000;
36
-
11
+ const minSizeToBotherWith = 10000;
12
+ const maxFeaturePitchWidth = 20000;
37
13
  function segmentsIntersect(x1, x2, y1, y2) {
38
- return x2 >= y1 && y2 >= x1;
14
+ return x2 >= y1 && y2 >= x1;
39
15
  }
40
-
41
16
  // a single row in the layout
42
- var LayoutRow = /*#__PURE__*/function () {
43
- function LayoutRow() {
44
- (0, _classCallCheck2.default)(this, LayoutRow);
45
- (0, _defineProperty2.default)(this, "padding", void 0);
46
- (0, _defineProperty2.default)(this, "allFilled", void 0);
47
- (0, _defineProperty2.default)(this, "widthLimit", void 0);
48
- (0, _defineProperty2.default)(this, "rowState", void 0);
49
- this.padding = 1;
50
- this.widthLimit = 1000000; // this.rowState.offset is the offset of the bits array relative to the genomic coordinates
51
- // (modified by pitchX, but we don't know that in this class)
52
- // this.rowState.bits is the array of items in the layout row, indexed by (x - this.offset)
53
- // this.rowState.min is the leftmost edge of all the rectangles we have in the layout
54
- // this.rowState.max is the rightmost edge of all the rectangles we have in the layout
55
- } // log(msg: string): void {
56
- // // if (this.rowNumber === 0)
57
- // // eslint-disable-next-line no-console
58
- // console.log(`r${this.rowNumber}: ${msg}`)
59
- // }
60
-
61
-
62
- (0, _createClass2.default)(LayoutRow, [{
63
- key: "setAllFilled",
64
- value: function setAllFilled(data) {
65
- this.allFilled = data;
17
+ class LayoutRow {
18
+ constructor() {
19
+ this.padding = 1;
20
+ this.widthLimit = 1000000;
21
+ // this.rowState.offset is the offset of the bits array relative to the genomic coordinates
22
+ // (modified by pitchX, but we don't know that in this class)
23
+ // this.rowState.bits is the array of items in the layout row, indexed by (x - this.offset)
24
+ // this.rowState.min is the leftmost edge of all the rectangles we have in the layout
25
+ // this.rowState.max is the rightmost edge of all the rectangles we have in the layout
66
26
  }
67
- }, {
68
- key: "getItemAt",
69
- value: function getItemAt(x) {
70
- if (this.allFilled) {
71
- return this.allFilled;
72
- }
73
-
74
- if (!this.rowState) {
75
- return undefined;
76
- }
77
-
78
- if (this.rowState.min === undefined) {
79
- return undefined;
80
- }
81
-
82
- if (x < this.rowState.min) {
83
- return undefined;
84
- }
85
-
86
- if (x >= this.rowState.max) {
87
- return undefined;
88
- }
89
-
90
- var offset = x - this.rowState.offset; // if (offset < 0)
91
- // debugger
92
- // if (offset >= this.rowState.bits.length)
93
- // debugger
94
-
95
- return this.rowState.bits[offset];
27
+ // log(msg: string): void {
28
+ // // if (this.rowNumber === 0)
29
+ // // eslint-disable-next-line no-console
30
+ // console.log(`r${this.rowNumber}: ${msg}`)
31
+ // }
32
+ setAllFilled(data) {
33
+ this.allFilled = data;
96
34
  }
97
- }, {
98
- key: "isRangeClear",
99
- value: function isRangeClear(left, right) {
100
- if (this.allFilled) {
101
- return false;
102
- }
103
-
104
- if (!this.rowState) {
105
- return true;
106
- }
107
-
108
- var _this$rowState = this.rowState,
109
- min = _this$rowState.min,
110
- max = _this$rowState.max;
111
-
112
- if (right <= min || left >= max) {
35
+ getItemAt(x) {
36
+ if (this.allFilled) {
37
+ return this.allFilled;
38
+ }
39
+ if (!this.rowState) {
40
+ return undefined;
41
+ }
42
+ if (this.rowState.min === undefined) {
43
+ return undefined;
44
+ }
45
+ if (x < this.rowState.min) {
46
+ return undefined;
47
+ }
48
+ if (x >= this.rowState.max) {
49
+ return undefined;
50
+ }
51
+ const offset = x - this.rowState.offset;
52
+ // if (offset < 0)
53
+ // debugger
54
+ // if (offset >= this.rowState.bits.length)
55
+ // debugger
56
+ return this.rowState.bits[offset];
57
+ }
58
+ isRangeClear(left, right) {
59
+ if (this.allFilled) {
60
+ return false;
61
+ }
62
+ if (!this.rowState) {
63
+ return true;
64
+ }
65
+ const { min, max } = this.rowState;
66
+ if (right <= min || left >= max) {
67
+ return true;
68
+ }
69
+ // TODO: check right and middle before looping
70
+ const maxX = Math.min(max, right);
71
+ let x = Math.max(min, left);
72
+ for (; x < right && x < maxX; x += 1) {
73
+ if (this.getItemAt(x)) {
74
+ return false;
75
+ }
76
+ }
113
77
  return true;
114
- } // TODO: check right and middle before looping
115
-
116
-
117
- var maxX = Math.min(max, right);
118
- var x = Math.max(min, left);
119
-
120
- for (; x < right && x < maxX; x += 1) {
121
- if (this.getItemAt(x)) {
122
- return false;
123
- }
124
- }
125
-
126
- return true;
127
78
  }
128
- }, {
129
- key: "initialize",
130
- value: function initialize(left, right) {
131
- // NOTE: this.rowState.min, this.rowState.max, and this.rowState.offset are interbase coordinates
132
- var rectWidth = right - left;
133
- return {
134
- offset: left - rectWidth,
135
- min: left,
136
- max: right,
137
- bits: new Array(3 * rectWidth)
138
- }; // this.log(`initialize ${this.rowState.min} - ${this.rowState.max} (${this.rowState.bits.length})`)
79
+ initialize(left, right) {
80
+ // NOTE: this.rowState.min, this.rowState.max, and this.rowState.offset are interbase coordinates
81
+ const rectWidth = right - left;
82
+ return {
83
+ offset: left - rectWidth,
84
+ min: left,
85
+ max: right,
86
+ bits: new Array(3 * rectWidth),
87
+ };
88
+ // this.log(`initialize ${this.rowState.min} - ${this.rowState.max} (${this.rowState.bits.length})`)
139
89
  }
140
- }, {
141
- key: "addRect",
142
- value: function addRect(rect, data) {
143
- var left = rect.l;
144
- var right = rect.r + this.padding; // only padding on the right
145
-
146
- if (!this.rowState) {
147
- this.rowState = this.initialize(left, right);
148
- } // or check if we need to expand to the left and/or to the right
149
-
150
-
151
- var oLeft = left - this.rowState.offset;
152
- var oRight = right - this.rowState.offset;
153
- var currLength = this.rowState.bits.length; // expand rightward if necessary
154
-
155
- if (oRight >= this.rowState.bits.length) {
156
- var additionalLength = oRight + 1;
157
-
158
- if (this.rowState.bits.length + additionalLength > this.widthLimit) {
159
- console.warn('Layout width limit exceeded, discarding old layout. Please be more careful about discarding unused blocks.');
160
- this.rowState = this.initialize(left, right);
161
- } else if (additionalLength > 0) {
162
- this.rowState.bits = this.rowState.bits.concat(new Array(additionalLength));
163
- }
164
- } // expand leftward if necessary
165
-
166
-
167
- if (left < this.rowState.offset) {
168
- // use math.min to avoid negative lengths
169
- var _additionalLength = Math.min(currLength - oLeft, this.rowState.offset);
170
-
171
- if (this.rowState.bits.length + _additionalLength > this.widthLimit) {
172
- console.warn('Layout width limit exceeded, discarding old layout. Please be more careful about discarding unused blocks.');
173
- this.rowState = this.initialize(left, right);
174
- } else {
175
- this.rowState.bits = new Array(_additionalLength).concat(this.rowState.bits);
176
- this.rowState.offset -= _additionalLength;
177
- }
178
- }
179
-
180
- oRight = right - this.rowState.offset;
181
- oLeft = left - this.rowState.offset;
182
- var w = oRight - oLeft;
183
-
184
- if (w > maxFeaturePitchWidth) {
185
- console.warn("Layout X pitch set too low, feature spans ".concat(w, " bits in a single row."), rect, data);
186
- }
187
-
188
- for (var x = oLeft; x < oRight; x += 1) {
189
- this.rowState.bits[x] = data;
190
- }
191
-
192
- if (left < this.rowState.min) {
193
- this.rowState.min = left;
194
- }
195
-
196
- if (right > this.rowState.max) {
197
- this.rowState.max = right;
198
- }
90
+ addRect(rect, data) {
91
+ const left = rect.l;
92
+ const right = rect.r + this.padding; // only padding on the right
93
+ if (!this.rowState) {
94
+ this.rowState = this.initialize(left, right);
95
+ }
96
+ // or check if we need to expand to the left and/or to the right
97
+ let oLeft = left - this.rowState.offset;
98
+ let oRight = right - this.rowState.offset;
99
+ const currLength = this.rowState.bits.length;
100
+ // expand rightward if necessary
101
+ if (oRight >= this.rowState.bits.length) {
102
+ const additionalLength = oRight + 1;
103
+ if (this.rowState.bits.length + additionalLength > this.widthLimit) {
104
+ console.warn('Layout width limit exceeded, discarding old layout. Please be more careful about discarding unused blocks.');
105
+ this.rowState = this.initialize(left, right);
106
+ }
107
+ else if (additionalLength > 0) {
108
+ this.rowState.bits = this.rowState.bits.concat(new Array(additionalLength));
109
+ }
110
+ }
111
+ // expand leftward if necessary
112
+ if (left < this.rowState.offset) {
113
+ // use math.min to avoid negative lengths
114
+ const additionalLength = Math.min(currLength - oLeft, this.rowState.offset);
115
+ if (this.rowState.bits.length + additionalLength > this.widthLimit) {
116
+ console.warn('Layout width limit exceeded, discarding old layout. Please be more careful about discarding unused blocks.');
117
+ this.rowState = this.initialize(left, right);
118
+ }
119
+ else {
120
+ this.rowState.bits = new Array(additionalLength).concat(this.rowState.bits);
121
+ this.rowState.offset -= additionalLength;
122
+ }
123
+ }
124
+ oRight = right - this.rowState.offset;
125
+ oLeft = left - this.rowState.offset;
126
+ const w = oRight - oLeft;
127
+ if (w > maxFeaturePitchWidth) {
128
+ console.warn(`Layout X pitch set too low, feature spans ${w} bits in a single row.`, rect, data);
129
+ }
130
+ for (let x = oLeft; x < oRight; x += 1) {
131
+ this.rowState.bits[x] = data;
132
+ }
133
+ if (left < this.rowState.min) {
134
+ this.rowState.min = left;
135
+ }
136
+ if (right > this.rowState.max) {
137
+ this.rowState.max = right;
138
+ }
199
139
  }
200
140
  /**
201
141
  * Given a range of interbase coordinates, deletes all data dealing with that range
202
142
  */
203
-
204
- }, {
205
- key: "discardRange",
206
- value: function discardRange(left, right) {
207
- if (this.allFilled) {
208
- return;
209
- } // allFilled is irrevocable currently
210
- // if we have no data, do nothing
211
-
212
-
213
- if (!this.rowState) {
214
- return;
215
- } // if doesn't overlap at all, do nothing
216
-
217
-
218
- if (right <= this.rowState.min || left >= this.rowState.max) {
219
- return;
220
- } // if completely encloses range, discard everything
221
-
222
-
223
- if (left <= this.rowState.min && right >= this.rowState.max) {
224
- this.rowState = undefined;
225
- return;
226
- } // if overlaps left edge, adjust the min
227
-
228
-
229
- if (right > this.rowState.min && left <= this.rowState.min) {
230
- this.rowState.min = right;
231
- } // if overlaps right edge, adjust the max
232
-
233
-
234
- if (left < this.rowState.max && right >= this.rowState.max) {
235
- this.rowState.max = left;
236
- } // now trim the left, right, or both sides of the array
237
-
238
-
239
- if (this.rowState.offset < this.rowState.min - minSizeToBotherWith && this.rowState.bits.length > this.rowState.max + minSizeToBotherWith - this.rowState.offset) {
240
- // trim both sides
241
- var leftTrimAmount = this.rowState.min - this.rowState.offset;
242
- var rightTrimAmount = this.rowState.bits.length - 1 - (this.rowState.max - this.rowState.offset); // if (rightTrimAmount <= 0) debugger
243
- // if (leftTrimAmount <= 0) debugger
244
- // this.log(`trim both sides, ${leftTrimAmount} from left, ${rightTrimAmount} from right`)
245
-
246
- this.rowState.bits = this.rowState.bits.slice(leftTrimAmount, this.rowState.bits.length - rightTrimAmount);
247
- this.rowState.offset += leftTrimAmount; // if (this.rowState.offset > this.rowState.min) debugger
248
- // if (this.rowState.bits.length <= this.rowState.max - this.rowState.offset) debugger
249
- } else if (this.rowState.offset < this.rowState.min - minSizeToBotherWith) {
250
- // trim left side
251
- var desiredOffset = this.rowState.min - Math.floor(minSizeToBotherWith / 2);
252
- var trimAmount = desiredOffset - this.rowState.offset; // this.log(`trim left side by ${trimAmount}`)
253
-
254
- this.rowState.bits.splice(0, trimAmount);
255
- this.rowState.offset += trimAmount; // if (this.rowState.offset > this.rowState.min) debugger
256
- // if (this.rowState.bits.length <= this.rowState.max - this.rowState.offset) debugger
257
- } else if (this.rowState.bits.length > this.rowState.max - this.rowState.offset + minSizeToBotherWith) {
258
- // trim right side
259
- var desiredLength = this.rowState.max - this.rowState.offset + 1 + Math.floor(minSizeToBotherWith / 2); // this.log(`trim right side by ${this.rowState.bits.length-desiredLength}`)
260
- // if (desiredLength > this.rowState.bits.length) debugger
261
-
262
- this.rowState.bits.length = desiredLength; // if (this.rowState.offset > this.rowState.min) debugger
143
+ discardRange(left, right) {
144
+ if (this.allFilled) {
145
+ return;
146
+ } // allFilled is irrevocable currently
147
+ // if we have no data, do nothing
148
+ if (!this.rowState) {
149
+ return;
150
+ }
151
+ // if doesn't overlap at all, do nothing
152
+ if (right <= this.rowState.min || left >= this.rowState.max) {
153
+ return;
154
+ }
155
+ // if completely encloses range, discard everything
156
+ if (left <= this.rowState.min && right >= this.rowState.max) {
157
+ this.rowState = undefined;
158
+ return;
159
+ }
160
+ // if overlaps left edge, adjust the min
161
+ if (right > this.rowState.min && left <= this.rowState.min) {
162
+ this.rowState.min = right;
163
+ }
164
+ // if overlaps right edge, adjust the max
165
+ if (left < this.rowState.max && right >= this.rowState.max) {
166
+ this.rowState.max = left;
167
+ }
168
+ // now trim the left, right, or both sides of the array
169
+ if (this.rowState.offset < this.rowState.min - minSizeToBotherWith &&
170
+ this.rowState.bits.length >
171
+ this.rowState.max + minSizeToBotherWith - this.rowState.offset) {
172
+ // trim both sides
173
+ const leftTrimAmount = this.rowState.min - this.rowState.offset;
174
+ const rightTrimAmount = this.rowState.bits.length -
175
+ 1 -
176
+ (this.rowState.max - this.rowState.offset);
177
+ // if (rightTrimAmount <= 0) debugger
178
+ // if (leftTrimAmount <= 0) debugger
179
+ // this.log(`trim both sides, ${leftTrimAmount} from left, ${rightTrimAmount} from right`)
180
+ this.rowState.bits = this.rowState.bits.slice(leftTrimAmount, this.rowState.bits.length - rightTrimAmount);
181
+ this.rowState.offset += leftTrimAmount;
182
+ // if (this.rowState.offset > this.rowState.min) debugger
183
+ // if (this.rowState.bits.length <= this.rowState.max - this.rowState.offset) debugger
184
+ }
185
+ else if (this.rowState.offset < this.rowState.min - minSizeToBotherWith) {
186
+ // trim left side
187
+ const desiredOffset = this.rowState.min - Math.floor(minSizeToBotherWith / 2);
188
+ const trimAmount = desiredOffset - this.rowState.offset;
189
+ // this.log(`trim left side by ${trimAmount}`)
190
+ this.rowState.bits.splice(0, trimAmount);
191
+ this.rowState.offset += trimAmount;
192
+ // if (this.rowState.offset > this.rowState.min) debugger
193
+ // if (this.rowState.bits.length <= this.rowState.max - this.rowState.offset) debugger
194
+ }
195
+ else if (this.rowState.bits.length >
196
+ this.rowState.max - this.rowState.offset + minSizeToBotherWith) {
197
+ // trim right side
198
+ const desiredLength = this.rowState.max -
199
+ this.rowState.offset +
200
+ 1 +
201
+ Math.floor(minSizeToBotherWith / 2);
202
+ // this.log(`trim right side by ${this.rowState.bits.length-desiredLength}`)
203
+ // if (desiredLength > this.rowState.bits.length) debugger
204
+ this.rowState.bits.length = desiredLength;
205
+ // if (this.rowState.offset > this.rowState.min) debugger
206
+ // if (this.rowState.bits.length <= this.rowState.max - this.rowState.offset) debugger
207
+ }
208
+ // if (this.rowState.offset > this.rowState.min) debugger
263
209
  // if (this.rowState.bits.length <= this.rowState.max - this.rowState.offset) debugger
264
- } // if (this.rowState.offset > this.rowState.min) debugger
265
- // if (this.rowState.bits.length <= this.rowState.max - this.rowState.offset) debugger
266
- // if range now enclosed in the new bounds, loop through and clear the bits
267
-
268
-
269
- var oLeft = Math.max(this.rowState.min, left) - this.rowState.offset; // if (oLeft < 0) debugger
270
- // if (oLeft >= this.rowState.bits.length) debugger
271
- // if (oRight < 0) debugger
272
- // if (oRight >= this.rowState.bits.length) debugger
273
-
274
- var oRight = Math.min(right, this.rowState.max) - this.rowState.offset;
275
-
276
- for (var x = oLeft; x >= 0 && x < oRight; x += 1) {
277
- this.rowState.bits[x] = undefined;
278
- }
210
+ // if range now enclosed in the new bounds, loop through and clear the bits
211
+ const oLeft = Math.max(this.rowState.min, left) - this.rowState.offset;
212
+ // if (oLeft < 0) debugger
213
+ // if (oLeft >= this.rowState.bits.length) debugger
214
+ // if (oRight < 0) debugger
215
+ // if (oRight >= this.rowState.bits.length) debugger
216
+ const oRight = Math.min(right, this.rowState.max) - this.rowState.offset;
217
+ for (let x = oLeft; x >= 0 && x < oRight; x += 1) {
218
+ this.rowState.bits[x] = undefined;
219
+ }
279
220
  }
280
- }]);
281
- return LayoutRow;
282
- }();
283
-
284
- var GranularRectLayout = /*#__PURE__*/function () {
285
- /*
286
- *
287
- * pitchX - layout grid pitch in the X direction
288
- * pitchY - layout grid pitch in the Y direction
289
- * maxHeight - maximum layout height, default Infinity (no max)
290
- */
291
- function GranularRectLayout() {
292
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
293
- _ref$pitchX = _ref.pitchX,
294
- pitchX = _ref$pitchX === void 0 ? 10 : _ref$pitchX,
295
- _ref$pitchY = _ref.pitchY,
296
- pitchY = _ref$pitchY === void 0 ? 10 : _ref$pitchY,
297
- _ref$maxHeight = _ref.maxHeight,
298
- maxHeight = _ref$maxHeight === void 0 ? 10000 : _ref$maxHeight,
299
- _ref$hardRowLimit = _ref.hardRowLimit,
300
- hardRowLimit = _ref$hardRowLimit === void 0 ? 10000 : _ref$hardRowLimit,
301
- _ref$displayMode = _ref.displayMode,
302
- displayMode = _ref$displayMode === void 0 ? 'normal' : _ref$displayMode;
303
-
304
- (0, _classCallCheck2.default)(this, GranularRectLayout);
305
- (0, _defineProperty2.default)(this, "pitchX", void 0);
306
- (0, _defineProperty2.default)(this, "pitchY", void 0);
307
- (0, _defineProperty2.default)(this, "hardRowLimit", void 0);
308
- (0, _defineProperty2.default)(this, "bitmap", void 0);
309
- (0, _defineProperty2.default)(this, "rectangles", void 0);
310
- (0, _defineProperty2.default)(this, "maxHeightReached", void 0);
311
- (0, _defineProperty2.default)(this, "maxHeight", void 0);
312
- (0, _defineProperty2.default)(this, "displayMode", void 0);
313
- (0, _defineProperty2.default)(this, "pTotalHeight", void 0);
314
- this.pitchX = pitchX;
315
- this.pitchY = pitchY;
316
- this.hardRowLimit = hardRowLimit;
317
- this.maxHeightReached = false;
318
- this.displayMode = displayMode; // reduce the pitchY to try and pack the features tighter
319
-
320
- if (this.displayMode === 'compact') {
321
- this.pitchY = Math.round(this.pitchY / 4) || 1;
322
- this.pitchX = Math.round(this.pitchX / 4) || 1;
221
+ }
222
+ class GranularRectLayout {
223
+ /*
224
+ *
225
+ * pitchX - layout grid pitch in the X direction
226
+ * pitchY - layout grid pitch in the Y direction
227
+ * maxHeight - maximum layout height, default Infinity (no max)
228
+ */
229
+ constructor({ pitchX = 10, pitchY = 10, maxHeight = 10000, hardRowLimit = 10000, displayMode = 'normal', } = {}) {
230
+ this.pitchX = pitchX;
231
+ this.pitchY = pitchY;
232
+ this.hardRowLimit = hardRowLimit;
233
+ this.maxHeightReached = false;
234
+ this.displayMode = displayMode;
235
+ // reduce the pitchY to try and pack the features tighter
236
+ if (this.displayMode === 'compact') {
237
+ this.pitchY = Math.round(this.pitchY / 4) || 1;
238
+ this.pitchX = Math.round(this.pitchX / 4) || 1;
239
+ }
240
+ this.bitmap = [];
241
+ this.rectangles = new Map();
242
+ this.maxHeight = Math.ceil(maxHeight / this.pitchY);
243
+ this.pTotalHeight = 0; // total height, in units of bitmap squares (px/pitchY)
323
244
  }
324
-
325
- this.bitmap = [];
326
- this.rectangles = new Map();
327
- this.maxHeight = Math.ceil(maxHeight / this.pitchY);
328
- this.pTotalHeight = 0; // total height, in units of bitmap squares (px/pitchY)
329
- }
330
- /**
331
- * @returns top position for the rect, or Null if laying
332
- * out the rect would exceed maxHeight
333
- */
334
-
335
-
336
- (0, _createClass2.default)(GranularRectLayout, [{
337
- key: "addRect",
338
- value: function addRect(id, left, right, height, data) {
339
- // if we have already laid it out, return its layout
340
- var storedRec = this.rectangles.get(id);
341
-
342
- if (storedRec) {
343
- if (storedRec.top === null) {
344
- return null;
345
- } // add it to the bitmap again, since that bitmap range may have been
346
- // discarded
347
-
348
-
349
- this.addRectToBitmap(storedRec);
350
- return storedRec.top * this.pitchY;
351
- }
352
-
353
- var pLeft = Math.floor(left / this.pitchX);
354
- var pRight = Math.floor(right / this.pitchX);
355
- var pHeight = Math.ceil(height / this.pitchY);
356
- var rectangle = {
357
- id: id,
358
- l: pLeft,
359
- r: pRight,
360
- top: null,
361
- h: pHeight,
362
- originalHeight: height,
363
- data: data
364
- };
365
- var maxTop = this.maxHeight - pHeight;
366
- var top = 0;
367
-
368
- if (this.displayMode !== 'collapse') {
369
- for (; top <= maxTop; top += 1) {
370
- if (!this.collides(rectangle, top)) {
371
- break;
372
- }
373
- }
374
-
375
- if (top > maxTop) {
376
- rectangle.top = null;
377
- this.rectangles.set(id, rectangle);
378
- this.maxHeightReached = true;
379
- return null;
380
- }
381
- }
382
-
383
- rectangle.top = top;
384
- this.addRectToBitmap(rectangle);
385
- this.rectangles.set(id, rectangle);
386
- this.pTotalHeight = Math.max(this.pTotalHeight || 0, top + pHeight);
387
- return top * this.pitchY;
245
+ /**
246
+ * @returns top position for the rect, or Null if laying
247
+ * out the rect would exceed maxHeight
248
+ */
249
+ addRect(id, left, right, height, data) {
250
+ // if we have already laid it out, return its layout
251
+ const storedRec = this.rectangles.get(id);
252
+ if (storedRec) {
253
+ if (storedRec.top === null) {
254
+ return null;
255
+ }
256
+ // add it to the bitmap again, since that bitmap range may have been
257
+ // discarded
258
+ this.addRectToBitmap(storedRec);
259
+ return storedRec.top * this.pitchY;
260
+ }
261
+ const pLeft = Math.floor(left / this.pitchX);
262
+ const pRight = Math.floor(right / this.pitchX);
263
+ const pHeight = Math.ceil(height / this.pitchY);
264
+ const rectangle = {
265
+ id,
266
+ l: pLeft,
267
+ r: pRight,
268
+ top: null,
269
+ h: pHeight,
270
+ originalHeight: height,
271
+ data,
272
+ };
273
+ const maxTop = this.maxHeight - pHeight;
274
+ let top = 0;
275
+ if (this.displayMode !== 'collapse') {
276
+ for (; top <= maxTop; top += 1) {
277
+ if (!this.collides(rectangle, top)) {
278
+ break;
279
+ }
280
+ }
281
+ if (top > maxTop) {
282
+ rectangle.top = null;
283
+ this.rectangles.set(id, rectangle);
284
+ this.maxHeightReached = true;
285
+ return null;
286
+ }
287
+ }
288
+ rectangle.top = top;
289
+ this.addRectToBitmap(rectangle);
290
+ this.rectangles.set(id, rectangle);
291
+ this.pTotalHeight = Math.max(this.pTotalHeight || 0, top + pHeight);
292
+ return top * this.pitchY;
388
293
  }
389
- }, {
390
- key: "collides",
391
- value: function collides(rect, top) {
392
- var bitmap = this.bitmap;
393
- var maxY = top + rect.h;
394
-
395
- for (var y = top; y < maxY; y += 1) {
396
- var row = bitmap[y];
397
-
398
- if (row && !row.isRangeClear(rect.l, rect.r)) {
399
- return true;
400
- }
401
- }
402
-
403
- return false;
294
+ collides(rect, top) {
295
+ const { bitmap } = this;
296
+ const maxY = top + rect.h;
297
+ for (let y = top; y < maxY; y += 1) {
298
+ const row = bitmap[y];
299
+ if (row && !row.isRangeClear(rect.l, rect.r)) {
300
+ return true;
301
+ }
302
+ }
303
+ return false;
404
304
  }
405
305
  /**
406
306
  * make a subarray if it does not exist
407
307
  */
408
-
409
- }, {
410
- key: "autovivifyRow",
411
- value: function autovivifyRow(bitmap, y) {
412
- var row = bitmap[y];
413
-
414
- if (!row) {
415
- if (y > this.hardRowLimit) {
416
- throw new Error("layout hard limit (".concat(this.hardRowLimit * this.pitchY, "px) exceeded, aborting layout"));
417
- }
418
-
419
- row = new LayoutRow();
420
- bitmap[y] = row;
421
- }
422
-
423
- return row;
308
+ autovivifyRow(bitmap, y) {
309
+ let row = bitmap[y];
310
+ if (!row) {
311
+ if (y > this.hardRowLimit) {
312
+ throw new Error(`layout hard limit (${this.hardRowLimit * this.pitchY}px) exceeded, aborting layout`);
313
+ }
314
+ row = new LayoutRow();
315
+ bitmap[y] = row;
316
+ }
317
+ return row;
424
318
  }
425
- }, {
426
- key: "addRectToBitmap",
427
- value: function addRectToBitmap(rect) {
428
- if (rect.top === null) {
429
- return;
430
- }
431
-
432
- var data = rect.id;
433
- var yEnd = rect.top + rect.h;
434
-
435
- if (rect.r - rect.l > maxFeaturePitchWidth) {
436
- // the rect is very big in relation to the view size, just pretend, for
437
- // the purposes of layout, that it extends infinitely. this will cause
438
- // weird layout if a user scrolls manually for a very, very long time
439
- // along the genome at the same zoom level. but most users will not do
440
- // that. hopefully.
441
- for (var y = rect.top; y < yEnd; y += 1) {
442
- this.autovivifyRow(this.bitmap, y).setAllFilled(data);
443
- }
444
- } else {
445
- for (var _y = rect.top; _y < yEnd; _y += 1) {
446
- this.autovivifyRow(this.bitmap, _y).addRect(rect, data);
447
- }
448
- }
319
+ addRectToBitmap(rect) {
320
+ if (rect.top === null) {
321
+ return;
322
+ }
323
+ const data = rect.id;
324
+ const yEnd = rect.top + rect.h;
325
+ if (rect.r - rect.l > maxFeaturePitchWidth) {
326
+ // the rect is very big in relation to the view size, just pretend, for
327
+ // the purposes of layout, that it extends infinitely. this will cause
328
+ // weird layout if a user scrolls manually for a very, very long time
329
+ // along the genome at the same zoom level. but most users will not do
330
+ // that. hopefully.
331
+ for (let y = rect.top; y < yEnd; y += 1) {
332
+ this.autovivifyRow(this.bitmap, y).setAllFilled(data);
333
+ }
334
+ }
335
+ else {
336
+ for (let y = rect.top; y < yEnd; y += 1) {
337
+ this.autovivifyRow(this.bitmap, y).addRect(rect, data);
338
+ }
339
+ }
449
340
  }
450
341
  /**
451
342
  * Given a range of X coordinates, deletes all data dealing with
452
343
  * the features.
453
344
  */
454
-
455
- }, {
456
- key: "discardRange",
457
- value: function discardRange(left, right) {
458
- // console.log( 'discard', left, right );
459
- var pLeft = Math.floor(left / this.pitchX);
460
- var pRight = Math.floor(right / this.pitchX);
461
- var bitmap = this.bitmap;
462
-
463
- for (var y = 0; y < bitmap.length; y += 1) {
464
- var row = bitmap[y];
465
-
466
- if (row) {
467
- row.discardRange(pLeft, pRight);
468
- }
469
- }
345
+ discardRange(left, right) {
346
+ // console.log( 'discard', left, right );
347
+ const pLeft = Math.floor(left / this.pitchX);
348
+ const pRight = Math.floor(right / this.pitchX);
349
+ const { bitmap } = this;
350
+ for (let y = 0; y < bitmap.length; y += 1) {
351
+ const row = bitmap[y];
352
+ if (row) {
353
+ row.discardRange(pLeft, pRight);
354
+ }
355
+ }
470
356
  }
471
- }, {
472
- key: "hasSeen",
473
- value: function hasSeen(id) {
474
- return this.rectangles.has(id);
357
+ hasSeen(id) {
358
+ return this.rectangles.has(id);
475
359
  }
476
- }, {
477
- key: "getByCoord",
478
- value: function getByCoord(x, y) {
479
- var pY = Math.floor(y / this.pitchY);
480
- var row = this.bitmap[pY];
481
-
482
- if (!row) {
483
- return undefined;
484
- }
485
-
486
- var pX = Math.floor(x / this.pitchX);
487
- return row.getItemAt(pX);
360
+ getByCoord(x, y) {
361
+ const pY = Math.floor(y / this.pitchY);
362
+ const row = this.bitmap[pY];
363
+ if (!row) {
364
+ return undefined;
365
+ }
366
+ const pX = Math.floor(x / this.pitchX);
367
+ return row.getItemAt(pX);
488
368
  }
489
- }, {
490
- key: "getByID",
491
- value: function getByID(id) {
492
- var r = this.rectangles.get(id);
493
-
494
- if (r) {
495
- var t = r.top * this.pitchY;
496
- return [r.l * this.pitchX, t, r.r * this.pitchX, t + r.originalHeight];
497
- }
498
-
499
- return undefined;
369
+ getByID(id) {
370
+ const r = this.rectangles.get(id);
371
+ if (r) {
372
+ const t = r.top * this.pitchY;
373
+ return [r.l * this.pitchX, t, r.r * this.pitchX, t + r.originalHeight];
374
+ }
375
+ return undefined;
500
376
  }
501
- }, {
502
- key: "getDataByID",
503
- value: function getDataByID(id) {
504
- var _this$rectangles$get;
505
-
506
- return (_this$rectangles$get = this.rectangles.get(id)) === null || _this$rectangles$get === void 0 ? void 0 : _this$rectangles$get.data;
377
+ getDataByID(id) {
378
+ var _a;
379
+ return (_a = this.rectangles.get(id)) === null || _a === void 0 ? void 0 : _a.data;
507
380
  }
508
- }, {
509
- key: "cleanup",
510
- value: function cleanup() {}
511
- }, {
512
- key: "getTotalHeight",
513
- value: function getTotalHeight() {
514
- return this.pTotalHeight * this.pitchY;
381
+ cleanup() { }
382
+ getTotalHeight() {
383
+ return this.pTotalHeight * this.pitchY;
515
384
  }
516
- }, {
517
- key: "totalHeight",
518
- get: function get() {
519
- return this.getTotalHeight();
385
+ get totalHeight() {
386
+ return this.getTotalHeight();
520
387
  }
521
- }, {
522
- key: "getRectangles",
523
- value: function getRectangles() {
524
- var _this = this;
525
-
526
- return new Map(Array.from(this.rectangles.entries()).map(function (_ref2) {
527
- var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
528
- id = _ref3[0],
529
- rect = _ref3[1];
530
-
531
- var l = rect.l,
532
- r = rect.r,
533
- originalHeight = rect.originalHeight,
534
- top = rect.top;
535
- var t = (top || 0) * _this.pitchY;
536
- var b = t + originalHeight;
537
- return [id, [l * _this.pitchX, t, r * _this.pitchX, b]]; // left, top, right, bottom
538
- }));
388
+ getRectangles() {
389
+ return new Map(Array.from(this.rectangles.entries()).map(([id, rect]) => {
390
+ const { l, r, originalHeight, top } = rect;
391
+ const t = (top || 0) * this.pitchY;
392
+ const b = t + originalHeight;
393
+ return [id, [l * this.pitchX, t, r * this.pitchX, b]]; // left, top, right, bottom
394
+ }));
539
395
  }
540
- }, {
541
- key: "serializeRegion",
542
- value: function serializeRegion(region) {
543
- var regionRectangles = {};
544
- var maxHeightReached = false;
545
-
546
- var _iterator = _createForOfIteratorHelper(this.rectangles.entries()),
547
- _step;
548
-
549
- try {
550
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
551
- var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
552
- id = _step$value[0],
553
- rect = _step$value[1];
554
-
555
- var l = rect.l,
556
- r = rect.r,
557
- originalHeight = rect.originalHeight,
558
- top = rect.top;
559
-
560
- if (rect.top === null) {
561
- maxHeightReached = true;
562
- } else {
563
- var t = (top || 0) * this.pitchY;
564
- var b = t + originalHeight;
565
- var y1 = l * this.pitchX;
566
- var y2 = r * this.pitchX;
567
- var x1 = region.start;
568
- var x2 = region.end; // add +/- pitchX to avoid resolution causing errors
569
-
570
- if (segmentsIntersect(x1, x2, y1 - this.pitchX, y2 + this.pitchX)) {
571
- regionRectangles[id] = [y1, t, y2, b];
396
+ serializeRegion(region) {
397
+ const regionRectangles = {};
398
+ let maxHeightReached = false;
399
+ for (const [id, rect] of this.rectangles.entries()) {
400
+ const { l, r, originalHeight, top } = rect;
401
+ if (rect.top === null) {
402
+ maxHeightReached = true;
403
+ }
404
+ else {
405
+ const t = (top || 0) * this.pitchY;
406
+ const b = t + originalHeight;
407
+ const y1 = l * this.pitchX;
408
+ const y2 = r * this.pitchX;
409
+ const x1 = region.start;
410
+ const x2 = region.end;
411
+ // add +/- pitchX to avoid resolution causing errors
412
+ if (segmentsIntersect(x1, x2, y1 - this.pitchX, y2 + this.pitchX)) {
413
+ regionRectangles[id] = [y1, t, y2, b];
414
+ }
572
415
  }
573
- }
574
- }
575
- } catch (err) {
576
- _iterator.e(err);
577
- } finally {
578
- _iterator.f();
579
- }
580
-
581
- return {
582
- rectangles: regionRectangles,
583
- containsNoTransferables: true,
584
- totalHeight: this.getTotalHeight(),
585
- maxHeightReached: maxHeightReached
586
- };
416
+ }
417
+ return {
418
+ rectangles: regionRectangles,
419
+ containsNoTransferables: true,
420
+ totalHeight: this.getTotalHeight(),
421
+ maxHeightReached,
422
+ };
587
423
  }
588
- }, {
589
- key: "toJSON",
590
- value: function toJSON() {
591
- var rectangles = (0, _index.objectFromEntries)(this.getRectangles());
592
- return {
593
- rectangles: rectangles,
594
- containsNoTransferables: true,
595
- totalHeight: this.getTotalHeight(),
596
- maxHeightReached: this.maxHeightReached
597
- };
424
+ toJSON() {
425
+ const rectangles = Object.fromEntries(this.getRectangles());
426
+ return {
427
+ rectangles,
428
+ containsNoTransferables: true,
429
+ totalHeight: this.getTotalHeight(),
430
+ maxHeightReached: this.maxHeightReached,
431
+ };
598
432
  }
599
- }]);
600
- return GranularRectLayout;
601
- }();
602
-
603
- exports.default = GranularRectLayout;
433
+ }
434
+ exports.default = GranularRectLayout;