@jbrowse/core 2.0.1 → 2.1.0

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