@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,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;