@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.
- package/BaseFeatureWidget/BaseFeatureDetail.d.ts +6 -0
- package/BaseFeatureWidget/BaseFeatureDetail.js +313 -592
- package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -479
- package/BaseFeatureWidget/index.js +88 -126
- package/BaseFeatureWidget/types.js +1 -4
- package/BaseFeatureWidget/util.js +40 -75
- package/CorePlugin.js +55 -94
- package/Plugin.js +9 -34
- package/PluginLoader.js +153 -422
- package/PluginManager.d.ts +17 -14
- package/PluginManager.js +377 -666
- package/ReExports/Attributes.js +3 -10
- package/ReExports/BaseCard.js +3 -10
- package/ReExports/DataGrid.js +5 -12
- package/ReExports/FeatureDetails.js +3 -10
- package/ReExports/index.js +6 -12
- package/ReExports/list.d.ts +5 -0
- package/ReExports/list.js +271 -7
- package/ReExports/material-ui-colors.js +15 -16
- package/ReExports/modules.d.ts +0 -1
- package/ReExports/modules.js +453 -798
- package/TextSearch/BaseResults.js +51 -123
- package/TextSearch/TextSearchManager.js +66 -144
- package/assemblyManager/assembly.js +280 -555
- package/assemblyManager/assemblyConfigSchema.js +47 -64
- package/assemblyManager/assemblyManager.js +126 -272
- package/assemblyManager/index.js +9 -22
- package/configuration/configurationSchema.js +167 -203
- package/configuration/configurationSlot.js +248 -326
- package/configuration/index.js +19 -35
- package/configuration/util.js +131 -173
- package/data_adapters/BaseAdapter.d.ts +2 -2
- package/data_adapters/BaseAdapter.js +132 -521
- package/data_adapters/CytobandAdapter.js +40 -126
- package/data_adapters/dataAdapterCache.js +77 -158
- package/package.json +4 -5
- package/pluggableElementTypes/AdapterType.js +24 -79
- package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
- package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
- package/pluggableElementTypes/ConnectionType.js +22 -65
- package/pluggableElementTypes/DisplayType.js +35 -82
- package/pluggableElementTypes/InternetAccountType.js +23 -64
- package/pluggableElementTypes/PluggableElementBase.js +8 -20
- package/pluggableElementTypes/RpcMethodType.js +85 -427
- package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
- package/pluggableElementTypes/TrackType.js +26 -70
- package/pluggableElementTypes/ViewType.js +21 -63
- package/pluggableElementTypes/WidgetType.js +21 -64
- package/pluggableElementTypes/index.d.ts +4 -3
- package/pluggableElementTypes/index.js +42 -125
- package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
- package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
- package/pluggableElementTypes/models/BaseTrackModel.js +139 -199
- package/pluggableElementTypes/models/BaseViewModel.js +24 -40
- package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
- package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
- package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
- package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
- package/pluggableElementTypes/models/index.js +21 -70
- package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
- package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
- package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
- package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
- package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -264
- package/pluggableElementTypes/renderers/RendererType.js +31 -105
- package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
- package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
- package/pluggableElementTypes/renderers/index.js +19 -62
- package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
- package/rpc/BaseRpcDriver.js +169 -405
- package/rpc/MainThreadRpcDriver.js +27 -150
- package/rpc/RpcManager.js +58 -159
- package/rpc/WebWorkerRpcDriver.js +54 -171
- package/rpc/configSchema.js +25 -49
- package/rpc/coreRpcMethods.js +221 -959
- package/rpc/remoteAbortSignals.js +46 -70
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/AboutDialog.js +106 -162
- package/ui/App.js +157 -242
- package/ui/AssemblySelector.js +59 -120
- package/ui/CascadingMenu.js +101 -196
- package/ui/ColorPicker.d.ts +16 -0
- package/ui/ColorPicker.js +97 -0
- package/ui/Drawer.js +28 -61
- package/ui/DrawerWidget.js +108 -202
- package/ui/DropDownMenu.js +60 -91
- package/ui/EditableTypography.js +87 -149
- package/ui/ErrorMessage.js +41 -56
- package/ui/FactoryResetDialog.js +24 -57
- package/ui/FatalErrorDialog.js +59 -91
- package/ui/FileSelector/FileSelector.js +123 -189
- package/ui/FileSelector/LocalFileChooser.js +44 -75
- package/ui/FileSelector/UrlChooser.js +17 -38
- package/ui/FileSelector/index.js +6 -12
- package/ui/Icons.js +45 -69
- package/ui/Logo.js +57 -110
- package/ui/Menu.js +232 -354
- package/ui/PrerenderedCanvas.js +63 -87
- package/ui/ResizeHandle.js +87 -116
- package/ui/ReturnToImportFormDialog.js +32 -63
- package/ui/SanitizedHTML.js +64 -47
- package/ui/Snackbar.js +74 -101
- package/ui/SnackbarModel.js +37 -51
- package/ui/Tooltip.js +49 -76
- package/ui/ViewContainer.js +113 -196
- package/ui/colors.d.ts +10 -0
- package/ui/colors.js +78 -0
- package/ui/index.js +51 -181
- package/ui/react-colorful.d.ts +17 -0
- package/ui/react-colorful.js +455 -0
- package/ui/theme.js +199 -247
- package/util/Base1DUtils.js +163 -202
- package/util/Base1DViewModel.js +121 -168
- package/util/QuickLRU.js +84 -332
- package/util/TimeTraveller.d.ts +19 -0
- package/util/TimeTraveller.js +86 -0
- package/util/aborting.js +49 -127
- package/util/analytics.js +91 -154
- package/util/blockTypes.js +106 -240
- package/util/calculateDynamicBlocks.js +98 -128
- package/util/calculateStaticBlocks.js +105 -125
- package/util/color/cssColorsLevel4.js +156 -160
- package/util/color/index.js +33 -55
- package/util/compositeMap.js +49 -333
- package/util/formatFastaStrings.js +9 -14
- package/util/idMaker.js +18 -31
- package/util/index.d.ts +7 -20
- package/util/index.js +742 -1188
- package/util/io/RemoteFileWithRangeCache.js +88 -257
- package/util/io/index.js +95 -169
- package/util/jexl.js +60 -115
- package/util/jexlStrings.js +24 -29
- package/util/layouts/BaseLayout.js +1 -4
- package/util/layouts/GranularRectLayout.js +388 -555
- package/util/layouts/MultiLayout.js +41 -109
- package/util/layouts/PrecomputedLayout.js +56 -112
- package/util/layouts/PrecomputedMultiLayout.js +22 -59
- package/util/layouts/SceneGraph.js +127 -197
- package/util/layouts/index.js +29 -66
- package/util/mst-reflection.js +55 -71
- package/util/offscreenCanvasPonyfill.js +66 -134
- package/util/offscreenCanvasUtils.d.ts +2 -7
- package/util/offscreenCanvasUtils.js +49 -146
- package/util/range.js +29 -40
- package/util/rxjs.js +20 -27
- package/util/simpleFeature.js +88 -152
- package/util/stats.js +91 -151
- package/util/tracks.js +130 -173
- package/util/types/index.js +110 -179
- package/util/types/mst.js +91 -146
- package/util/types/util.js +1 -4
- package/util/when.js +54 -101
- package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
- package/BaseFeatureWidget/index.test.js +0 -69
- package/TextSearch/BaseResults.test.js +0 -42
- package/configuration/configurationSchema.test.js +0 -266
- package/configuration/configurationSlot.test.js +0 -69
- package/configuration/util.test.js +0 -39
- package/data_adapters/BaseAdapter.test.js +0 -200
- package/declare.d.js +0 -1
- package/pluggableElementTypes/RpcMethodType.test.js +0 -118
- package/pluggableElementTypes/renderers/declare.d.js +0 -1
- package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
- package/rpc/BaseRpcDriver.test.js +0 -540
- package/rpc/declaration.d.js +0 -1
- package/ui/FatalErrorDialog.test.js +0 -82
- package/ui/SanitizedHTML.test.js +0 -36
- package/ui/theme.test.js +0 -92
- package/util/Base1DViewModel.test.js +0 -130
- package/util/calculateDynamicBlocks.test.js +0 -74
- package/util/calculateStaticBlocks.test.js +0 -297
- package/util/declare.d.js +0 -1
- package/util/formatFastaStrings.test.js +0 -40
- package/util/index.test.js +0 -213
- package/util/jexlStrings.test.js +0 -48
- package/util/layouts/GranularRectLayout.test.js +0 -99
- package/util/range.test.js +0 -64
- package/util/simpleFeature.test.js +0 -34
- package/util/stats.test.js +0 -172
package/util/blockTypes.js
CHANGED
|
@@ -1,266 +1,132 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
57
|
-
value: function getBlocks() {
|
|
58
|
-
return this.blocks;
|
|
20
|
+
getBlocks() {
|
|
21
|
+
return this.blocks;
|
|
59
22
|
}
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
get: function get() {
|
|
80
|
-
return this.blocks.length;
|
|
32
|
+
get length() {
|
|
33
|
+
return this.blocks.length;
|
|
81
34
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
194
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
244
|
-
|
|
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.
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
147
|
-
|
|
148
|
-
|
|
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;
|