@jbrowse/core 1.7.11 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +20 -4
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +313 -558
  3. package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -473
  4. package/BaseFeatureWidget/index.d.ts +2 -2
  5. package/BaseFeatureWidget/index.js +88 -124
  6. package/BaseFeatureWidget/types.d.ts +1 -0
  7. package/BaseFeatureWidget/types.js +1 -4
  8. package/BaseFeatureWidget/util.js +40 -75
  9. package/CorePlugin.js +55 -94
  10. package/Plugin.js +9 -34
  11. package/PluginLoader.js +153 -422
  12. package/PluginManager.d.ts +84 -117
  13. package/PluginManager.js +377 -666
  14. package/ReExports/Attributes.d.ts +2 -0
  15. package/ReExports/Attributes.js +5 -0
  16. package/ReExports/BaseCard.d.ts +2 -0
  17. package/ReExports/BaseCard.js +5 -0
  18. package/ReExports/DataGrid.d.ts +2 -0
  19. package/ReExports/DataGrid.js +6 -0
  20. package/ReExports/FeatureDetails.d.ts +2 -0
  21. package/ReExports/FeatureDetails.js +5 -0
  22. package/ReExports/index.js +6 -12
  23. package/ReExports/list.d.ts +5 -0
  24. package/ReExports/list.js +271 -7
  25. package/ReExports/material-ui-colors.d.ts +1 -19
  26. package/ReExports/material-ui-colors.js +16 -158
  27. package/ReExports/modules.d.ts +68 -109
  28. package/ReExports/modules.js +455 -244
  29. package/TextSearch/BaseResults.js +51 -123
  30. package/TextSearch/TextSearchManager.d.ts +3 -1
  31. package/TextSearch/TextSearchManager.js +66 -144
  32. package/assemblyManager/assembly.js +280 -554
  33. package/assemblyManager/assemblyConfigSchema.js +47 -64
  34. package/assemblyManager/assemblyManager.d.ts +12 -10
  35. package/assemblyManager/assemblyManager.js +126 -270
  36. package/assemblyManager/index.js +9 -22
  37. package/configuration/configurationSchema.js +167 -203
  38. package/configuration/configurationSlot.js +248 -326
  39. package/configuration/index.js +19 -35
  40. package/configuration/util.d.ts +1 -1
  41. package/configuration/util.js +131 -173
  42. package/data_adapters/BaseAdapter.d.ts +2 -2
  43. package/data_adapters/BaseAdapter.js +132 -521
  44. package/data_adapters/CytobandAdapter.js +40 -126
  45. package/data_adapters/dataAdapterCache.js +77 -158
  46. package/package.json +16 -18
  47. package/pluggableElementTypes/AdapterType.js +24 -79
  48. package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
  49. package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
  50. package/pluggableElementTypes/ConnectionType.js +22 -65
  51. package/pluggableElementTypes/DisplayType.js +35 -82
  52. package/pluggableElementTypes/InternetAccountType.js +23 -64
  53. package/pluggableElementTypes/PluggableElementBase.js +8 -20
  54. package/pluggableElementTypes/RpcMethodType.js +85 -427
  55. package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
  56. package/pluggableElementTypes/TrackType.js +26 -70
  57. package/pluggableElementTypes/ViewType.js +21 -63
  58. package/pluggableElementTypes/WidgetType.js +21 -64
  59. package/pluggableElementTypes/index.d.ts +4 -3
  60. package/pluggableElementTypes/index.js +42 -125
  61. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
  62. package/pluggableElementTypes/models/BaseDisplayModel.d.ts +10 -10
  63. package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
  64. package/pluggableElementTypes/models/BaseTrackModel.d.ts +1 -1
  65. package/pluggableElementTypes/models/BaseTrackModel.js +139 -200
  66. package/pluggableElementTypes/models/BaseViewModel.js +24 -40
  67. package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
  68. package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
  69. package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
  70. package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
  71. package/pluggableElementTypes/models/index.js +21 -70
  72. package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
  73. package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
  74. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
  75. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
  76. package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -255
  77. package/pluggableElementTypes/renderers/RendererType.js +31 -105
  78. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
  79. package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +2 -2
  80. package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
  81. package/pluggableElementTypes/renderers/index.js +19 -62
  82. package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
  83. package/rpc/BaseRpcDriver.js +169 -405
  84. package/rpc/MainThreadRpcDriver.js +27 -150
  85. package/rpc/RpcManager.js +58 -159
  86. package/rpc/WebWorkerRpcDriver.js +54 -171
  87. package/rpc/configSchema.js +25 -49
  88. package/rpc/coreRpcMethods.d.ts +1 -3
  89. package/rpc/coreRpcMethods.js +221 -959
  90. package/rpc/remoteAbortSignals.js +46 -70
  91. package/tsconfig.build.tsbuildinfo +1 -1
  92. package/ui/AboutDialog.js +107 -158
  93. package/ui/App.js +157 -261
  94. package/ui/AssemblySelector.d.ts +1 -1
  95. package/ui/AssemblySelector.js +59 -115
  96. package/ui/CascadingMenu.js +100 -199
  97. package/ui/ColorPicker.d.ts +16 -0
  98. package/ui/ColorPicker.js +97 -0
  99. package/ui/Drawer.js +28 -58
  100. package/ui/DrawerWidget.js +109 -209
  101. package/ui/DropDownMenu.d.ts +0 -8
  102. package/ui/DropDownMenu.js +60 -97
  103. package/ui/EditableTypography.d.ts +1 -1
  104. package/ui/EditableTypography.js +87 -155
  105. package/ui/ErrorMessage.js +41 -66
  106. package/ui/FactoryResetDialog.js +24 -57
  107. package/ui/FatalErrorDialog.js +59 -91
  108. package/ui/FileSelector/FileSelector.js +123 -189
  109. package/ui/FileSelector/LocalFileChooser.js +44 -71
  110. package/ui/FileSelector/UrlChooser.js +17 -38
  111. package/ui/FileSelector/index.js +6 -12
  112. package/ui/Icons.d.ts +1 -1
  113. package/ui/Icons.js +45 -69
  114. package/ui/Logo.js +57 -110
  115. package/ui/Menu.d.ts +1 -1
  116. package/ui/Menu.js +232 -355
  117. package/ui/PrerenderedCanvas.js +63 -78
  118. package/ui/ResizeHandle.js +87 -114
  119. package/ui/ReturnToImportFormDialog.js +32 -59
  120. package/ui/SanitizedHTML.js +63 -52
  121. package/ui/Snackbar.js +74 -99
  122. package/ui/SnackbarModel.js +37 -51
  123. package/ui/Tooltip.d.ts +3 -1
  124. package/ui/Tooltip.js +49 -74
  125. package/ui/ViewContainer.js +113 -183
  126. package/ui/colors.d.ts +10 -0
  127. package/ui/colors.js +78 -0
  128. package/ui/index.js +51 -181
  129. package/ui/react-colorful.d.ts +17 -0
  130. package/ui/react-colorful.js +455 -0
  131. package/ui/theme.d.ts +279 -131
  132. package/ui/theme.js +197 -225
  133. package/util/Base1DUtils.d.ts +32 -0
  134. package/util/Base1DUtils.js +174 -0
  135. package/util/Base1DViewModel.d.ts +16 -37
  136. package/util/Base1DViewModel.js +116 -295
  137. package/util/QuickLRU.js +84 -332
  138. package/util/TimeTraveller.d.ts +19 -0
  139. package/util/TimeTraveller.js +86 -0
  140. package/util/aborting.js +49 -127
  141. package/util/analytics.js +91 -154
  142. package/util/blockTypes.js +106 -240
  143. package/util/calculateDynamicBlocks.js +98 -128
  144. package/util/calculateStaticBlocks.js +105 -125
  145. package/util/color/cssColorsLevel4.js +156 -160
  146. package/util/color/index.js +33 -55
  147. package/util/compositeMap.js +49 -333
  148. package/util/formatFastaStrings.js +9 -14
  149. package/util/idMaker.js +18 -31
  150. package/util/index.d.ts +18 -39
  151. package/util/index.js +743 -1236
  152. package/util/io/RemoteFileWithRangeCache.js +88 -257
  153. package/util/io/index.js +95 -169
  154. package/util/jexl.js +60 -115
  155. package/util/jexlStrings.js +24 -29
  156. package/util/layouts/BaseLayout.js +1 -4
  157. package/util/layouts/GranularRectLayout.js +388 -557
  158. package/util/layouts/MultiLayout.js +41 -109
  159. package/util/layouts/PrecomputedLayout.js +56 -114
  160. package/util/layouts/PrecomputedMultiLayout.js +22 -59
  161. package/util/layouts/SceneGraph.js +127 -197
  162. package/util/layouts/index.js +29 -66
  163. package/util/mst-reflection.js +55 -71
  164. package/util/offscreenCanvasPonyfill.js +66 -134
  165. package/util/offscreenCanvasUtils.d.ts +2 -7
  166. package/util/offscreenCanvasUtils.js +49 -146
  167. package/util/range.js +29 -40
  168. package/util/rxjs.js +20 -27
  169. package/util/simpleFeature.js +88 -152
  170. package/util/stats.js +91 -151
  171. package/util/tracks.js +130 -171
  172. package/util/types/index.d.ts +3 -3
  173. package/util/types/index.js +110 -179
  174. package/util/types/mst.d.ts +3 -3
  175. package/util/types/mst.js +91 -142
  176. package/util/types/util.js +1 -4
  177. package/util/when.js +54 -101
  178. package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
  179. package/BaseFeatureWidget/index.test.js +0 -51
  180. package/TextSearch/BaseResults.test.js +0 -42
  181. package/configuration/configurationSchema.test.js +0 -266
  182. package/configuration/configurationSlot.test.js +0 -69
  183. package/configuration/util.test.js +0 -39
  184. package/data_adapters/BaseAdapter.test.js +0 -200
  185. package/declare.d.js +0 -1
  186. package/pluggableElementTypes/RpcMethodType.test.js +0 -118
  187. package/pluggableElementTypes/renderers/declare.d.js +0 -1
  188. package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
  189. package/rpc/BaseRpcDriver.test.js +0 -540
  190. package/rpc/declaration.d.js +0 -1
  191. package/ui/FatalErrorDialog.test.js +0 -82
  192. package/ui/SanitizedHTML.test.js +0 -36
  193. package/ui/theme.test.js +0 -111
  194. package/util/Base1DViewModel.test.js +0 -130
  195. package/util/calculateDynamicBlocks.test.js +0 -74
  196. package/util/calculateStaticBlocks.test.js +0 -297
  197. package/util/declare.d.js +0 -1
  198. package/util/formatFastaStrings.test.js +0 -40
  199. package/util/index.test.js +0 -213
  200. package/util/jexlStrings.test.js +0 -48
  201. package/util/layouts/GranularRectLayout.test.js +0 -99
  202. package/util/range.test.js +0 -64
  203. package/util/simpleFeature.test.js +0 -34
  204. package/util/stats.test.js +0 -172
package/util/index.js CHANGED
@@ -1,446 +1,207 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof3 = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
9
17
  });
