@jbrowse/plugin-circular-view 1.6.7 → 1.7.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.
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.cartesianToPolar = cartesianToPolar;
9
+ exports.thetaRangesOverlap = thetaRangesOverlap;
10
+ exports.viewportVisibleSection = viewportVisibleSection;
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ function findCircleIntersectionX(y, cx, cy, r, resultArray) {
15
+ var d = Math.abs(y - cy);
16
+
17
+ if (d > r) {
18
+ return;
19
+ }
20
+
21
+ if (d === r) {
22
+ resultArray.push([cx, y]);
23
+ }
24
+
25
+ var solution = Math.sqrt(r * r - d * d);
26
+ resultArray.push([cx - solution, y]);
27
+ resultArray.push([cx + solution, y]);
28
+ }
29
+
30
+ function findCircleIntersectionY(x, cx, cy, r, resultArray) {
31
+ var d = Math.abs(x - cx);
32
+
33
+ if (d > r) {
34
+ return;
35
+ }
36
+
37
+ if (d === r) {
38
+ resultArray.push([x, cy]);
39
+ }
40
+
41
+ var solution = Math.sqrt(r * r - d * d);
42
+ resultArray.push([x, cy - solution]);
43
+ resultArray.push([x, cy + solution]);
44
+ }
45
+
46
+ function cartesianToTheta(x, y) {
47
+ var theta = (Math.atan(y / x) + 2 * Math.PI) % (2 * Math.PI);
48
+
49
+ if (x < 0) {
50
+ if (y <= 0) {
51
+ theta += Math.PI;
52
+ } else {
53
+ theta -= Math.PI;
54
+ }
55
+ }
56
+
57
+ return theta;
58
+ }
59
+
60
+ function cartesianToPolar(x, y) {
61
+ var rho = Math.sqrt(x * x + y * y);
62
+
63
+ if (rho === 0) {
64
+ return [0, 0];
65
+ }
66
+
67
+ var theta = cartesianToTheta(x, y);
68
+ return [rho, theta];
69
+ }
70
+
71
+ var twoPi = 2 * Math.PI;
72
+
73
+ function thetaRangesOverlap(r1start, r1length, r2start, r2length) {
74
+ if (r1length <= 0 || r2length <= 0) {
75
+ return false;
76
+ }
77
+
78
+ if (r1length + 0.0001 >= twoPi || r2length + 0.0001 >= twoPi) {
79
+ return true;
80
+ } // put both range starts between 2π and 4π
81
+
82
+
83
+ r1start = (r1start % twoPi + twoPi) % twoPi + twoPi;
84
+ r2start = (r2start % twoPi + twoPi) % twoPi + twoPi;
85
+
86
+ if (r1start < r2start + r2length && r1start + r1length > r2start) {
87
+ return true;
88
+ } // move r2 2π to the left and check
89
+
90
+
91
+ r2start -= twoPi;
92
+
93
+ if (r1start < r2start + r2length && r1start + r1length > r2start) {
94
+ return true;
95
+ } // move it 2π to the right and check
96
+
97
+
98
+ r2start += twoPi + twoPi;
99
+ return r1start < r2start + r2length && r1start + r1length > r2start;
100
+ } // return which arc range has any part of the circle visible in the viewport
101
+
102
+
103
+ function viewportVisibleSection(viewSides, circleCenter, circleRadius) {
104
+ var _viewSides = (0, _slicedToArray2["default"])(viewSides, 4),
105
+ viewL = _viewSides[0],
106
+ viewR = _viewSides[1],
107
+ viewT = _viewSides[2],
108
+ viewB = _viewSides[3];
109
+
110
+ var _circleCenter = (0, _slicedToArray2["default"])(circleCenter, 2),
111
+ cx = _circleCenter[0],
112
+ cy = _circleCenter[1]; // transform coordinate system to center of circle
113
+
114
+
115
+ viewL -= cx;
116
+ viewR -= cx;
117
+ viewT -= cy;
118
+ viewB -= cy;
119
+ var centerIsInsideViewport = viewL < 0 && viewR > 0 && viewT < 0 && viewB > 0;
120
+
121
+ if (centerIsInsideViewport) {
122
+ var _vertices = [[viewL, viewT], [viewR, viewT], [viewL, viewB], [viewR, viewB]];
123
+ var maxRho = -Infinity;
124
+
125
+ for (var i = 0; i < _vertices.length; i += 1) {
126
+ var _vertices$i = (0, _slicedToArray2["default"])(_vertices[i], 2),
127
+ x = _vertices$i[0],
128
+ y = _vertices$i[1];
129
+
130
+ var rho = Math.sqrt(x * x + y * y);
131
+
132
+ if (rho > maxRho) {
133
+ maxRho = rho;
134
+ }
135
+ }
136
+
137
+ return {
138
+ rho: [0, Math.min(circleRadius, maxRho)],
139
+ theta: [0, 2 * Math.PI]
140
+ };
141
+ } // const viewportCompletelyContainsCircle =
142
+ // circleCenter[0] - viewL >= circleRadius &&
143
+ // viewR - circleCenter[0] >= circleRadius &&
144
+ // circleCenter[1] - viewT >= circleRadius &&
145
+ // viewB - circleCenter[1] >= circleRadius
146
+ // if (viewportCompletelyContainsCircle) {
147
+ // return [0, 2 * Math.PI]
148
+ // }
149
+ // const distToCenterSquared = ([x, y]) => {
150
+ // const [cx, cy] = circleCenter
151
+ // const sq = n => n * n
152
+ // return sq(x - cx) + sq(y - cy)
153
+ // }
154
+ // const circleRadiusSquared = circleRadius * circleRadius
155
+ // const tlInside = distToCenterSquared([viewL, viewT]) <= circleRadiusSquared
156
+ // const trInside = distToCenterSquared([viewR, viewT]) <= circleRadiusSquared
157
+ // const blInside = distToCenterSquared([viewL, viewB]) <= circleRadiusSquared
158
+ // const brInside = distToCenterSquared([viewR, viewB]) <= circleRadiusSquared
159
+ // const noIntersection = !tlInside && !trInside && !blInside && !brInside
160
+ // if (noIntersection) return undefined
161
+ // const circleCompletelyContainsViewport =
162
+ // tlInside && trInside && blInside && brInside
163
+ // if (circleCompletelyContainsViewport) {
164
+ // // viewport is in the circle, but the center is not in it, so take max
165
+ // // and min of thetas to the center
166
+ // const thetas = [
167
+ // Math.atan(viewT / viewL),
168
+ // Math.atan(viewT / viewR),
169
+ // Math.atan(viewB / viewL),
170
+ // Math.atan(viewB / viewR),
171
+ // ]
172
+ // return [Math.min(...thetas), Math.max(...thetas)]
173
+ // }
174
+ // if we get here, the viewport is partly in, partly out of the circle
175
+ // const viewLIntersects = Math.abs(viewL - circleCenter[0]) <= circleRadius
176
+ // const viewRIntersects = Math.abs(viewR - circleCenter[0]) <= circleRadius
177
+ // const viewTIntersects = Math.abs(viewT - circleCenter[1]) <= circleRadius
178
+ // const viewBIntersects = Math.abs(viewB - circleCenter[1]) <= circleRadius
179
+ // const numIntersectingSides =
180
+ // Number(viewLIntersects) +
181
+ // Number(viewRIntersects) +
182
+ // Number(viewTIntersects) +
183
+ // Number(viewBIntersects)
184
+ // if (numIntersectingSides === 4) return [0, 2 * Math.PI]
185
+ // if (numIntersectingSides === 3) {
186
+ // // TODO calculate the thetas of the
187
+ // } else if (numIntersectingSides === 2) {
188
+ // // TODO calculate the thetas of the 2 intersection points
189
+ // } else if (numIntersectingSides === 1) {
190
+ // // TODO calculate the thetas of the 1-2 intersection points of the line, and the angle between
191
+ // }
192
+ // make a list of vertices-of-interest that lie inside both shapes to examine
193
+ // to determine the range covered by their intersection
194
+ // transform coordinates to have the circle as the origin and find the intersections
195
+ // of the circle and the view rectangle
196
+
197
+
198
+ var vertices = [[viewL, viewT], [viewR, viewT], [viewL, viewB], [viewR, viewB]];
199
+ findCircleIntersectionY(viewL, 0, 0, circleRadius, vertices);
200
+ findCircleIntersectionY(viewR, 0, 0, circleRadius, vertices);
201
+ findCircleIntersectionX(viewT, 0, 0, circleRadius, vertices);
202
+ findCircleIntersectionX(viewB, 0, 0, circleRadius, vertices); // for each edge, also look at the closest point to center if it is inside the circle
203
+
204
+ if (-viewL < circleRadius) {
205
+ vertices.push([viewL, 0]);
206
+ }
207
+
208
+ if (viewR < circleRadius) {
209
+ vertices.push([viewR, 0]);
210
+ }
211
+
212
+ if (-viewT < circleRadius) {
213
+ vertices.push([0, viewT]);
214
+ }
215
+
216
+ if (viewB < circleRadius) {
217
+ vertices.push([0, viewB]);
218
+ } // const verticesOriginal = vertices.map(([x, y]) => [x + cx, y + cy])
219
+ // now convert them all to polar and take the max and min of rho and theta
220
+ // const viewportCenterTheta = cartesianToTheta(viewR + viewL, viewT + viewB)
221
+
222
+
223
+ var reflect = viewL >= 0 ? -1 : 1; // viewportCenterTheta < Math.PI / 2 || viewportCenterTheta > 1.5 * Math.PI
224
+ // ? -1
225
+ // : 1
226
+
227
+ var rhoMin = Infinity;
228
+ var rhoMax = -Infinity;
229
+ var thetaMin = Infinity;
230
+ var thetaMax = -Infinity;
231
+
232
+ for (var _i = 0; _i < vertices.length; _i += 1) {
233
+ // ignore vertex if outside the viewport
234
+ var _vertices$_i = (0, _slicedToArray2["default"])(vertices[_i], 2),
235
+ vx = _vertices$_i[0],
236
+ vy = _vertices$_i[1];
237
+
238
+ if (vx >= viewL && vx <= viewR && vy >= viewT && vy <= viewB) {
239
+ var _cartesianToPolar = cartesianToPolar(vx * reflect, vy * reflect),
240
+ _cartesianToPolar2 = (0, _slicedToArray2["default"])(_cartesianToPolar, 2),
241
+ _rho = _cartesianToPolar2[0],
242
+ theta = _cartesianToPolar2[1]; // ignore vertex if outside the circle
243
+
244
+
245
+ if (_rho <= circleRadius + 0.001) {
246
+ // ignore theta if rho is 0
247
+ if (theta < thetaMin && _rho > 0.0001) {
248
+ thetaMin = theta;
249
+ }
250
+
251
+ if (theta > thetaMax && _rho > 0.0001) {
252
+ thetaMax = theta;
253
+ }
254
+
255
+ if (_rho < rhoMin) {
256
+ rhoMin = _rho;
257
+ }
258
+
259
+ if (_rho > rhoMax) {
260
+ rhoMax = _rho;
261
+ }
262
+ }
263
+ }
264
+ }
265
+
266
+ if (reflect === -1) {
267
+ thetaMin += Math.PI;
268
+ thetaMax += Math.PI;
269
+ }
270
+
271
+ if (thetaMin > 2 * Math.PI && thetaMax > 2 * Math.PI) {
272
+ thetaMin -= 2 * Math.PI;
273
+ thetaMax -= 2 * Math.PI;
274
+ }
275
+
276
+ return {
277
+ rho: [rhoMin, Math.min(circleRadius, rhoMax)],
278
+ theta: [thetaMin, thetaMax]
279
+ };
280
+ }
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
6
+
7
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
8
+
9
+ var _viewportVisibleRegion = require("./viewportVisibleRegion");
10
+
11
+ describe('viewportVisibleSection', function () {
12
+ // test('circle contained in viewport', () => {
13
+ // const result = viewportVisibleSection([0, 1, 0, 1], [0.5, 0.5], 0.3)
14
+ // expect(result).toEqual({ rho: [0, 0.3], theta: [0, 2 * Math.PI] })
15
+ // })
16
+ // test('viewport completely inside circle', () => {
17
+ // const result = viewportVisibleSection([0, 1, 0, 1], [0.5, 0.5], 20)
18
+ // expect(result.theta).toEqual([0, 2 * Math.PI])
19
+ // expect(result.rho[0]).toEqual(0)
20
+ // expect(result.rho[1]).toBeCloseTo(0.7071)
21
+ // })
22
+ // test('viewport on left half of circle', () => {
23
+ // const result = viewportVisibleSection([200, 500, 0, 1000], [500, 500], 20)
24
+ // expect(result).toEqual({
25
+ // rho: [0, 20],
26
+ // theta: [Math.PI / 2, 1.5 * Math.PI],
27
+ // })
28
+ // })
29
+ // test('viewport on right half of circle', () => {
30
+ // const result = viewportVisibleSection([200, 500, 0, 1000], [200, 500], 20)
31
+ // expect(result).toEqual({
32
+ // rho: [0, 20],
33
+ // theta: [1.5 * Math.PI, 2.5 * Math.PI],
34
+ // })
35
+ // })
36
+ // test('viewport corner in circle', () => {
37
+ // const { theta, rho } = viewportVisibleSection(
38
+ // [200, 500, 0, 700],
39
+ // [199, 701],
40
+ // 100,
41
+ // )
42
+ // expect(rho).toEqual([1.4142135623730951, 100])
43
+ // expect(theta[0]).toBeCloseTo(1.5 * Math.PI, 1)
44
+ // expect(theta[1]).toBeCloseTo(2 * Math.PI, 1)
45
+ // })
46
+ // test('viewport on center right', () => {
47
+ // const { theta, rho } = viewportVisibleSection(
48
+ // [1102, 2153, 880, 1280],
49
+ // [1068.8119697255406, 1068.8119697255406],
50
+ // 1048.8119697255406,
51
+ // )
52
+ // expect(theta[1]).toBeGreaterThan(2 * Math.PI)
53
+ // expect(theta[1]).toBeLessThan(2.5 * Math.PI)
54
+ // expect(theta[0]).toBeGreaterThan(1.5 * Math.PI)
55
+ // expect(theta[0]).toBeLessThan(2 * Math.PI)
56
+ // })
57
+ // test('viewport on center right 2', () => {
58
+ // const { theta, rho } = viewportVisibleSection(
59
+ // [1816, 2937, 1074, 1474],
60
+ // [1468.6015446723616, 1468.6015446723616],
61
+ // 1448.6015446723616,
62
+ // )
63
+ // expect(theta[1]).toBeGreaterThan(2 * Math.PI)
64
+ // expect(theta[1]).toBeLessThan(2.5 * Math.PI)
65
+ // expect(theta[0]).toBeGreaterThan(1.5 * Math.PI)
66
+ // expect(theta[0]).toBeLessThan(2 * Math.PI)
67
+ // })
68
+ // test('viewport on lower center', () => {
69
+ // const { theta, rho } = viewportVisibleSection(
70
+ // [259, 1350, 1176, 1576],
71
+ // [787.7952717090081, 787.7952717090081],
72
+ // 767.7952717090081,
73
+ // )
74
+ // expect(theta[1]).toBeGreaterThan(Math.PI / 2)
75
+ // expect(theta[1]).toBeLessThan(Math.PI)
76
+ // expect(theta[0]).toBeGreaterThan(0)
77
+ // expect(theta[0]).toBeLessThan(Math.PI / 2)
78
+ // })
79
+ // test('viewport on upper center', () => {
80
+ // const { theta, rho } = viewportVisibleSection(
81
+ // [286, 1377, 0, 400],
82
+ // [787.7952717090081, 787.7952717090081],
83
+ // 767.7952717090081,
84
+ // )
85
+ // expect(theta[1]).toBeGreaterThan(1.5 * Math.PI)
86
+ // expect(theta[1]).toBeLessThan(2 * Math.PI)
87
+ // expect(theta[0]).toBeGreaterThan(Math.PI)
88
+ // expect(theta[0]).toBeLessThan(1.5 * Math.PI)
89
+ // })
90
+ test('viewport on upper center 2', function () {
91
+ // [180.48708681644143, 359.3411680673888] [4.6042679453532855, 541.6042679453533]
92
+ // see '~/Desktop/Screen Shot 2019-06-28 at 3.01.22 PM.png'
93
+ var _viewportVisibleSecti = (0, _viewportVisibleRegion.viewportVisibleSection)([0, 962, 157, 557], [561.6042679453533, 561.6042679453533], 541.6042679453533),
94
+ theta = _viewportVisibleSecti.theta;
95
+
96
+ expect(theta[1]).toBeGreaterThan(1.75 * Math.PI);
97
+ expect(theta[1]).toBeLessThan(2 * Math.PI);
98
+ expect(theta[0]).toBeGreaterThan(Math.PI);
99
+ expect(theta[0]).toBeLessThan(1.1 * Math.PI);
100
+ });
101
+ });
102
+ describe('cartesian to polar', function () {
103
+ ;
104
+ [[[-1, -1], [1.414, 180 + 45]], [[-1, 1], [1.414, 90 + 45]], [[1, 1], [1.414, 45]], [[1, -1], [1.414, 360 - 45]], [[0, 1], [1, 90]], [[0, -1], [1, 270]], [[-1, 0], [1, 180]], [[1, 0], [1, 0]]].forEach(function (testCase) {
105
+ var _testCase = (0, _slicedToArray2["default"])(testCase, 2),
106
+ input = _testCase[0],
107
+ output = _testCase[1];
108
+
109
+ test("".concat(input, " -> ").concat(output), function () {
110
+ var result = _viewportVisibleRegion.cartesianToPolar.apply(void 0, (0, _toConsumableArray2["default"])(input));
111
+
112
+ expect(result[0]).toBeCloseTo(output[0]);
113
+ expect(result[1] * 180 / Math.PI).toBeCloseTo(output[1]);
114
+ });
115
+ });
116
+ });
117
+ describe('theta overlap testing', function () {
118
+ ;
119
+ [[[0, 2 * Math.PI, 0, 2 * Math.PI], true], [[6.1, Math.PI / 2, 0, Math.PI / 2], true], [[6.1, Math.PI / 2, 0, 0.1], true], [[6.1, 0.1, 6.12, 0.05], true], [[-12, 0.1, -12.05, 0.05], false], [[-12, 0.1, -12.05, 0.06], true]].forEach(function (testCase) {
120
+ var _testCase2 = (0, _slicedToArray2["default"])(testCase, 2),
121
+ input = _testCase2[0],
122
+ output = _testCase2[1];
123
+
124
+ test("".concat(input, " -> ").concat(output), function () {
125
+ var result = _viewportVisibleRegion.thetaRangesOverlap.apply(void 0, (0, _toConsumableArray2["default"])(input));
126
+
127
+ expect(result).toBe(output);
128
+ });
129
+ });
130
+ });
package/dist/index.js CHANGED
@@ -1,8 +1,182 @@
1
+ "use strict";
1
2
 
