@jbrowse/core 2.0.0 → 2.1.2

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