10
- var _exportNames = {
11
- inDevelopment: true,
12
- inProduction: true,
13
- useDebounce: true,
14
- useDebouncedCallback: true,
15
- findParentThat: true,
16
- springAnimate: true,
17
- findParentThatIs: true,
18
- getSession: true,
19
- getContainingView: true,
20
- getContainingTrack: true,
21
- getContainingDisplay: true,
22
- assembleLocString: true,
23
- parseLocStringOneBased: true,
24
- parseLocString: true,
25
- compareLocs: true,
26
- compareLocStrings: true,
27
- clamp: true,
28
- bpToPx: true,
29
- radToDeg: true,
30
- degToRad: true,
31
- polarToCartesian: true,
32
- cartesianToPolar: true,
33
- featureSpanPx: true,
34
- bpSpanPx: true,
35
- objectFromEntries: true,
36
- iterMap: true,
37
- mergeConfigs: true,
38
- findLastIndex: true,
39
- makeAbortableReaction: true,
40
- renameRegionIfNeeded: true,
41
- renameRegionsIfNeeded: true,
42
- minmax: true,
43
- stringify: true,
44
- isElectron: true,
45
- revcom: true,
46
- complement: true,
47
- blobToDataURL: true,
48
- rIC: true,
49
- measureText: true,
50
- defaultStarts: true,
51
- defaultStops: true,
52
- defaultCodonTable: true,
53
- generateCodonTable: true,
54
- updateStatus: true,
55
- hashCode: true,
56
- objectHash: true,
57
- bytesForRegions: true,
58
- viewBpToPx: true,
59
- supportedIndexingAdapters: true,
60
- getBpDisplayStr: true,
61
- toLocale: true,
62
- getTickDisplayStr: true,
63
- getViewParams: true,
64
- getLayoutId: true,
65
- SimpleFeature: true,
66
- isFeature: true
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
67
24
  };
68
- Object.defineProperty(exports, "SimpleFeature", {
69
- enumerable: true,
70
- get: function get() {
71
- return _simpleFeature.default;
72
- }
73
- });
74
- exports.assembleLocString = assembleLocString;
75
- exports.blobToDataURL = blobToDataURL;
76
- exports.bpSpanPx = bpSpanPx;
77
- exports.bpToPx = bpToPx;
78
- exports.bytesForRegions = bytesForRegions;
79
- exports.cartesianToPolar = cartesianToPolar;
80
- exports.clamp = clamp;
81
- exports.compareLocStrings = compareLocStrings;
82
- exports.compareLocs = compareLocs;
83
- exports.defaultStops = exports.defaultStarts = exports.defaultCodonTable = exports.complement = void 0;
84
- exports.degToRad = degToRad;
85
- exports.featureSpanPx = featureSpanPx;
86
- exports.findLastIndex = findLastIndex;
87
- exports.findParentThat = findParentThat;
88
- exports.findParentThatIs = findParentThatIs;
89
- exports.generateCodonTable = generateCodonTable;
90
- exports.getBpDisplayStr = getBpDisplayStr;
91
- exports.getContainingDisplay = getContainingDisplay;
92
- exports.getContainingTrack = getContainingTrack;
93
- exports.getContainingView = getContainingView;
94
- exports.getLayoutId = getLayoutId;
95
- exports.getSession = getSession;
96
- exports.getTickDisplayStr = getTickDisplayStr;
97
- exports.getViewParams = getViewParams;
98
- exports.hashCode = hashCode;
99
- exports.isElectron = exports.inProduction = exports.inDevelopment = void 0;
100
- Object.defineProperty(exports, "isFeature", {
101
- enumerable: true,
102
- get: function get() {
103
- return _simpleFeature.isFeature;
104
- }
105
- });
106
- exports.iterMap = iterMap;
107
- exports.makeAbortableReaction = makeAbortableReaction;
108
- exports.measureText = measureText;
109
- exports.mergeConfigs = mergeConfigs;
110
- exports.minmax = minmax;
111
- exports.objectFromEntries = void 0;
112
- exports.objectHash = objectHash;
113
- exports.parseLocString = parseLocString;
114
- exports.parseLocStringOneBased = parseLocStringOneBased;
115
- exports.polarToCartesian = polarToCartesian;
116
- exports.rIC = void 0;
117
- exports.radToDeg = radToDeg;
118
- exports.renameRegionIfNeeded = renameRegionIfNeeded;
119
- exports.renameRegionsIfNeeded = renameRegionsIfNeeded;
120
- exports.revcom = revcom;
121
- exports.springAnimate = springAnimate;
122
- exports.stringify = stringify;
123
- exports.supportedIndexingAdapters = supportedIndexingAdapters;
124
- exports.toLocale = toLocale;
125
- exports.updateStatus = updateStatus;
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.toLocale = exports.getBpDisplayStr = exports.supportedIndexingAdapters = exports.bytesForRegions = exports.objectHash = exports.hashCode = exports.updateStatus = exports.generateCodonTable = exports.defaultCodonTable = exports.defaultStops = exports.defaultStarts = exports.measureText = exports.rIC = exports.blobToDataURL = exports.complement = exports.revcom = exports.isElectron = exports.stringify = exports.minmax = exports.renameRegionsIfNeeded = exports.renameRegionIfNeeded = exports.makeAbortableReaction = exports.findLastIndex = exports.iterMap = exports.bpSpanPx = exports.featureSpanPx = exports.cartesianToPolar = exports.polarToCartesian = exports.degToRad = exports.radToDeg = exports.bpToPx = exports.clamp = exports.compareLocStrings = exports.compareLocs = exports.parseLocString = exports.parseLocStringOneBased = exports.assembleLocString = exports.getContainingDisplay = exports.getContainingTrack = exports.getContainingView = exports.getSession = exports.findParentThatIs = exports.springAnimate = exports.findParentThat = exports.useDebouncedCallback = exports.useDebounce = exports.inProduction = exports.inDevelopment = exports.isFeature = exports.SimpleFeature = void 0;
33
+ exports.measureGridWidth = exports.getStr = exports.getUriLink = exports.useLocalStorage = exports.getLayoutId = exports.getViewParams = exports.getTickDisplayStr = void 0;
34
+ /* eslint-disable @typescript-eslint/no-explicit-any */
35
+ const react_1 = require("react");
36
+ const is_object_1 = __importDefault(require("is-object"));
37
+ const mobx_state_tree_1 = require("mobx-state-tree");
38
+ const mobx_1 = require("mobx");
39
+ const simpleFeature_1 = __importStar(require("./simpleFeature"));
40
+ exports.SimpleFeature = simpleFeature_1.default;
41
+ Object.defineProperty(exports, "isFeature", { enumerable: true, get: function () { return simpleFeature_1.isFeature; } });
42
+ const types_1 = require("./types");
43
+ const aborting_1 = require("./aborting");
44
+ const types_2 = require("./types");
45
+ __exportStar(require("./types"), exports);
46
+ __exportStar(require("./aborting"), exports);
47
+ __exportStar(require("./when"), exports);
48
+ __exportStar(require("./range"), exports);
49
+ __exportStar(require("./offscreenCanvasPonyfill"), exports);
50
+ __exportStar(require("./offscreenCanvasUtils"), exports);
51
+ exports.inDevelopment = typeof process === 'object' &&
52
+ process.env &&
53
+ process.env.NODE_ENV === 'development';
54
+ exports.inProduction = !exports.inDevelopment;
55
+ function useDebounce(value, delay) {
56
+ const [debouncedValue, setDebouncedValue] = (0, react_1.useState)(value);
57
+ (0, react_1.useEffect)(() => {
58
+ const handle = setTimeout(() => {
59
+ setDebouncedValue(value);
60
+ }, delay);
61
+ return () => {
62
+ clearTimeout(handle);
63
+ };
64
+ }, [value, delay]);
65
+ return debouncedValue;
66
+ }
126
67
  exports.useDebounce = useDebounce;
