@jbrowse/plugin-circular-view 1.7.0 → 1.7.3
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/dist/BaseChordDisplay/components/BaseChordDisplay.d.ts +9 -9
- package/dist/BaseChordDisplay/components/DisplayError.d.ts +4 -4
- package/dist/BaseChordDisplay/components/Loading.d.ts +10 -10
- package/dist/BaseChordDisplay/components/RpcRenderedSvgGroup.d.ts +4 -4
- package/dist/BaseChordDisplay/index.d.ts +3 -3
- package/dist/BaseChordDisplay/models/BaseChordDisplayModel.d.ts +99 -99
- package/dist/BaseChordDisplay/models/baseChordDisplayConfig.d.ts +2 -2
- package/dist/BaseChordDisplay/models/renderReaction.d.ts +30 -30
- package/dist/CircularView/components/CircularView.d.ts +4 -4
- package/dist/CircularView/components/ImportForm.d.ts +5 -5
- package/dist/CircularView/components/Ruler.d.ts +5 -5
- package/dist/CircularView/models/CircularView.d.ts +97 -97
- package/dist/CircularView/models/slices.d.ts +27 -27
- package/dist/CircularView/models/viewportVisibleRegion.d.ts +6 -6
- package/dist/index.d.ts +8 -8
- package/package.json +4 -3
- package/dist/CircularView/models/slices.test.d.ts +0 -1
- package/dist/CircularView/models/viewportVisibleRegion.test.d.ts +0 -1
- package/dist/plugin-circular-view.cjs.development.js +0 -3013
- package/dist/plugin-circular-view.cjs.development.js.map +0 -1
- package/dist/plugin-circular-view.cjs.production.min.js +0 -2
- package/dist/plugin-circular-view.cjs.production.min.js.map +0 -1
- package/dist/plugin-circular-view.esm.js +0 -3004
- package/dist/plugin-circular-view.esm.js.map +0 -1
|
@@ -1,3004 +0,0 @@
|
|
|
1
|
-
import React, { lazy, useState } from 'react';
|
|
2
|
-
import { transaction, when } from 'mobx';
|
|
3
|
-
import { polarToCartesian, objectFromEntries, assembleLocString, clamp, getSession, isSessionModelWithWidgets, getContainingView, makeAbortableReaction, isAbstractMenuManager, radToDeg } from '@jbrowse/core/util';
|
|
4
|
-
import Plugin from '@jbrowse/core/Plugin';
|
|
5
|
-
import ViewType from '@jbrowse/core/pluggableElementTypes/ViewType';
|
|
6
|
-
import DataUsageIcon from '@material-ui/icons/DataUsage';
|
|
7
|
-
import { types, getParent, cast, resolveIdentifier, getRoot, getEnv, isAlive } from 'mobx-state-tree';
|
|
8
|
-
import { Region } from '@jbrowse/core/util/types/mst';
|
|
9
|
-
import { readConfObject, getConf, ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
10
|
-
import { BaseViewModel, BaseDisplay } from '@jbrowse/core/pluggableElementTypes/models';
|
|
11
|
-
import CircularChordRendererType from '@jbrowse/core/pluggableElementTypes/renderers/CircularChordRendererType';
|
|
12
|
-
import { isFeature } from '@jbrowse/core/util/simpleFeature';
|
|
13
|
-
import { getParentRenderProps, getTrackAssemblyNames, getRpcSessionId } from '@jbrowse/core/util/tracks';
|
|
14
|
-
import { observer } from 'mobx-react';
|
|
15
|
-
import { ErrorMessage as ErrorMessage$1, ResizeHandle } from '@jbrowse/core/ui';
|
|
16
|
-
import { Container, Grid, Button, makeStyles as makeStyles$1, IconButton } from '@material-ui/core';
|
|
17
|
-
import { grey } from '@material-ui/core/colors';
|
|
18
|
-
import ZoomOut from '@material-ui/icons/ZoomOut';
|
|
19
|
-
import ZoomIn from '@material-ui/icons/ZoomIn';
|
|
20
|
-
import RotateLeft from '@material-ui/icons/RotateLeft';
|
|
21
|
-
import RotateRight from '@material-ui/icons/RotateRight';
|
|
22
|
-
import LockOutline from '@material-ui/icons/LockOutlined';
|
|
23
|
-
import LockOpen from '@material-ui/icons/LockOpen';
|
|
24
|
-
import { TrackSelector } from '@jbrowse/core/ui/Icons';
|
|
25
|
-
import { makeContrasting } from '@jbrowse/core/util/color';
|
|
26
|
-
import { useTheme, makeStyles } from '@material-ui/core/styles';
|
|
27
|
-
import ErrorMessage from '@jbrowse/core/ui/ErrorMessage';
|
|
28
|
-
import AssemblySelector from '@jbrowse/core/ui/AssemblySelector';
|
|
29
|
-
|
|
30
|
-
function ownKeys(object, enumerableOnly) {
|
|
31
|
-
var keys = Object.keys(object);
|
|
32
|
-
|
|
33
|
-
if (Object.getOwnPropertySymbols) {
|
|
34
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
35
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
36
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
37
|
-
})), keys.push.apply(keys, symbols);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return keys;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function _objectSpread2(target) {
|
|
44
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
45
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
46
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
47
|
-
_defineProperty(target, key, source[key]);
|
|
48
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
49
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return target;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
57
|
-
try {
|
|
58
|
-
var info = gen[key](arg);
|
|
59
|
-
var value = info.value;
|
|
60
|
-
} catch (error) {
|
|
61
|
-
reject(error);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (info.done) {
|
|
66
|
-
resolve(value);
|
|
67
|
-
} else {
|
|
68
|
-
Promise.resolve(value).then(_next, _throw);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function _asyncToGenerator(fn) {
|
|
73
|
-
return function () {
|
|
74
|
-
var self = this,
|
|
75
|
-
args = arguments;
|
|
76
|
-
return new Promise(function (resolve, reject) {
|
|
77
|
-
var gen = fn.apply(self, args);
|
|
78
|
-
|
|
79
|
-
function _next(value) {
|
|
80
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function _throw(err) {
|
|
84
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
_next(undefined);
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function _classCallCheck(instance, Constructor) {
|
|
93
|
-
if (!(instance instanceof Constructor)) {
|
|
94
|
-
throw new TypeError("Cannot call a class as a function");
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function _defineProperties(target, props) {
|
|
99
|
-
for (var i = 0; i < props.length; i++) {
|
|
100
|
-
var descriptor = props[i];
|
|
101
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
102
|
-
descriptor.configurable = true;
|
|
103
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
104
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
109
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
110
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
111
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
112
|
-
writable: false
|
|
113
|
-
});
|
|
114
|
-
return Constructor;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function _defineProperty(obj, key, value) {
|
|
118
|
-
if (key in obj) {
|
|
119
|
-
Object.defineProperty(obj, key, {
|
|
120
|
-
value: value,
|
|
121
|
-
enumerable: true,
|
|
122
|
-
configurable: true,
|
|
123
|
-
writable: true
|
|
124
|
-
});
|
|
125
|
-
} else {
|
|
126
|
-
obj[key] = value;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return obj;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function _inherits(subClass, superClass) {
|
|
133
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
134
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
138
|
-
constructor: {
|
|
139
|
-
value: subClass,
|
|
140
|
-
writable: true,
|
|
141
|
-
configurable: true
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
Object.defineProperty(subClass, "prototype", {
|
|
145
|
-
writable: false
|
|
146
|
-
});
|
|
147
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function _getPrototypeOf(o) {
|
|
151
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
152
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
153
|
-
};
|
|
154
|
-
return _getPrototypeOf(o);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function _setPrototypeOf(o, p) {
|
|
158
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
159
|
-
o.__proto__ = p;
|
|
160
|
-
return o;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
return _setPrototypeOf(o, p);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function _isNativeReflectConstruct() {
|
|
167
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
168
|
-
if (Reflect.construct.sham) return false;
|
|
169
|
-
if (typeof Proxy === "function") return true;
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
173
|
-
return true;
|
|
174
|
-
} catch (e) {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
180
|
-
if (source == null) return {};
|
|
181
|
-
var target = {};
|
|
182
|
-
var sourceKeys = Object.keys(source);
|
|
183
|
-
var key, i;
|
|
184
|
-
|
|
185
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
186
|
-
key = sourceKeys[i];
|
|
187
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
188
|
-
target[key] = source[key];
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return target;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function _objectWithoutProperties(source, excluded) {
|
|
195
|
-
if (source == null) return {};
|
|
196
|
-
|
|
197
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
198
|
-
|
|
199
|
-
var key, i;
|
|
200
|
-
|
|
201
|
-
if (Object.getOwnPropertySymbols) {
|
|
202
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
203
|
-
|
|
204
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
205
|
-
key = sourceSymbolKeys[i];
|
|
206
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
207
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
208
|
-
target[key] = source[key];
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return target;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function _assertThisInitialized(self) {
|
|
216
|
-
if (self === void 0) {
|
|
217
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return self;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function _possibleConstructorReturn(self, call) {
|
|
224
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
225
|
-
return call;
|
|
226
|
-
} else if (call !== void 0) {
|
|
227
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return _assertThisInitialized(self);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function _createSuper(Derived) {
|
|
234
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
235
|
-
|
|
236
|
-
return function _createSuperInternal() {
|
|
237
|
-
var Super = _getPrototypeOf(Derived),
|
|
238
|
-
result;
|
|
239
|
-
|
|
240
|
-
if (hasNativeReflectConstruct) {
|
|
241
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
242
|
-
|
|
243
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
244
|
-
} else {
|
|
245
|
-
result = Super.apply(this, arguments);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return _possibleConstructorReturn(this, result);
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function _slicedToArray(arr, i) {
|
|
253
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function _toConsumableArray(arr) {
|
|
257
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function _arrayWithoutHoles(arr) {
|
|
261
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function _arrayWithHoles(arr) {
|
|
265
|
-
if (Array.isArray(arr)) return arr;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function _iterableToArray(iter) {
|
|
269
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function _iterableToArrayLimit(arr, i) {
|
|
273
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
274
|
-
|
|
275
|
-
if (_i == null) return;
|
|
276
|
-
var _arr = [];
|
|
277
|
-
var _n = true;
|
|
278
|
-
var _d = false;
|
|
279
|
-
|
|
280
|
-
var _s, _e;
|
|
281
|
-
|
|
282
|
-
try {
|
|
283
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
284
|
-
_arr.push(_s.value);
|
|
285
|
-
|
|
286
|
-
if (i && _arr.length === i) break;
|
|
287
|
-
}
|
|
288
|
-
} catch (err) {
|
|
289
|
-
_d = true;
|
|
290
|
-
_e = err;
|
|
291
|
-
} finally {
|
|
292
|
-
try {
|
|
293
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
294
|
-
} finally {
|
|
295
|
-
if (_d) throw _e;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return _arr;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
303
|
-
if (!o) return;
|
|
304
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
305
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
306
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
307
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
308
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function _arrayLikeToArray(arr, len) {
|
|
312
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
313
|
-
|
|
314
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
315
|
-
|
|
316
|
-
return arr2;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function _nonIterableSpread() {
|
|
320
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function _nonIterableRest() {
|
|
324
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
328
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
329
|
-
|
|
330
|
-
if (!it) {
|
|
331
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
332
|
-
if (it) o = it;
|
|
333
|
-
var i = 0;
|
|
334
|
-
|
|
335
|
-
var F = function () {};
|
|
336
|
-
|
|
337
|
-
return {
|
|
338
|
-
s: F,
|
|
339
|
-
n: function () {
|
|
340
|
-
if (i >= o.length) return {
|
|
341
|
-
done: true
|
|
342
|
-
};
|
|
343
|
-
return {
|
|
344
|
-
done: false,
|
|
345
|
-
value: o[i++]
|
|
346
|
-
};
|
|
347
|
-
},
|
|
348
|
-
e: function (e) {
|
|
349
|
-
throw e;
|
|
350
|
-
},
|
|
351
|
-
f: F
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
var normalCompletion = true,
|
|
359
|
-
didErr = false,
|
|
360
|
-
err;
|
|
361
|
-
return {
|
|
362
|
-
s: function () {
|
|
363
|
-
it = it.call(o);
|
|
364
|
-
},
|
|
365
|
-
n: function () {
|
|
366
|
-
var step = it.next();
|
|
367
|
-
normalCompletion = step.done;
|
|
368
|
-
return step;
|
|
369
|
-
},
|
|
370
|
-
e: function (e) {
|
|
371
|
-
didErr = true;
|
|
372
|
-
err = e;
|
|
373
|
-
},
|
|
374
|
-
f: function () {
|
|
375
|
-
try {
|
|
376
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
377
|
-
} finally {
|
|
378
|
-
if (didErr) throw err;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function createCommonjsModule(fn, module) {
|
|
385
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
389
|
-
/**
|
|
390
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
391
|
-
*
|
|
392
|
-
* This source code is licensed under the MIT license found in the
|
|
393
|
-
* LICENSE file in the root directory of this source tree.
|
|
394
|
-
*/
|
|
395
|
-
var runtime = function (exports) {
|
|
396
|
-
|
|
397
|
-
var Op = Object.prototype;
|
|
398
|
-
var hasOwn = Op.hasOwnProperty;
|
|
399
|
-
var undefined$1; // More compressible than void 0.
|
|
400
|
-
|
|
401
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
402
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
403
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
404
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
405
|
-
|
|
406
|
-
function define(obj, key, value) {
|
|
407
|
-
Object.defineProperty(obj, key, {
|
|
408
|
-
value: value,
|
|
409
|
-
enumerable: true,
|
|
410
|
-
configurable: true,
|
|
411
|
-
writable: true
|
|
412
|
-
});
|
|
413
|
-
return obj[key];
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
try {
|
|
417
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
418
|
-
define({}, "");
|
|
419
|
-
} catch (err) {
|
|
420
|
-
define = function define(obj, key, value) {
|
|
421
|
-
return obj[key] = value;
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
426
|
-
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
427
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
428
|
-
var generator = Object.create(protoGenerator.prototype);
|
|
429
|
-
var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
|
|
430
|
-
// .throw, and .return methods.
|
|
431
|
-
|
|
432
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
433
|
-
return generator;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
|
|
437
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
438
|
-
// have been (and was previously) designed to take a closure to be
|
|
439
|
-
// invoked without arguments, but in all the cases we care about we
|
|
440
|
-
// already have an existing method we want to call, so there's no need
|
|
441
|
-
// to create a new function object. We can even get away with assuming
|
|
442
|
-
// the method takes exactly one argument, since that happens to be true
|
|
443
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
444
|
-
// only additional allocation required is the completion record, which
|
|
445
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
446
|
-
|
|
447
|
-
function tryCatch(fn, obj, arg) {
|
|
448
|
-
try {
|
|
449
|
-
return {
|
|
450
|
-
type: "normal",
|
|
451
|
-
arg: fn.call(obj, arg)
|
|
452
|
-
};
|
|
453
|
-
} catch (err) {
|
|
454
|
-
return {
|
|
455
|
-
type: "throw",
|
|
456
|
-
arg: err
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
var GenStateSuspendedStart = "suspendedStart";
|
|
462
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
463
|
-
var GenStateExecuting = "executing";
|
|
464
|
-
var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
|
|
465
|
-
// breaking out of the dispatch switch statement.
|
|
466
|
-
|
|
467
|
-
var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
|
|
468
|
-
// .constructor.prototype properties for functions that return Generator
|
|
469
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
470
|
-
// minifier not to mangle the names of these two functions.
|
|
471
|
-
|
|
472
|
-
function Generator() {}
|
|
473
|
-
|
|
474
|
-
function GeneratorFunction() {}
|
|
475
|
-
|
|
476
|
-
function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
|
|
477
|
-
// don't natively support it.
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
var IteratorPrototype = {};
|
|
481
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
482
|
-
return this;
|
|
483
|
-
});
|
|
484
|
-
var getProto = Object.getPrototypeOf;
|
|
485
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
486
|
-
|
|
487
|
-
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
488
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
489
|
-
// of the polyfill.
|
|
490
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
494
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
495
|
-
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
496
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
497
|
-
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
498
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
499
|
-
|
|
500
|
-
function defineIteratorMethods(prototype) {
|
|
501
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
502
|
-
define(prototype, method, function (arg) {
|
|
503
|
-
return this._invoke(method, arg);
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
exports.isGeneratorFunction = function (genFun) {
|
|
509
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
510
|
-
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
511
|
-
// do is to check its .name property.
|
|
512
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
exports.mark = function (genFun) {
|
|
516
|
-
if (Object.setPrototypeOf) {
|
|
517
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
518
|
-
} else {
|
|
519
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
520
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
genFun.prototype = Object.create(Gp);
|
|
524
|
-
return genFun;
|
|
525
|
-
}; // Within the body of any async function, `await x` is transformed to
|
|
526
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
527
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
528
|
-
// meant to be awaited.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
exports.awrap = function (arg) {
|
|
532
|
-
return {
|
|
533
|
-
__await: arg
|
|
534
|
-
};
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
538
|
-
function invoke(method, arg, resolve, reject) {
|
|
539
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
540
|
-
|
|
541
|
-
if (record.type === "throw") {
|
|
542
|
-
reject(record.arg);
|
|
543
|
-
} else {
|
|
544
|
-
var result = record.arg;
|
|
545
|
-
var value = result.value;
|
|
546
|
-
|
|
547
|
-
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
548
|
-
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
549
|
-
invoke("next", value, resolve, reject);
|
|
550
|
-
}, function (err) {
|
|
551
|
-
invoke("throw", err, resolve, reject);
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
556
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
557
|
-
// the .value of the Promise<{value,done}> result for the
|
|
558
|
-
// current iteration.
|
|
559
|
-
result.value = unwrapped;
|
|
560
|
-
resolve(result);
|
|
561
|
-
}, function (error) {
|
|
562
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
563
|
-
// into the async generator function so it can be handled there.
|
|
564
|
-
return invoke("throw", error, resolve, reject);
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
var previousPromise;
|
|
570
|
-
|
|
571
|
-
function enqueue(method, arg) {
|
|
572
|
-
function callInvokeWithMethodAndArg() {
|
|
573
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
574
|
-
invoke(method, arg, resolve, reject);
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
579
|
-
// all previous Promises have been resolved before calling invoke,
|
|
580
|
-
// so that results are always delivered in the correct order. If
|
|
581
|
-
// enqueue has not been called before, then it is important to
|
|
582
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
583
|
-
// so that the async generator function has the opportunity to do
|
|
584
|
-
// any necessary setup in a predictable way. This predictability
|
|
585
|
-
// is why the Promise constructor synchronously invokes its
|
|
586
|
-
// executor callback, and why async functions synchronously
|
|
587
|
-
// execute code before the first await. Since we implement simple
|
|
588
|
-
// async functions in terms of async generators, it is especially
|
|
589
|
-
// important to get this right, even though it requires care.
|
|
590
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
|
|
591
|
-
// invocations of the iterator.
|
|
592
|
-
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
593
|
-
} // Define the unified helper method that is used to implement .next,
|
|
594
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
this._invoke = enqueue;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
601
|
-
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
602
|
-
return this;
|
|
603
|
-
});
|
|
604
|
-
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
605
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
606
|
-
// the final result produced by the iterator.
|
|
607
|
-
|
|
608
|
-
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
609
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
610
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
611
|
-
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
612
|
-
: iter.next().then(function (result) {
|
|
613
|
-
return result.done ? result.value : iter.next();
|
|
614
|
-
});
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
618
|
-
var state = GenStateSuspendedStart;
|
|
619
|
-
return function invoke(method, arg) {
|
|
620
|
-
if (state === GenStateExecuting) {
|
|
621
|
-
throw new Error("Generator is already running");
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
if (state === GenStateCompleted) {
|
|
625
|
-
if (method === "throw") {
|
|
626
|
-
throw arg;
|
|
627
|
-
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
628
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
return doneResult();
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
context.method = method;
|
|
635
|
-
context.arg = arg;
|
|
636
|
-
|
|
637
|
-
while (true) {
|
|
638
|
-
var delegate = context.delegate;
|
|
639
|
-
|
|
640
|
-
if (delegate) {
|
|
641
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
642
|
-
|
|
643
|
-
if (delegateResult) {
|
|
644
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
645
|
-
return delegateResult;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
if (context.method === "next") {
|
|
650
|
-
// Setting context._sent for legacy support of Babel's
|
|
651
|
-
// function.sent implementation.
|
|
652
|
-
context.sent = context._sent = context.arg;
|
|
653
|
-
} else if (context.method === "throw") {
|
|
654
|
-
if (state === GenStateSuspendedStart) {
|
|
655
|
-
state = GenStateCompleted;
|
|
656
|
-
throw context.arg;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
context.dispatchException(context.arg);
|
|
660
|
-
} else if (context.method === "return") {
|
|
661
|
-
context.abrupt("return", context.arg);
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
state = GenStateExecuting;
|
|
665
|
-
var record = tryCatch(innerFn, self, context);
|
|
666
|
-
|
|
667
|
-
if (record.type === "normal") {
|
|
668
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
669
|
-
// GenStateExecuting and loop back for another invocation.
|
|
670
|
-
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
671
|
-
|
|
672
|
-
if (record.arg === ContinueSentinel) {
|
|
673
|
-
continue;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
return {
|
|
677
|
-
value: record.arg,
|
|
678
|
-
done: context.done
|
|
679
|
-
};
|
|
680
|
-
} else if (record.type === "throw") {
|
|
681
|
-
state = GenStateCompleted; // Dispatch the exception by looping back around to the
|
|
682
|
-
// context.dispatchException(context.arg) call above.
|
|
683
|
-
|
|
684
|
-
context.method = "throw";
|
|
685
|
-
context.arg = record.arg;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
690
|
-
// result, either by returning a { value, done } result from the
|
|
691
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
692
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
696
|
-
var method = delegate.iterator[context.method];
|
|
697
|
-
|
|
698
|
-
if (method === undefined$1) {
|
|
699
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
700
|
-
// method always terminates the yield* loop.
|
|
701
|
-
context.delegate = null;
|
|
702
|
-
|
|
703
|
-
if (context.method === "throw") {
|
|
704
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
705
|
-
if (delegate.iterator["return"]) {
|
|
706
|
-
// If the delegate iterator has a return method, give it a
|
|
707
|
-
// chance to clean up.
|
|
708
|
-
context.method = "return";
|
|
709
|
-
context.arg = undefined$1;
|
|
710
|
-
maybeInvokeDelegate(delegate, context);
|
|
711
|
-
|
|
712
|
-
if (context.method === "throw") {
|
|
713
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
714
|
-
// "return" to "throw", let that override the TypeError below.
|
|
715
|
-
return ContinueSentinel;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
context.method = "throw";
|
|
720
|
-
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
return ContinueSentinel;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
727
|
-
|
|
728
|
-
if (record.type === "throw") {
|
|
729
|
-
context.method = "throw";
|
|
730
|
-
context.arg = record.arg;
|
|
731
|
-
context.delegate = null;
|
|
732
|
-
return ContinueSentinel;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
var info = record.arg;
|
|
736
|
-
|
|
737
|
-
if (!info) {
|
|
738
|
-
context.method = "throw";
|
|
739
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
740
|
-
context.delegate = null;
|
|
741
|
-
return ContinueSentinel;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
if (info.done) {
|
|
745
|
-
// Assign the result of the finished delegate to the temporary
|
|
746
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
747
|
-
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
748
|
-
|
|
749
|
-
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
750
|
-
// exception, let the outer generator proceed normally. If
|
|
751
|
-
// context.method was "next", forget context.arg since it has been
|
|
752
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
753
|
-
// "return", allow the original .return call to continue in the
|
|
754
|
-
// outer generator.
|
|
755
|
-
|
|
756
|
-
if (context.method !== "return") {
|
|
757
|
-
context.method = "next";
|
|
758
|
-
context.arg = undefined$1;
|
|
759
|
-
}
|
|
760
|
-
} else {
|
|
761
|
-
// Re-yield the result returned by the delegate method.
|
|
762
|
-
return info;
|
|
763
|
-
} // The delegate iterator is finished, so forget it and continue with
|
|
764
|
-
// the outer generator.
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
context.delegate = null;
|
|
768
|
-
return ContinueSentinel;
|
|
769
|
-
} // Define Generator.prototype.{next,throw,return} in terms of the
|
|
770
|
-
// unified ._invoke helper method.
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
defineIteratorMethods(Gp);
|
|
774
|
-
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
775
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
776
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
777
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
778
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
779
|
-
|
|
780
|
-
define(Gp, iteratorSymbol, function () {
|
|
781
|
-
return this;
|
|
782
|
-
});
|
|
783
|
-
define(Gp, "toString", function () {
|
|
784
|
-
return "[object Generator]";
|
|
785
|
-
});
|
|
786
|
-
|
|
787
|
-
function pushTryEntry(locs) {
|
|
788
|
-
var entry = {
|
|
789
|
-
tryLoc: locs[0]
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
if (1 in locs) {
|
|
793
|
-
entry.catchLoc = locs[1];
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
if (2 in locs) {
|
|
797
|
-
entry.finallyLoc = locs[2];
|
|
798
|
-
entry.afterLoc = locs[3];
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
this.tryEntries.push(entry);
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
function resetTryEntry(entry) {
|
|
805
|
-
var record = entry.completion || {};
|
|
806
|
-
record.type = "normal";
|
|
807
|
-
delete record.arg;
|
|
808
|
-
entry.completion = record;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
function Context(tryLocsList) {
|
|
812
|
-
// The root entry object (effectively a try statement without a catch
|
|
813
|
-
// or a finally block) gives us a place to store values thrown from
|
|
814
|
-
// locations where there is no enclosing try statement.
|
|
815
|
-
this.tryEntries = [{
|
|
816
|
-
tryLoc: "root"
|
|
817
|
-
}];
|
|
818
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
819
|
-
this.reset(true);
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
exports.keys = function (object) {
|
|
823
|
-
var keys = [];
|
|
824
|
-
|
|
825
|
-
for (var key in object) {
|
|
826
|
-
keys.push(key);
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
keys.reverse(); // Rather than returning an object with a next method, we keep
|
|
830
|
-
// things simple and return the next function itself.
|
|
831
|
-
|
|
832
|
-
return function next() {
|
|
833
|
-
while (keys.length) {
|
|
834
|
-
var key = keys.pop();
|
|
835
|
-
|
|
836
|
-
if (key in object) {
|
|
837
|
-
next.value = key;
|
|
838
|
-
next.done = false;
|
|
839
|
-
return next;
|
|
840
|
-
}
|
|
841
|
-
} // To avoid creating an additional object, we just hang the .value
|
|
842
|
-
// and .done properties off the next function object itself. This
|
|
843
|
-
// also ensures that the minifier will not anonymize the function.
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
next.done = true;
|
|
847
|
-
return next;
|
|
848
|
-
};
|
|
849
|
-
};
|
|
850
|
-
|
|
851
|
-
function values(iterable) {
|
|
852
|
-
if (iterable) {
|
|
853
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
854
|
-
|
|
855
|
-
if (iteratorMethod) {
|
|
856
|
-
return iteratorMethod.call(iterable);
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
if (typeof iterable.next === "function") {
|
|
860
|
-
return iterable;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
if (!isNaN(iterable.length)) {
|
|
864
|
-
var i = -1,
|
|
865
|
-
next = function next() {
|
|
866
|
-
while (++i < iterable.length) {
|
|
867
|
-
if (hasOwn.call(iterable, i)) {
|
|
868
|
-
next.value = iterable[i];
|
|
869
|
-
next.done = false;
|
|
870
|
-
return next;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
next.value = undefined$1;
|
|
875
|
-
next.done = true;
|
|
876
|
-
return next;
|
|
877
|
-
};
|
|
878
|
-
|
|
879
|
-
return next.next = next;
|
|
880
|
-
}
|
|
881
|
-
} // Return an iterator with no values.
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
return {
|
|
885
|
-
next: doneResult
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
exports.values = values;
|
|
890
|
-
|
|
891
|
-
function doneResult() {
|
|
892
|
-
return {
|
|
893
|
-
value: undefined$1,
|
|
894
|
-
done: true
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
Context.prototype = {
|
|
899
|
-
constructor: Context,
|
|
900
|
-
reset: function reset(skipTempReset) {
|
|
901
|
-
this.prev = 0;
|
|
902
|
-
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
903
|
-
// function.sent implementation.
|
|
904
|
-
|
|
905
|
-
this.sent = this._sent = undefined$1;
|
|
906
|
-
this.done = false;
|
|
907
|
-
this.delegate = null;
|
|
908
|
-
this.method = "next";
|
|
909
|
-
this.arg = undefined$1;
|
|
910
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
911
|
-
|
|
912
|
-
if (!skipTempReset) {
|
|
913
|
-
for (var name in this) {
|
|
914
|
-
// Not sure about the optimal order of these conditions:
|
|
915
|
-
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
916
|
-
this[name] = undefined$1;
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
},
|
|
921
|
-
stop: function stop() {
|
|
922
|
-
this.done = true;
|
|
923
|
-
var rootEntry = this.tryEntries[0];
|
|
924
|
-
var rootRecord = rootEntry.completion;
|
|
925
|
-
|
|
926
|
-
if (rootRecord.type === "throw") {
|
|
927
|
-
throw rootRecord.arg;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
return this.rval;
|
|
931
|
-
},
|
|
932
|
-
dispatchException: function dispatchException(exception) {
|
|
933
|
-
if (this.done) {
|
|
934
|
-
throw exception;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
var context = this;
|
|
938
|
-
|
|
939
|
-
function handle(loc, caught) {
|
|
940
|
-
record.type = "throw";
|
|
941
|
-
record.arg = exception;
|
|
942
|
-
context.next = loc;
|
|
943
|
-
|
|
944
|
-
if (caught) {
|
|
945
|
-
// If the dispatched exception was caught by a catch block,
|
|
946
|
-
// then let that catch block handle the exception normally.
|
|
947
|
-
context.method = "next";
|
|
948
|
-
context.arg = undefined$1;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
return !!caught;
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
955
|
-
var entry = this.tryEntries[i];
|
|
956
|
-
var record = entry.completion;
|
|
957
|
-
|
|
958
|
-
if (entry.tryLoc === "root") {
|
|
959
|
-
// Exception thrown outside of any try block that could handle
|
|
960
|
-
// it, so set the completion value of the entire function to
|
|
961
|
-
// throw the exception.
|
|
962
|
-
return handle("end");
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
if (entry.tryLoc <= this.prev) {
|
|
966
|
-
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
967
|
-
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
968
|
-
|
|
969
|
-
if (hasCatch && hasFinally) {
|
|
970
|
-
if (this.prev < entry.catchLoc) {
|
|
971
|
-
return handle(entry.catchLoc, true);
|
|
972
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
973
|
-
return handle(entry.finallyLoc);
|
|
974
|
-
}
|
|
975
|
-
} else if (hasCatch) {
|
|
976
|
-
if (this.prev < entry.catchLoc) {
|
|
977
|
-
return handle(entry.catchLoc, true);
|
|
978
|
-
}
|
|
979
|
-
} else if (hasFinally) {
|
|
980
|
-
if (this.prev < entry.finallyLoc) {
|
|
981
|
-
return handle(entry.finallyLoc);
|
|
982
|
-
}
|
|
983
|
-
} else {
|
|
984
|
-
throw new Error("try statement without catch or finally");
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
},
|
|
989
|
-
abrupt: function abrupt(type, arg) {
|
|
990
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
991
|
-
var entry = this.tryEntries[i];
|
|
992
|
-
|
|
993
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
994
|
-
var finallyEntry = entry;
|
|
995
|
-
break;
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
1000
|
-
// Ignore the finally entry if control is not jumping to a
|
|
1001
|
-
// location outside the try/catch block.
|
|
1002
|
-
finallyEntry = null;
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1006
|
-
record.type = type;
|
|
1007
|
-
record.arg = arg;
|
|
1008
|
-
|
|
1009
|
-
if (finallyEntry) {
|
|
1010
|
-
this.method = "next";
|
|
1011
|
-
this.next = finallyEntry.finallyLoc;
|
|
1012
|
-
return ContinueSentinel;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
return this.complete(record);
|
|
1016
|
-
},
|
|
1017
|
-
complete: function complete(record, afterLoc) {
|
|
1018
|
-
if (record.type === "throw") {
|
|
1019
|
-
throw record.arg;
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
if (record.type === "break" || record.type === "continue") {
|
|
1023
|
-
this.next = record.arg;
|
|
1024
|
-
} else if (record.type === "return") {
|
|
1025
|
-
this.rval = this.arg = record.arg;
|
|
1026
|
-
this.method = "return";
|
|
1027
|
-
this.next = "end";
|
|
1028
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
1029
|
-
this.next = afterLoc;
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
return ContinueSentinel;
|
|
1033
|
-
},
|
|
1034
|
-
finish: function finish(finallyLoc) {
|
|
1035
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1036
|
-
var entry = this.tryEntries[i];
|
|
1037
|
-
|
|
1038
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
1039
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
1040
|
-
resetTryEntry(entry);
|
|
1041
|
-
return ContinueSentinel;
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
},
|
|
1045
|
-
"catch": function _catch(tryLoc) {
|
|
1046
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1047
|
-
var entry = this.tryEntries[i];
|
|
1048
|
-
|
|
1049
|
-
if (entry.tryLoc === tryLoc) {
|
|
1050
|
-
var record = entry.completion;
|
|
1051
|
-
|
|
1052
|
-
if (record.type === "throw") {
|
|
1053
|
-
var thrown = record.arg;
|
|
1054
|
-
resetTryEntry(entry);
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
return thrown;
|
|
1058
|
-
}
|
|
1059
|
-
} // The context.catch method must only be called with a location
|
|
1060
|
-
// argument that corresponds to a known catch block.
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
throw new Error("illegal catch attempt");
|
|
1064
|
-
},
|
|
1065
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
1066
|
-
this.delegate = {
|
|
1067
|
-
iterator: values(iterable),
|
|
1068
|
-
resultName: resultName,
|
|
1069
|
-
nextLoc: nextLoc
|
|
1070
|
-
};
|
|
1071
|
-
|
|
1072
|
-
if (this.method === "next") {
|
|
1073
|
-
// Deliberately forget the last sent value so that we don't
|
|
1074
|
-
// accidentally pass it on to the delegate.
|
|
1075
|
-
this.arg = undefined$1;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
return ContinueSentinel;
|
|
1079
|
-
}
|
|
1080
|
-
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1081
|
-
// or not, return the runtime object so that we can declare the variable
|
|
1082
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1083
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1084
|
-
|
|
1085
|
-
return exports;
|
|
1086
|
-
}( // If this script is executing as a CommonJS module, use module.exports
|
|
1087
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1088
|
-
// object. Either way, the resulting object will be used to initialize
|
|
1089
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
1090
|
-
module.exports );
|
|
1091
|
-
|
|
1092
|
-
try {
|
|
1093
|
-
regeneratorRuntime = runtime;
|
|
1094
|
-
} catch (accidentalStrictMode) {
|
|
1095
|
-
// This module should not be running in strict mode, so the above
|
|
1096
|
-
// assignment should always work unless something is misconfigured. Just
|
|
1097
|
-
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
1098
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
1099
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
1100
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
1101
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
1102
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
1103
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1104
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
1105
|
-
if (typeof globalThis === "object") {
|
|
1106
|
-
globalThis.regeneratorRuntime = runtime;
|
|
1107
|
-
} else {
|
|
1108
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
});
|
|
1112
|
-
|
|
1113
|
-
function findCircleIntersectionX(y, cx, cy, r, resultArray) {
|
|
1114
|
-
var d = Math.abs(y - cy);
|
|
1115
|
-
|
|
1116
|
-
if (d > r) {
|
|
1117
|
-
return;
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
if (d === r) {
|
|
1121
|
-
resultArray.push([cx, y]);
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
var solution = Math.sqrt(r * r - d * d);
|
|
1125
|
-
resultArray.push([cx - solution, y]);
|
|
1126
|
-
resultArray.push([cx + solution, y]);
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
function findCircleIntersectionY(x, cx, cy, r, resultArray) {
|
|
1130
|
-
var d = Math.abs(x - cx);
|
|
1131
|
-
|
|
1132
|
-
if (d > r) {
|
|
1133
|
-
return;
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
if (d === r) {
|
|
1137
|
-
resultArray.push([x, cy]);
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
var solution = Math.sqrt(r * r - d * d);
|
|
1141
|
-
resultArray.push([x, cy - solution]);
|
|
1142
|
-
resultArray.push([x, cy + solution]);
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
function cartesianToTheta(x, y) {
|
|
1146
|
-
var theta = (Math.atan(y / x) + 2 * Math.PI) % (2 * Math.PI);
|
|
1147
|
-
|
|
1148
|
-
if (x < 0) {
|
|
1149
|
-
if (y <= 0) {
|
|
1150
|
-
theta += Math.PI;
|
|
1151
|
-
} else {
|
|
1152
|
-
theta -= Math.PI;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
return theta;
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
function cartesianToPolar(x, y) {
|
|
1160
|
-
var rho = Math.sqrt(x * x + y * y);
|
|
1161
|
-
|
|
1162
|
-
if (rho === 0) {
|
|
1163
|
-
return [0, 0];
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
var theta = cartesianToTheta(x, y);
|
|
1167
|
-
return [rho, theta];
|
|
1168
|
-
}
|
|
1169
|
-
var twoPi = 2 * Math.PI;
|
|
1170
|
-
function thetaRangesOverlap(r1start, r1length, r2start, r2length) {
|
|
1171
|
-
if (r1length <= 0 || r2length <= 0) {
|
|
1172
|
-
return false;
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
if (r1length + 0.0001 >= twoPi || r2length + 0.0001 >= twoPi) {
|
|
1176
|
-
return true;
|
|
1177
|
-
} // put both range starts between 2π and 4π
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
r1start = (r1start % twoPi + twoPi) % twoPi + twoPi;
|
|
1181
|
-
r2start = (r2start % twoPi + twoPi) % twoPi + twoPi;
|
|
1182
|
-
|
|
1183
|
-
if (r1start < r2start + r2length && r1start + r1length > r2start) {
|
|
1184
|
-
return true;
|
|
1185
|
-
} // move r2 2π to the left and check
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
r2start -= twoPi;
|
|
1189
|
-
|
|
1190
|
-
if (r1start < r2start + r2length && r1start + r1length > r2start) {
|
|
1191
|
-
return true;
|
|
1192
|
-
} // move it 2π to the right and check
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
r2start += twoPi + twoPi;
|
|
1196
|
-
return r1start < r2start + r2length && r1start + r1length > r2start;
|
|
1197
|
-
} // return which arc range has any part of the circle visible in the viewport
|
|
1198
|
-
|
|
1199
|
-
function viewportVisibleSection(viewSides, circleCenter, circleRadius) {
|
|
1200
|
-
var _viewSides = _slicedToArray(viewSides, 4),
|
|
1201
|
-
viewL = _viewSides[0],
|
|
1202
|
-
viewR = _viewSides[1],
|
|
1203
|
-
viewT = _viewSides[2],
|
|
1204
|
-
viewB = _viewSides[3];
|
|
1205
|
-
|
|
1206
|
-
var _circleCenter = _slicedToArray(circleCenter, 2),
|
|
1207
|
-
cx = _circleCenter[0],
|
|
1208
|
-
cy = _circleCenter[1]; // transform coordinate system to center of circle
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
viewL -= cx;
|
|
1212
|
-
viewR -= cx;
|
|
1213
|
-
viewT -= cy;
|
|
1214
|
-
viewB -= cy;
|
|
1215
|
-
var centerIsInsideViewport = viewL < 0 && viewR > 0 && viewT < 0 && viewB > 0;
|
|
1216
|
-
|
|
1217
|
-
if (centerIsInsideViewport) {
|
|
1218
|
-
var _vertices = [[viewL, viewT], [viewR, viewT], [viewL, viewB], [viewR, viewB]];
|
|
1219
|
-
var maxRho = -Infinity;
|
|
1220
|
-
|
|
1221
|
-
for (var i = 0; i < _vertices.length; i += 1) {
|
|
1222
|
-
var _vertices$i = _slicedToArray(_vertices[i], 2),
|
|
1223
|
-
x = _vertices$i[0],
|
|
1224
|
-
y = _vertices$i[1];
|
|
1225
|
-
|
|
1226
|
-
var rho = Math.sqrt(x * x + y * y);
|
|
1227
|
-
|
|
1228
|
-
if (rho > maxRho) {
|
|
1229
|
-
maxRho = rho;
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
return {
|
|
1234
|
-
rho: [0, Math.min(circleRadius, maxRho)],
|
|
1235
|
-
theta: [0, 2 * Math.PI]
|
|
1236
|
-
};
|
|
1237
|
-
} // const viewportCompletelyContainsCircle =
|
|
1238
|
-
// circleCenter[0] - viewL >= circleRadius &&
|
|
1239
|
-
// viewR - circleCenter[0] >= circleRadius &&
|
|
1240
|
-
// circleCenter[1] - viewT >= circleRadius &&
|
|
1241
|
-
// viewB - circleCenter[1] >= circleRadius
|
|
1242
|
-
// if (viewportCompletelyContainsCircle) {
|
|
1243
|
-
// return [0, 2 * Math.PI]
|
|
1244
|
-
// }
|
|
1245
|
-
// const distToCenterSquared = ([x, y]) => {
|
|
1246
|
-
// const [cx, cy] = circleCenter
|
|
1247
|
-
// const sq = n => n * n
|
|
1248
|
-
// return sq(x - cx) + sq(y - cy)
|
|
1249
|
-
// }
|
|
1250
|
-
// const circleRadiusSquared = circleRadius * circleRadius
|
|
1251
|
-
// const tlInside = distToCenterSquared([viewL, viewT]) <= circleRadiusSquared
|
|
1252
|
-
// const trInside = distToCenterSquared([viewR, viewT]) <= circleRadiusSquared
|
|
1253
|
-
// const blInside = distToCenterSquared([viewL, viewB]) <= circleRadiusSquared
|
|
1254
|
-
// const brInside = distToCenterSquared([viewR, viewB]) <= circleRadiusSquared
|
|
1255
|
-
// const noIntersection = !tlInside && !trInside && !blInside && !brInside
|
|
1256
|
-
// if (noIntersection) return undefined
|
|
1257
|
-
// const circleCompletelyContainsViewport =
|
|
1258
|
-
// tlInside && trInside && blInside && brInside
|
|
1259
|
-
// if (circleCompletelyContainsViewport) {
|
|
1260
|
-
// // viewport is in the circle, but the center is not in it, so take max
|
|
1261
|
-
// // and min of thetas to the center
|
|
1262
|
-
// const thetas = [
|
|
1263
|
-
// Math.atan(viewT / viewL),
|
|
1264
|
-
// Math.atan(viewT / viewR),
|
|
1265
|
-
// Math.atan(viewB / viewL),
|
|
1266
|
-
// Math.atan(viewB / viewR),
|
|
1267
|
-
// ]
|
|
1268
|
-
// return [Math.min(...thetas), Math.max(...thetas)]
|
|
1269
|
-
// }
|
|
1270
|
-
// if we get here, the viewport is partly in, partly out of the circle
|
|
1271
|
-
// const viewLIntersects = Math.abs(viewL - circleCenter[0]) <= circleRadius
|
|
1272
|
-
// const viewRIntersects = Math.abs(viewR - circleCenter[0]) <= circleRadius
|
|
1273
|
-
// const viewTIntersects = Math.abs(viewT - circleCenter[1]) <= circleRadius
|
|
1274
|
-
// const viewBIntersects = Math.abs(viewB - circleCenter[1]) <= circleRadius
|
|
1275
|
-
// const numIntersectingSides =
|
|
1276
|
-
// Number(viewLIntersects) +
|
|
1277
|
-
// Number(viewRIntersects) +
|
|
1278
|
-
// Number(viewTIntersects) +
|
|
1279
|
-
// Number(viewBIntersects)
|
|
1280
|
-
// if (numIntersectingSides === 4) return [0, 2 * Math.PI]
|
|
1281
|
-
// if (numIntersectingSides === 3) {
|
|
1282
|
-
// // TODO calculate the thetas of the
|
|
1283
|
-
// } else if (numIntersectingSides === 2) {
|
|
1284
|
-
// // TODO calculate the thetas of the 2 intersection points
|
|
1285
|
-
// } else if (numIntersectingSides === 1) {
|
|
1286
|
-
// // TODO calculate the thetas of the 1-2 intersection points of the line, and the angle between
|
|
1287
|
-
// }
|
|
1288
|
-
// make a list of vertices-of-interest that lie inside both shapes to examine
|
|
1289
|
-
// to determine the range covered by their intersection
|
|
1290
|
-
// transform coordinates to have the circle as the origin and find the intersections
|
|
1291
|
-
// of the circle and the view rectangle
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
var vertices = [[viewL, viewT], [viewR, viewT], [viewL, viewB], [viewR, viewB]];
|
|
1295
|
-
findCircleIntersectionY(viewL, 0, 0, circleRadius, vertices);
|
|
1296
|
-
findCircleIntersectionY(viewR, 0, 0, circleRadius, vertices);
|
|
1297
|
-
findCircleIntersectionX(viewT, 0, 0, circleRadius, vertices);
|
|
1298
|
-
findCircleIntersectionX(viewB, 0, 0, circleRadius, vertices); // for each edge, also look at the closest point to center if it is inside the circle
|
|
1299
|
-
|
|
1300
|
-
if (-viewL < circleRadius) {
|
|
1301
|
-
vertices.push([viewL, 0]);
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
if (viewR < circleRadius) {
|
|
1305
|
-
vertices.push([viewR, 0]);
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
if (-viewT < circleRadius) {
|
|
1309
|
-
vertices.push([0, viewT]);
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
if (viewB < circleRadius) {
|
|
1313
|
-
vertices.push([0, viewB]);
|
|
1314
|
-
} // const verticesOriginal = vertices.map(([x, y]) => [x + cx, y + cy])
|
|
1315
|
-
// now convert them all to polar and take the max and min of rho and theta
|
|
1316
|
-
// const viewportCenterTheta = cartesianToTheta(viewR + viewL, viewT + viewB)
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
var reflect = viewL >= 0 ? -1 : 1; // viewportCenterTheta < Math.PI / 2 || viewportCenterTheta > 1.5 * Math.PI
|
|
1320
|
-
// ? -1
|
|
1321
|
-
// : 1
|
|
1322
|
-
|
|
1323
|
-
var rhoMin = Infinity;
|
|
1324
|
-
var rhoMax = -Infinity;
|
|
1325
|
-
var thetaMin = Infinity;
|
|
1326
|
-
var thetaMax = -Infinity;
|
|
1327
|
-
|
|
1328
|
-
for (var _i = 0; _i < vertices.length; _i += 1) {
|
|
1329
|
-
// ignore vertex if outside the viewport
|
|
1330
|
-
var _vertices$_i = _slicedToArray(vertices[_i], 2),
|
|
1331
|
-
vx = _vertices$_i[0],
|
|
1332
|
-
vy = _vertices$_i[1];
|
|
1333
|
-
|
|
1334
|
-
if (vx >= viewL && vx <= viewR && vy >= viewT && vy <= viewB) {
|
|
1335
|
-
var _cartesianToPolar = cartesianToPolar(vx * reflect, vy * reflect),
|
|
1336
|
-
_cartesianToPolar2 = _slicedToArray(_cartesianToPolar, 2),
|
|
1337
|
-
_rho = _cartesianToPolar2[0],
|
|
1338
|
-
theta = _cartesianToPolar2[1]; // ignore vertex if outside the circle
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
if (_rho <= circleRadius + 0.001) {
|
|
1342
|
-
// ignore theta if rho is 0
|
|
1343
|
-
if (theta < thetaMin && _rho > 0.0001) {
|
|
1344
|
-
thetaMin = theta;
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
if (theta > thetaMax && _rho > 0.0001) {
|
|
1348
|
-
thetaMax = theta;
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
if (_rho < rhoMin) {
|
|
1352
|
-
rhoMin = _rho;
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
if (_rho > rhoMax) {
|
|
1356
|
-
rhoMax = _rho;
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
if (reflect === -1) {
|
|
1363
|
-
thetaMin += Math.PI;
|
|
1364
|
-
thetaMax += Math.PI;
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
if (thetaMin > 2 * Math.PI && thetaMax > 2 * Math.PI) {
|
|
1368
|
-
thetaMin -= 2 * Math.PI;
|
|
1369
|
-
thetaMax -= 2 * Math.PI;
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
return {
|
|
1373
|
-
rho: [rhoMin, Math.min(circleRadius, rhoMax)],
|
|
1374
|
-
theta: [thetaMin, thetaMax]
|
|
1375
|
-
};
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
var Slice = /*#__PURE__*/function () {
|
|
1379
|
-
function Slice(view, region, currentRadianOffset, radianWidth) {
|
|
1380
|
-
_classCallCheck(this, Slice);
|
|
1381
|
-
|
|
1382
|
-
this.region = region;
|
|
1383
|
-
this.radianWidth = radianWidth;
|
|
1384
|
-
var bpPerRadian = view.bpPerRadian;
|
|
1385
|
-
this.key = assembleLocString(region);
|
|
1386
|
-
this.offsetRadians = currentRadianOffset;
|
|
1387
|
-
this.bpPerRadian = bpPerRadian;
|
|
1388
|
-
this.flipped = false;
|
|
1389
|
-
this.startRadians = this.offsetRadians;
|
|
1390
|
-
this.endRadians = region.widthBp / this.bpPerRadian + this.offsetRadians;
|
|
1391
|
-
Object.freeze(this);
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
_createClass(Slice, [{
|
|
1395
|
-
key: "bpToXY",
|
|
1396
|
-
value: function bpToXY(bp, radiusPx) {
|
|
1397
|
-
var offsetBp;
|
|
1398
|
-
|
|
1399
|
-
if (this.region.elided) {
|
|
1400
|
-
offsetBp = this.region.widthBp / 2;
|
|
1401
|
-
} else if (this.flipped) {
|
|
1402
|
-
offsetBp = this.region.end - bp;
|
|
1403
|
-
} else {
|
|
1404
|
-
offsetBp = bp - this.region.start;
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
var totalRadians = offsetBp / this.bpPerRadian + this.offsetRadians;
|
|
1408
|
-
return polarToCartesian(radiusPx, totalRadians);
|
|
1409
|
-
}
|
|
1410
|
-
}, {
|
|
1411
|
-
key: "toJSON",
|
|
1412
|
-
value: function toJSON() {
|
|
1413
|
-
return objectFromEntries(Object.entries(this));
|
|
1414
|
-
}
|
|
1415
|
-
}]);
|
|
1416
|
-
|
|
1417
|
-
return Slice;
|
|
1418
|
-
}(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1419
|
-
|
|
1420
|
-
function calculateStaticSlices(self) {
|
|
1421
|
-
var slices = [];
|
|
1422
|
-
var currentRadianOffset = 0;
|
|
1423
|
-
|
|
1424
|
-
var _iterator = _createForOfIteratorHelper(self.elidedRegions),
|
|
1425
|
-
_step;
|
|
1426
|
-
|
|
1427
|
-
try {
|
|
1428
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1429
|
-
var region = _step.value;
|
|
1430
|
-
var radianWidth = region.widthBp / self.bpPerRadian + self.spacingPx / self.pxPerRadian;
|
|
1431
|
-
slices.push(new Slice(self, region, currentRadianOffset, radianWidth));
|
|
1432
|
-
currentRadianOffset += radianWidth;
|
|
1433
|
-
}
|
|
1434
|
-
} catch (err) {
|
|
1435
|
-
_iterator.e(err);
|
|
1436
|
-
} finally {
|
|
1437
|
-
_iterator.f();
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
return slices;
|
|
1441
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
function sliceIsVisible(self, slice) {
|
|
1445
|
-
var _self$visibleSection$ = _slicedToArray(self.visibleSection.theta, 2),
|
|
1446
|
-
visibleThetaMin = _self$visibleSection$[0],
|
|
1447
|
-
visibleThetaMax = _self$visibleSection$[1];
|
|
1448
|
-
|
|
1449
|
-
return thetaRangesOverlap(slice.offsetRadians + self.offsetRadians, slice.radianWidth, visibleThetaMin, visibleThetaMax - visibleThetaMin);
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
function CircularView(pluginManager) {
|
|
1453
|
-
var minHeight = 40;
|
|
1454
|
-
var minWidth = 100;
|
|
1455
|
-
var defaultHeight = 400;
|
|
1456
|
-
return types.compose(BaseViewModel, types.model('CircularView', {
|
|
1457
|
-
type: types.literal('CircularView'),
|
|
1458
|
-
offsetRadians: -Math.PI / 2,
|
|
1459
|
-
bpPerPx: 2000000,
|
|
1460
|
-
tracks: types.array(pluginManager.pluggableMstType('track', 'stateModel')),
|
|
1461
|
-
hideVerticalResizeHandle: false,
|
|
1462
|
-
hideTrackSelectorButton: false,
|
|
1463
|
-
lockedFitToWindow: true,
|
|
1464
|
-
disableImportForm: false,
|
|
1465
|
-
height: types.optional(types.refinement('trackHeight', types.number, function (n) {
|
|
1466
|
-
return n >= minHeight;
|
|
1467
|
-
}), defaultHeight),
|
|
1468
|
-
minimumRadiusPx: 25,
|
|
1469
|
-
spacingPx: 10,
|
|
1470
|
-
paddingPx: 80,
|
|
1471
|
-
lockedPaddingPx: 100,
|
|
1472
|
-
minVisibleWidth: 6,
|
|
1473
|
-
minimumBlockWidth: 20,
|
|
1474
|
-
displayedRegions: types.array(Region),
|
|
1475
|
-
scrollX: 0,
|
|
1476
|
-
scrollY: 0,
|
|
1477
|
-
trackSelectorType: 'hierarchical'
|
|
1478
|
-
})["volatile"](function () {
|
|
1479
|
-
return {
|
|
1480
|
-
width: 0
|
|
1481
|
-
};
|
|
1482
|
-
}).views(function (self) {
|
|
1483
|
-
return {
|
|
1484
|
-
get staticSlices() {
|
|
1485
|
-
return calculateStaticSlices(self);
|
|
1486
|
-
},
|
|
1487
|
-
|
|
1488
|
-
get visibleStaticSlices() {
|
|
1489
|
-
return this.staticSlices.filter(sliceIsVisible.bind(this, self));
|
|
1490
|
-
},
|
|
1491
|
-
|
|
1492
|
-
get visibleSection() {
|
|
1493
|
-
return viewportVisibleSection([self.scrollX, self.scrollX + self.width, self.scrollY, self.scrollY + self.height], this.centerXY, this.radiusPx);
|
|
1494
|
-
},
|
|
1495
|
-
|
|
1496
|
-
get circumferencePx() {
|
|
1497
|
-
var elidedBp = 0;
|
|
1498
|
-
|
|
1499
|
-
var _iterator = _createForOfIteratorHelper(this.elidedRegions),
|
|
1500
|
-
_step;
|
|
1501
|
-
|
|
1502
|
-
try {
|
|
1503
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1504
|
-
var r = _step.value;
|
|
1505
|
-
elidedBp += r.widthBp;
|
|
1506
|
-
}
|
|
1507
|
-
} catch (err) {
|
|
1508
|
-
_iterator.e(err);
|
|
1509
|
-
} finally {
|
|
1510
|
-
_iterator.f();
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
return elidedBp / self.bpPerPx + self.spacingPx * this.elidedRegions.length;
|
|
1514
|
-
},
|
|
1515
|
-
|
|
1516
|
-
get radiusPx() {
|
|
1517
|
-
return this.circumferencePx / (2 * Math.PI);
|
|
1518
|
-
},
|
|
1519
|
-
|
|
1520
|
-
get bpPerRadian() {
|
|
1521
|
-
return self.bpPerPx * this.radiusPx;
|
|
1522
|
-
},
|
|
1523
|
-
|
|
1524
|
-
get pxPerRadian() {
|
|
1525
|
-
return this.radiusPx;
|
|
1526
|
-
},
|
|
1527
|
-
|
|
1528
|
-
get centerXY() {
|
|
1529
|
-
return [this.radiusPx + self.paddingPx, this.radiusPx + self.paddingPx];
|
|
1530
|
-
},
|
|
1531
|
-
|
|
1532
|
-
get totalBp() {
|
|
1533
|
-
var total = 0;
|
|
1534
|
-
|
|
1535
|
-
var _iterator2 = _createForOfIteratorHelper(self.displayedRegions),
|
|
1536
|
-
_step2;
|
|
1537
|
-
|
|
1538
|
-
try {
|
|
1539
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1540
|
-
var region = _step2.value;
|
|
1541
|
-
total += region.end - region.start;
|
|
1542
|
-
}
|
|
1543
|
-
} catch (err) {
|
|
1544
|
-
_iterator2.e(err);
|
|
1545
|
-
} finally {
|
|
1546
|
-
_iterator2.f();
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
return total;
|
|
1550
|
-
},
|
|
1551
|
-
|
|
1552
|
-
get maximumRadiusPx() {
|
|
1553
|
-
return self.lockedFitToWindow ? Math.min(self.width, self.height) / 2 - self.lockedPaddingPx : 1000000;
|
|
1554
|
-
},
|
|
1555
|
-
|
|
1556
|
-
get maxBpPerPx() {
|
|
1557
|
-
var minCircumferencePx = 2 * Math.PI * self.minimumRadiusPx;
|
|
1558
|
-
return this.totalBp / minCircumferencePx;
|
|
1559
|
-
},
|
|
1560
|
-
|
|
1561
|
-
get minBpPerPx() {
|
|
1562
|
-
// min depends on window dimensions, clamp between old min(0.01) and max
|
|
1563
|
-
var maxCircumferencePx = 2 * Math.PI * this.maximumRadiusPx;
|
|
1564
|
-
return clamp(this.totalBp / maxCircumferencePx, 0.0000000001, this.maxBpPerPx);
|
|
1565
|
-
},
|
|
1566
|
-
|
|
1567
|
-
get atMaxBpPerPx() {
|
|
1568
|
-
return self.bpPerPx >= this.maxBpPerPx;
|
|
1569
|
-
},
|
|
1570
|
-
|
|
1571
|
-
get atMinBpPerPx() {
|
|
1572
|
-
return self.bpPerPx <= this.minBpPerPx;
|
|
1573
|
-
},
|
|
1574
|
-
|
|
1575
|
-
get tooSmallToLock() {
|
|
1576
|
-
return this.minBpPerPx <= 0.0000000001;
|
|
1577
|
-
},
|
|
1578
|
-
|
|
1579
|
-
get figureDimensions() {
|
|
1580
|
-
return [this.radiusPx * 2 + 2 * self.paddingPx, this.radiusPx * 2 + 2 * self.paddingPx];
|
|
1581
|
-
},
|
|
1582
|
-
|
|
1583
|
-
get figureWidth() {
|
|
1584
|
-
return this.figureDimensions[0];
|
|
1585
|
-
},
|
|
1586
|
-
|
|
1587
|
-
get figureHeight() {
|
|
1588
|
-
return this.figureDimensions[1];
|
|
1589
|
-
},
|
|
1590
|
-
|
|
1591
|
-
// this is displayedRegions, post-processed to
|
|
1592
|
-
// elide regions that are too small to see reasonably
|
|
1593
|
-
get elidedRegions() {
|
|
1594
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1595
|
-
var visible = [];
|
|
1596
|
-
self.displayedRegions.forEach(function (region) {
|
|
1597
|
-
var widthBp = region.end - region.start;
|
|
1598
|
-
var widthPx = widthBp / self.bpPerPx;
|
|
1599
|
-
|
|
1600
|
-
if (widthPx < self.minVisibleWidth) {
|
|
1601
|
-
// too small to see, collapse into a single elision region
|
|
1602
|
-
var lastVisible = visible[visible.length - 1];
|
|
1603
|
-
|
|
1604
|
-
if (lastVisible && lastVisible.elided) {
|
|
1605
|
-
lastVisible.regions.push(_objectSpread2({}, region));
|
|
1606
|
-
lastVisible.widthBp += widthBp;
|
|
1607
|
-
} else {
|
|
1608
|
-
visible.push({
|
|
1609
|
-
elided: true,
|
|
1610
|
-
widthBp: widthBp,
|
|
1611
|
-
regions: [_objectSpread2({}, region)]
|
|
1612
|
-
});
|
|
1613
|
-
}
|
|
1614
|
-
} else {
|
|
1615
|
-
// big enough to see, display it
|
|
1616
|
-
visible.push(_objectSpread2(_objectSpread2({}, region), {}, {
|
|
1617
|
-
widthBp: widthBp
|
|
1618
|
-
}));
|
|
1619
|
-
}
|
|
1620
|
-
}); // remove any single-region elisions
|
|
1621
|
-
|
|
1622
|
-
for (var i = 0; i < visible.length; i += 1) {
|
|
1623
|
-
var v = visible[i];
|
|
1624
|
-
|
|
1625
|
-
if (v.elided && v.regions.length === 1) {
|
|
1626
|
-
delete v.elided;
|
|
1627
|
-
visible[i] = _objectSpread2(_objectSpread2({}, v), v.regions[0]);
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
|
|
1631
|
-
return visible;
|
|
1632
|
-
},
|
|
1633
|
-
|
|
1634
|
-
get assemblyNames() {
|
|
1635
|
-
var assemblyNames = [];
|
|
1636
|
-
self.displayedRegions.forEach(function (displayedRegion) {
|
|
1637
|
-
if (!assemblyNames.includes(displayedRegion.assemblyName)) {
|
|
1638
|
-
assemblyNames.push(displayedRegion.assemblyName);
|
|
1639
|
-
}
|
|
1640
|
-
});
|
|
1641
|
-
return assemblyNames;
|
|
1642
|
-
},
|
|
1643
|
-
|
|
1644
|
-
get initialized() {
|
|
1645
|
-
var _getSession = getSession(self),
|
|
1646
|
-
assemblyManager = _getSession.assemblyManager;
|
|
1647
|
-
|
|
1648
|
-
return this.assemblyNames.every(function (a) {
|
|
1649
|
-
var _assemblyManager$get;
|
|
1650
|
-
|
|
1651
|
-
return (_assemblyManager$get = assemblyManager.get(a)) === null || _assemblyManager$get === void 0 ? void 0 : _assemblyManager$get.initialized;
|
|
1652
|
-
});
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
};
|
|
1656
|
-
})["volatile"](function () {
|
|
1657
|
-
return {
|
|
1658
|
-
error: undefined
|
|
1659
|
-
};
|
|
1660
|
-
}).actions(function (self) {
|
|
1661
|
-
return {
|
|
1662
|
-
// toggle action with a flag stating which mode it's in
|
|
1663
|
-
setWidth: function setWidth(newWidth) {
|
|
1664
|
-
self.width = Math.max(newWidth, minWidth);
|
|
1665
|
-
return self.width;
|
|
1666
|
-
},
|
|
1667
|
-
setHeight: function setHeight(newHeight) {
|
|
1668
|
-
self.height = Math.max(newHeight, minHeight);
|
|
1669
|
-
return self.height;
|
|
1670
|
-
},
|
|
1671
|
-
resizeHeight: function resizeHeight(distance) {
|
|
1672
|
-
var oldHeight = self.height;
|
|
1673
|
-
var newHeight = this.setHeight(self.height + distance);
|
|
1674
|
-
this.setModelViewWhenAdjust(!self.tooSmallToLock);
|
|
1675
|
-
return newHeight - oldHeight;
|
|
1676
|
-
},
|
|
1677
|
-
resizeWidth: function resizeWidth(distance) {
|
|
1678
|
-
var oldWidth = self.width;
|
|
1679
|
-
var newWidth = this.setWidth(self.width + distance);
|
|
1680
|
-
this.setModelViewWhenAdjust(!self.tooSmallToLock);
|
|
1681
|
-
return newWidth - oldWidth;
|
|
1682
|
-
},
|
|
1683
|
-
rotateClockwiseButton: function rotateClockwiseButton() {
|
|
1684
|
-
this.rotateClockwise(Math.PI / 6);
|
|
1685
|
-
},
|
|
1686
|
-
rotateCounterClockwiseButton: function rotateCounterClockwiseButton() {
|
|
1687
|
-
this.rotateCounterClockwise(Math.PI / 6);
|
|
1688
|
-
},
|
|
1689
|
-
rotateClockwise: function rotateClockwise() {
|
|
1690
|
-
var distance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.17;
|
|
1691
|
-
self.offsetRadians += distance;
|
|
1692
|
-
},
|
|
1693
|
-
rotateCounterClockwise: function rotateCounterClockwise() {
|
|
1694
|
-
var distance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.17;
|
|
1695
|
-
self.offsetRadians -= distance;
|
|
1696
|
-
},
|
|
1697
|
-
zoomInButton: function zoomInButton() {
|
|
1698
|
-
this.setBpPerPx(self.bpPerPx / 1.4);
|
|
1699
|
-
},
|
|
1700
|
-
zoomOutButton: function zoomOutButton() {
|
|
1701
|
-
this.setBpPerPx(self.bpPerPx * 1.4);
|
|
1702
|
-
},
|
|
1703
|
-
setBpPerPx: function setBpPerPx(newVal) {
|
|
1704
|
-
self.bpPerPx = clamp(newVal, self.minBpPerPx, self.maxBpPerPx);
|
|
1705
|
-
},
|
|
1706
|
-
setModelViewWhenAdjust: function setModelViewWhenAdjust(secondCondition) {
|
|
1707
|
-
if (self.lockedFitToWindow && secondCondition) {
|
|
1708
|
-
this.setBpPerPx(self.minBpPerPx);
|
|
1709
|
-
}
|
|
1710
|
-
},
|
|
1711
|
-
closeView: function closeView() {
|
|
1712
|
-
getParent(self, 2).removeView(self);
|
|
1713
|
-
},
|
|
1714
|
-
setDisplayedRegions: function setDisplayedRegions(regions) {
|
|
1715
|
-
var previouslyEmpty = self.displayedRegions.length === 0;
|
|
1716
|
-
self.displayedRegions = cast(regions);
|
|
1717
|
-
|
|
1718
|
-
if (previouslyEmpty) {
|
|
1719
|
-
this.setBpPerPx(self.minBpPerPx);
|
|
1720
|
-
} else {
|
|
1721
|
-
this.setBpPerPx(self.bpPerPx);
|
|
1722
|
-
}
|
|
1723
|
-
},
|
|
1724
|
-
activateTrackSelector: function activateTrackSelector() {
|
|
1725
|
-
if (self.trackSelectorType === 'hierarchical') {
|
|
1726
|
-
var session = getSession(self);
|
|
1727
|
-
|
|
1728
|
-
if (isSessionModelWithWidgets(session)) {
|
|
1729
|
-
var selector = session.addWidget('HierarchicalTrackSelectorWidget', 'hierarchicalTrackSelector', {
|
|
1730
|
-
view: self
|
|
1731
|
-
});
|
|
1732
|
-
session.showWidget(selector);
|
|
1733
|
-
return selector;
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1737
|
-
throw new Error("invalid track selector type ".concat(self.trackSelectorType));
|
|
1738
|
-
},
|
|
1739
|
-
toggleTrack: function toggleTrack(trackId) {
|
|
1740
|
-
// if we have any tracks with that configuration, turn them off
|
|
1741
|
-
var hiddenCount = this.hideTrack(trackId); // if none had that configuration, turn one on
|
|
1742
|
-
|
|
1743
|
-
if (!hiddenCount) {
|
|
1744
|
-
this.showTrack(trackId);
|
|
1745
|
-
}
|
|
1746
|
-
},
|
|
1747
|
-
setError: function setError(error) {
|
|
1748
|
-
console.error(error);
|
|
1749
|
-
self.error = error;
|
|
1750
|
-
},
|
|
1751
|
-
showTrack: function showTrack(trackId) {
|
|
1752
|
-
var initialSnapshot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1753
|
-
var trackConfigSchema = pluginManager.pluggableConfigSchemaType('track');
|
|
1754
|
-
var configuration = resolveIdentifier(trackConfigSchema, getRoot(self), trackId);
|
|
1755
|
-
var trackType = pluginManager.getTrackType(configuration.type);
|
|
1756
|
-
|
|
1757
|
-
if (!trackType) {
|
|
1758
|
-
throw new Error("unknown track type ".concat(configuration.type));
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
var viewType = pluginManager.getViewType(self.type);
|
|
1762
|
-
var supportedDisplays = viewType.displayTypes.map(function (displayType) {
|
|
1763
|
-
return displayType.name;
|
|
1764
|
-
});
|
|
1765
|
-
var displayConf = configuration.displays.find(function (d) {
|
|
1766
|
-
return supportedDisplays.includes(d.type);
|
|
1767
|
-
});
|
|
1768
|
-
var track = trackType.stateModel.create(_objectSpread2(_objectSpread2({}, initialSnapshot), {}, {
|
|
1769
|
-
type: configuration.type,
|
|
1770
|
-
configuration: configuration,
|
|
1771
|
-
displays: [{
|
|
1772
|
-
type: displayConf.type,
|
|
1773
|
-
configuration: displayConf
|
|
1774
|
-
}]
|
|
1775
|
-
}));
|
|
1776
|
-
self.tracks.push(track);
|
|
1777
|
-
},
|
|
1778
|
-
addTrackConf: function addTrackConf(configuration) {
|
|
1779
|
-
var initialSnapshot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1780
|
-
var type = configuration.type;
|
|
1781
|
-
var name = readConfObject(configuration, 'name');
|
|
1782
|
-
var trackType = pluginManager.getTrackType(type);
|
|
1783
|
-
|
|
1784
|
-
if (!trackType) {
|
|
1785
|
-
throw new Error("unknown track type ".concat(configuration.type));
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
var viewType = pluginManager.getViewType(self.type);
|
|
1789
|
-
var supportedDisplays = viewType.displayTypes.map(function (displayType) {
|
|
1790
|
-
return displayType.name;
|
|
1791
|
-
});
|
|
1792
|
-
var displayConf = configuration.displays.find(function (d) {
|
|
1793
|
-
return supportedDisplays.includes(d.type);
|
|
1794
|
-
});
|
|
1795
|
-
var track = trackType.stateModel.create(_objectSpread2(_objectSpread2({}, initialSnapshot), {}, {
|
|
1796
|
-
name: name,
|
|
1797
|
-
type: type,
|
|
1798
|
-
configuration: configuration,
|
|
1799
|
-
displays: [{
|
|
1800
|
-
type: displayConf.type,
|
|
1801
|
-
configuration: displayConf
|
|
1802
|
-
}]
|
|
1803
|
-
}));
|
|
1804
|
-
self.tracks.push(track);
|
|
1805
|
-
},
|
|
1806
|
-
hideTrack: function hideTrack(trackId) {
|
|
1807
|
-
var trackConfigSchema = pluginManager.pluggableConfigSchemaType('track');
|
|
1808
|
-
var configuration = resolveIdentifier(trackConfigSchema, getRoot(self), trackId); // if we have any tracks with that configuration, turn them off
|
|
1809
|
-
|
|
1810
|
-
var shownTracks = self.tracks.filter(function (t) {
|
|
1811
|
-
return t.configuration === configuration;
|
|
1812
|
-
});
|
|
1813
|
-
transaction(function () {
|
|
1814
|
-
return shownTracks.forEach(function (t) {
|
|
1815
|
-
return self.tracks.remove(t);
|
|
1816
|
-
});
|
|
1817
|
-
});
|
|
1818
|
-
return shownTracks.length;
|
|
1819
|
-
},
|
|
1820
|
-
toggleFitToWindowLock: function toggleFitToWindowLock() {
|
|
1821
|
-
self.lockedFitToWindow = !self.lockedFitToWindow; // when going unlocked -> locked and circle is cut off, set to the locked minBpPerPx
|
|
1822
|
-
|
|
1823
|
-
this.setModelViewWhenAdjust(self.atMinBpPerPx);
|
|
1824
|
-
return self.lockedFitToWindow;
|
|
1825
|
-
}
|
|
1826
|
-
};
|
|
1827
|
-
}));
|
|
1828
|
-
}
|
|
1829
|
-
/*
|
|
1830
|
-
PLANS
|
|
1831
|
-
|
|
1832
|
-
- tracks
|
|
1833
|
-
- ruler tick marks
|
|
1834
|
-
- set viewport scroll from state snapshot
|
|
1835
|
-
|
|
1836
|
-
*/
|
|
1837
|
-
|
|
1838
|
-
var ChordDisplayLoadingFactory = (function (pluginManager) {
|
|
1839
|
-
var lib = pluginManager.lib;
|
|
1840
|
-
var React = lib.react;
|
|
1841
|
-
var useState = React.useState,
|
|
1842
|
-
useEffect = React.useEffect;
|
|
1843
|
-
var makeStyles = lib['@material-ui/core/styles'].makeStyles;
|
|
1844
|
-
var observer = lib['mobx-react'].observer;
|
|
1845
|
-
var useStyles = makeStyles(function (theme) {
|
|
1846
|
-
var offset = 2;
|
|
1847
|
-
var duration = 1.4;
|
|
1848
|
-
return {
|
|
1849
|
-
path: {
|
|
1850
|
-
strokeDasharray: 187,
|
|
1851
|
-
strokeDashoffset: 50,
|
|
1852
|
-
animation: "$dash ".concat(duration, "s ease-in-out infinite, $colors ").concat(duration * 4, "s ease-in-out infinite")
|
|
1853
|
-
},
|
|
1854
|
-
'@keyframes colors': {
|
|
1855
|
-
'0%': {
|
|
1856
|
-
stroke: theme.palette.primary.light
|
|
1857
|
-
},
|
|
1858
|
-
'25%': {
|
|
1859
|
-
stroke: theme.palette.secondary.light
|
|
1860
|
-
},
|
|
1861
|
-
'50%': {
|
|
1862
|
-
stroke: theme.palette.tertiary.light
|
|
1863
|
-
},
|
|
1864
|
-
'75%': {
|
|
1865
|
-
stroke: theme.palette.quaternary.light
|
|
1866
|
-
},
|
|
1867
|
-
'100%': {
|
|
1868
|
-
stroke: theme.palette.primary.light
|
|
1869
|
-
}
|
|
1870
|
-
},
|
|
1871
|
-
'@keyframes dash': {
|
|
1872
|
-
'0%': {
|
|
1873
|
-
strokeDashoffset: offset
|
|
1874
|
-
},
|
|
1875
|
-
'50%': {
|
|
1876
|
-
strokeDashoffset: offset / 4,
|
|
1877
|
-
transform: 'rotate(135deg)'
|
|
1878
|
-
},
|
|
1879
|
-
'100%': {
|
|
1880
|
-
strokeDashoffset: offset,
|
|
1881
|
-
transform: 'rotate(720deg)'
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1884
|
-
};
|
|
1885
|
-
}); // 'repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,.5) 5px, rgba(255,255,255,.5) 10px)',
|
|
1886
|
-
|
|
1887
|
-
var Loading = observer(function (_ref) {
|
|
1888
|
-
var radius = _ref.model.renderProps.radius;
|
|
1889
|
-
var classes = useStyles(); // only show the loading message after 400ms to prevent excessive flickering
|
|
1890
|
-
|
|
1891
|
-
var _useState = useState(false),
|
|
1892
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1893
|
-
shown = _useState2[0],
|
|
1894
|
-
setShown = _useState2[1];
|
|
1895
|
-
|
|
1896
|
-
useEffect(function () {
|
|
1897
|
-
var timeout = setTimeout(function () {
|
|
1898
|
-
return setShown(true);
|
|
1899
|
-
}, 400);
|
|
1900
|
-
return function () {
|
|
1901
|
-
return clearTimeout(timeout);
|
|
1902
|
-
};
|
|
1903
|
-
});
|
|
1904
|
-
return !shown ? null : React.createElement("g", null, React.createElement("defs", null, React.createElement("pattern", {
|
|
1905
|
-
id: "diagonalHatch",
|
|
1906
|
-
width: "10",
|
|
1907
|
-
height: "10",
|
|
1908
|
-
patternTransform: "rotate(45 0 0)",
|
|
1909
|
-
patternUnits: "userSpaceOnUse"
|
|
1910
|
-
}, React.createElement("line", {
|
|
1911
|
-
x1: "0",
|
|
1912
|
-
y1: "0",
|
|
1913
|
-
x2: "0",
|
|
1914
|
-
y2: "10",
|
|
1915
|
-
style: {
|
|
1916
|
-
stroke: 'rgba(255,255,255,0.5)',
|
|
1917
|
-
strokeWidth: 10
|
|
1918
|
-
}
|
|
1919
|
-
}))), React.createElement("circle", {
|
|
1920
|
-
cx: "0",
|
|
1921
|
-
cy: "0",
|
|
1922
|
-
r: radius,
|
|
1923
|
-
fill: "#f1f1f1"
|
|
1924
|
-
}), React.createElement("circle", {
|
|
1925
|
-
cx: "0",
|
|
1926
|
-
cy: "0",
|
|
1927
|
-
r: radius,
|
|
1928
|
-
fill: "url(#diagonalHatch)"
|
|
1929
|
-
}), React.createElement("text", {
|
|
1930
|
-
x: "0",
|
|
1931
|
-
y: "0",
|
|
1932
|
-
transform: "rotate(90 0 0)",
|
|
1933
|
-
dominantBaseline: "middle",
|
|
1934
|
-
textAnchor: "middle"
|
|
1935
|
-
}, "Loading\u2026"), React.createElement("circle", {
|
|
1936
|
-
className: classes.path,
|
|
1937
|
-
fill: "none",
|
|
1938
|
-
strokeWidth: "4",
|
|
1939
|
-
strokeLinecap: "round",
|
|
1940
|
-
cx: "0",
|
|
1941
|
-
cy: "0",
|
|
1942
|
-
r: "60"
|
|
1943
|
-
}));
|
|
1944
|
-
});
|
|
1945
|
-
return Loading;
|
|
1946
|
-
});
|
|
1947
|
-
|
|
1948
|
-
var ChordDisplayErrorFactory = (function (_ref) {
|
|
1949
|
-
var jbrequire = _ref.jbrequire;
|
|
1950
|
-
var React = jbrequire('react');
|
|
1951
|
-
|
|
1952
|
-
var _jbrequire = jbrequire('@material-ui/core/styles'),
|
|
1953
|
-
makeStyles = _jbrequire.makeStyles;
|
|
1954
|
-
|
|
1955
|
-
var _jbrequire2 = jbrequire('mobx-react'),
|
|
1956
|
-
observer = _jbrequire2.observer;
|
|
1957
|
-
|
|
1958
|
-
var useStyles = makeStyles({
|
|
1959
|
-
errorMessage: {},
|
|
1960
|
-
errorBackground: {},
|
|
1961
|
-
errorText: {}
|
|
1962
|
-
}); // 'repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,.5) 5px, rgba(255,255,255,.5) 10px)',
|
|
1963
|
-
|
|
1964
|
-
var DisplayError = observer(function (_ref2) {
|
|
1965
|
-
var _ref2$model = _ref2.model,
|
|
1966
|
-
radius = _ref2$model.renderProps.radius,
|
|
1967
|
-
error = _ref2$model.error;
|
|
1968
|
-
var classes = useStyles();
|
|
1969
|
-
return /*#__PURE__*/React.createElement("g", {
|
|
1970
|
-
className: classes.errorMessage
|
|
1971
|
-
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("pattern", {
|
|
1972
|
-
id: "diagonalHatch",
|
|
1973
|
-
width: "10",
|
|
1974
|
-
height: "10",
|
|
1975
|
-
patternTransform: "rotate(45 0 0)",
|
|
1976
|
-
patternUnits: "userSpaceOnUse"
|
|
1977
|
-
}, /*#__PURE__*/React.createElement("line", {
|
|
1978
|
-
x1: "0",
|
|
1979
|
-
y1: "0",
|
|
1980
|
-
x2: "0",
|
|
1981
|
-
y2: "10",
|
|
1982
|
-
style: {
|
|
1983
|
-
stroke: 'rgba(255,0,0,0.5)',
|
|
1984
|
-
strokeWidth: 10
|
|
1985
|
-
}
|
|
1986
|
-
}))), /*#__PURE__*/React.createElement("circle", {
|
|
1987
|
-
className: classes.errorBackground,
|
|
1988
|
-
cx: "0",
|
|
1989
|
-
cy: "0",
|
|
1990
|
-
r: radius,
|
|
1991
|
-
fill: "#ffb4b4"
|
|
1992
|
-
}), /*#__PURE__*/React.createElement("circle", {
|
|
1993
|
-
className: classes.errorPattern,
|
|
1994
|
-
cx: "0",
|
|
1995
|
-
cy: "0",
|
|
1996
|
-
r: radius,
|
|
1997
|
-
fill: "url(#diagonalHatch)"
|
|
1998
|
-
}), /*#__PURE__*/React.createElement("text", {
|
|
1999
|
-
className: classes.errorText,
|
|
2000
|
-
x: "0",
|
|
2001
|
-
y: "0",
|
|
2002
|
-
transform: "rotate(90 0 0)",
|
|
2003
|
-
dominantBaseline: "middle",
|
|
2004
|
-
textAnchor: "middle"
|
|
2005
|
-
}, String(error)));
|
|
2006
|
-
});
|
|
2007
|
-
return DisplayError;
|
|
2008
|
-
});
|
|
2009
|
-
|
|
2010
|
-
var RpcRenderedSvgGroupF = (function (_ref) {
|
|
2011
|
-
var jbrequire = _ref.jbrequire;
|
|
2012
|
-
var React = jbrequire('react');
|
|
2013
|
-
|
|
2014
|
-
var _jbrequire = jbrequire('mobx-state-tree'),
|
|
2015
|
-
isAlive = _jbrequire.isAlive;
|
|
2016
|
-
|
|
2017
|
-
var useEffect = React.useEffect,
|
|
2018
|
-
useRef = React.useRef;
|
|
2019
|
-
|
|
2020
|
-
var _jbrequire2 = jbrequire('mobx-react'),
|
|
2021
|
-
observer = _jbrequire2.observer,
|
|
2022
|
-
MobxPropTypes = _jbrequire2.PropTypes;
|
|
2023
|
-
|
|
2024
|
-
var _jbrequire3 = jbrequire('react-dom'),
|
|
2025
|
-
unmountComponentAtNode = _jbrequire3.unmountComponentAtNode,
|
|
2026
|
-
hydrate = _jbrequire3.hydrate;
|
|
2027
|
-
|
|
2028
|
-
var _jbrequire4 = jbrequire('@jbrowse/core/util'),
|
|
2029
|
-
rIC = _jbrequire4.rIC;
|
|
2030
|
-
|
|
2031
|
-
function RpcRenderedSvgGroup(_ref2) {
|
|
2032
|
-
var model = _ref2.model;
|
|
2033
|
-
var data = model.data,
|
|
2034
|
-
html = model.html,
|
|
2035
|
-
filled = model.filled,
|
|
2036
|
-
renderingComponent = model.renderingComponent;
|
|
2037
|
-
var ssrContainerNode = useRef(null);
|
|
2038
|
-
useEffect(function () {
|
|
2039
|
-
var domNode = ssrContainerNode.current;
|
|
2040
|
-
|
|
2041
|
-
function doHydrate() {
|
|
2042
|
-
if (domNode && filled) {
|
|
2043
|
-
if (domNode && domNode.innerHTML) {
|
|
2044
|
-
domNode.style.display = 'none';
|
|
2045
|
-
unmountComponentAtNode(domNode);
|
|
2046
|
-
} // setting outline:none fixes react "focusable" element issue. see
|
|
2047
|
-
// https://github.com/GMOD/jbrowse-components/issues/2160
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
domNode.style.outline = 'none';
|
|
2051
|
-
domNode.innerHTML = html; // use requestIdleCallback to defer main-thread rendering
|
|
2052
|
-
// and hydration for when we have some free time. helps
|
|
2053
|
-
// keep the framerate up.
|
|
2054
|
-
|
|
2055
|
-
rIC(function () {
|
|
2056
|
-
if (!isAlive(model)) {
|
|
2057
|
-
return;
|
|
2058
|
-
}
|
|
2059
|
-
|
|
2060
|
-
var mainThreadRendering = React.createElement(renderingComponent, _objectSpread2(_objectSpread2({}, data), model.renderProps()), null);
|
|
2061
|
-
rIC(function () {
|
|
2062
|
-
if (!isAlive(model)) {
|
|
2063
|
-
return;
|
|
2064
|
-
}
|
|
2065
|
-
|
|
2066
|
-
hydrate(mainThreadRendering, domNode);
|
|
2067
|
-
});
|
|
2068
|
-
});
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
|
|
2072
|
-
doHydrate();
|
|
2073
|
-
return function () {
|
|
2074
|
-
if (domNode) {
|
|
2075
|
-
unmountComponentAtNode(domNode);
|
|
2076
|
-
}
|
|
2077
|
-
};
|
|
2078
|
-
});
|
|
2079
|
-
return /*#__PURE__*/React.createElement("g", {
|
|
2080
|
-
ref: ssrContainerNode
|
|
2081
|
-
});
|
|
2082
|
-
}
|
|
2083
|
-
|
|
2084
|
-
RpcRenderedSvgGroup.propTypes = {
|
|
2085
|
-
model: MobxPropTypes.observableObject.isRequired
|
|
2086
|
-
};
|
|
2087
|
-
return observer(RpcRenderedSvgGroup);
|
|
2088
|
-
});
|
|
2089
|
-
|
|
2090
|
-
var BaseChordDisplay = (function (_ref) {
|
|
2091
|
-
var lib = _ref.lib,
|
|
2092
|
-
load = _ref.load;
|
|
2093
|
-
var React = lib.react;
|
|
2094
|
-
var _lib$mobxReact = lib['mobx-react'],
|
|
2095
|
-
observer = _lib$mobxReact.observer,
|
|
2096
|
-
MobxPropTypes = _lib$mobxReact.PropTypes;
|
|
2097
|
-
var Loading = load(ChordDisplayLoadingFactory);
|
|
2098
|
-
var DisplayError = load(ChordDisplayErrorFactory);
|
|
2099
|
-
var RpcRenderedSvgGroup = load(RpcRenderedSvgGroupF); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2100
|
-
|
|
2101
|
-
function BaseChordDisplay(_ref2) {
|
|
2102
|
-
var display = _ref2.display;
|
|
2103
|
-
|
|
2104
|
-
if (display.error) {
|
|
2105
|
-
return React.createElement(DisplayError, {
|
|
2106
|
-
model: display
|
|
2107
|
-
});
|
|
2108
|
-
}
|
|
2109
|
-
|
|
2110
|
-
if (!display.filled) {
|
|
2111
|
-
return React.createElement(Loading, {
|
|
2112
|
-
model: display
|
|
2113
|
-
});
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
return React.createElement(RpcRenderedSvgGroup, {
|
|
2117
|
-
model: display
|
|
2118
|
-
});
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2121
|
-
BaseChordDisplay.propTypes = {
|
|
2122
|
-
display: MobxPropTypes.observableObject.isRequired
|
|
2123
|
-
};
|
|
2124
|
-
return observer(BaseChordDisplay);
|
|
2125
|
-
});
|
|
2126
|
-
|
|
2127
|
-
var _excluded = ["html"];
|
|
2128
|
-
var renderReactionFactory = (function (_ref) {
|
|
2129
|
-
var jbrequire = _ref.jbrequire;
|
|
2130
|
-
|
|
2131
|
-
var _jbrequire = jbrequire('@jbrowse/core/util/tracks'),
|
|
2132
|
-
getRpcSessionId = _jbrequire.getRpcSessionId;
|
|
2133
|
-
|
|
2134
|
-
var _jbrequire2 = jbrequire('@jbrowse/core/util'),
|
|
2135
|
-
getContainingView = _jbrequire2.getContainingView;
|
|
2136
|
-
|
|
2137
|
-
var _jbrequire3 = jbrequire('@jbrowse/core/util'),
|
|
2138
|
-
getSession = _jbrequire3.getSession;
|
|
2139
|
-
|
|
2140
|
-
function renderReactionData(self) {
|
|
2141
|
-
var _view$displayedRegion;
|
|
2142
|
-
|
|
2143
|
-
var view = getContainingView(self);
|
|
2144
|
-
var rendererType = self.rendererType;
|
|
2145
|
-
|
|
2146
|
-
var _getSession = getSession(view),
|
|
2147
|
-
rpcManager = _getSession.rpcManager;
|
|
2148
|
-
|
|
2149
|
-
return {
|
|
2150
|
-
rendererType: rendererType,
|
|
2151
|
-
rpcManager: rpcManager,
|
|
2152
|
-
renderProps: self.renderProps(),
|
|
2153
|
-
renderArgs: {
|
|
2154
|
-
assemblyName: (_view$displayedRegion = view.displayedRegions[0]) === null || _view$displayedRegion === void 0 ? void 0 : _view$displayedRegion.assemblyName,
|
|
2155
|
-
adapterConfig: JSON.parse(JSON.stringify(self.adapterConfig)),
|
|
2156
|
-
rendererType: rendererType.name,
|
|
2157
|
-
regions: JSON.parse(JSON.stringify(view.displayedRegions)),
|
|
2158
|
-
blockDefinitions: self.blockDefinitions,
|
|
2159
|
-
sessionId: getRpcSessionId(self),
|
|
2160
|
-
timeout: 1000000
|
|
2161
|
-
}
|
|
2162
|
-
};
|
|
2163
|
-
}
|
|
2164
|
-
|
|
2165
|
-
function renderReactionEffect(_x, _x2, _x3) {
|
|
2166
|
-
return _renderReactionEffect.apply(this, arguments);
|
|
2167
|
-
}
|
|
2168
|
-
|
|
2169
|
-
function _renderReactionEffect() {
|
|
2170
|
-
_renderReactionEffect = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(props, signal, self) {
|
|
2171
|
-
var rendererType, rpcManager, cannotBeRenderedReason, renderArgs, renderProps, _yield$rendererType$r, html, data;
|
|
2172
|
-
|
|
2173
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2174
|
-
while (1) {
|
|
2175
|
-
switch (_context.prev = _context.next) {
|
|
2176
|
-
case 0:
|
|
2177
|
-
if (props) {
|
|
2178
|
-
_context.next = 2;
|
|
2179
|
-
break;
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
throw new Error('cannot render with no props');
|
|
2183
|
-
|
|
2184
|
-
case 2:
|
|
2185
|
-
rendererType = props.rendererType, rpcManager = props.rpcManager, cannotBeRenderedReason = props.cannotBeRenderedReason, renderArgs = props.renderArgs, renderProps = props.renderProps;
|
|
2186
|
-
|
|
2187
|
-
if (!cannotBeRenderedReason) {
|
|
2188
|
-
_context.next = 5;
|
|
2189
|
-
break;
|
|
2190
|
-
}
|
|
2191
|
-
|
|
2192
|
-
return _context.abrupt("return", {
|
|
2193
|
-
message: cannotBeRenderedReason
|
|
2194
|
-
});
|
|
2195
|
-
|
|
2196
|
-
case 5:
|
|
2197
|
-
if (!(!props.renderProps.radius || !props.renderArgs.regions || !props.renderArgs.regions.length)) {
|
|
2198
|
-
_context.next = 7;
|
|
2199
|
-
break;
|
|
2200
|
-
}
|
|
2201
|
-
|
|
2202
|
-
return _context.abrupt("return", {
|
|
2203
|
-
message: 'Skipping render'
|
|
2204
|
-
});
|
|
2205
|
-
|
|
2206
|
-
case 7:
|
|
2207
|
-
if (self.isCompatibleWithRenderer(rendererType)) {
|
|
2208
|
-
_context.next = 9;
|
|
2209
|
-
break;
|
|
2210
|
-
}
|
|
2211
|
-
|
|
2212
|
-
throw new Error("renderer ".concat(rendererType.name, " is not compatible with this display type"));
|
|
2213
|
-
|
|
2214
|
-
case 9:
|
|
2215
|
-
_context.next = 11;
|
|
2216
|
-
return rendererType.renderInClient(rpcManager, _objectSpread2(_objectSpread2(_objectSpread2({}, renderArgs), renderProps), {}, {
|
|
2217
|
-
signal: signal
|
|
2218
|
-
}));
|
|
2219
|
-
|
|
2220
|
-
case 11:
|
|
2221
|
-
_yield$rendererType$r = _context.sent;
|
|
2222
|
-
html = _yield$rendererType$r.html;
|
|
2223
|
-
data = _objectWithoutProperties(_yield$rendererType$r, _excluded);
|
|
2224
|
-
return _context.abrupt("return", {
|
|
2225
|
-
html: html,
|
|
2226
|
-
data: data,
|
|
2227
|
-
renderingComponent: rendererType.ReactComponent
|
|
2228
|
-
});
|
|
2229
|
-
|
|
2230
|
-
case 15:
|
|
2231
|
-
case "end":
|
|
2232
|
-
return _context.stop();
|
|
2233
|
-
}
|
|
2234
|
-
}
|
|
2235
|
-
}, _callee);
|
|
2236
|
-
}));
|
|
2237
|
-
return _renderReactionEffect.apply(this, arguments);
|
|
2238
|
-
}
|
|
2239
|
-
|
|
2240
|
-
return {
|
|
2241
|
-
renderReactionData: renderReactionData,
|
|
2242
|
-
renderReactionEffect: renderReactionEffect
|
|
2243
|
-
};
|
|
2244
|
-
});
|
|
2245
|
-
|
|
2246
|
-
var BaseChordDisplayModel = /*#__PURE__*/types.compose('BaseChordDisplay', BaseDisplay, types.model({
|
|
2247
|
-
bezierRadiusRatio: 0.1,
|
|
2248
|
-
assemblyName: types.maybe(types.string)
|
|
2249
|
-
}))["volatile"](function () {
|
|
2250
|
-
return {
|
|
2251
|
-
// NOTE: all this volatile stuff has to be filled in at once
|
|
2252
|
-
// so that it stays consistent
|
|
2253
|
-
filled: false,
|
|
2254
|
-
reactElement: undefined,
|
|
2255
|
-
data: undefined,
|
|
2256
|
-
message: '',
|
|
2257
|
-
renderingComponent: undefined,
|
|
2258
|
-
refNameMap: undefined
|
|
2259
|
-
};
|
|
2260
|
-
}).actions(function (self) {
|
|
2261
|
-
var _getEnv = getEnv(self),
|
|
2262
|
-
pluginManager = _getEnv.pluginManager;
|
|
2263
|
-
|
|
2264
|
-
var track = self;
|
|
2265
|
-
return {
|
|
2266
|
-
onChordClick: function onChordClick(feature) {
|
|
2267
|
-
getConf(self, 'onChordClick', {
|
|
2268
|
-
feature: feature,
|
|
2269
|
-
track: track,
|
|
2270
|
-
pluginManager: pluginManager
|
|
2271
|
-
});
|
|
2272
|
-
}
|
|
2273
|
-
};
|
|
2274
|
-
}).views(function (self) {
|
|
2275
|
-
return {
|
|
2276
|
-
get blockDefinitions() {
|
|
2277
|
-
var origSlices = getContainingView(self).staticSlices;
|
|
2278
|
-
|
|
2279
|
-
if (!self.refNameMap) {
|
|
2280
|
-
return origSlices;
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
var slices = JSON.parse(JSON.stringify(origSlices)); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2284
|
-
|
|
2285
|
-
slices.forEach(function (slice) {
|
|
2286
|
-
var regions = slice.region.elided ? slice.region.regions : [slice.region];
|
|
2287
|
-
regions.forEach(function (region) {
|
|
2288
|
-
var _self$refNameMap;
|
|
2289
|
-
|
|
2290
|
-
var renamed = (_self$refNameMap = self.refNameMap) === null || _self$refNameMap === void 0 ? void 0 : _self$refNameMap[region.refName];
|
|
2291
|
-
|
|
2292
|
-
if (renamed && region.refName !== renamed) {
|
|
2293
|
-
region.refName = renamed;
|
|
2294
|
-
}
|
|
2295
|
-
});
|
|
2296
|
-
});
|
|
2297
|
-
return slices;
|
|
2298
|
-
},
|
|
2299
|
-
|
|
2300
|
-
renderProps: function renderProps() {
|
|
2301
|
-
var view = getContainingView(self);
|
|
2302
|
-
return _objectSpread2(_objectSpread2({}, getParentRenderProps(self)), {}, {
|
|
2303
|
-
rpcDriverName: self.rpcDriverName,
|
|
2304
|
-
displayModel: self,
|
|
2305
|
-
bezierRadius: view.radiusPx * self.bezierRadiusRatio,
|
|
2306
|
-
radius: view.radiusPx,
|
|
2307
|
-
blockDefinitions: this.blockDefinitions,
|
|
2308
|
-
onChordClick: self.onChordClick
|
|
2309
|
-
});
|
|
2310
|
-
},
|
|
2311
|
-
|
|
2312
|
-
/**
|
|
2313
|
-
* the pluggable element type object for this diplay's
|
|
2314
|
-
* renderer
|
|
2315
|
-
*/
|
|
2316
|
-
get rendererType() {
|
|
2317
|
-
var display = self;
|
|
2318
|
-
|
|
2319
|
-
var _getEnv2 = getEnv(self),
|
|
2320
|
-
pluginManager = _getEnv2.pluginManager;
|
|
2321
|
-
|
|
2322
|
-
var ThisRendererType = pluginManager.getRendererType(self.rendererTypeName);
|
|
2323
|
-
|
|
2324
|
-
if (!ThisRendererType) {
|
|
2325
|
-
throw new Error("renderer \"".concat(display.rendererTypeName, "\" not found"));
|
|
2326
|
-
}
|
|
2327
|
-
|
|
2328
|
-
if (!ThisRendererType.ReactComponent) {
|
|
2329
|
-
throw new Error("renderer ".concat(display.rendererTypeName, " has no ReactComponent, it may not be completely implemented yet"));
|
|
2330
|
-
}
|
|
2331
|
-
|
|
2332
|
-
return ThisRendererType;
|
|
2333
|
-
},
|
|
2334
|
-
|
|
2335
|
-
isCompatibleWithRenderer: function isCompatibleWithRenderer(renderer) {
|
|
2336
|
-
return !!(renderer instanceof CircularChordRendererType);
|
|
2337
|
-
},
|
|
2338
|
-
|
|
2339
|
-
/**
|
|
2340
|
-
* returns a string feature ID if the globally-selected object
|
|
2341
|
-
* is probably a feature
|
|
2342
|
-
*/
|
|
2343
|
-
get selectedFeatureId() {
|
|
2344
|
-
if (!isAlive(self)) {
|
|
2345
|
-
return undefined;
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
var session = getSession(self);
|
|
2349
|
-
|
|
2350
|
-
if (!session) {
|
|
2351
|
-
return undefined;
|
|
2352
|
-
}
|
|
2353
|
-
|
|
2354
|
-
var selection = session.selection; // does it quack like a feature?
|
|
2355
|
-
|
|
2356
|
-
if (isFeature(selection)) {
|
|
2357
|
-
return selection.id();
|
|
2358
|
-
}
|
|
2359
|
-
|
|
2360
|
-
return undefined;
|
|
2361
|
-
}
|
|
2362
|
-
|
|
2363
|
-
};
|
|
2364
|
-
}).actions(function (self) {
|
|
2365
|
-
return {
|
|
2366
|
-
renderStarted: function renderStarted() {
|
|
2367
|
-
self.filled = false;
|
|
2368
|
-
self.message = '';
|
|
2369
|
-
self.reactElement = undefined;
|
|
2370
|
-
self.data = undefined;
|
|
2371
|
-
self.error = undefined;
|
|
2372
|
-
self.renderingComponent = undefined;
|
|
2373
|
-
},
|
|
2374
|
-
renderSuccess: function renderSuccess(_ref) {
|
|
2375
|
-
var message = _ref.message,
|
|
2376
|
-
data = _ref.data,
|
|
2377
|
-
reactElement = _ref.reactElement,
|
|
2378
|
-
renderingComponent = _ref.renderingComponent;
|
|
2379
|
-
|
|
2380
|
-
if (message) {
|
|
2381
|
-
self.filled = false;
|
|
2382
|
-
self.message = message;
|
|
2383
|
-
self.reactElement = undefined;
|
|
2384
|
-
self.data = undefined;
|
|
2385
|
-
self.error = undefined;
|
|
2386
|
-
self.renderingComponent = undefined;
|
|
2387
|
-
} else {
|
|
2388
|
-
self.filled = true;
|
|
2389
|
-
self.message = '';
|
|
2390
|
-
self.reactElement = reactElement;
|
|
2391
|
-
self.data = data;
|
|
2392
|
-
self.error = undefined;
|
|
2393
|
-
self.renderingComponent = renderingComponent;
|
|
2394
|
-
}
|
|
2395
|
-
},
|
|
2396
|
-
renderError: function renderError(error) {
|
|
2397
|
-
console.error(error); // the rendering failed for some reason
|
|
2398
|
-
|
|
2399
|
-
self.filled = false;
|
|
2400
|
-
self.message = '';
|
|
2401
|
-
self.reactElement = undefined;
|
|
2402
|
-
self.data = undefined;
|
|
2403
|
-
self.error = error;
|
|
2404
|
-
self.renderingComponent = undefined;
|
|
2405
|
-
},
|
|
2406
|
-
setRefNameMap: function setRefNameMap(refNameMap) {
|
|
2407
|
-
self.refNameMap = refNameMap;
|
|
2408
|
-
}
|
|
2409
|
-
};
|
|
2410
|
-
}).actions(function (self) {
|
|
2411
|
-
var _getEnv3 = getEnv(self),
|
|
2412
|
-
pluginManager = _getEnv3.pluginManager;
|
|
2413
|
-
|
|
2414
|
-
var _pluginManager$jbrequ = pluginManager.jbrequire(renderReactionFactory),
|
|
2415
|
-
renderReactionData = _pluginManager$jbrequ.renderReactionData,
|
|
2416
|
-
renderReactionEffect = _pluginManager$jbrequ.renderReactionEffect;
|
|
2417
|
-
|
|
2418
|
-
return {
|
|
2419
|
-
afterAttach: function afterAttach() {
|
|
2420
|
-
makeAbortableReaction(self, renderReactionData, renderReactionEffect, {
|
|
2421
|
-
name: "".concat(self.type, " ").concat(self.id, " rendering"),
|
|
2422
|
-
// delay: self.renderDelay || 300,
|
|
2423
|
-
fireImmediately: true
|
|
2424
|
-
}, self.renderStarted, self.renderSuccess, self.renderError);
|
|
2425
|
-
makeAbortableReaction(self, function () {
|
|
2426
|
-
return {
|
|
2427
|
-
assemblyNames: getTrackAssemblyNames(self.parentTrack),
|
|
2428
|
-
adapter: getConf(getParent(self, 2), 'adapter'),
|
|
2429
|
-
assemblyManager: getSession(self).assemblyManager
|
|
2430
|
-
};
|
|
2431
|
-
},
|
|
2432
|
-
/*#__PURE__*/
|
|
2433
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2434
|
-
function () {
|
|
2435
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref2, signal) {
|
|
2436
|
-
var assemblyNames, adapter, assemblyManager;
|
|
2437
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2438
|
-
while (1) {
|
|
2439
|
-
switch (_context.prev = _context.next) {
|
|
2440
|
-
case 0:
|
|
2441
|
-
assemblyNames = _ref2.assemblyNames, adapter = _ref2.adapter, assemblyManager = _ref2.assemblyManager;
|
|
2442
|
-
return _context.abrupt("return", assemblyManager.getRefNameMapForAdapter(adapter, assemblyNames[0], {
|
|
2443
|
-
signal: signal,
|
|
2444
|
-
sessionId: getRpcSessionId(self)
|
|
2445
|
-
}));
|
|
2446
|
-
|
|
2447
|
-
case 2:
|
|
2448
|
-
case "end":
|
|
2449
|
-
return _context.stop();
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
}, _callee);
|
|
2453
|
-
}));
|
|
2454
|
-
|
|
2455
|
-
return function (_x, _x2) {
|
|
2456
|
-
return _ref3.apply(this, arguments);
|
|
2457
|
-
};
|
|
2458
|
-
}(), {
|
|
2459
|
-
name: "".concat(self.type, " ").concat(self.id, " getting refNames"),
|
|
2460
|
-
fireImmediately: true
|
|
2461
|
-
}, function () {}, function (refNameMap) {
|
|
2462
|
-
self.setRefNameMap(refNameMap);
|
|
2463
|
-
}, function (error) {
|
|
2464
|
-
console.error(error);
|
|
2465
|
-
self.setError(error);
|
|
2466
|
-
});
|
|
2467
|
-
}
|
|
2468
|
-
};
|
|
2469
|
-
});
|
|
2470
|
-
|
|
2471
|
-
var baseChordDisplayConfig = /*#__PURE__*/ConfigurationSchema('BaseChordDisplay', {
|
|
2472
|
-
onChordClick: {
|
|
2473
|
-
type: 'boolean',
|
|
2474
|
-
description: 'callback that should be run when a chord in the track is clicked',
|
|
2475
|
-
defaultValue: false,
|
|
2476
|
-
contextVariable: ['feature', 'track', 'pluginManager']
|
|
2477
|
-
}
|
|
2478
|
-
}, {
|
|
2479
|
-
explicitIdentifier: 'displayId'
|
|
2480
|
-
});
|
|
2481
|
-
|
|
2482
|
-
var CircularViewPlugin = /*#__PURE__*/function (_Plugin) {
|
|
2483
|
-
_inherits(CircularViewPlugin, _Plugin);
|
|
2484
|
-
|
|
2485
|
-
var _super = /*#__PURE__*/_createSuper(CircularViewPlugin);
|
|
2486
|
-
|
|
2487
|
-
function CircularViewPlugin() {
|
|
2488
|
-
var _this;
|
|
2489
|
-
|
|
2490
|
-
_classCallCheck(this, CircularViewPlugin);
|
|
2491
|
-
|
|
2492
|
-
_this = _super.apply(this, arguments);
|
|
2493
|
-
_this.name = 'CircularViewPlugin';
|
|
2494
|
-
return _this;
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2497
|
-
_createClass(CircularViewPlugin, [{
|
|
2498
|
-
key: "install",
|
|
2499
|
-
value: function install(pluginManager) {
|
|
2500
|
-
pluginManager.addViewType(function () {
|
|
2501
|
-
return new ViewType({
|
|
2502
|
-
ReactComponent: /*#__PURE__*/lazy(function () {
|
|
2503
|
-
return Promise.resolve().then(function () { return CircularView$2; });
|
|
2504
|
-
}),
|
|
2505
|
-
stateModel: CircularView(pluginManager),
|
|
2506
|
-
name: 'CircularView'
|
|
2507
|
-
});
|
|
2508
|
-
});
|
|
2509
|
-
pluginManager.addToExtensionPoint('LaunchView-CircularView',
|
|
2510
|
-
/*#__PURE__*/
|
|
2511
|
-
// @ts-ignore
|
|
2512
|
-
function () {
|
|
2513
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
|
|
2514
|
-
var session, assembly, _ref$tracks, tracks, assemblyManager, view, asm;
|
|
2515
|
-
|
|
2516
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2517
|
-
while (1) {
|
|
2518
|
-
switch (_context.prev = _context.next) {
|
|
2519
|
-
case 0:
|
|
2520
|
-
session = _ref.session, assembly = _ref.assembly, _ref$tracks = _ref.tracks, tracks = _ref$tracks === void 0 ? [] : _ref$tracks;
|
|
2521
|
-
assemblyManager = session.assemblyManager;
|
|
2522
|
-
view = session.addView('CircularView', {});
|
|
2523
|
-
_context.next = 5;
|
|
2524
|
-
return when(function () {
|
|
2525
|
-
return view.initialized;
|
|
2526
|
-
});
|
|
2527
|
-
|
|
2528
|
-
case 5:
|
|
2529
|
-
if (assembly) {
|
|
2530
|
-
_context.next = 7;
|
|
2531
|
-
break;
|
|
2532
|
-
}
|
|
2533
|
-
|
|
2534
|
-
throw new Error('No assembly provided when launching circular genome view');
|
|
2535
|
-
|
|
2536
|
-
case 7:
|
|
2537
|
-
_context.next = 9;
|
|
2538
|
-
return assemblyManager.waitForAssembly(assembly);
|
|
2539
|
-
|
|
2540
|
-
case 9:
|
|
2541
|
-
asm = _context.sent;
|
|
2542
|
-
|
|
2543
|
-
if (asm) {
|
|
2544
|
-
_context.next = 12;
|
|
2545
|
-
break;
|
|
2546
|
-
}
|
|
2547
|
-
|
|
2548
|
-
throw new Error("Assembly \"".concat(assembly, "\" not found when launching circular genome view"));
|
|
2549
|
-
|
|
2550
|
-
case 12:
|
|
2551
|
-
view.setDisplayedRegions(asm.regions || []);
|
|
2552
|
-
tracks.forEach(function (track) {
|
|
2553
|
-
return view.showTrack(track);
|
|
2554
|
-
});
|
|
2555
|
-
|
|
2556
|
-
case 14:
|
|
2557
|
-
case "end":
|
|
2558
|
-
return _context.stop();
|
|
2559
|
-
}
|
|
2560
|
-
}
|
|
2561
|
-
}, _callee);
|
|
2562
|
-
}));
|
|
2563
|
-
|
|
2564
|
-
return function (_x) {
|
|
2565
|
-
return _ref2.apply(this, arguments);
|
|
2566
|
-
};
|
|
2567
|
-
}());
|
|
2568
|
-
}
|
|
2569
|
-
}, {
|
|
2570
|
-
key: "configure",
|
|
2571
|
-
value: function configure(pluginManager) {
|
|
2572
|
-
if (isAbstractMenuManager(pluginManager.rootModel)) {
|
|
2573
|
-
pluginManager.rootModel.appendToSubMenu(['Add'], {
|
|
2574
|
-
label: 'Circular view',
|
|
2575
|
-
icon: DataUsageIcon,
|
|
2576
|
-
onClick: function onClick(session) {
|
|
2577
|
-
session.addView('CircularView', {});
|
|
2578
|
-
}
|
|
2579
|
-
});
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
}]);
|
|
2583
|
-
|
|
2584
|
-
return CircularViewPlugin;
|
|
2585
|
-
}(Plugin);
|
|
2586
|
-
|
|
2587
|
-
var useStyles = /*#__PURE__*/makeStyles({
|
|
2588
|
-
rulerLabel: {
|
|
2589
|
-
fontSize: '0.8rem',
|
|
2590
|
-
fontWeight: 500,
|
|
2591
|
-
lineHeight: 1.6,
|
|
2592
|
-
letterSpacing: '0.0075em'
|
|
2593
|
-
}
|
|
2594
|
-
});
|
|
2595
|
-
|
|
2596
|
-
function sliceArcPath(slice, radiusPx, startBase, endBase) {
|
|
2597
|
-
// A rx ry x-axis-rotation large-arc-flag sweep-flag x y
|
|
2598
|
-
if (slice.flipped) {
|
|
2599
|
-
var _ref = [endBase, startBase];
|
|
2600
|
-
startBase = _ref[0];
|
|
2601
|
-
endBase = _ref[1];
|
|
2602
|
-
}
|
|
2603
|
-
|
|
2604
|
-
var startXY = slice.bpToXY(startBase, radiusPx);
|
|
2605
|
-
var endXY = slice.bpToXY(endBase, radiusPx);
|
|
2606
|
-
var largeArc = Math.abs(endBase - startBase) / slice.bpPerRadian > Math.PI ? '1' : '0';
|
|
2607
|
-
var sweepFlag = '1';
|
|
2608
|
-
return ['M'].concat(_toConsumableArray(startXY), ['A', radiusPx, radiusPx, '0', largeArc, sweepFlag], _toConsumableArray(endXY)).join(' ');
|
|
2609
|
-
}
|
|
2610
|
-
|
|
2611
|
-
var ElisionRulerArc = /*#__PURE__*/observer(function (_ref2) {
|
|
2612
|
-
var model = _ref2.model,
|
|
2613
|
-
slice = _ref2.slice;
|
|
2614
|
-
var theme = useTheme();
|
|
2615
|
-
var modelRadiusPx = model.radiusPx;
|
|
2616
|
-
var radiusPx = modelRadiusPx + 1;
|
|
2617
|
-
var endRadians = slice.endRadians,
|
|
2618
|
-
startRadians = slice.startRadians,
|
|
2619
|
-
region = slice.region;
|
|
2620
|
-
var startXY = polarToCartesian(radiusPx, startRadians);
|
|
2621
|
-
var endXY = polarToCartesian(radiusPx, endRadians);
|
|
2622
|
-
var widthPx = (endRadians - startRadians) * radiusPx;
|
|
2623
|
-
var largeArc = endRadians - startRadians > Math.PI ? '1' : '0'; // TODO: draw the elision
|
|
2624
|
-
|
|
2625
|
-
var centerRadians = (endRadians + startRadians) / 2;
|
|
2626
|
-
var regionCountString = "[".concat(Number(region.regions.length).toLocaleString(), "]");
|
|
2627
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RulerLabel, {
|
|
2628
|
-
text: regionCountString,
|
|
2629
|
-
view: model,
|
|
2630
|
-
maxWidthPx: widthPx,
|
|
2631
|
-
radians: centerRadians,
|
|
2632
|
-
radiusPx: radiusPx,
|
|
2633
|
-
title: "".concat(Number(region.regions.length).toLocaleString(), " more regions"),
|
|
2634
|
-
color: theme.palette.text.primary
|
|
2635
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
2636
|
-
d: ['M'].concat(_toConsumableArray(startXY), ['A', radiusPx, radiusPx, '0', largeArc, '1'], _toConsumableArray(endXY)).join(' '),
|
|
2637
|
-
stroke: theme.palette.text.secondary,
|
|
2638
|
-
strokeWidth: 2,
|
|
2639
|
-
strokeDasharray: "2,2",
|
|
2640
|
-
fill: "none"
|
|
2641
|
-
}));
|
|
2642
|
-
});
|
|
2643
|
-
var RulerLabel = /*#__PURE__*/observer(function (_ref3) {
|
|
2644
|
-
var view = _ref3.view,
|
|
2645
|
-
text = _ref3.text,
|
|
2646
|
-
maxWidthPx = _ref3.maxWidthPx,
|
|
2647
|
-
radians = _ref3.radians,
|
|
2648
|
-
radiusPx = _ref3.radiusPx,
|
|
2649
|
-
title = _ref3.title,
|
|
2650
|
-
color = _ref3.color;
|
|
2651
|
-
var classes = useStyles();
|
|
2652
|
-
var textXY = polarToCartesian(radiusPx + 5, radians);
|
|
2653
|
-
|
|
2654
|
-
if (!text) {
|
|
2655
|
-
return null;
|
|
2656
|
-
}
|
|
2657
|
-
|
|
2658
|
-
if (text.length * 6.5 < maxWidthPx) {
|
|
2659
|
-
// text is rotated parallel to the ruler arc
|
|
2660
|
-
return /*#__PURE__*/React.createElement("text", {
|
|
2661
|
-
x: 0,
|
|
2662
|
-
y: 0,
|
|
2663
|
-
className: classes.rulerLabel,
|
|
2664
|
-
textAnchor: "middle",
|
|
2665
|
-
dominantBaseline: "baseline",
|
|
2666
|
-
transform: "translate(".concat(textXY, ") rotate(").concat(radToDeg(radians) + 90, ")"),
|
|
2667
|
-
style: {
|
|
2668
|
-
fill: color
|
|
2669
|
-
}
|
|
2670
|
-
}, text, /*#__PURE__*/React.createElement("title", null, title || text));
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
|
-
if (maxWidthPx > 4) {
|
|
2674
|
-
// text is rotated perpendicular to the ruler arc
|
|
2675
|
-
var overallRotation = radToDeg(radians + view.offsetRadians - Math.PI / 2);
|
|
2676
|
-
|
|
2677
|
-
if (overallRotation >= 180) {
|
|
2678
|
-
return /*#__PURE__*/React.createElement("text", {
|
|
2679
|
-
x: 0,
|
|
2680
|
-
y: 0,
|
|
2681
|
-
className: classes.rulerLabel,
|
|
2682
|
-
textAnchor: "start",
|
|
2683
|
-
dominantBaseline: "middle",
|
|
2684
|
-
transform: "translate(".concat(textXY, ") rotate(").concat(radToDeg(radians), ")"),
|
|
2685
|
-
style: {
|
|
2686
|
-
fill: color
|
|
2687
|
-
}
|
|
2688
|
-
}, text, /*#__PURE__*/React.createElement("title", null, title || text));
|
|
2689
|
-
}
|
|
2690
|
-
|
|
2691
|
-
return /*#__PURE__*/React.createElement("text", {
|
|
2692
|
-
x: 0,
|
|
2693
|
-
y: 0,
|
|
2694
|
-
className: classes.rulerLabel,
|
|
2695
|
-
textAnchor: "end",
|
|
2696
|
-
dominantBaseline: "middle",
|
|
2697
|
-
transform: "translate(".concat(textXY, ") rotate(").concat(radToDeg(radians) + 180, ")"),
|
|
2698
|
-
style: {
|
|
2699
|
-
fill: color
|
|
2700
|
-
}
|
|
2701
|
-
}, text, /*#__PURE__*/React.createElement("title", null, title || text));
|
|
2702
|
-
} // if you get here there is no room for the text at all
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
return null;
|
|
2706
|
-
});
|
|
2707
|
-
var RegionRulerArc = /*#__PURE__*/observer(function (_ref4) {
|
|
2708
|
-
var model = _ref4.model,
|
|
2709
|
-
slice = _ref4.slice;
|
|
2710
|
-
var theme = useTheme();
|
|
2711
|
-
var radiusPx = model.radiusPx;
|
|
2712
|
-
var region = slice.region,
|
|
2713
|
-
endRadians = slice.endRadians,
|
|
2714
|
-
startRadians = slice.startRadians;
|
|
2715
|
-
var centerRadians = (endRadians + startRadians) / 2;
|
|
2716
|
-
var widthPx = (endRadians - startRadians) * radiusPx;
|
|
2717
|
-
var session = getSession(model);
|
|
2718
|
-
var color;
|
|
2719
|
-
var assembly = session.assemblyManager.get(slice.region.assemblyName);
|
|
2720
|
-
|
|
2721
|
-
if (assembly) {
|
|
2722
|
-
color = assembly.getRefNameColor(region.refName);
|
|
2723
|
-
}
|
|
2724
|
-
|
|
2725
|
-
if (color) {
|
|
2726
|
-
try {
|
|
2727
|
-
color = makeContrasting(color, theme.palette.background.paper);
|
|
2728
|
-
} catch (error) {
|
|
2729
|
-
color = theme.palette.text.primary;
|
|
2730
|
-
}
|
|
2731
|
-
} else {
|
|
2732
|
-
color = theme.palette.text.primary;
|
|
2733
|
-
} // TODO: slice flipping
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RulerLabel, {
|
|
2737
|
-
text: region.refName,
|
|
2738
|
-
view: model,
|
|
2739
|
-
maxWidthPx: widthPx,
|
|
2740
|
-
radians: centerRadians,
|
|
2741
|
-
radiusPx: radiusPx,
|
|
2742
|
-
color: color
|
|
2743
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
2744
|
-
d: sliceArcPath(slice, radiusPx + 1, region.start, region.end),
|
|
2745
|
-
stroke: color,
|
|
2746
|
-
strokeWidth: 2,
|
|
2747
|
-
fill: "none"
|
|
2748
|
-
}, /*#__PURE__*/React.createElement("title", null, region.refName)));
|
|
2749
|
-
});
|
|
2750
|
-
var CircularRuler = /*#__PURE__*/observer(function Ruler(_ref5) {
|
|
2751
|
-
var model = _ref5.model,
|
|
2752
|
-
slice = _ref5.slice;
|
|
2753
|
-
|
|
2754
|
-
if (slice.region.elided) {
|
|
2755
|
-
return /*#__PURE__*/React.createElement(ElisionRulerArc, {
|
|
2756
|
-
key: assembleLocString(slice.region.regions[0]),
|
|
2757
|
-
model: model,
|
|
2758
|
-
slice: slice
|
|
2759
|
-
});
|
|
2760
|
-
}
|
|
2761
|
-
|
|
2762
|
-
return /*#__PURE__*/React.createElement(RegionRulerArc, {
|
|
2763
|
-
key: assembleLocString(slice.region),
|
|
2764
|
-
model: model,
|
|
2765
|
-
slice: slice
|
|
2766
|
-
});
|
|
2767
|
-
});
|
|
2768
|
-
|
|
2769
|
-
var useStyles$1 = /*#__PURE__*/makeStyles$1(function (theme) {
|
|
2770
|
-
return {
|
|
2771
|
-
importFormContainer: {
|
|
2772
|
-
marginBottom: theme.spacing(4)
|
|
2773
|
-
}
|
|
2774
|
-
};
|
|
2775
|
-
}); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2776
|
-
|
|
2777
|
-
var ImportForm = /*#__PURE__*/observer(function (_ref) {
|
|
2778
|
-
var model = _ref.model;
|
|
2779
|
-
var classes = useStyles$1();
|
|
2780
|
-
var session = getSession(model);
|
|
2781
|
-
var modelError = model.error;
|
|
2782
|
-
var assemblyNames = session.assemblyNames,
|
|
2783
|
-
assemblyManager = session.assemblyManager;
|
|
2784
|
-
|
|
2785
|
-
var _useState = useState(assemblyNames[0]),
|
|
2786
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
2787
|
-
selectedAsm = _useState2[0],
|
|
2788
|
-
setSelectedAsm = _useState2[1];
|
|
2789
|
-
|
|
2790
|
-
var _useState3 = useState(modelError),
|
|
2791
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
2792
|
-
error = _useState4[0],
|
|
2793
|
-
setError = _useState4[1];
|
|
2794
|
-
|
|
2795
|
-
var assembly = assemblyManager.get(selectedAsm);
|
|
2796
|
-
var assemblyError = assemblyNames.length ? assembly === null || assembly === void 0 ? void 0 : assembly.error : 'No configured assemblies';
|
|
2797
|
-
var regions = (assembly === null || assembly === void 0 ? void 0 : assembly.regions) || [];
|
|
2798
|
-
var err = assemblyError || error;
|
|
2799
|
-
return /*#__PURE__*/React.createElement(Container, {
|
|
2800
|
-
className: classes.importFormContainer
|
|
2801
|
-
}, err ? /*#__PURE__*/React.createElement(Grid, {
|
|
2802
|
-
container: true,
|
|
2803
|
-
spacing: 1,
|
|
2804
|
-
justifyContent: "center",
|
|
2805
|
-
alignItems: "center"
|
|
2806
|
-
}, /*#__PURE__*/React.createElement(Grid, {
|
|
2807
|
-
item: true
|
|
2808
|
-
}, /*#__PURE__*/React.createElement(ErrorMessage, {
|
|
2809
|
-
error: err
|
|
2810
|
-
}))) : null, /*#__PURE__*/React.createElement(Grid, {
|
|
2811
|
-
container: true,
|
|
2812
|
-
spacing: 1,
|
|
2813
|
-
justifyContent: "center",
|
|
2814
|
-
alignItems: "center"
|
|
2815
|
-
}, /*#__PURE__*/React.createElement(Grid, {
|
|
2816
|
-
item: true
|
|
2817
|
-
}, /*#__PURE__*/React.createElement(AssemblySelector, {
|
|
2818
|
-
onChange: function onChange(val) {
|
|
2819
|
-
setError(undefined);
|
|
2820
|
-
setSelectedAsm(val);
|
|
2821
|
-
},
|
|
2822
|
-
session: session,
|
|
2823
|
-
selected: selectedAsm
|
|
2824
|
-
})), /*#__PURE__*/React.createElement(Grid, {
|
|
2825
|
-
item: true
|
|
2826
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
2827
|
-
disabled: !(regions !== null && regions !== void 0 && regions.length),
|
|
2828
|
-
onClick: function onClick() {
|
|
2829
|
-
return model.setDisplayedRegions(regions);
|
|
2830
|
-
},
|
|
2831
|
-
variant: "contained",
|
|
2832
|
-
color: "primary"
|
|
2833
|
-
}, regions.length ? 'Open' : 'Loading…'))));
|
|
2834
|
-
});
|
|
2835
|
-
|
|
2836
|
-
var dragHandleHeight = 3;
|
|
2837
|
-
var useStyles$2 = /*#__PURE__*/makeStyles$1(function (theme) {
|
|
2838
|
-
return {
|
|
2839
|
-
root: {
|
|
2840
|
-
position: 'relative',
|
|
2841
|
-
marginBottom: theme.spacing(1),
|
|
2842
|
-
overflow: 'hidden',
|
|
2843
|
-
background: 'white'
|
|
2844
|
-
},
|
|
2845
|
-
scroller: {
|
|
2846
|
-
overflow: 'auto'
|
|
2847
|
-
},
|
|
2848
|
-
sliceRoot: {
|
|
2849
|
-
background: 'none',
|
|
2850
|
-
// background: theme.palette.background.paper,
|
|
2851
|
-
boxSizing: 'content-box',
|
|
2852
|
-
display: 'block'
|
|
2853
|
-
},
|
|
2854
|
-
iconButton: {
|
|
2855
|
-
padding: '4px',
|
|
2856
|
-
margin: '0 2px 0 2px'
|
|
2857
|
-
},
|
|
2858
|
-
controls: {
|
|
2859
|
-
overflow: 'hidden',
|
|
2860
|
-
whiteSpace: 'nowrap',
|
|
2861
|
-
position: 'absolute',
|
|
2862
|
-
background: grey[200],
|
|
2863
|
-
boxSizing: 'border-box',
|
|
2864
|
-
borderRight: '1px solid #a2a2a2',
|
|
2865
|
-
borderBottom: '1px solid #a2a2a2',
|
|
2866
|
-
left: 0,
|
|
2867
|
-
top: 0
|
|
2868
|
-
},
|
|
2869
|
-
importFormContainer: {
|
|
2870
|
-
marginBottom: theme.spacing(4)
|
|
2871
|
-
}
|
|
2872
|
-
};
|
|
2873
|
-
});
|
|
2874
|
-
var Slices = /*#__PURE__*/observer(function (_ref) {
|
|
2875
|
-
var model = _ref.model;
|
|
2876
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, model.staticSlices.map(function (slice) {
|
|
2877
|
-
return /*#__PURE__*/React.createElement(CircularRuler, {
|
|
2878
|
-
key: assembleLocString(slice.region.elided ? slice.region.regions[0] : slice.region),
|
|
2879
|
-
model: model,
|
|
2880
|
-
slice: slice
|
|
2881
|
-
});
|
|
2882
|
-
}), model.tracks.map(function (track) {
|
|
2883
|
-
var display = track.displays[0];
|
|
2884
|
-
return /*#__PURE__*/React.createElement(display.RenderingComponent, {
|
|
2885
|
-
key: display.id,
|
|
2886
|
-
display: display,
|
|
2887
|
-
view: model
|
|
2888
|
-
});
|
|
2889
|
-
}));
|
|
2890
|
-
});
|
|
2891
|
-
var Controls = /*#__PURE__*/observer(function (_ref2) {
|
|
2892
|
-
var model = _ref2.model,
|
|
2893
|
-
showingFigure = _ref2.showingFigure;
|
|
2894
|
-
var classes = useStyles$2();
|
|
2895
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2896
|
-
className: classes.controls
|
|
2897
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
2898
|
-
onClick: model.zoomOutButton,
|
|
2899
|
-
className: classes.iconButton,
|
|
2900
|
-
title: model.lockedFitToWindow ? 'unlock to zoom out' : 'zoom out',
|
|
2901
|
-
disabled: !showingFigure || model.atMaxBpPerPx || model.lockedFitToWindow,
|
|
2902
|
-
color: "secondary"
|
|
2903
|
-
}, /*#__PURE__*/React.createElement(ZoomOut, null)), /*#__PURE__*/React.createElement(IconButton, {
|
|
2904
|
-
onClick: model.zoomInButton,
|
|
2905
|
-
className: classes.iconButton,
|
|
2906
|
-
title: "zoom in",
|
|
2907
|
-
disabled: !showingFigure || model.atMinBpPerPx,
|
|
2908
|
-
color: "secondary"
|
|
2909
|
-
}, /*#__PURE__*/React.createElement(ZoomIn, null)), /*#__PURE__*/React.createElement(IconButton, {
|
|
2910
|
-
onClick: model.rotateCounterClockwiseButton,
|
|
2911
|
-
className: classes.iconButton,
|
|
2912
|
-
title: "rotate counter-clockwise",
|
|
2913
|
-
disabled: !showingFigure,
|
|
2914
|
-
color: "secondary"
|
|
2915
|
-
}, /*#__PURE__*/React.createElement(RotateLeft, null)), /*#__PURE__*/React.createElement(IconButton, {
|
|
2916
|
-
onClick: model.rotateClockwiseButton,
|
|
2917
|
-
className: classes.iconButton,
|
|
2918
|
-
title: "rotate clockwise",
|
|
2919
|
-
disabled: !showingFigure,
|
|
2920
|
-
color: "secondary"
|
|
2921
|
-
}, /*#__PURE__*/React.createElement(RotateRight, null)), /*#__PURE__*/React.createElement(IconButton, {
|
|
2922
|
-
onClick: model.toggleFitToWindowLock,
|
|
2923
|
-
className: classes.iconButton,
|
|
2924
|
-
title: model.lockedFitToWindow ? 'locked model to window size' : 'unlocked model to zoom further',
|
|
2925
|
-
disabled: model.tooSmallToLock,
|
|
2926
|
-
color: "secondary"
|
|
2927
|
-
}, model.lockedFitToWindow ? /*#__PURE__*/React.createElement(LockOutline, null) : /*#__PURE__*/React.createElement(LockOpen, null)), model.hideTrackSelectorButton ? null : /*#__PURE__*/React.createElement(IconButton, {
|
|
2928
|
-
onClick: model.activateTrackSelector,
|
|
2929
|
-
title: "Open track selector",
|
|
2930
|
-
"data-testid": "circular_track_select",
|
|
2931
|
-
color: "secondary"
|
|
2932
|
-
}, /*#__PURE__*/React.createElement(TrackSelector, null)));
|
|
2933
|
-
});
|
|
2934
|
-
var CircularView$1 = /*#__PURE__*/observer(function (_ref3) {
|
|
2935
|
-
var model = _ref3.model;
|
|
2936
|
-
var classes = useStyles$2();
|
|
2937
|
-
var initialized = !!model.displayedRegions.length && model.figureWidth && model.figureHeight;
|
|
2938
|
-
var showImportForm = !initialized && !model.disableImportForm;
|
|
2939
|
-
var showFigure = initialized && !showImportForm;
|
|
2940
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2941
|
-
className: classes.root,
|
|
2942
|
-
style: {
|
|
2943
|
-
width: model.width,
|
|
2944
|
-
height: model.height
|
|
2945
|
-
},
|
|
2946
|
-
"data-testid": model.id
|
|
2947
|
-
}, model.error ? /*#__PURE__*/React.createElement(ErrorMessage$1, {
|
|
2948
|
-
error: model.error
|
|
2949
|
-
}) : /*#__PURE__*/React.createElement(React.Fragment, null, showImportForm ? /*#__PURE__*/React.createElement(ImportForm, {
|
|
2950
|
-
model: model
|
|
2951
|
-
}) : null, /*#__PURE__*/React.createElement(React.Fragment, null, !showFigure ? null : /*#__PURE__*/React.createElement("div", {
|
|
2952
|
-
className: classes.scroller,
|
|
2953
|
-
style: {
|
|
2954
|
-
width: model.width,
|
|
2955
|
-
height: model.height
|
|
2956
|
-
}
|
|
2957
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
2958
|
-
className: classes.rotator,
|
|
2959
|
-
style: {
|
|
2960
|
-
transform: ["rotate(".concat(model.offsetRadians, "rad)")].join(' '),
|
|
2961
|
-
transition: 'transform 0.5s',
|
|
2962
|
-
transformOrigin: model.centerXY.map(function (x) {
|
|
2963
|
-
return "".concat(x, "px");
|
|
2964
|
-
}).join(' ')
|
|
2965
|
-
}
|
|
2966
|
-
}, /*#__PURE__*/React.createElement("svg", {
|
|
2967
|
-
style: {
|
|
2968
|
-
position: 'absolute',
|
|
2969
|
-
left: 0,
|
|
2970
|
-
top: 0
|
|
2971
|
-
},
|
|
2972
|
-
className: classes.sliceRoot,
|
|
2973
|
-
width: "".concat(model.figureWidth, "px"),
|
|
2974
|
-
height: "".concat(model.figureHeight, "px"),
|
|
2975
|
-
version: "1.1"
|
|
2976
|
-
}, /*#__PURE__*/React.createElement("g", {
|
|
2977
|
-
transform: "translate(".concat(model.centerXY, ")")
|
|
2978
|
-
}, /*#__PURE__*/React.createElement(Slices, {
|
|
2979
|
-
model: model
|
|
2980
|
-
}))))), /*#__PURE__*/React.createElement(Controls, {
|
|
2981
|
-
model: model,
|
|
2982
|
-
showingFigure: showFigure
|
|
2983
|
-
}), model.hideVerticalResizeHandle ? null : /*#__PURE__*/React.createElement(ResizeHandle, {
|
|
2984
|
-
onDrag: model.resizeHeight,
|
|
2985
|
-
style: {
|
|
2986
|
-
height: dragHandleHeight,
|
|
2987
|
-
position: 'absolute',
|
|
2988
|
-
bottom: 0,
|
|
2989
|
-
left: 0,
|
|
2990
|
-
background: '#ccc',
|
|
2991
|
-
boxSizing: 'border-box',
|
|
2992
|
-
borderTop: '1px solid #fafafa'
|
|
2993
|
-
}
|
|
2994
|
-
}))));
|
|
2995
|
-
});
|
|
2996
|
-
|
|
2997
|
-
var CircularView$2 = {
|
|
2998
|
-
__proto__: null,
|
|
2999
|
-
'default': CircularView$1
|
|
3000
|
-
};
|
|
3001
|
-
|
|
3002
|
-
export default CircularViewPlugin;
|
|
3003
|
-
export { BaseChordDisplay as BaseChordDisplayComponentFactory, BaseChordDisplayModel, baseChordDisplayConfig };
|
|
3004
|
-
//# sourceMappingURL=plugin-circular-view.esm.js.map
|