@jbrowse/core 2.0.1 → 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 (179) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +6 -0
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +313 -592
  3. package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -479
  4. package/BaseFeatureWidget/index.js +88 -126
  5. package/BaseFeatureWidget/types.js +1 -4
  6. package/BaseFeatureWidget/util.js +40 -75
  7. package/CorePlugin.js +55 -94
  8. package/Plugin.js +9 -34
  9. package/PluginLoader.js +153 -422
  10. package/PluginManager.d.ts +17 -14
  11. package/PluginManager.js +377 -666
  12. package/ReExports/Attributes.js +3 -10
  13. package/ReExports/BaseCard.js +3 -10
  14. package/ReExports/DataGrid.js +5 -12
  15. package/ReExports/FeatureDetails.js +3 -10
  16. package/ReExports/index.js +6 -12
  17. package/ReExports/list.d.ts +5 -0
  18. package/ReExports/list.js +271 -7
  19. package/ReExports/material-ui-colors.js +15 -16
  20. package/ReExports/modules.d.ts +0 -1
  21. package/ReExports/modules.js +453 -798
  22. package/TextSearch/BaseResults.js +51 -123
  23. package/TextSearch/TextSearchManager.js +66 -144
  24. package/assemblyManager/assembly.js +280 -555
  25. package/assemblyManager/assemblyConfigSchema.js +47 -64
  26. package/assemblyManager/assemblyManager.js +126 -272
  27. package/assemblyManager/index.js +9 -22
  28. package/configuration/configurationSchema.js +167 -203
  29. package/configuration/configurationSlot.js +248 -326
  30. package/configuration/index.js +19 -35
  31. package/configuration/util.js +131 -173
  32. package/data_adapters/BaseAdapter.d.ts +2 -2
  33. package/data_adapters/BaseAdapter.js +132 -521
  34. package/data_adapters/CytobandAdapter.js +40 -126
  35. package/data_adapters/dataAdapterCache.js +77 -158
  36. package/package.json +4 -5
  37. package/pluggableElementTypes/AdapterType.js +24 -79
  38. package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
  39. package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
  40. package/pluggableElementTypes/ConnectionType.js +22 -65
  41. package/pluggableElementTypes/DisplayType.js +35 -82
  42. package/pluggableElementTypes/InternetAccountType.js +23 -64
  43. package/pluggableElementTypes/PluggableElementBase.js +8 -20
  44. package/pluggableElementTypes/RpcMethodType.js +85 -427
  45. package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
  46. package/pluggableElementTypes/TrackType.js +26 -70
  47. package/pluggableElementTypes/ViewType.js +21 -63
  48. package/pluggableElementTypes/WidgetType.js +21 -64
  49. package/pluggableElementTypes/index.d.ts +4 -3
  50. package/pluggableElementTypes/index.js +42 -125
  51. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
  52. package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
  53. package/pluggableElementTypes/models/BaseTrackModel.js +139 -199
  54. package/pluggableElementTypes/models/BaseViewModel.js +24 -40
  55. package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
  56. package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
  57. package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
  58. package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
  59. package/pluggableElementTypes/models/index.js +21 -70
  60. package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
  61. package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
  62. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
  63. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
  64. package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -264
  65. package/pluggableElementTypes/renderers/RendererType.js +31 -105
  66. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
  67. package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
  68. package/pluggableElementTypes/renderers/index.js +19 -62
  69. package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
  70. package/rpc/BaseRpcDriver.js +169 -405
  71. package/rpc/MainThreadRpcDriver.js +27 -150
  72. package/rpc/RpcManager.js +58 -159
  73. package/rpc/WebWorkerRpcDriver.js +54 -171
  74. package/rpc/configSchema.js +25 -49
  75. package/rpc/coreRpcMethods.js +221 -959
  76. package/rpc/remoteAbortSignals.js +46 -70
  77. package/tsconfig.build.tsbuildinfo +1 -1
  78. package/ui/AboutDialog.js +106 -162
  79. package/ui/App.js +157 -242
  80. package/ui/AssemblySelector.js +59 -120
  81. package/ui/CascadingMenu.js +101 -196
  82. package/ui/ColorPicker.d.ts +16 -0
  83. package/ui/ColorPicker.js +97 -0
  84. package/ui/Drawer.js +28 -61
  85. package/ui/DrawerWidget.js +108 -202
  86. package/ui/DropDownMenu.js +60 -91
  87. package/ui/EditableTypography.js +87 -149
  88. package/ui/ErrorMessage.js +41 -56
  89. package/ui/FactoryResetDialog.js +24 -57
  90. package/ui/FatalErrorDialog.js +59 -91
  91. package/ui/FileSelector/FileSelector.js +123 -189
  92. package/ui/FileSelector/LocalFileChooser.js +44 -75
  93. package/ui/FileSelector/UrlChooser.js +17 -38
  94. package/ui/FileSelector/index.js +6 -12
  95. package/ui/Icons.js +45 -69
  96. package/ui/Logo.js +57 -110
  97. package/ui/Menu.js +232 -354
  98. package/ui/PrerenderedCanvas.js +63 -87
  99. package/ui/ResizeHandle.js +87 -116
  100. package/ui/ReturnToImportFormDialog.js +32 -63
  101. package/ui/SanitizedHTML.js +64 -47
  102. package/ui/Snackbar.js +74 -101
  103. package/ui/SnackbarModel.js +37 -51
  104. package/ui/Tooltip.js +49 -76
  105. package/ui/ViewContainer.js +113 -196
  106. package/ui/colors.d.ts +10 -0
  107. package/ui/colors.js +78 -0
  108. package/ui/index.js +51 -181
  109. package/ui/react-colorful.d.ts +17 -0
  110. package/ui/react-colorful.js +455 -0
  111. package/ui/theme.js +199 -247
  112. package/util/Base1DUtils.js +163 -202
  113. package/util/Base1DViewModel.js +121 -168
  114. package/util/QuickLRU.js +84 -332
  115. package/util/TimeTraveller.d.ts +19 -0
  116. package/util/TimeTraveller.js +86 -0
  117. package/util/aborting.js +49 -127
  118. package/util/analytics.js +91 -154
  119. package/util/blockTypes.js +106 -240
  120. package/util/calculateDynamicBlocks.js +98 -128
  121. package/util/calculateStaticBlocks.js +105 -125
  122. package/util/color/cssColorsLevel4.js +156 -160
  123. package/util/color/index.js +33 -55
  124. package/util/compositeMap.js +49 -333
  125. package/util/formatFastaStrings.js +9 -14
  126. package/util/idMaker.js +18 -31
  127. package/util/index.d.ts +7 -20
  128. package/util/index.js +742 -1188
  129. package/util/io/RemoteFileWithRangeCache.js +88 -257
  130. package/util/io/index.js +95 -169
  131. package/util/jexl.js +60 -115
  132. package/util/jexlStrings.js +24 -29
  133. package/util/layouts/BaseLayout.js +1 -4
  134. package/util/layouts/GranularRectLayout.js +388 -555
  135. package/util/layouts/MultiLayout.js +41 -109
  136. package/util/layouts/PrecomputedLayout.js +56 -112
  137. package/util/layouts/PrecomputedMultiLayout.js +22 -59
  138. package/util/layouts/SceneGraph.js +127 -197
  139. package/util/layouts/index.js +29 -66
  140. package/util/mst-reflection.js +55 -71
  141. package/util/offscreenCanvasPonyfill.js +66 -134
  142. package/util/offscreenCanvasUtils.d.ts +2 -7
  143. package/util/offscreenCanvasUtils.js +49 -146
  144. package/util/range.js +29 -40
  145. package/util/rxjs.js +20 -27
  146. package/util/simpleFeature.js +88 -152
  147. package/util/stats.js +91 -151
  148. package/util/tracks.js +130 -173
  149. package/util/types/index.js +110 -179
  150. package/util/types/mst.js +91 -146
  151. package/util/types/util.js +1 -4
  152. package/util/when.js +54 -101
  153. package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
  154. package/BaseFeatureWidget/index.test.js +0 -69
  155. package/TextSearch/BaseResults.test.js +0 -42
  156. package/configuration/configurationSchema.test.js +0 -266
  157. package/configuration/configurationSlot.test.js +0 -69
  158. package/configuration/util.test.js +0 -39
  159. package/data_adapters/BaseAdapter.test.js +0 -200
  160. package/declare.d.js +0 -1
  161. package/pluggableElementTypes/RpcMethodType.test.js +0 -118
  162. package/pluggableElementTypes/renderers/declare.d.js +0 -1
  163. package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
  164. package/rpc/BaseRpcDriver.test.js +0 -540
  165. package/rpc/declaration.d.js +0 -1
  166. package/ui/FatalErrorDialog.test.js +0 -82
  167. package/ui/SanitizedHTML.test.js +0 -36
  168. package/ui/theme.test.js +0 -92
  169. package/util/Base1DViewModel.test.js +0 -130
  170. package/util/calculateDynamicBlocks.test.js +0 -74
  171. package/util/calculateStaticBlocks.test.js +0 -297
  172. package/util/declare.d.js +0 -1
  173. package/util/formatFastaStrings.test.js +0 -40
  174. package/util/index.test.js +0 -213
  175. package/util/jexlStrings.test.js +0 -48
  176. package/util/layouts/GranularRectLayout.test.js +0 -99
  177. package/util/range.test.js +0 -64
  178. package/util/simpleFeature.test.js +0 -34
  179. package/util/stats.test.js +0 -172