127
- exports.useDebouncedCallback = useDebouncedCallback;
128
- exports.viewBpToPx = viewBpToPx;
129
-
130
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
131
-
132
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
133
-
134
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
135
-
136
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
137
-
138
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
139
-
140
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
141
-
142
- var _react = require("react");
143
-
144
- var _mobxStateTree = require("mobx-state-tree");
145
-
146
- var _mobx = require("mobx");
147
-
148
- var _object = _interopRequireDefault(require("object.fromentries"));
149
-
150
- var _deepmerge = _interopRequireDefault(require("deepmerge"));
151
-
152
- var _simpleFeature = _interopRequireWildcard(require("./simpleFeature"));
153
-
154
- var _types = require("./types");
155
-
156
- Object.keys(_types).forEach(function (key) {
157
- if (key === "default" || key === "__esModule") return;
158
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
159
- if (key in exports && exports[key] === _types[key]) return;
160
- Object.defineProperty(exports, key, {
161
- enumerable: true,
162
- get: function get() {
163
- return _types[key];
164
- }
165
- });
166
- });
167
-
168
- var _aborting = require("./aborting");
169
-
170
- Object.keys(_aborting).forEach(function (key) {
171
- if (key === "default" || key === "__esModule") return;
172
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
173
- if (key in exports && exports[key] === _aborting[key]) return;
174
- Object.defineProperty(exports, key, {
175
- enumerable: true,
176
- get: function get() {
177
- return _aborting[key];
178
- }
179
- });
180
- });
181
-
182
- var _when = require("./when");
183
-
184
- Object.keys(_when).forEach(function (key) {
185
- if (key === "default" || key === "__esModule") return;
186
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
187
- if (key in exports && exports[key] === _when[key]) return;
188
- Object.defineProperty(exports, key, {
189
- enumerable: true,
190
- get: function get() {
191
- return _when[key];
192
- }
193
- });
194
- });
195
-
196
- var _range = require("./range");
197
-
198
- Object.keys(_range).forEach(function (key) {
199
- if (key === "default" || key === "__esModule") return;
200
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
201
- if (key in exports && exports[key] === _range[key]) return;
202
- Object.defineProperty(exports, key, {
203
- enumerable: true,
204
- get: function get() {
205
- return _range[key];
206
- }
207
- });
208
- });
209
-
210
- var _offscreenCanvasPonyfill = require("./offscreenCanvasPonyfill");
211
-
212
- Object.keys(_offscreenCanvasPonyfill).forEach(function (key) {
213
- if (key === "default" || key === "__esModule") return;
214
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
215
- if (key in exports && exports[key] === _offscreenCanvasPonyfill[key]) return;
216
- Object.defineProperty(exports, key, {
217
- enumerable: true,
218
- get: function get() {
219
- return _offscreenCanvasPonyfill[key];
220
- }
221
- });
222
- });
223
-
224
- var _offscreenCanvasUtils = require("./offscreenCanvasUtils");
225
-
226
- Object.keys(_offscreenCanvasUtils).forEach(function (key) {
227
- if (key === "default" || key === "__esModule") return;
228
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
229
- if (key in exports && exports[key] === _offscreenCanvasUtils[key]) return;
230
- Object.defineProperty(exports, key, {
231
- enumerable: true,
232
- get: function get() {
233
- return _offscreenCanvasUtils[key];
68
+ // https://stackoverflow.com/questions/56283920/how-to-debounce-a-callback-in-functional-component-using-hooks
69
+ function useDebouncedCallback(callback, wait = 400) {
70
+ // track args & timeout handle between calls
71
+ const argsRef = (0, react_1.useRef)();
72
+ const timeout = (0, react_1.useRef)();
73
+ function cleanup() {
74
+ if (timeout.current) {
75
+ clearTimeout(timeout.current);
76
+ }
234
77
  }
235
- });
236
- });
237
-
238
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
239
-
240
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
241
-
242
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
243
-
244
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
245
-
246
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
247
-
248
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
249
-
250
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
251
-
252
- if (!Object.fromEntries) {
253
- // @ts-ignore
254
- _object.default.shim();
255
- }
256
-
257
- var inDevelopment = (typeof process === "undefined" ? "undefined" : (0, _typeof2.default)(process)) === 'object' && process.env && process.env.NODE_ENV === 'development';
258
- exports.inDevelopment = inDevelopment;
259
- var inProduction = !inDevelopment;
260
- exports.inProduction = inProduction;
261
-
262
- function useDebounce(value, delay) {
263
- var _useState = (0, _react.useState)(value),
264
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
265
- debouncedValue = _useState2[0],
266
- setDebouncedValue = _useState2[1];
267
-
268
- (0, _react.useEffect)(function () {
269
- var handle = setTimeout(function () {
270
- setDebouncedValue(value);
271
- }, delay);
272
- return function () {
273
- clearTimeout(handle);
78
+ // make sure our timeout gets cleared if our consuming component gets unmounted
79
+ (0, react_1.useEffect)(() => cleanup, []);
80
+ return function debouncedCallback(...args) {
81
+ // capture latest args
82
+ argsRef.current = args;
83
+ // clear debounce timer
84
+ cleanup();
85
+ // start waiting again
86
+ timeout.current = setTimeout(() => {
87
+ if (argsRef.current) {
88
+ callback(...argsRef.current);
89
+ }
90
+ }, wait);
274
91
  };
275
- }, [value, delay]);
276
- return debouncedValue;
277
- } // https://stackoverflow.com/questions/56283920/how-to-debounce-a-callback-in-functional-component-using-hooks
278
-
279
-
280
- function useDebouncedCallback(callback) {
281
- var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
282
- // track args & timeout handle between calls
283
- var argsRef = (0, _react.useRef)();
284
- var timeout = (0, _react.useRef)();
285
-
286
- function cleanup() {
287
- if (timeout.current) {
288
- clearTimeout(timeout.current);
289
- }
290
- } // make sure our timeout gets cleared if our consuming component gets unmounted
291
-
292
-
293
- (0, _react.useEffect)(function () {
294
- return cleanup;
295
- }, []);
296
- return function debouncedCallback() {
297
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
298
- args[_key] = arguments[_key];
299
- }
300
-
301
- // capture latest args
302
- argsRef.current = args; // clear debounce timer
303
-
304
- cleanup(); // start waiting again
305
-
306
- timeout.current = setTimeout(function () {
307
- if (argsRef.current) {
308
- callback.apply(void 0, (0, _toConsumableArray2.default)(argsRef.current));
309
- }
310
- }, wait);
311
- };
312
92
  }
93
+ exports.useDebouncedCallback = useDebouncedCallback;
313
94
  /** find the first node in the hierarchy that matches the given predicate */
314
-
315
-
316
95
  function findParentThat(node, predicate) {
317
- if (!(0, _mobxStateTree.hasParent)(node)) {
318
- throw new Error('node does not have parent');
319
- }
320
-
321
- var currentNode = (0, _mobxStateTree.getParent)(node);
322
-
323
- while (currentNode && (0, _mobxStateTree.isAlive)(currentNode)) {
324
- if (predicate(currentNode)) {
325
- return currentNode;
96
+ if (!(0, mobx_state_tree_1.hasParent)(node)) {
97
+ throw new Error('node does not have parent');
326
98
  }
327
-
328
- if ((0, _mobxStateTree.hasParent)(currentNode)) {
329
- currentNode = (0, _mobxStateTree.getParent)(currentNode);
330
- } else {
331
- break;
99
+ let currentNode = (0, mobx_state_tree_1.getParent)(node);
100
+ while (currentNode && (0, mobx_state_tree_1.isAlive)(currentNode)) {
101
+ if (predicate(currentNode)) {
102
+ return currentNode;
103
+ }
104
+ if ((0, mobx_state_tree_1.hasParent)(currentNode)) {
105
+ currentNode = (0, mobx_state_tree_1.getParent)(currentNode);
106
+ }
107
+ else {
108
+ break;
109
+ }
332
110
  }
333
- }
334
-
335
- throw new Error('no matching node found');
111
+ throw new Error('no matching node found');
336
112
  }
337
-
113
+ exports.findParentThat = findParentThat;
338
114
  // based on https://github.com/react-spring/react-spring/blob/cd5548a987383b8023efd620f3726a981f9e18ea/src/animated/FrameLoop.ts
339
- function springAnimate(fromValue, toValue, setValue) {
340
- var onFinish = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {};
341
- var precision = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
342
- var tension = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 170;
343
- var friction = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 26;
344
- var mass = 1;
345
-
346
- if (!precision) {
347
- precision = Math.abs(toValue - fromValue) / 1000;
348
- }
349
-
350
- var animationFrameId;
351
-
352
- function update(animation) {
353
- var time = Date.now();
354
- var position = animation.lastPosition;
355
- var lastTime = animation.lastTime || time;
356
- var velocity = animation.lastVelocity || 0; // If we lost a lot of frames just jump to the end.
357
-
358
- if (time > lastTime + 64) {
359
- lastTime = time;
360
- } // http://gafferongames.com/game-physics/fix-your-timestep/
361
-
362
-
363
- var numSteps = Math.floor(time - lastTime);
364
-
365
- for (var i = 0; i < numSteps; ++i) {
366
- var force = -tension * (position - toValue);
367
- var damping = -friction * velocity;
368
- var acceleration = (force + damping) / mass;
369
- velocity += acceleration * 1 / 1000;
370
- position += velocity * 1 / 1000;
115
+ function springAnimate(fromValue, toValue, setValue, onFinish = () => { }, precision = 0, tension = 170, friction = 26) {
116
+ const mass = 1;
117
+ if (!precision) {
118
+ precision = Math.abs(toValue - fromValue) / 1000;
371
119
  }
372
-
373
- var isVelocity = Math.abs(velocity) <= precision;
374
- var isDisplacement = tension !== 0 ? Math.abs(toValue - position) <= precision : true;
375
- var endOfAnimation = isVelocity && isDisplacement;
376
-
377
- if (endOfAnimation) {
378
- setValue(toValue);
379
- onFinish();
380
- } else {
381
- setValue(position);
382
- animationFrameId = requestAnimationFrame(function () {
383
- return update({
384
- lastPosition: position,
385
- lastTime: time,
386
- lastVelocity: velocity
387
- });
388
- });
120
+ let animationFrameId;
121
+ function update(animation) {
122
+ const time = Date.now();
123
+ let position = animation.lastPosition;
124
+ let lastTime = animation.lastTime || time;
125
+ let velocity = animation.lastVelocity || 0;
126
+ // If we lost a lot of frames just jump to the end.
127
+ if (time > lastTime + 64) {
128
+ lastTime = time;
129
+ }
130
+ // http://gafferongames.com/game-physics/fix-your-timestep/
131
+ const numSteps = Math.floor(time - lastTime);
132
+ for (let i = 0; i < numSteps; ++i) {
133
+ const force = -tension * (position - toValue);
134
+ const damping = -friction * velocity;
135
+ const acceleration = (force + damping) / mass;
136
+ velocity += (acceleration * 1) / 1000;
137
+ position += (velocity * 1) / 1000;
138
+ }
139
+ const isVelocity = Math.abs(velocity) <= precision;
140
+ const isDisplacement = tension !== 0 ? Math.abs(toValue - position) <= precision : true;
141
+ const endOfAnimation = isVelocity && isDisplacement;
142
+ if (endOfAnimation) {
143
+ setValue(toValue);
144
+ onFinish();
145
+ }
146
+ else {
147
+ setValue(position);
148
+ animationFrameId = requestAnimationFrame(() => update({
149
+ lastPosition: position,
150
+ lastTime: time,
151
+ lastVelocity: velocity,
152
+ }));
153
+ }
389
154
  }
390
- }
391
-
392
- return [function () {
393
- return update({
394
- lastPosition: fromValue
395
- });
396
- }, function () {
397
- return cancelAnimationFrame(animationFrameId);
398
- }];
155
+ return [
156
+ () => update({ lastPosition: fromValue }),
157
+ () => cancelAnimationFrame(animationFrameId),
158
+ ];
399
159
  }
160
+ exports.springAnimate = springAnimate;
400
161
  /** find the first node in the hierarchy that matches the given 'is' typescript type guard predicate */
401
-
402
-
403
162
  function findParentThatIs(node, predicate) {
404
- return findParentThat(node, predicate);
163
+ return findParentThat(node, predicate);
405
164
  }
165
+ exports.findParentThatIs = findParentThatIs;
406
166
  /** get the current JBrowse session model, starting at any node in the state tree */
407
-
408
-
409
167
  function getSession(node) {
410
- try {
411
- return findParentThatIs(node, _types.isSessionModel);
412
- } catch (e) {
413
- throw new Error('no session model found!');
414
- }
168
+ try {
169
+ return findParentThatIs(node, types_1.isSessionModel);
170
+ }
171
+ catch (e) {
172
+ throw new Error('no session model found!');
173
+ }
415
174
  }
175
+ exports.getSession = getSession;
416
176
  /** get the state model of the view in the state tree that contains the given node */
417
-
418
-
419
177
  function getContainingView(node) {
420
- try {
421
- return findParentThatIs(node, _types.isViewModel);
422
- } catch (e) {
423
- throw new Error('no containing view found');
424
- }
178
+ try {
179
+ return findParentThatIs(node, types_1.isViewModel);
180
+ }
181
+ catch (e) {
182
+ throw new Error('no containing view found');
183
+ }
425
184
  }
185
+ exports.getContainingView = getContainingView;
426
186
  /** get the state model of the view in the state tree that contains the given node */
427
-
428
-
429
187
  function getContainingTrack(node) {
430
- try {
431
- return findParentThatIs(node, _types.isTrackModel);
432
- } catch (e) {
433
- throw new Error('no containing track found');
434
- }
188
+ try {
189
+ return findParentThatIs(node, types_1.isTrackModel);
190
+ }
191
+ catch (e) {
192
+ throw new Error('no containing track found');
193
+ }
435
194
  }
436
-
195
+ exports.getContainingTrack = getContainingTrack;
437
196
  function getContainingDisplay(node) {
438
- try {
439
- return findParentThatIs(node, _types.isDisplayModel);
440
- } catch (e) {
441
- throw new Error('no containing display found');
442
- }
197
+ try {
198
+ return findParentThatIs(node, types_1.isDisplayModel);
199
+ }
200
+ catch (e) {
201
+ throw new Error('no containing display found');
202
+ }
443
203
  }
204
+ exports.getContainingDisplay = getContainingDisplay;
444
205
  /**
445
206
  * Assemble a 1-based "locString" from an interbase genomic location
446
207
  * @param region - Region
@@ -475,155 +236,122 @@ function getContainingDisplay(node) {
475
236
  * // ↳ 'chr1:1'
476
237
  * ```
477
238
  */
478
-
479
-
480
239
  function assembleLocString(region) {
481
- var assemblyName = region.assemblyName,
482
- refName = region.refName,
483
- start = region.start,
484
- end = region.end,
485
- reversed = region.reversed;
486
- var assemblyNameString = assemblyName ? "{".concat(assemblyName, "}") : '';
487
- var startString;
488
-
489
- if (start !== undefined) {
490
- startString = ":".concat((start + 1).toLocaleString('en-US'));
491
- } else if (end !== undefined) {
492
- startString = ':1';
493
- } else {
494
- startString = '';
495
- }
496
-
497
- var endString;
498
-
499
- if (end !== undefined) {
500
- endString = start !== undefined && start + 1 === end ? '' : "..".concat(end.toLocaleString('en-US'));
501
- } else {
502
- endString = start !== undefined ? '..' : '';
503
- }
504
-
505
- var rev = '';
506
-
507
- if (reversed) {
508
- rev = '[rev]';
509
- }
510
-
511
- return "".concat(assemblyNameString).concat(refName).concat(startString).concat(endString).concat(rev);
240
+ const { assemblyName, refName, start, end, reversed } = region;
241
+ const assemblyNameString = assemblyName ? `{${assemblyName}}` : '';
242
+ let startString;
243
+ if (start !== undefined) {
244
+ startString = `:${(start + 1).toLocaleString('en-US')}`;
245
+ }
246
+ else if (end !== undefined) {
247
+ startString = ':1';
248
+ }
249
+ else {
250
+ startString = '';
251
+ }
252
+ let endString;
253
+ if (end !== undefined) {
254
+ endString =
255
+ start !== undefined && start + 1 === end
256
+ ? ''
257
+ : `..${end.toLocaleString('en-US')}`;
258
+ }
259
+ else {
260
+ endString = start !== undefined ? '..' : '';
261
+ }
262
+ let rev = '';
263
+ if (reversed) {
264
+ rev = '[rev]';
265
+ }
266
+ return `${assemblyNameString}${refName}${startString}${endString}${rev}`;
512
267
  }
513
-
268
+ exports.assembleLocString = assembleLocString;
514
269
  function parseLocStringOneBased(locString, isValidRefName) {
515
- if (!locString) {
516
- throw new Error('no location string provided, could not parse');
517
- }
518
-
519
- var reversed = false;
520
-
521
- if (locString.endsWith('[rev]')) {
522
- reversed = true;
523
- locString = locString.replace(/\[rev\]$/, '');
524
- } // remove any whitespace
525
-
526
-
527
- locString = locString.replace(/\s/, ''); // refNames can have colons, ref https://samtools.github.io/hts-specs/SAMv1.pdf Appendix A
528
-
529
- var assemblyMatch = locString.match(/(\{(.+)\})?(.+)/);
530
-
531
- if (!assemblyMatch) {
532
- throw new Error("invalid location string: \"".concat(locString, "\""));
533
- }
534
-
535
- var _assemblyMatch = (0, _slicedToArray2.default)(assemblyMatch, 4),
536
- assemblyName = _assemblyMatch[2],
537
- location = _assemblyMatch[3];
538
-
539
- if (!assemblyName && location.startsWith('{}')) {
540
- throw new Error("no assembly name was provided in location \"".concat(location, "\""));
541
- }
542
-
543
- var lastColonIdx = location.lastIndexOf(':');
544
-
545
- if (lastColonIdx === -1) {
546
- if (isValidRefName(location, assemblyName)) {
547
- return {
548
- assemblyName: assemblyName,
549
- refName: location,
550
- reversed: reversed
551
- };
270
+ if (!locString) {
271
+ throw new Error('no location string provided, could not parse');
272
+ }
273
+ let reversed = false;
274
+ if (locString.endsWith('[rev]')) {
275
+ reversed = true;
276
+ locString = locString.replace(/\[rev\]$/, '');
277
+ }
278
+ // remove any whitespace
279
+ locString = locString.replace(/\s/, '');
280
+ // refNames can have colons, ref https://samtools.github.io/hts-specs/SAMv1.pdf Appendix A
281
+ const assemblyMatch = locString.match(/(\{(.+)\})?(.+)/);
282
+ if (!assemblyMatch) {
283
+ throw new Error(`invalid location string: "${locString}"`);
284
+ }
285
+ const [, , assemblyName, location] = assemblyMatch;
286
+ if (!assemblyName && location.startsWith('{}')) {
287
+ throw new Error(`no assembly name was provided in location "${location}"`);
552
288
  }
553
-
554
- throw new Error("Unknown reference sequence \"".concat(location, "\""));
555
- }
556
-
557
- var prefix = location.slice(0, lastColonIdx);
558
- var suffix = location.slice(lastColonIdx + 1);
559
-
560
- if (isValidRefName(prefix, assemblyName) && isValidRefName(location, assemblyName)) {
561
- throw new Error("ambiguous location string: \"".concat(locString, "\""));
562
- } else if (isValidRefName(prefix, assemblyName)) {
563
- if (suffix) {
564
- // see if it's a range
565
- var rangeMatch = suffix.match(/^(-?(\d+|\d{1,3}(,\d{3})*))(\.\.|-)(-?(\d+|\d{1,3}(,\d{3})*))$/); // see if it's a single point
566
-
567
- var singleMatch = suffix.match(/^(-?(\d+|\d{1,3}(,\d{3})*))(\.\.|-)?$/);
568
-
569
- if (rangeMatch) {
570
- var _rangeMatch = (0, _slicedToArray2.default)(rangeMatch, 6),
571
- _start = _rangeMatch[1],
572
- _end = _rangeMatch[5];
573
-
574
- if (_start !== undefined && _end !== undefined) {
575
- return {
576
- assemblyName: assemblyName,
577
- refName: prefix,
578
- start: +_start.replace(/,/g, ''),
579
- end: +_end.replace(/,/g, ''),
580
- reversed: reversed
581
- };
289
+ const lastColonIdx = location.lastIndexOf(':');
290
+ if (lastColonIdx === -1) {
291
+ if (isValidRefName(location, assemblyName)) {
292
+ return { assemblyName, refName: location, reversed };
293
+ }
294
+ throw new Error(`Unknown reference sequence "${location}"`);
295
+ }
296
+ const prefix = location.slice(0, lastColonIdx);
297
+ const suffix = location.slice(lastColonIdx + 1);
298
+ if (isValidRefName(prefix, assemblyName) &&
299
+ isValidRefName(location, assemblyName)) {
300
+ throw new Error(`ambiguous location string: "${locString}"`);
301
+ }
302
+ else if (isValidRefName(prefix, assemblyName)) {
303
+ if (suffix) {
304
+ // see if it's a range
305
+ const rangeMatch = suffix.match(/^(-?(\d+|\d{1,3}(,\d{3})*))(\.\.|-)(-?(\d+|\d{1,3}(,\d{3})*))$/);
306
+ // see if it's a single point
307
+ const singleMatch = suffix.match(/^(-?(\d+|\d{1,3}(,\d{3})*))(\.\.|-)?$/);
308
+ if (rangeMatch) {
309
+ const [, start, , , , end] = rangeMatch;
310
+ if (start !== undefined && end !== undefined) {
311
+ return {
312
+ assemblyName,
313
+ refName: prefix,
314
+ start: +start.replace(/,/g, ''),
315
+ end: +end.replace(/,/g, ''),
316
+ reversed,
317
+ };
318
+ }
319
+ }
320
+ else if (singleMatch) {
321
+ const [, start, , , separator] = singleMatch;
322
+ if (start !== undefined) {
323
+ if (separator) {
324
+ // indefinite end
325
+ return {
326
+ assemblyName,
327
+ refName: prefix,
328
+ start: +start.replace(/,/g, ''),
329
+ reversed,
330
+ };
331
+ }
332
+ return {
333
+ assemblyName,
334
+ refName: prefix,
335
+ start: +start.replace(/,/g, ''),
336
+ end: +start.replace(/,/g, ''),
337
+ reversed,
338
+ };
339
+ }
340
+ }
341
+ else {
342
+ throw new Error(`could not parse range "${suffix}" on location "${locString}"`);
343
+ }
582
344
  }
583
- } else if (singleMatch) {
584
- var _singleMatch = (0, _slicedToArray2.default)(singleMatch, 5),
585
- _start2 = _singleMatch[1],
586
- separator = _singleMatch[4];
587
-
588
- if (_start2 !== undefined) {
589
- if (separator) {
590
- // indefinite end
591
- return {
592
- assemblyName: assemblyName,
593
- refName: prefix,
594
- start: +_start2.replace(/,/g, ''),
595
- reversed: reversed
596
- };
597
- }
598
-
599
- return {
600
- assemblyName: assemblyName,
601
- refName: prefix,
602
- start: +_start2.replace(/,/g, ''),
603
- end: +_start2.replace(/,/g, ''),
604
- reversed: reversed
605
- };
345
+ else {
346
+ return { assemblyName, refName: prefix, reversed };
606
347
  }
607
- } else {
608
- throw new Error("could not parse range \"".concat(suffix, "\" on location \"").concat(locString, "\""));
609
- }
610
- } else {
611
- return {
612
- assemblyName: assemblyName,
613
- refName: prefix,
614
- reversed: reversed
615
- };
616
348
  }
617
- } else if (isValidRefName(location, assemblyName)) {
618
- return {
619
- assemblyName: assemblyName,
620
- refName: location,
621
- reversed: reversed
622
- };
623
- }
624
-
625
- throw new Error("unknown reference sequence name in location \"".concat(locString, "\""));
349
+ else if (isValidRefName(location, assemblyName)) {
350
+ return { assemblyName, refName: location, reversed };
351
+ }
352
+ throw new Error(`unknown reference sequence name in location "${locString}"`);
626
353
  }
354
+ exports.parseLocStringOneBased = parseLocStringOneBased;
627
355
  /**
628
356
  * Parse a 1-based location string into an interbase genomic location
629
357
  * @param locString - Location string
@@ -661,55 +389,48 @@ function parseLocStringOneBased(locString, isValidRefName) {
661
389
  * // ↳ { refName: 'chr1', start: 0}
662
390
  * ```
663
391
  */
664
-
665
-
666
392
  function parseLocString(locString, isValidRefName) {
667
- var parsed = parseLocStringOneBased(locString, isValidRefName);
668
-
669
- if (typeof parsed.start === 'number') {
670
- parsed.start -= 1;
671
- }
672
-
673
- return parsed;
393
+ const parsed = parseLocStringOneBased(locString, isValidRefName);
394
+ if (typeof parsed.start === 'number') {
395
+ parsed.start -= 1;
396
+ }
397
+ return parsed;
674
398
  }
675
-
399
+ exports.parseLocString = parseLocString;
676
400
  function compareLocs(locA, locB) {
677
- var assemblyComp = locA.assemblyName || locB.assemblyName ? (locA.assemblyName || '').localeCompare(locB.assemblyName || '') : 0;
678
-
679
- if (assemblyComp) {
680
- return assemblyComp;
681
- }
682
-
683
- var refComp = locA.refName || locB.refName ? (locA.refName || '').localeCompare(locB.refName || '') : 0;
684
-
685
- if (refComp) {
686
- return refComp;
687
- }
688
-
689
- if (locA.start !== undefined && locB.start !== undefined) {
690
- var startComp = locA.start - locB.start;
691
-
692
- if (startComp) {
693
- return startComp;
401
+ const assemblyComp = locA.assemblyName || locB.assemblyName
402
+ ? (locA.assemblyName || '').localeCompare(locB.assemblyName || '')
403
+ : 0;
404
+ if (assemblyComp) {
405
+ return assemblyComp;
694
406
  }
695
- }
696
-
697
- if (locA.end !== undefined && locB.end !== undefined) {
698
- var endComp = locA.end - locB.end;
699
-
700
- if (endComp) {
701
- return endComp;
407
+ const refComp = locA.refName || locB.refName
408
+ ? (locA.refName || '').localeCompare(locB.refName || '')
409
+ : 0;
410
+ if (refComp) {
411
+ return refComp;
702
412
  }
703
- }
704
-
705
- return 0;
413
+ if (locA.start !== undefined && locB.start !== undefined) {
414
+ const startComp = locA.start - locB.start;
415
+ if (startComp) {
416
+ return startComp;
417
+ }
418
+ }
419
+ if (locA.end !== undefined && locB.end !== undefined) {
420
+ const endComp = locA.end - locB.end;
421
+ if (endComp) {
422
+ return endComp;
423
+ }
424
+ }
425
+ return 0;
706
426
  }
707
-
427
+ exports.compareLocs = compareLocs;
708
428
  function compareLocStrings(a, b, isValidRefName) {
709
- var locA = parseLocString(a, isValidRefName);
710
- var locB = parseLocString(b, isValidRefName);
711
- return compareLocs(locA, locB);
429
+ const locA = parseLocString(a, isValidRefName);
430
+ const locB = parseLocString(b, isValidRefName);
431
+ return compareLocs(locA, locB);
712
432
  }
433
+ exports.compareLocStrings = compareLocStrings;
713
434
  /**
714
435
  * Ensure that a number is at least min and at most max.
715
436
  *
@@ -717,119 +438,78 @@ function compareLocStrings(a, b, isValidRefName) {
717
438
  * @param min -
718
439
  * @param max -
719
440
  */
720
-
721
-
722
441
  function clamp(num, min, max) {
723
- if (num < min) {
724
- return min;
725
- }
726
-
727
- if (num > max) {
728
- return max;
729
- }
730
-
731
- return num;
442
+ if (num < min) {
443
+ return min;
444
+ }
445
+ if (num > max) {
446
+ return max;
447
+ }
448
+ return num;
732
449
  }
733
-
450
+ exports.clamp = clamp;
734
451
  function roundToNearestPointOne(num) {
735
- return Math.round(num * 10) / 10;
452
+ return Math.round(num * 10) / 10;
736
453
  }
737
454
  /**
738
455
  * @param bp -
739
456
  * @param region -
740
457
  * @param bpPerPx -
741
458
  */
742
-
743
-
744
- function bpToPx(bp, _ref, bpPerPx) {
745
- var reversed = _ref.reversed,
746
- _ref$end = _ref.end,
747
- end = _ref$end === void 0 ? 0 : _ref$end,
748
- _ref$start = _ref.start,
749
- start = _ref$start === void 0 ? 0 : _ref$start;
750
- return roundToNearestPointOne((reversed ? end - bp : bp - start) / bpPerPx);
459
+ function bpToPx(bp, { reversed, end = 0, start = 0, }, bpPerPx) {
460
+ return roundToNearestPointOne((reversed ? end - bp : bp - start) / bpPerPx);
751
461
  }
752
-
753
- var oneEightyOverPi = 180.0 / Math.PI;
754
- var piOverOneEighty = Math.PI / 180.0;
755
-
462
+ exports.bpToPx = bpToPx;
463
+ const oneEightyOverPi = 180.0 / Math.PI;
464
+ const piOverOneEighty = Math.PI / 180.0;
756
465
  function radToDeg(radians) {
757
- return radians * oneEightyOverPi % 360;
466
+ return (radians * oneEightyOverPi) % 360;
758
467
  }
759
-
468
+ exports.radToDeg = radToDeg;
760
469
  function degToRad(degrees) {
761
- return degrees * piOverOneEighty % (2 * Math.PI);
470
+ return (degrees * piOverOneEighty) % (2 * Math.PI);
762
471
  }
472
+ exports.degToRad = degToRad;
763
473
  /**
764
474
  * @returns [x, y]
765
475
  */
766
-
767
-
768
476
  function polarToCartesian(rho, theta) {
769
- return [rho * Math.cos(theta), rho * Math.sin(theta)];
477
+ return [rho * Math.cos(theta), rho * Math.sin(theta)];
770
478
  }
479
+ exports.polarToCartesian = polarToCartesian;
771
480
  /**
772
481
  * @param x - the x
773
482
  * @param y - the y
774
483
  * @returns [rho, theta]
775
484
  */
776
-
777
-
778
485
  function cartesianToPolar(x, y) {
779
- var rho = Math.sqrt(x * x + y * y);
780
- var theta = Math.atan(y / x);
781
- return [rho, theta];
486
+ const rho = Math.sqrt(x * x + y * y);
487
+ const theta = Math.atan(y / x);
488
+ return [rho, theta];
782
489
  }
783
-
490
+ exports.cartesianToPolar = cartesianToPolar;
784
491
  function featureSpanPx(feature, region, bpPerPx) {
785
- return bpSpanPx(feature.get('start'), feature.get('end'), region, bpPerPx);
492
+ return bpSpanPx(feature.get('start'), feature.get('end'), region, bpPerPx);
786
493
  }
787
-
494
+ exports.featureSpanPx = featureSpanPx;
788
495
  function bpSpanPx(leftBp, rightBp, region, bpPerPx) {
789
- var start = bpToPx(leftBp, region, bpPerPx);
790
- var end = bpToPx(rightBp, region, bpPerPx);
791
- return region.reversed ? [end, start] : [start, end];
496
+ const start = bpToPx(leftBp, region, bpPerPx);
497
+ const end = bpToPx(rightBp, region, bpPerPx);
498
+ return region.reversed ? [end, start] : [start, end];
792
499
  }
793
-
794
- var objectFromEntries = Object.fromEntries.bind(Object); // do an array map of an iterable
795
-
796
- exports.objectFromEntries = objectFromEntries;
797
-
500
+ exports.bpSpanPx = bpSpanPx;
501
+ // do an array map of an iterable
798
502
  function iterMap(iterable, func, sizeHint) {
799
- var results = sizeHint ? new Array(sizeHint) : [];
800
- var counter = 0;
801
-
802
- var _iterator = _createForOfIteratorHelper(iterable),
803
- _step;
804
-
805
- try {
806
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
807
- var _item = _step.value;
808
- results[counter] = func(_item);
809
- counter += 1;
503
+ const results = sizeHint ? new Array(sizeHint) : [];
504
+ let counter = 0;
505
+ for (const item of iterable) {
506
+ results[counter] = func(item);
507
+ counter += 1;
810
508
  }
811
- } catch (err) {
812
- _iterator.e(err);
813
- } finally {
814
- _iterator.f();
815
- }
816
-
817
- return results;
509
+ return results;
818
510
  }
819
-
820
- // similar to electron.js
821
- function mergeConfigs(A, B) {
822
- var merged = (0, _deepmerge.default)(A, B);
823
-
824
- if (B.defaultSession) {
825
- merged.defaultSession = B.defaultSession;
826
- } else if (A.defaultSession) {
827
- merged.defaultSession = A.defaultSession;
828
- }
829
-
830
- return merged;
831
- } // https://stackoverflow.com/a/53187807
832
-
511
+ exports.iterMap = iterMap;
512
+ // https://stackoverflow.com/a/53187807
833
513
  /**
834
514
  * Returns the index of the last element in the array where predicate is true,
835
515
  * and -1 otherwise.
@@ -839,19 +519,16 @@ function mergeConfigs(A, B) {
839
519
  * element is found, findLastIndex immediately returns that element index.
840
520
  * Otherwise, findLastIndex returns -1.
841
521
  */
842
-
843
-
844
522
  function findLastIndex(array, predicate) {
845
- var l = array.length;
846
-
847
- while (l--) {
848
- if (predicate(array[l], l, array)) {
849
- return l;
523
+ let l = array.length;
524
+ while (l--) {
525
+ if (predicate(array[l], l, array)) {
526
+ return l;
527
+ }
850
528
  }
851
- }
852
-
853
- return -1;
529
+ return -1;
854
530
  }
531
+ exports.findLastIndex = findLastIndex;
855
532
  /**
856
533
  * makes a mobx reaction with the given functions, that calls actions on the
857
534
  * model for each stage of execution, and to abort the reaction function when
@@ -869,600 +546,430 @@ function findLastIndex(array, predicate) {
869
546
  * @param successFunction -
870
547
  * @param errorFunction -
871
548
  */
872
-
873
-
874
- function makeAbortableReaction(self, dataFunction, asyncReactionFunction, reactionOptions, startedFunction, successFunction, errorFunction) {
875
- var inProgress;
876
-
877
- function handleError(error) {
878
- if (!(0, _aborting.isAbortException)(error)) {
879
- if ((0, _mobxStateTree.isAlive)(self)) {
880
- errorFunction(error);
881
- } else {
882
- console.error(error);
883
- }
884
- }
885
- }
886
-
887
- var reactionDisposer = (0, _mobx.reaction)(function () {
888
- try {
889
- return dataFunction(self);
890
- } catch (e) {
891
- handleError(e);
892
- return undefined;
549
+ function makeAbortableReaction(self, dataFunction, asyncReactionFunction,
550
+ // @ts-ignore
551
+ reactionOptions, startedFunction, successFunction, errorFunction) {
552
+ let inProgress;
553
+ function handleError(error) {
554
+ if (!(0, aborting_1.isAbortException)(error)) {
555
+ if ((0, mobx_state_tree_1.isAlive)(self)) {
556
+ errorFunction(error);
557
+ }
558
+ else {
559
+ console.error(error);
560
+ }
561
+ }
893
562
  }
894
- }, /*#__PURE__*/function () {
895
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(data, mobxReactionHandle) {
896
- var thisInProgress, result;
897
- return _regenerator.default.wrap(function _callee$(_context) {
898
- while (1) {
899
- switch (_context.prev = _context.next) {
900
- case 0:
901
- if (inProgress && !inProgress.signal.aborted) {
902
- inProgress.abort();
903
- }
904
-
905
- if ((0, _mobxStateTree.isAlive)(self)) {
906
- _context.next = 3;
907
- break;
908
- }
909
-
910
- return _context.abrupt("return");
911
-
912
- case 3:
913
- inProgress = new AbortController();
914
- thisInProgress = inProgress;
915
- startedFunction(thisInProgress);
916
- _context.prev = 6;
917
- _context.next = 9;
918
- return asyncReactionFunction(data, thisInProgress.signal, self, mobxReactionHandle);
919
-
920
- case 9:
921
- result = _context.sent;
922
- (0, _aborting.checkAbortSignal)(thisInProgress.signal);
923
-
924
- if ((0, _mobxStateTree.isAlive)(self)) {
563
+ (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.reaction)(() => {
564
+ try {
565
+ return dataFunction(self);
566
+ }
567
+ catch (e) {
568
+ handleError(e);
569
+ return undefined;
570
+ }
571
+ }, async (data, mobxReactionHandle) => {
572
+ if (inProgress && !inProgress.signal.aborted) {
573
+ inProgress.abort();
574
+ }
575
+ if (!(0, mobx_state_tree_1.isAlive)(self)) {
576
+ return;
577
+ }
578
+ inProgress = new AbortController();
579
+ const thisInProgress = inProgress;
580
+ startedFunction(thisInProgress);
581
+ try {
582
+ const result = await asyncReactionFunction(data, thisInProgress.signal, self,
583
+ // @ts-ignore
584
+ mobxReactionHandle);
585
+ (0, aborting_1.checkAbortSignal)(thisInProgress.signal);
586
+ if ((0, mobx_state_tree_1.isAlive)(self)) {
925
587
  successFunction(result);
926
- }
927
-
928
- _context.next = 18;
929
- break;
930
-
931
- case 14:
932
- _context.prev = 14;
933
- _context.t0 = _context["catch"](6);
934
-
935
- if (thisInProgress && !thisInProgress.signal.aborted) {
588
+ }
589
+ }
590
+ catch (e) {
591
+ if (thisInProgress && !thisInProgress.signal.aborted) {
936
592
  thisInProgress.abort();
937
- }
938
-
939
- handleError(_context.t0);
940
-
941
- case 18:
942
- case "end":
943
- return _context.stop();
944
- }
593
+ }
594
+ handleError(e);
945
595
  }
946
- }, _callee, null, [[6, 14]]);
947
- }));
948
-
949
- return function (_x, _x2) {
950
- return _ref2.apply(this, arguments);
951
- };
952
- }(), reactionOptions);
953
- (0, _mobxStateTree.addDisposer)(self, reactionDisposer);
954
- (0, _mobxStateTree.addDisposer)(self, function () {
955
- if (inProgress && !inProgress.signal.aborted) {
956
- inProgress.abort();
957
- }
958
- });
596
+ }, reactionOptions));
597
+ (0, mobx_state_tree_1.addDisposer)(self, () => {
598
+ if (inProgress && !inProgress.signal.aborted) {
599
+ inProgress.abort();
600
+ }
601
+ });
959
602
  }
960
-
603
+ exports.makeAbortableReaction = makeAbortableReaction;
961
604
  function renameRegionIfNeeded(refNameMap, region) {
962
- if ((0, _mobxStateTree.isStateTreeNode)(region) && !(0, _mobxStateTree.isAlive)(region)) {
963
- return region;
964
- }
965
-
966
- if (region && refNameMap && refNameMap[region.refName]) {
967
- // clone the region so we don't modify it
968
- if ((0, _mobxStateTree.isStateTreeNode)(region)) {
969
- region = _objectSpread({}, (0, _mobxStateTree.getSnapshot)(region));
970
- } else {
971
- region = _objectSpread({}, region);
972
- } // modify it directly in the container
973
-
974
-
975
- var newRef = refNameMap[region.refName];
976
-
977
- if (newRef) {
978
- return _objectSpread(_objectSpread({}, region), {}, {
979
- refName: newRef,
980
- originalRefName: region.refName
981
- });
605
+ if ((0, mobx_state_tree_1.isStateTreeNode)(region) && !(0, mobx_state_tree_1.isAlive)(region)) {
606
+ return region;
982
607
  }
983
- }
984
-
985
- return region;
986
- }
987
-
988
- function renameRegionsIfNeeded(_x3, _x4) {
989
- return _renameRegionsIfNeeded.apply(this, arguments);
990
- }
991
-
992
- function _renameRegionsIfNeeded() {
993
- _renameRegionsIfNeeded = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(assemblyManager, args) {
994
- var _args$regions, regions, adapterConfig, assemblyNames, assemblyMaps;
995
-
996
- return _regenerator.default.wrap(function _callee3$(_context3) {
997
- while (1) {
998
- switch (_context3.prev = _context3.next) {
999
- case 0:
1000
- _args$regions = args.regions, regions = _args$regions === void 0 ? [] : _args$regions, adapterConfig = args.adapterConfig;
1001
-
1002
- if (args.sessionId) {
1003
- _context3.next = 3;
1004
- break;
1005
- }
1006
-
1007
- throw new Error('sessionId is required');
1008
-
1009
- case 3:
1010
- assemblyNames = regions.map(function (region) {
1011
- return region.assemblyName;
1012
- });
1013
- _context3.t0 = Object;
1014
- _context3.next = 7;
1015
- return Promise.all(assemblyNames.map( /*#__PURE__*/function () {
1016
- var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(assemblyName) {
1017
- return _regenerator.default.wrap(function _callee2$(_context2) {
1018
- while (1) {
1019
- switch (_context2.prev = _context2.next) {
1020
- case 0:
1021
- _context2.t0 = assemblyName;
1022
- _context2.next = 3;
1023
- return assemblyManager.getRefNameMapForAdapter(adapterConfig, assemblyName, args);
1024
-
1025
- case 3:
1026
- _context2.t1 = _context2.sent;
1027
- return _context2.abrupt("return", [_context2.t0, _context2.t1]);
1028
-
1029
- case 5:
1030
- case "end":
1031
- return _context2.stop();
1032
- }
1033
- }
1034
- }, _callee2);
1035
- }));
1036
-
1037
- return function (_x10) {
1038
- return _ref6.apply(this, arguments);
1039
- };
1040
- }()));
1041
-
1042
- case 7:
1043
- _context3.t1 = _context3.sent;
1044
- assemblyMaps = _context3.t0.fromEntries.call(_context3.t0, _context3.t1);
1045
- return _context3.abrupt("return", _objectSpread(_objectSpread({}, args), {}, {
1046
- regions: regions.map(function (region, i) {
1047
- return (// note: uses assemblyNames defined above since region could be dead now
1048
- renameRegionIfNeeded(assemblyMaps[assemblyNames[i]], region)
1049
- );
1050
- })
1051
- }));
1052
-
1053
- case 10:
1054
- case "end":
1055
- return _context3.stop();
608
+ if (region && refNameMap && refNameMap[region.refName]) {
609
+ // clone the region so we don't modify it
610
+ if ((0, mobx_state_tree_1.isStateTreeNode)(region)) {
611
+ // @ts-ignore
612
+ region = { ...(0, mobx_state_tree_1.getSnapshot)(region) };
1056
613
  }
1057
- }
1058
- }, _callee3);
1059
- }));
1060
- return _renameRegionsIfNeeded.apply(this, arguments);
614
+ else {
615
+ region = { ...region };
616
+ }
617
+ // modify it directly in the container
618
+ const newRef = refNameMap[region.refName];
619
+ if (newRef) {
620
+ return { ...region, refName: newRef, originalRefName: region.refName };
621
+ }
622
+ }
623
+ return region;
1061
624
  }
1062
-
625
+ exports.renameRegionIfNeeded = renameRegionIfNeeded;
626
+ async function renameRegionsIfNeeded(assemblyManager, args) {
627
+ const { regions = [], adapterConfig } = args;
628
+ if (!args.sessionId) {
629
+ throw new Error('sessionId is required');
630
+ }
631
+ const assemblyNames = regions.map(region => region.assemblyName);
632
+ const assemblyMaps = Object.fromEntries(await Promise.all(assemblyNames.map(async (assemblyName) => {
633
+ return [
634
+ assemblyName,
635
+ await assemblyManager.getRefNameMapForAdapter(adapterConfig, assemblyName, args),
636
+ ];
637
+ })));
638
+ return {
639
+ ...args,
640
+ regions: regions.map((region, i) =>
641
+ // note: uses assemblyNames defined above since region could be dead now
642
+ renameRegionIfNeeded(assemblyMaps[assemblyNames[i]], region)),
643
+ };
644
+ }
645
+ exports.renameRegionsIfNeeded = renameRegionsIfNeeded;
1063
646
  function minmax(a, b) {
1064
- return [Math.min(a, b), Math.max(a, b)];
647
+ return [Math.min(a, b), Math.max(a, b)];
1065
648
  }
1066
-
1067
- function stringify(_ref3) {
1068
- var refName = _ref3.refName,
1069
- coord = _ref3.coord,
1070
- oob = _ref3.oob;
1071
- return "".concat(refName, ":").concat(coord.toLocaleString('en-US')).concat(oob ? ' (out of bounds)' : '');
1072
- } // this is recommended in a later comment in https://github.com/electron/electron/issues/2288
649
+ exports.minmax = minmax;
650
+ function stringify({ refName, coord, oob, }) {
651
+ return refName
652
+ ? `${refName}:${coord.toLocaleString('en-US')}${oob ? ' (out of bounds)' : ''}`
653
+ : '';
654
+ }
655
+ exports.stringify = stringify;
656
+ // this is recommended in a later comment in https://github.com/electron/electron/issues/2288
1073
657
  // for detecting electron in a renderer process, which is the one that has node enabled for us
1074
658
  // const isElectron = process.versions.electron
1075
659
  // const i2 = process.versions.hasOwnProperty('electron')
1076
-
1077
-
1078
- var isElectron = /electron/i.test(typeof navigator !== 'undefined' ? navigator.userAgent : '');
1079
- exports.isElectron = isElectron;
1080
-
660
+ exports.isElectron = /electron/i.test(typeof navigator !== 'undefined' ? navigator.userAgent : '');
1081
661
  function revcom(seqString) {
1082
- return complement(seqString).split('').reverse().join('');
662
+ return (0, exports.complement)(seqString).split('').reverse().join('');
1083
663
  }
1084
-
1085
- var complement = function () {
1086
- var complementRegex = /[ACGT]/gi; // from bioperl: tr/acgtrymkswhbvdnxACGTRYMKSWHBVDNX/tgcayrkmswdvbhnxTGCAYRKMSWDVBHNX/
1087
- // generated with:
1088
- // perl -MJSON -E '@l = split "","acgtrymkswhbvdnxACGTRYMKSWHBVDNX"; print to_json({ map { my $in = $_; tr/acgtrymkswhbvdnxACGTRYMKSWHBVDNX/tgcayrkmswdvbhnxTGCAYRKMSWDVBHNX/; $in => $_ } @l})'
1089
-
1090
- var complementTable = {
1091
- S: 'S',
1092
- w: 'w',
1093
- T: 'A',
1094
- r: 'y',
1095
- a: 't',
1096
- N: 'N',
1097
- K: 'M',
1098
- x: 'x',
1099
- d: 'h',
1100
- Y: 'R',
1101
- V: 'B',
1102
- y: 'r',
1103
- M: 'K',
1104
- h: 'd',
1105
- k: 'm',
1106
- C: 'G',
1107
- g: 'c',
1108
- t: 'a',
1109
- A: 'T',
1110
- n: 'n',
1111
- W: 'W',
1112
- X: 'X',
1113
- m: 'k',
1114
- v: 'b',
1115
- B: 'V',
1116
- s: 's',
1117
- H: 'D',
1118
- c: 'g',
1119
- D: 'H',
1120
- b: 'v',
1121
- R: 'Y',
1122
- G: 'C'
1123
- };
1124
- return function (seqString) {
1125
- return seqString.replace(complementRegex, function (m) {
1126
- return complementTable[m] || '';
1127
- });
1128
- };
1129
- }();
1130
-
1131
- exports.complement = complement;
1132
-
1133
- function blobToDataURL(blob) {
1134
- var a = new FileReader();
1135
- return new Promise(function (resolve, reject) {
1136
- a.onload = function (e) {
1137
- if (e.target) {
1138
- resolve(e.target.result);
1139
- } else {
1140
- reject(new Error('unknown result reading blob from canvas'));
1141
- }
664
+ exports.revcom = revcom;
665
+ exports.complement = (() => {
666
+ const complementRegex = /[ACGT]/gi;
667
+ // from bioperl: tr/acgtrymkswhbvdnxACGTRYMKSWHBVDNX/tgcayrkmswdvbhnxTGCAYRKMSWDVBHNX/
668
+ // generated with:
669
+ // perl -MJSON -E '@l = split "","acgtrymkswhbvdnxACGTRYMKSWHBVDNX"; print to_json({ map { my $in = $_; tr/acgtrymkswhbvdnxACGTRYMKSWHBVDNX/tgcayrkmswdvbhnxTGCAYRKMSWDVBHNX/; $in => $_ } @l})'
670
+ const complementTable = {
671
+ S: 'S',
672
+ w: 'w',
673
+ T: 'A',
674
+ r: 'y',
675
+ a: 't',
676
+ N: 'N',
677
+ K: 'M',
678
+ x: 'x',
679
+ d: 'h',
680
+ Y: 'R',
681
+ V: 'B',
682
+ y: 'r',
683
+ M: 'K',
684
+ h: 'd',
685
+ k: 'm',
686
+ C: 'G',
687
+ g: 'c',
688
+ t: 'a',
689
+ A: 'T',
690
+ n: 'n',
691
+ W: 'W',
692
+ X: 'X',
693
+ m: 'k',
694
+ v: 'b',
695
+ B: 'V',
696
+ s: 's',
697
+ H: 'D',
698
+ c: 'g',
699
+ D: 'H',
700
+ b: 'v',
701
+ R: 'Y',
702
+ G: 'C',
1142
703
  };
1143
-
1144
- a.readAsDataURL(blob);
1145
- });
1146
- } // requires immediate execution in jest environment, because (hypothesis) it
704
+ return (seqString) => {
705
+ return seqString.replace(complementRegex, m => complementTable[m] || '');
706
+ };
707
+ })();
708
+ function blobToDataURL(blob) {
709
+ const a = new FileReader();
710
+ return new Promise((resolve, reject) => {
711
+ a.onload = e => {
712
+ if (e.target) {
713
+ resolve(e.target.result);
714
+ }
715
+ else {
716
+ reject(new Error('unknown result reading blob from canvas'));
717
+ }
718
+ };
719
+ a.readAsDataURL(blob);
720
+ });
721
+ }
722
+ exports.blobToDataURL = blobToDataURL;
723
+ // requires immediate execution in jest environment, because (hypothesis) it
1147
724
  // otherwise listens for prerendered_canvas but reads empty pixels, and doesn't
1148
725
  // get the contents of the canvas
1149
-
1150
-
1151
- var rIC = typeof jest === 'undefined' ? // @ts-ignore
1152
- typeof window !== 'undefined' && window.requestIdleCallback ? // @ts-ignore
1153
- window.requestIdleCallback : function (cb) {
1154
- return setTimeout(function () {
1155
- return cb();
1156
- }, 1);
1157
- } : function (cb) {
1158
- return cb();
1159
- }; // xref https://gist.github.com/tophtucker/62f93a4658387bb61e4510c37e2e97cf
1160
-
1161
- exports.rIC = rIC;
1162
-
1163
- function measureText(str) {
1164
- var fontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
1165
- // prettier-ignore
1166
- var widths = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2796875, 0.2765625, 0.3546875, 0.5546875, 0.5546875, 0.8890625, 0.665625, 0.190625, 0.3328125, 0.3328125, 0.3890625, 0.5828125, 0.2765625, 0.3328125, 0.2765625, 0.3015625, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.2765625, 0.2765625, 0.584375, 0.5828125, 0.584375, 0.5546875, 1.0140625, 0.665625, 0.665625, 0.721875, 0.721875, 0.665625, 0.609375, 0.7765625, 0.721875, 0.2765625, 0.5, 0.665625, 0.5546875, 0.8328125, 0.721875, 0.7765625, 0.665625, 0.7765625, 0.721875, 0.665625, 0.609375, 0.721875, 0.665625, 0.94375, 0.665625, 0.665625, 0.609375, 0.2765625, 0.3546875, 0.2765625, 0.4765625, 0.5546875, 0.3328125, 0.5546875, 0.5546875, 0.5, 0.5546875, 0.5546875, 0.2765625, 0.5546875, 0.5546875, 0.221875, 0.240625, 0.5, 0.221875, 0.8328125, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.3328125, 0.5, 0.2765625, 0.5546875, 0.5, 0.721875, 0.5, 0.5, 0.5, 0.3546875, 0.259375, 0.353125, 0.5890625];
1167
- var avg = 0.5279276315789471;
1168
- return String(str).split('').map(function (c) {
1169
- return c.charCodeAt(0) < widths.length ? widths[c.charCodeAt(0)] : avg;
1170
- }).reduce(function (cur, acc) {
1171
- return acc + cur;
1172
- }, 0) * fontSize;
726
+ exports.rIC = typeof jest === 'undefined'
727
+ ? // @ts-ignore
728
+ typeof window !== 'undefined' && window.requestIdleCallback
729
+ ? // @ts-ignore
730
+ window.requestIdleCallback
731
+ : (cb) => setTimeout(() => cb(), 1)
732
+ : (cb) => cb();
733
+ // prettier-ignore
734
+ const widths = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2796875, 0.2765625, 0.3546875, 0.5546875, 0.5546875, 0.8890625, 0.665625, 0.190625, 0.3328125, 0.3328125, 0.3890625, 0.5828125, 0.2765625, 0.3328125, 0.2765625, 0.3015625, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.2765625, 0.2765625, 0.584375, 0.5828125, 0.584375, 0.5546875, 1.0140625, 0.665625, 0.665625, 0.721875, 0.721875, 0.665625, 0.609375, 0.7765625, 0.721875, 0.2765625, 0.5, 0.665625, 0.5546875, 0.8328125, 0.721875, 0.7765625, 0.665625, 0.7765625, 0.721875, 0.665625, 0.609375, 0.721875, 0.665625, 0.94375, 0.665625, 0.665625, 0.609375, 0.2765625, 0.3546875, 0.2765625, 0.4765625, 0.5546875, 0.3328125, 0.5546875, 0.5546875, 0.5, 0.5546875, 0.5546875, 0.2765625, 0.5546875, 0.5546875, 0.221875, 0.240625, 0.5, 0.221875, 0.8328125, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.3328125, 0.5, 0.2765625, 0.5546875, 0.5, 0.721875, 0.5, 0.5, 0.5, 0.3546875, 0.259375, 0.353125, 0.5890625];
735
+ // xref https://gist.github.com/tophtucker/62f93a4658387bb61e4510c37e2e97cf
736
+ function measureText(str, fontSize = 10) {
737
+ var _a;
738
+ const avg = 0.5279276315789471;
739
+ const s = String(str);
740
+ let total = 0;
741
+ for (let i = 0; i < s.length; i++) {
742
+ const code = s.charCodeAt(i);
743
+ total += (_a = widths[code]) !== null && _a !== void 0 ? _a : avg;
744
+ }
745
+ return total * fontSize;
1173
746
  }
1174
-
1175
- var defaultStarts = ['ATG'];
1176
- exports.defaultStarts = defaultStarts;
1177
- var defaultStops = ['TAA', 'TAG', 'TGA'];
1178
- exports.defaultStops = defaultStops;
1179
- var defaultCodonTable = {
1180
- TCA: 'S',
1181
- TCC: 'S',
1182
- TCG: 'S',
1183
- TCT: 'S',
1184
- TTC: 'F',
1185
- TTT: 'F',
1186
- TTA: 'L',
1187
- TTG: 'L',
1188
- TAC: 'Y',
1189
- TAT: 'Y',
1190
- TAA: '*',
1191
- TAG: '*',
1192
- TGC: 'C',
1193
- TGT: 'C',
1194
- TGA: '*',
1195
- TGG: 'W',
1196
- CTA: 'L',
1197
- CTC: 'L',
1198
- CTG: 'L',
1199
- CTT: 'L',
1200
- CCA: 'P',
1201
- CCC: 'P',
1202
- CCG: 'P',
1203
- CCT: 'P',
1204
- CAC: 'H',
1205
- CAT: 'H',
1206
- CAA: 'Q',
1207
- CAG: 'Q',
1208
- CGA: 'R',
1209
- CGC: 'R',
1210
- CGG: 'R',
1211
- CGT: 'R',
1212
- ATA: 'I',
1213
- ATC: 'I',
1214
- ATT: 'I',
1215
- ATG: 'M',
1216
- ACA: 'T',
1217
- ACC: 'T',
1218
- ACG: 'T',
1219
- ACT: 'T',
1220
- AAC: 'N',
1221
- AAT: 'N',
1222
- AAA: 'K',
1223
- AAG: 'K',
1224
- AGC: 'S',
1225
- AGT: 'S',
1226
- AGA: 'R',
1227
- AGG: 'R',
1228
- GTA: 'V',
1229
- GTC: 'V',
1230
- GTG: 'V',
1231
- GTT: 'V',
1232
- GCA: 'A',
1233
- GCC: 'A',
1234
- GCG: 'A',
1235
- GCT: 'A',
1236
- GAC: 'D',
1237
- GAT: 'D',
1238
- GAA: 'E',
1239
- GAG: 'E',
1240
- GGA: 'G',
1241
- GGC: 'G',
1242
- GGG: 'G',
1243
- GGT: 'G'
747
+ exports.measureText = measureText;
748
+ exports.defaultStarts = ['ATG'];
749
+ exports.defaultStops = ['TAA', 'TAG', 'TGA'];
750
+ exports.defaultCodonTable = {
751
+ TCA: 'S',
752
+ TCC: 'S',
753
+ TCG: 'S',
754
+ TCT: 'S',
755
+ TTC: 'F',
756
+ TTT: 'F',
757
+ TTA: 'L',
758
+ TTG: 'L',
759
+ TAC: 'Y',
760
+ TAT: 'Y',
761
+ TAA: '*',
762
+ TAG: '*',
763
+ TGC: 'C',
764
+ TGT: 'C',
765
+ TGA: '*',
766
+ TGG: 'W',
767
+ CTA: 'L',
768
+ CTC: 'L',
769
+ CTG: 'L',
770
+ CTT: 'L',
771
+ CCA: 'P',
772
+ CCC: 'P',
773
+ CCG: 'P',
774
+ CCT: 'P',
775
+ CAC: 'H',
776
+ CAT: 'H',
777
+ CAA: 'Q',
778
+ CAG: 'Q',
779
+ CGA: 'R',
780
+ CGC: 'R',
781
+ CGG: 'R',
782
+ CGT: 'R',
783
+ ATA: 'I',
784
+ ATC: 'I',
785
+ ATT: 'I',
786
+ ATG: 'M',
787
+ ACA: 'T',
788
+ ACC: 'T',
789
+ ACG: 'T',
790
+ ACT: 'T',
791
+ AAC: 'N',
792
+ AAT: 'N',
793
+ AAA: 'K',
794
+ AAG: 'K',
795
+ AGC: 'S',
796
+ AGT: 'S',
797
+ AGA: 'R',
798
+ AGG: 'R',
799
+ GTA: 'V',
800
+ GTC: 'V',
801
+ GTG: 'V',
802
+ GTT: 'V',
803
+ GCA: 'A',
804
+ GCC: 'A',
805
+ GCG: 'A',
806
+ GCT: 'A',
807
+ GAC: 'D',
808
+ GAT: 'D',
809
+ GAA: 'E',
810
+ GAG: 'E',
811
+ GGA: 'G',
812
+ GGC: 'G',
813
+ GGG: 'G',
814
+ GGT: 'G',
1244
815
  };
1245
816
  /**
1246
817
  * take CodonTable above and generate larger codon table that includes
1247
818
  * all permutations of upper and lower case nucleotides
1248
819
  */
1249
-
1250
- exports.defaultCodonTable = defaultCodonTable;
1251
-
1252
820
  function generateCodonTable(table) {
1253
- var tempCodonTable = {};
1254
- Object.keys(table).forEach(function (codon) {
1255
- var aa = table[codon];
1256
- var nucs = [];
1257
-
1258
- for (var i = 0; i < 3; i++) {
1259
- var nuc = codon.charAt(i);
1260
- nucs[i] = [];
1261
- nucs[i][0] = nuc.toUpperCase();
1262
- nucs[i][1] = nuc.toLowerCase();
1263
- }
1264
-
1265
- for (var _i = 0; _i < 2; _i++) {
1266
- var n0 = nucs[0][_i];
1267
-
1268
- for (var j = 0; j < 2; j++) {
1269
- var n1 = nucs[1][j];
1270
-
1271
- for (var k = 0; k < 2; k++) {
1272
- var n2 = nucs[2][k];
1273
- var triplet = n0 + n1 + n2;
1274
- tempCodonTable[triplet] = aa;
821
+ const tempCodonTable = {};
822
+ Object.keys(table).forEach(codon => {
823
+ const aa = table[codon];
824
+ const nucs = [];
825
+ for (let i = 0; i < 3; i++) {
826
+ const nuc = codon.charAt(i);
827
+ nucs[i] = [];
828
+ nucs[i][0] = nuc.toUpperCase();
829
+ nucs[i][1] = nuc.toLowerCase();
1275
830
  }
1276
- }
1277
- }
1278
- });
1279
- return tempCodonTable;
1280
- } // call statusCallback with current status and clear when finished
1281
-
1282
-
1283
- function updateStatus(_x5, _x6, _x7) {
1284
- return _updateStatus.apply(this, arguments);
1285
- }
1286
-
1287
- function _updateStatus() {
1288
- _updateStatus = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(msg, cb, fn) {
1289
- var res;
1290
- return _regenerator.default.wrap(function _callee4$(_context4) {
1291
- while (1) {
1292
- switch (_context4.prev = _context4.next) {
1293
- case 0:
1294
- cb(msg);
1295
- _context4.next = 3;
1296
- return fn();
1297
-
1298
- case 3:
1299
- res = _context4.sent;
1300
- cb('');
1301
- return _context4.abrupt("return", res);
1302
-
1303
- case 6:
1304
- case "end":
1305
- return _context4.stop();
831
+ for (let i = 0; i < 2; i++) {
832
+ const n0 = nucs[0][i];
833
+ for (let j = 0; j < 2; j++) {
834
+ const n1 = nucs[1][j];
835
+ for (let k = 0; k < 2; k++) {
836
+ const n2 = nucs[2][k];
837
+ const triplet = n0 + n1 + n2;
838
+ tempCodonTable[triplet] = aa;
839
+ }
840
+ }
1306
841
  }
1307
- }
1308
- }, _callee4);
1309
- }));
1310
- return _updateStatus.apply(this, arguments);
842
+ });
843
+ return tempCodonTable;
844
+ }
845
+ exports.generateCodonTable = generateCodonTable;
846
+ // call statusCallback with current status and clear when finished
847
+ async function updateStatus(msg, cb, fn) {
848
+ cb(msg);
849
+ const res = await fn();
850
+ cb('');
851
+ return res;
1311
852
  }
1312
-
853
+ exports.updateStatus = updateStatus;
1313
854
  function hashCode(str) {
1314
- var hash = 0;
1315
-
1316
- if (str.length === 0) {
855
+ let hash = 0;
856
+ if (str.length === 0) {
857
+ return hash;
858
+ }
859
+ for (let i = 0; i < str.length; i++) {
860
+ const chr = str.charCodeAt(i);
861
+ hash = (hash << 5) - hash + chr;
862
+ hash |= 0; // Convert to 32bit integer
863
+ }
1317
864
  return hash;
1318
- }
1319
-
1320
- for (var i = 0; i < str.length; i++) {
1321
- var chr = str.charCodeAt(i);
1322
- hash = (hash << 5) - hash + chr;
1323
- hash |= 0; // Convert to 32bit integer
1324
- }
1325
-
1326
- return hash;
1327
865
  }
1328
-
866
+ exports.hashCode = hashCode;
1329
867
  function objectHash(obj) {
1330
- return "".concat(hashCode(JSON.stringify(obj)));
1331
- }
1332
-
1333
- function bytesForRegions(_x8, _x9) {
1334
- return _bytesForRegions.apply(this, arguments);
868
+ return `${hashCode(JSON.stringify(obj))}`;
1335
869
  }
1336
-
1337
- function _bytesForRegions() {
1338
- _bytesForRegions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(regions, index) {
1339
- var blockResults;
1340
- return _regenerator.default.wrap(function _callee5$(_context5) {
1341
- while (1) {
1342
- switch (_context5.prev = _context5.next) {
1343
- case 0:
1344
- _context5.next = 2;
1345
- return Promise.all(regions.map(function (r) {
1346
- return index.blocksForRange(r.refName, r.start, r.end);
1347
- }));
1348
-
1349
- case 2:
1350
- blockResults = _context5.sent;
1351
- return _context5.abrupt("return", blockResults.flat().map(function (block) {
1352
- return {
1353
- start: block.minv.blockPosition,
1354
- end: block.maxv.blockPosition + 65535
1355
- };
1356
- }).reduce(function (a, b) {
1357
- return a + b.end - b.start;
1358
- }, 0));
1359
-
1360
- case 4:
1361
- case "end":
1362
- return _context5.stop();
1363
- }
1364
- }
1365
- }, _callee5);
1366
- }));
1367
- return _bytesForRegions.apply(this, arguments);
870
+ exports.objectHash = objectHash;
871
+ async function bytesForRegions(regions, index) {
872
+ const blockResults = await Promise.all(regions.map(r => index.blocksForRange(r.refName, r.start, r.end)));
873
+ return blockResults
874
+ .flat()
875
+ .map(block => ({
876
+ start: block.minv.blockPosition,
877
+ end: block.maxv.blockPosition + 65535,
878
+ }))
879
+ .reduce((a, b) => a + b.end - b.start, 0);
1368
880
  }
1369
-
1370
- function viewBpToPx(_ref4) {
1371
- var refName = _ref4.refName,
1372
- coord = _ref4.coord,
1373
- regionNumber = _ref4.regionNumber,
1374
- self = _ref4.self;
1375
- var offsetBp = 0;
1376
- var interRegionPaddingBp = self.interRegionPaddingWidth * self.bpPerPx;
1377
- var minimumBlockBp = self.minimumBlockWidth * self.bpPerPx;
1378
- var index = self.displayedRegions.findIndex(function (region, idx) {
1379
- var len = region.end - region.start;
1380
-
1381
- if (refName === region.refName && coord >= region.start && coord <= region.end) {
1382
- if (regionNumber ? regionNumber === idx : true) {
1383
- offsetBp += region.reversed ? region.end - coord : coord - region.start;
1384
- return true;
1385
- }
1386
- } // add the interRegionPaddingWidth if the boundary is in the screen
1387
- // e.g. offset>=0 && offset<width
1388
-
1389
-
1390
- if (len > minimumBlockBp && offsetBp / self.bpPerPx >= 0 && offsetBp / self.bpPerPx < self.width) {
1391
- offsetBp += len + interRegionPaddingBp;
1392
- } else {
1393
- offsetBp += len;
1394
- }
1395
-
1396
- return false;
1397
- });
1398
- var found = self.displayedRegions[index];
1399
-
1400
- if (found) {
1401
- return {
1402
- index: index,
1403
- offsetPx: Math.round(offsetBp / self.bpPerPx)
1404
- };
1405
- }
1406
-
1407
- return undefined;
1408
- } // supported adapter types by text indexer
881
+ exports.bytesForRegions = bytesForRegions;
882
+ // supported adapter types by text indexer
1409
883
  // ensure that this matches the method found in @jbrowse/text-indexing/util
1410
-
1411
-
1412
884
  function supportedIndexingAdapters(type) {
1413
- return ['Gff3TabixAdapter', 'VcfTabixAdapter', 'Gff3Adapter', 'VcfAdapter'].includes(type);
885
+ return [
886
+ 'Gff3TabixAdapter',
887
+ 'VcfTabixAdapter',
888
+ 'Gff3Adapter',
889
+ 'VcfAdapter',
890
+ ].includes(type);
1414
891
  }
1415
-
892
+ exports.supportedIndexingAdapters = supportedIndexingAdapters;
1416
893
  function getBpDisplayStr(totalBp) {
1417
- var str;
1418
-
1419
- if (Math.floor(totalBp / 1000000) > 0) {
1420
- str = "".concat(parseFloat((totalBp / 1000000).toPrecision(3)), "Mbp");
1421
- } else if (Math.floor(totalBp / 1000) > 0) {
1422
- str = "".concat(parseFloat((totalBp / 1000).toPrecision(3)), "Kbp");
1423
- } else {
1424
- str = "".concat(toLocale(Math.floor(totalBp)), "bp");
1425
- }
1426
-
1427
- return str;
894
+ let str;
895
+ if (Math.floor(totalBp / 1000000) > 0) {
896
+ str = `${parseFloat((totalBp / 1000000).toPrecision(3))}Mbp`;
897
+ }
898
+ else if (Math.floor(totalBp / 1000) > 0) {
899
+ str = `${parseFloat((totalBp / 1000).toPrecision(3))}Kbp`;
900
+ }
901
+ else {
902
+ str = `${toLocale(Math.floor(totalBp))}bp`;
903
+ }
904
+ return str;
1428
905
  }
1429
-
906
+ exports.getBpDisplayStr = getBpDisplayStr;
1430
907
  function toLocale(n) {
1431
- return n.toLocaleString('en-US');
908
+ return n.toLocaleString('en-US');
1432
909
  }
1433
-
910
+ exports.toLocale = toLocale;
1434
911
  function getTickDisplayStr(totalBp, bpPerPx) {
1435
- var str;
1436
-
1437
- if (Math.floor(bpPerPx / 1000) > 0) {
1438
- str = "".concat(toLocale(parseFloat((totalBp / 1000000).toFixed(2))), "M");
1439
- } else {
1440
- str = "".concat(toLocale(Math.floor(totalBp)));
1441
- }
1442
-
1443
- return str;
912
+ let str;
913
+ if (Math.floor(bpPerPx / 1000) > 0) {
914
+ str = `${toLocale(parseFloat((totalBp / 1000000).toFixed(2)))}M`;
915
+ }
916
+ else {
917
+ str = `${toLocale(Math.floor(totalBp))}`;
918
+ }
919
+ return str;
1444
920
  }
1445
-
921
+ exports.getTickDisplayStr = getTickDisplayStr;
1446
922
  function getViewParams(model, exportSVG) {
1447
- // @ts-ignore
1448
- var _getContainingView = getContainingView(model),
1449
- dynamicBlocks = _getContainingView.dynamicBlocks,
1450
- staticBlocks = _getContainingView.staticBlocks,
1451
- offsetPx = _getContainingView.offsetPx;
1452
-
1453
- var b = (dynamicBlocks === null || dynamicBlocks === void 0 ? void 0 : dynamicBlocks.contentBlocks[0]) || {};
1454
- var staticblock = (staticBlocks === null || staticBlocks === void 0 ? void 0 : staticBlocks.contentBlocks[0]) || {};
1455
- var staticblock1 = (staticBlocks === null || staticBlocks === void 0 ? void 0 : staticBlocks.contentBlocks[1]) || {};
1456
- return {
1457
- offsetPx: exportSVG ? 0 : offsetPx - staticblock.offsetPx,
1458
- offsetPx1: exportSVG ? 0 : offsetPx - staticblock1.offsetPx,
1459
- start: b.start,
1460
- end: b.end
1461
- };
923
+ // @ts-ignore
924
+ const { dynamicBlocks, staticBlocks, offsetPx } = getContainingView(model);
925
+ const b = (dynamicBlocks === null || dynamicBlocks === void 0 ? void 0 : dynamicBlocks.contentBlocks[0]) || {};
926
+ const staticblock = (staticBlocks === null || staticBlocks === void 0 ? void 0 : staticBlocks.contentBlocks[0]) || {};
927
+ const staticblock1 = (staticBlocks === null || staticBlocks === void 0 ? void 0 : staticBlocks.contentBlocks[1]) || {};
928
+ return {
929
+ offsetPx: exportSVG ? 0 : offsetPx - staticblock.offsetPx,
930
+ offsetPx1: exportSVG ? 0 : offsetPx - staticblock1.offsetPx,
931
+ start: b.start,
932
+ end: b.end,
933
+ };
1462
934
  }
1463
-
1464
- function getLayoutId(_ref5) {
1465
- var sessionId = _ref5.sessionId,
1466
- layoutId = _ref5.layoutId;
1467
- return sessionId + '-' + layoutId;
1468
- }
935
+ exports.getViewParams = getViewParams;
936
+ function getLayoutId({ sessionId, layoutId, }) {
937
+ return sessionId + '-' + layoutId;
938
+ }
939
+ exports.getLayoutId = getLayoutId;
940
+ // similar to https://blog.logrocket.com/using-localstorage-react-hooks/
941
+ const useLocalStorage = (key, defaultValue = '') => {
942
+ const [value, setValue] = (0, react_1.useState)(() => localStorage.getItem(key) || defaultValue);
943
+ (0, react_1.useEffect)(() => {
944
+ localStorage.setItem(key, value);
945
+ }, [key, value]);
946
+ // without this cast, tsc complained that the type of setValue could be a
947
+ // string or a callback
948
+ return [value, setValue];
949
+ };
950
+ exports.useLocalStorage = useLocalStorage;
951
+ function getUriLink(value) {
952
+ const { uri, baseUri = '' } = value;
953
+ let href;
954
+ try {
955
+ href = new URL(uri, baseUri).href;
956
+ }
957
+ catch (e) {
958
+ href = uri;
959
+ }
960
+ return href;
961
+ }
962
+ exports.getUriLink = getUriLink;
963
+ function getStr(obj) {
964
+ return (0, is_object_1.default)(obj)
965
+ ? (0, types_2.isUriLocation)(obj)
966
+ ? getUriLink(obj)
967
+ : JSON.stringify(obj)
968
+ : String(obj);
969
+ }
970
+ exports.getStr = getStr;
971
+ // heuristic measurement for a column of a @mui/x-data-grid, pass in values from a column
972
+ function measureGridWidth(elements) {
973
+ return Math.max(...elements.map(element => Math.min(Math.max(measureText(getStr(element), 14) + 50, 80), 1000)));
974
+ }
975
+ exports.measureGridWidth = measureGridWidth;