2
- 'use strict'
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
 
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./plugin-circular-view.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./plugin-circular-view.cjs.development.js')
8
- }
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ Object.defineProperty(exports, "BaseChordDisplayComponentFactory", {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _BaseChordDisplay.BaseChordDisplayComponentFactory;
14
+ }
15
+ });
16
+ Object.defineProperty(exports, "BaseChordDisplayModel", {
17
+ enumerable: true,
18
+ get: function get() {
19
+ return _BaseChordDisplay.BaseChordDisplayModel;
20
+ }
21
+ });
22
+ Object.defineProperty(exports, "baseChordDisplayConfig", {
23
+ enumerable: true,
24
+ get: function get() {
25
+ return _BaseChordDisplay.baseChordDisplayConfig;
26
+ }
27
+ });
28
+ exports["default"] = void 0;
29
+
30
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
31
+
32
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
33
+
34
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
35
+
36
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
37
+
38
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
39
+
40
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
41
+
42
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
43
+
44
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
45
+
46
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
47
+
48
+ var _react = require("react");
49
+
50
+ var _mobx = require("mobx");
51
+
52
+ var _util = require("@jbrowse/core/util");
53
+
54
+ var _Plugin2 = _interopRequireDefault(require("@jbrowse/core/Plugin"));
55
+
56
+ var _ViewType = _interopRequireDefault(require("@jbrowse/core/pluggableElementTypes/ViewType"));
57
+
58
+ var _DataUsage = _interopRequireDefault(require("@material-ui/icons/DataUsage"));
59
+
60
+ var _CircularView = _interopRequireDefault(require("./CircularView/models/CircularView"));
61
+
62
+ var _BaseChordDisplay = require("./BaseChordDisplay");
63
+
64
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
65
+
66
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
67
+
68
+ 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); }; }
69
+
70
+ 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; } }
71
+
72
+ var CircularViewPlugin = /*#__PURE__*/function (_Plugin) {
73
+ (0, _inherits2["default"])(CircularViewPlugin, _Plugin);
74
+
75
+ var _super = _createSuper(CircularViewPlugin);
76
+
77
+ function CircularViewPlugin() {
78
+ var _this;
79
+
80
+ (0, _classCallCheck2["default"])(this, CircularViewPlugin);
81
+
82
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
83
+ args[_key] = arguments[_key];
84
+ }
85
+
86
+ _this = _super.call.apply(_super, [this].concat(args));
87
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "name", 'CircularViewPlugin');
88
+ return _this;
89
+ }
90
+
91
+ (0, _createClass2["default"])(CircularViewPlugin, [{
92
+ key: "install",
93
+ value: function install(pluginManager) {
94
+ pluginManager.addViewType(function () {
95
+ return new _ViewType["default"]({
96
+ ReactComponent: /*#__PURE__*/(0, _react.lazy)(function () {
97
+ return Promise.resolve().then(function () {
98
+ return _interopRequireWildcard(require('./CircularView/components/CircularView'));
99
+ });
100
+ }),
101
+ stateModel: (0, _CircularView["default"])(pluginManager),
102
+ name: 'CircularView'
103
+ });
104
+ });
105
+ pluginManager.addToExtensionPoint('LaunchView-CircularView',
106
+ /*#__PURE__*/
107
+ // @ts-ignore
108
+ function () {
109
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref) {
110
+ var session, assembly, loc, _ref$tracks, tracks, assemblyManager, view, asm;
111
+
112
+ return _regenerator["default"].wrap(function _callee$(_context) {
113
+ while (1) {
114
+ switch (_context.prev = _context.next) {
115
+ case 0:
116
+ session = _ref.session, assembly = _ref.assembly, loc = _ref.loc, _ref$tracks = _ref.tracks, tracks = _ref$tracks === void 0 ? [] : _ref$tracks;
117
+ assemblyManager = session.assemblyManager;
118
+ view = session.addView('CircularView', {});
119
+ _context.next = 5;
120
+ return (0, _mobx.when)(function () {
121
+ return view.initialized;
122
+ });
123
+
124
+ case 5:
125
+ if (assembly) {
126
+ _context.next = 7;
127
+ break;
128
+ }
129
+
130
+ throw new Error('No assembly provided when launching circular genome view');
131
+
132
+ case 7:
133
+ _context.next = 9;
134
+ return assemblyManager.waitForAssembly(assembly);
135
+
136
+ case 9:
137
+ asm = _context.sent;
138
+
139
+ if (asm) {
140
+ _context.next = 12;
141
+ break;
142
+ }
143
+
144
+ throw new Error("Assembly \"".concat(assembly, "\" not found when launching circular genome view"));
145
+
146
+ case 12:
147
+ view.setDisplayedRegions(asm.regions || []);
148
+ tracks.forEach(function (track) {
149
+ return view.showTrack(track);
150
+ });
151
+
152
+ case 14:
153
+ case "end":
154
+ return _context.stop();
155
+ }
156
+ }
157
+ }, _callee);
158
+ }));
159
+
160
+ return function (_x) {
161
+ return _ref2.apply(this, arguments);
162
+ };
163
+ }());
164
+ }
165
+ }, {
166
+ key: "configure",
167
+ value: function configure(pluginManager) {
168
+ if ((0, _util.isAbstractMenuManager)(pluginManager.rootModel)) {
169
+ pluginManager.rootModel.appendToSubMenu(['Add'], {
170
+ label: 'Circular view',
171
+ icon: _DataUsage["default"],
172
+ onClick: function onClick(session) {
173
+ session.addView('CircularView', {});
174
+ }
175
+ });
176
+ }
177
+ }
178
+ }]);
179
+ return CircularViewPlugin;
180
+ }(_Plugin2["default"]);
181
+
182
+ exports["default"] = CircularViewPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-circular-view",
3
- "version": "1.6.7",
3
+ "version": "1.7.0",
4
4
  "description": "JBrowse 2 circular view",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -18,15 +18,12 @@
18
18
  "distMain": "dist/index.js",
19
19
  "srcMain": "src/index.ts",
20
20
  "main": "dist/index.js",
21
- "distModule": "dist/plugin-circular-view.esm.js",
22
- "module": "dist/plugin-circular-view.esm.js",
23
21
  "files": [
24
22
  "dist",
25
23
  "src"
26
24
  ],
27
25
  "scripts": {
28
- "start": "tsdx watch --verbose --noClean",
29
- "build": "tsdx build",
26
+ "build": "babel src --root-mode upward --out-dir dist --extensions .ts,.js,.tsx,.jsx",
30
27
  "test": "cd ../..; jest plugins/circular-view",
31
28
  "prepublishOnly": "yarn test",
32
29
  "prepack": "yarn build; yarn useDist",
@@ -49,5 +46,5 @@
49
46
  "publishConfig": {
50
47
  "access": "public"
51
48
  },
52
- "gitHead": "02012ec299c36647f755316571775d36b0fee5ec"
49
+ "gitHead": "cc13844074d11881d211342a6a7eea113561b70b"
53
50
  }