@@ -1,266 +1,132 @@
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.InterRegionPaddingBlock = exports.ElidedBlock = exports.ContentBlock = exports.BlockSet = exports.BaseBlock = void 0;
9
-
10
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
-
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
-
14
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
-
16
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
17
-
18
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
-
20
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
21
-
22
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
23
-
24
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
-
26
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
27
-
28
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
29
-
30
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
31
-
32
- var BlockSet = /*#__PURE__*/function () {
33
- function BlockSet() {
34
- var blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
35
- (0, _classCallCheck2.default)(this, BlockSet);
36
- this.blocks = blocks;
37
- }
38
-
39
- (0, _createClass2.default)(BlockSet, [{
40
- key: "push",
41
- value: function push(block) {
42
- if (block instanceof ElidedBlock) {
43
- if (this.blocks.length) {
44
- var lastBlock = this.blocks[this.blocks.length - 1];
45
-
46
- if (lastBlock instanceof ElidedBlock) {
47
- lastBlock.push(block);
48
- return;
49
- }
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InterRegionPaddingBlock = exports.ElidedBlock = exports.ContentBlock = exports.BaseBlock = exports.BlockSet = void 0;
4
+ class BlockSet {
5
+ constructor(blocks = []) {
6
+ this.blocks = blocks;
7
+ }
8
+ push(block) {
9
+ if (block instanceof ElidedBlock) {
10
+ if (this.blocks.length) {
11
+ const lastBlock = this.blocks[this.blocks.length - 1];
12
+ if (lastBlock instanceof ElidedBlock) {
13
+ lastBlock.push(block);
14
+ return;
15
+ }
16
+ }
50
17
  }
51
- }
52
-
53
- this.blocks.push(block);
18
+ this.blocks.push(block);
54
19
  }
55
- }, {
56
- key: "getBlocks",
57
- value: function getBlocks() {
58
- return this.blocks;
20
+ getBlocks() {
21
+ return this.blocks;
59
22
  }
60
- }, {
61
- key: "getRegions",
62
- value: function getRegions() {
63
- return this.blocks.map(function (block) {
64
- return block.toRegion();
65
- });
23
+ getRegions() {
24
+ return this.blocks.map(block => block.toRegion());
66
25
  }
67
- }, {
68
- key: "map",
69
- value: function map(func, thisarg) {
70
- return this.blocks.map(func, thisarg);
26
+ map(func, thisarg) {
27
+ return this.blocks.map(func, thisarg);
71
28
  }
72
- }, {
73
- key: "forEach",
74
- value: function forEach(func, thisarg) {
75
- return this.blocks.forEach(func, thisarg);
29
+ forEach(func, thisarg) {
30
+ return this.blocks.forEach(func, thisarg);
76
31
  }
77
- }, {
78
- key: "length",
79
- get: function get() {
80
- return this.blocks.length;
32
+ get length() {
33
+ return this.blocks.length;
81
34
  }
82
- }, {
83
- key: "totalWidthPx",
84
- get: function get() {
85
- return this.blocks.length ? this.blocks.map(function (blocks) {
86
- return blocks.widthPx;
87
- }).reduce(function (a, b) {
88
- return a + b;
89
- }) : 0;
35
+ get totalWidthPx() {
36
+ return this.blocks.length
37
+ ? this.blocks.map(blocks => blocks.widthPx).reduce((a, b) => a + b)
38
+ : 0;
90
39
  }
91
- }, {
92
- key: "totalWidthPxWithoutBorders",
93
- get: function get() {
94
- return this.blocks.length ? this.blocks.filter(function (block) {
95
- return block.variant !== 'boundary';
96
- }).map(function (blocks) {
97
- return blocks.widthPx;
98
- }).reduce(function (a, b) {
99
- return a + b;
100
- }) : 0;
40
+ get totalWidthPxWithoutBorders() {
41
+ return this.blocks.length
42
+ ? this.blocks
43
+ .filter(block => block.variant !== 'boundary')
44
+ .map(blocks => blocks.widthPx)
45
+ .reduce((a, b) => a + b)
46
+ : 0;
101
47
  }
102
- }, {
103
- key: "offsetPx",
104
- get: function get() {
105
- return this.blocks.length ? this.blocks[0].offsetPx : 0;
48
+ get offsetPx() {
49
+ return this.blocks.length ? this.blocks[0].offsetPx : 0;
106
50
  }
107
- }, {
108
- key: "contentBlocks",
109
- get: function get() {
110
- return this.blocks.filter(function (block) {
111
- return block instanceof ContentBlock;
112
- });
51
+ get contentBlocks() {
52
+ return this.blocks.filter(block => block instanceof ContentBlock);
113
53
  }
114
- }, {
115
- key: "totalBp",
116
- get: function get() {
117
- return this.contentBlocks.map(function (block) {
118
- return block.end - block.start;
119
- }).reduce(function (a, b) {
120
- return a + b;
121
- }, 0);
54
+ get totalBp() {
55
+ return this.contentBlocks
56
+ .map(block => block.end - block.start)
57
+ .reduce((a, b) => a + b, 0);
122
58
  }
123
- }]);
124
- return BlockSet;
125
- }();
126
-
59
+ }
127
60
  exports.BlockSet = BlockSet;
128
-
129
- var BaseBlock = /*#__PURE__*/function () {
130
- /**
131
- * a block that should be shown as filled with data
132
- */
133
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
- function BaseBlock(data) {
135
- (0, _classCallCheck2.default)(this, BaseBlock);
136
- (0, _defineProperty2.default)(this, "regionNumber", void 0);
137
- (0, _defineProperty2.default)(this, "reversed", void 0);
138
- (0, _defineProperty2.default)(this, "refName", void 0);
139
- (0, _defineProperty2.default)(this, "start", void 0);
140
- (0, _defineProperty2.default)(this, "end", void 0);
141
- (0, _defineProperty2.default)(this, "assemblyName", void 0);
142
- (0, _defineProperty2.default)(this, "key", void 0);
143
- (0, _defineProperty2.default)(this, "offsetPx", void 0);
144
- (0, _defineProperty2.default)(this, "widthPx", 0);
145
- (0, _defineProperty2.default)(this, "variant", void 0);
146
- (0, _defineProperty2.default)(this, "isLeftEndOfDisplayedRegion", void 0);
147
- Object.assign(this, data);
148
- this.assemblyName = data.assemblyName;
149
- this.refName = data.refName;
150
- this.start = data.start;
151
- this.end = data.end;
152
- this.key = data.key;
153
- this.offsetPx = data.offsetPx;
154
- }
155
- /**
156
- * rename the reference sequence of this block and return a new one
157
- *
158
- * @param refName -
159
- * @returns either a new block with a renamed reference sequence,
160
- * or the same block, if the ref name is not actually different
161
- */
162
-
163
-
164
- (0, _createClass2.default)(BaseBlock, [{
165
- key: "renameReference",
166
- value: function renameReference(refName) {
167
- if (this.refName && refName !== this.refName) {
168
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
169
- return new this.constructor(_objectSpread(_objectSpread({}, this), {}, {
170
- refName: refName
171
- }));
172
- }
173
-
174
- return this;
61
+ class BaseBlock {
62
+ /**
63
+ * a block that should be shown as filled with data
64
+ */
65
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
+ constructor(data) {
67
+ this.widthPx = 0;
68
+ Object.assign(this, data);
69
+ this.assemblyName = data.assemblyName;
70
+ this.refName = data.refName;
71
+ this.start = data.start;
72
+ this.end = data.end;
73
+ this.key = data.key;
74
+ this.offsetPx = data.offsetPx;
75
+ }
76
+ /**
77
+ * rename the reference sequence of this block and return a new one
78
+ *
79
+ * @param refName -
80
+ * @returns either a new block with a renamed reference sequence,
81
+ * or the same block, if the ref name is not actually different
82
+ */
83
+ renameReference(refName) {
84
+ if (this.refName && refName !== this.refName) {
85
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
+ return new this.constructor({ ...this, refName });
87
+ }
88
+ return this;
175
89
  }
176
- }, {
177
- key: "toRegion",
178
- value: function toRegion() {
179
- return {
180
- refName: this.refName,
181
- start: this.start,
182
- end: this.end,
183
- assemblyName: this.assemblyName,
184
- reversed: this.reversed
185
- };
90
+ toRegion() {
91
+ return {
92
+ refName: this.refName,
93
+ start: this.start,
94
+ end: this.end,
95
+ assemblyName: this.assemblyName,
96
+ reversed: this.reversed,
97
+ };
186
98
  }
187
- }]);
188
- return BaseBlock;
189
- }();
190
-
99
+ }
191
100
  exports.BaseBlock = BaseBlock;
192
-
193
- var ContentBlock = /*#__PURE__*/function (_BaseBlock) {
194
- (0, _inherits2.default)(ContentBlock, _BaseBlock);
195
-
196
- var _super = _createSuper(ContentBlock);
197
-
198
- function ContentBlock() {
199
- (0, _classCallCheck2.default)(this, ContentBlock);
200
- return _super.apply(this, arguments);
201
- }
202
-
203
- return (0, _createClass2.default)(ContentBlock);
204
- }(BaseBlock);
101
+ class ContentBlock extends BaseBlock {
102
+ }
103
+ exports.ContentBlock = ContentBlock;
205
104
  /**
206
105
  * marker block representing one or more blocks that are
207
106
  * too small to be shown at the current zoom level
208
107
  */
209
-
210
-
211
- exports.ContentBlock = ContentBlock;
212
-
213
- var ElidedBlock = /*#__PURE__*/function (_BaseBlock2) {
214
- (0, _inherits2.default)(ElidedBlock, _BaseBlock2);
215
-
216
- var _super2 = _createSuper(ElidedBlock);
217
-
218
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
219
- function ElidedBlock(data) {
220
- var _this;
221
-
222
- (0, _classCallCheck2.default)(this, ElidedBlock);
223
- _this = _super2.call(this, data);
224
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "widthPx", void 0);
225
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "elidedBlockCount", 0);
226
- _this.widthPx = data.widthPx;
227
- return _this;
228
- }
229
-
230
- (0, _createClass2.default)(ElidedBlock, [{
231
- key: "push",
232
- value: function push(otherBlock) {
233
- this.elidedBlockCount += 1;
234
-
235
- if (otherBlock) {
236
- this.refName = '';
237
- this.start = 0;
238
- this.end = 0;
239
- this.widthPx += otherBlock.widthPx;
240
- }
108
+ class ElidedBlock extends BaseBlock {
109
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
+ constructor(data) {
111
+ super(data);
112
+ this.elidedBlockCount = 0;
113
+ this.widthPx = data.widthPx;
241
114
  }
242
- }]);
243
- return ElidedBlock;
244
- }(BaseBlock);
115
+ push(otherBlock) {
116
+ this.elidedBlockCount += 1;
117
+ if (otherBlock) {
118
+ this.refName = '';
119
+ this.start = 0;
120
+ this.end = 0;
121
+ this.widthPx += otherBlock.widthPx;
122
+ }
123
+ }
124
+ }
125
+ exports.ElidedBlock = ElidedBlock;
245
126
  /**
246
127
  * marker block that sits between two different displayed regions
247
128
  * and provides a thick border between them
248
129
  */
249
-
250
-
251
- exports.ElidedBlock = ElidedBlock;
252
-
253
- var InterRegionPaddingBlock = /*#__PURE__*/function (_BaseBlock3) {
254
- (0, _inherits2.default)(InterRegionPaddingBlock, _BaseBlock3);
255
-
256
- var _super3 = _createSuper(InterRegionPaddingBlock);
257
-
258
- function InterRegionPaddingBlock() {
259
- (0, _classCallCheck2.default)(this, InterRegionPaddingBlock);
260
- return _super3.apply(this, arguments);
261
- }
262
-
263
- return (0, _createClass2.default)(InterRegionPaddingBlock);
264
- }(BaseBlock);
265
-
266
- exports.InterRegionPaddingBlock = InterRegionPaddingBlock;
130
+ class InterRegionPaddingBlock extends BaseBlock {
131
+ }
132
+ exports.InterRegionPaddingBlock = InterRegionPaddingBlock;
@@ -1,20 +1,8 @@
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 = calculateDynamicBlocks;
9
-
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
- var _range = require("./range");
13
-
14
- var _ = require(".");
15
-
16
- var _blockTypes = require("./blockTypes");
17
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const range_1 = require("./range");
4
+ const _1 = require(".");
5
+ const blockTypes_1 = require("./blockTypes");
18
6
  /**
19
7
  * returns a BlockSet of which the `blocks` attribute is an array of 'dynamic
20
8
  * blocks', which are blocks representing only the regions that are visible in
@@ -34,116 +22,98 @@ var _blockTypes = require("./blockTypes");
34
22
  *
35
23
  * @returns BlockSet of `{ refName, startBp, end, offset, reversed? }`
36
24
  */
37
- function calculateDynamicBlocks(model) {
38
- var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
39
- var elision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
40
- var offsetPx = model.offsetPx,
41
- displayedRegions = model.displayedRegions,
42
- bpPerPx = model.bpPerPx,
43
- width = model.width,
44
- minimumBlockWidth = model.minimumBlockWidth,
45
- interRegionPaddingWidth = model.interRegionPaddingWidth;
46
-
47
- if (!width) {
48
- throw new Error('view has no width, cannot calculate displayed blocks');
49
- }
50
-
51
- var blocks = new _blockTypes.BlockSet();
52
- var displayedRegionLeftPx = 0;
53
- var windowLeftPx = offsetPx;
54
- var windowRightPx = windowLeftPx + width;
55
- displayedRegions.forEach(function (region, regionNumber) {
56
- var assemblyName = region.assemblyName,
57
- refName = region.refName,
58
- regionStart = region.start,
59
- regionEnd = region.end,
60
- reversed = region.reversed;
61
- var displayedRegionRightPx = displayedRegionLeftPx + (regionEnd - regionStart) / bpPerPx;
62
- var regionWidthPx = (regionEnd - regionStart) / bpPerPx;
63
-
64
- if (displayedRegionLeftPx < windowRightPx && displayedRegionRightPx > windowLeftPx) {
65
- // this displayed region overlaps the view, so make a record for it
66
- var _intersection = (0, _range.intersection2)(windowLeftPx, windowRightPx, displayedRegionLeftPx, displayedRegionRightPx),
67
- _intersection2 = (0, _slicedToArray2.default)(_intersection, 2),
68
- leftPx = _intersection2[0],
69
- rightPx = _intersection2[1];
70
-
71
- var start;
72
- var end;
73
- var isLeftEndOfDisplayedRegion;
74
- var isRightEndOfDisplayedRegion;
75
- var blockOffsetPx;
76
-
77
- if (reversed) {
78
- start = Math.max(regionStart, regionEnd - (rightPx - displayedRegionLeftPx) * bpPerPx);
79
- end = regionEnd - (leftPx - displayedRegionLeftPx) * bpPerPx;
80
- isLeftEndOfDisplayedRegion = end === regionEnd;
81
- isRightEndOfDisplayedRegion = start === regionStart;
82
- blockOffsetPx = displayedRegionLeftPx + (regionEnd - end) / bpPerPx;
83
- } else {
84
- start = (leftPx - displayedRegionLeftPx) * bpPerPx + regionStart;
85
- end = Math.min(regionEnd, (rightPx - displayedRegionLeftPx) * bpPerPx + regionStart);
86
- isLeftEndOfDisplayedRegion = start === regionStart;
87
- isRightEndOfDisplayedRegion = end === regionEnd;
88
- blockOffsetPx = displayedRegionLeftPx + (start - regionStart) / bpPerPx;
89
- }
90
-
91
- var widthPx = (end - start) / bpPerPx;
92
- var blockData = {
93
- assemblyName: assemblyName,
94
- refName: refName,
95
- start: start,
96
- end: end,
97
- reversed: reversed,
98
- offsetPx: blockOffsetPx,
99
- parentRegion: region,
100
- regionNumber: regionNumber,
101
- widthPx: widthPx,
102
- isLeftEndOfDisplayedRegion: isLeftEndOfDisplayedRegion,
103
- isRightEndOfDisplayedRegion: isRightEndOfDisplayedRegion,
104
- key: ''
105
- };
106
- blockData.key = "".concat((0, _.assembleLocString)(blockData), "-").concat(regionNumber).concat(reversed ? '-reversed' : '');
107
-
108
- if (padding && blocks.length === 0 && isLeftEndOfDisplayedRegion) {
109
- blocks.push(new _blockTypes.InterRegionPaddingBlock({
110
- key: "".concat(blockData.key, "-beforeFirstRegion"),
111
- widthPx: -offsetPx,
112
- offsetPx: blockData.offsetPx + offsetPx,
113
- variant: 'boundary'
114
- }));
115
- }
116
-
117
- if (elision && regionWidthPx < minimumBlockWidth) {
118
- blocks.push(new _blockTypes.ElidedBlock(blockData));
119
- } else {
120
- blocks.push(new _blockTypes.ContentBlock(blockData));
121
- }
122
-
123
- if (padding) {
124
- // insert a inter-region padding block if we are crossing a displayed region
125
- if (regionWidthPx >= minimumBlockWidth && blockData.isRightEndOfDisplayedRegion && regionNumber < displayedRegions.length - 1) {
126
- blocks.push(new _blockTypes.InterRegionPaddingBlock({
127
- key: "".concat(blockData.key, "-rightpad"),
128
- widthPx: interRegionPaddingWidth,
129
- offsetPx: blockData.offsetPx + blockData.widthPx
130
- }));
131
- displayedRegionLeftPx += interRegionPaddingWidth;
132
- }
133
-
134
- if (regionNumber === displayedRegions.length - 1 && blockData.isRightEndOfDisplayedRegion) {
135
- blockOffsetPx = blockData.offsetPx + blockData.widthPx;
136
- blocks.push(new _blockTypes.InterRegionPaddingBlock({
137
- key: "".concat(blockData.key, "-afterLastRegion"),
138
- widthPx: width - blockOffsetPx + offsetPx,
139
- offsetPx: blockOffsetPx,
140
- variant: 'boundary'
141
- }));
142
- }
143
- }
25
+ function calculateDynamicBlocks(model, padding = true, elision = true) {
26
+ const { offsetPx, displayedRegions, bpPerPx, width, minimumBlockWidth, interRegionPaddingWidth, } = model;
27
+ if (!width) {
28
+ throw new Error('view has no width, cannot calculate displayed blocks');
144
29
  }
145
-
146
- displayedRegionLeftPx += (regionEnd - regionStart) / bpPerPx;
147
- });
148
- return blocks;
149
- }
30
+ const blocks = new blockTypes_1.BlockSet();
31
+ let displayedRegionLeftPx = 0;
32
+ const windowLeftPx = offsetPx;
33
+ const windowRightPx = windowLeftPx + width;
34
+ displayedRegions.forEach((region, regionNumber) => {
35
+ const { assemblyName, refName, start: regionStart, end: regionEnd, reversed, } = region;
36
+ const displayedRegionRightPx = displayedRegionLeftPx + (regionEnd - regionStart) / bpPerPx;
37
+ const regionWidthPx = (regionEnd - regionStart) / bpPerPx;
38
+ if (displayedRegionLeftPx < windowRightPx &&
39
+ displayedRegionRightPx > windowLeftPx) {
40
+ // this displayed region overlaps the view, so make a record for it
41
+ const [leftPx, rightPx] = (0, range_1.intersection2)(windowLeftPx, windowRightPx, displayedRegionLeftPx, displayedRegionRightPx);
42
+ let start;
43
+ let end;
44
+ let isLeftEndOfDisplayedRegion;
45
+ let isRightEndOfDisplayedRegion;
46
+ let blockOffsetPx;
47
+ if (reversed) {
48
+ start = Math.max(regionStart, regionEnd - (rightPx - displayedRegionLeftPx) * bpPerPx);
49
+ end = regionEnd - (leftPx - displayedRegionLeftPx) * bpPerPx;
50
+ isLeftEndOfDisplayedRegion = end === regionEnd;
51
+ isRightEndOfDisplayedRegion = start === regionStart;
52
+ blockOffsetPx = displayedRegionLeftPx + (regionEnd - end) / bpPerPx;
53
+ }
54
+ else {
55
+ start = (leftPx - displayedRegionLeftPx) * bpPerPx + regionStart;
56
+ end = Math.min(regionEnd, (rightPx - displayedRegionLeftPx) * bpPerPx + regionStart);
57
+ isLeftEndOfDisplayedRegion = start === regionStart;
58
+ isRightEndOfDisplayedRegion = end === regionEnd;
59
+ blockOffsetPx = displayedRegionLeftPx + (start - regionStart) / bpPerPx;
60
+ }
61
+ const widthPx = (end - start) / bpPerPx;
62
+ const blockData = {
63
+ assemblyName,
64
+ refName,
65
+ start,
66
+ end,
67
+ reversed,
68
+ offsetPx: blockOffsetPx,
69
+ parentRegion: region,
70
+ regionNumber,
71
+ widthPx,
72
+ isLeftEndOfDisplayedRegion,
73
+ isRightEndOfDisplayedRegion,
74
+ key: '',
75
+ };
76
+ blockData.key = `${(0, _1.assembleLocString)(blockData)}-${regionNumber}${reversed ? '-reversed' : ''}`;
77
+ if (padding && blocks.length === 0 && isLeftEndOfDisplayedRegion) {
78
+ blocks.push(new blockTypes_1.InterRegionPaddingBlock({
79
+ key: `${blockData.key}-beforeFirstRegion`,
80
+ widthPx: -offsetPx,
81
+ offsetPx: blockData.offsetPx + offsetPx,
82
+ variant: 'boundary',
83
+ }));
84
+ }
85
+ if (elision && regionWidthPx < minimumBlockWidth) {
86
+ blocks.push(new blockTypes_1.ElidedBlock(blockData));
87
+ }
88
+ else {
89
+ blocks.push(new blockTypes_1.ContentBlock(blockData));
90
+ }
91
+ if (padding) {
92
+ // insert a inter-region padding block if we are crossing a displayed region
93
+ if (regionWidthPx >= minimumBlockWidth &&
94
+ blockData.isRightEndOfDisplayedRegion &&
95
+ regionNumber < displayedRegions.length - 1) {
96
+ blocks.push(new blockTypes_1.InterRegionPaddingBlock({
97
+ key: `${blockData.key}-rightpad`,
98
+ widthPx: interRegionPaddingWidth,
99
+ offsetPx: blockData.offsetPx + blockData.widthPx,
100
+ }));
101
+ displayedRegionLeftPx += interRegionPaddingWidth;
102
+ }
103
+ if (regionNumber === displayedRegions.length - 1 &&
104
+ blockData.isRightEndOfDisplayedRegion) {
105
+ blockOffsetPx = blockData.offsetPx + blockData.widthPx;
106
+ blocks.push(new blockTypes_1.InterRegionPaddingBlock({
107
+ key: `${blockData.key}-afterLastRegion`,
108
+ widthPx: width - blockOffsetPx + offsetPx,
109
+ offsetPx: blockOffsetPx,
110
+ variant: 'boundary',
111
+ }));
112
+ }
113
+ }
114
+ }
115
+ displayedRegionLeftPx += (regionEnd - regionStart) / bpPerPx;
116
+ });
117
+ return blocks;
118
+ }
119
+ exports.default = calculateDynamicBlocks;