@jbrowse/core 1.4.1 → 1.5.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 (159) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +4 -4
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +27 -8
  3. package/BaseFeatureWidget/SequenceFeatureDetails.js +10 -10
  4. package/BaseFeatureWidget/index.js +1 -1
  5. package/BaseFeatureWidget/types.d.ts +1 -1
  6. package/BaseFeatureWidget/util.js +3 -3
  7. package/CorePlugin.d.ts +0 -1
  8. package/CorePlugin.js +13 -1
  9. package/PluginLoader.d.ts +26 -4
  10. package/PluginLoader.js +337 -51
  11. package/PluginManager.d.ts +18 -11
  12. package/PluginManager.js +53 -31
  13. package/ReExports/list.js +1 -1
  14. package/ReExports/material-ui-colors.js +38 -38
  15. package/ReExports/modules.d.ts +19 -20
  16. package/ReExports/modules.js +10 -3
  17. package/TextSearch/BaseResults.d.ts +5 -14
  18. package/TextSearch/BaseResults.js +16 -58
  19. package/TextSearch/BaseResults.test.js +1 -11
  20. package/TextSearch/TextSearchManager.d.ts +3 -3
  21. package/TextSearch/TextSearchManager.js +1 -1
  22. package/assemblyManager/assembly.d.ts +21 -8
  23. package/assemblyManager/assembly.js +163 -120
  24. package/assemblyManager/assemblyConfigSchema.d.ts +3 -0
  25. package/assemblyManager/{assemblyConfigSchemas.js → assemblyConfigSchema.js} +35 -27
  26. package/assemblyManager/assemblyManager.d.ts +169 -60
  27. package/assemblyManager/index.d.ts +1 -1
  28. package/assemblyManager/index.js +5 -5
  29. package/configuration/configurationSchema.d.ts +3 -2
  30. package/configuration/configurationSchema.js +7 -10
  31. package/configuration/configurationSchema.test.js +4 -2
  32. package/configuration/configurationSlot.js +5 -4
  33. package/configuration/index.js +4 -4
  34. package/configuration/util.js +5 -5
  35. package/data_adapters/BaseAdapter.d.ts +5 -3
  36. package/data_adapters/BaseAdapter.js +7 -4
  37. package/data_adapters/BaseAdapter.test.js +4 -2
  38. package/data_adapters/CytobandAdapter.d.ts +8 -0
  39. package/data_adapters/CytobandAdapter.js +128 -0
  40. package/data_adapters/dataAdapterCache.js +3 -3
  41. package/package.json +7 -6
  42. package/pluggableElementTypes/AdapterType.d.ts +9 -1
  43. package/pluggableElementTypes/AdapterType.js +20 -0
  44. package/pluggableElementTypes/InternetAccountType.d.ts +12 -0
  45. package/pluggableElementTypes/InternetAccountType.js +64 -0
  46. package/pluggableElementTypes/PluggableElementBase.d.ts +1 -2
  47. package/pluggableElementTypes/PluggableElementBase.js +2 -3
  48. package/pluggableElementTypes/RpcMethodType.d.ts +3 -0
  49. package/pluggableElementTypes/RpcMethodType.js +269 -26
  50. package/pluggableElementTypes/RpcMethodType.test.d.ts +4 -0
  51. package/pluggableElementTypes/RpcMethodType.test.js +118 -0
  52. package/pluggableElementTypes/ViewType.d.ts +1 -1
  53. package/pluggableElementTypes/WidgetType.d.ts +1 -0
  54. package/pluggableElementTypes/index.d.ts +7 -3
  55. package/pluggableElementTypes/index.js +127 -1
  56. package/pluggableElementTypes/models/BaseDisplayModel.d.ts +6 -6
  57. package/pluggableElementTypes/models/BaseDisplayModel.js +1 -3
  58. package/pluggableElementTypes/models/BaseViewModel.js +13 -15
  59. package/pluggableElementTypes/models/InternetAccountModel.d.ts +24 -0
  60. package/pluggableElementTypes/models/InternetAccountModel.js +85 -0
  61. package/pluggableElementTypes/models/baseInternetAccountConfig.d.ts +4 -0
  62. package/pluggableElementTypes/models/baseInternetAccountConfig.js +25 -0
  63. package/pluggableElementTypes/models/index.d.ts +3 -0
  64. package/pluggableElementTypes/models/index.js +24 -8
  65. package/pluggableElementTypes/renderers/BoxRendererType.js +1 -1
  66. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.d.ts +1 -1
  67. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +15 -6
  68. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +3 -3
  69. package/pluggableElementTypes/renderers/FeatureRendererType.js +17 -8
  70. package/pluggableElementTypes/renderers/RendererType.d.ts +1 -0
  71. package/pluggableElementTypes/renderers/RendererType.js +4 -1
  72. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +1 -1
  73. package/pluggableElementTypes/renderers/index.d.ts +9 -0
  74. package/pluggableElementTypes/renderers/index.js +63 -0
  75. package/rpc/BaseRpcDriver.js +5 -9
  76. package/rpc/BaseRpcDriver.test.js +6 -6
  77. package/rpc/RpcManager.d.ts +1 -1
  78. package/rpc/RpcManager.js +44 -16
  79. package/rpc/WebWorkerRpcDriver.js +3 -3
  80. package/rpc/coreRpcMethods.d.ts +2 -1
  81. package/rpc/coreRpcMethods.js +109 -75
  82. package/rpc/remoteAbortSignals.js +2 -2
  83. package/ui/App.d.ts +17 -4
  84. package/ui/App.js +55 -41
  85. package/ui/Drawer.d.ts +6 -14
  86. package/ui/Drawer.js +11 -12
  87. package/ui/DrawerWidget.d.ts +5 -3
  88. package/ui/DrawerWidget.js +100 -61
  89. package/ui/ErrorMessage.d.ts +5 -0
  90. package/ui/ErrorMessage.js +54 -0
  91. package/ui/FileSelector/FileSelector.d.ts +11 -0
  92. package/ui/FileSelector/FileSelector.js +198 -0
  93. package/ui/FileSelector/LocalFileChooser.d.ts +7 -0
  94. package/ui/FileSelector/LocalFileChooser.js +79 -0
  95. package/ui/FileSelector/UrlChooser.d.ts +9 -0
  96. package/ui/FileSelector/UrlChooser.js +41 -0
  97. package/ui/FileSelector/index.d.ts +2 -0
  98. package/ui/FileSelector/index.js +13 -0
  99. package/ui/Icons.d.ts +4 -0
  100. package/ui/Icons.js +34 -0
  101. package/ui/Logo.js +1 -1
  102. package/ui/PrerenderedCanvas.d.ts +1 -0
  103. package/ui/PrerenderedCanvas.js +4 -1
  104. package/ui/ResizeHandle.d.ts +2 -3
  105. package/ui/ResizeHandle.js +6 -7
  106. package/ui/SanitizedHTML.js +1 -1
  107. package/ui/Snackbar.js +4 -6
  108. package/ui/SnackbarModel.d.ts +16 -0
  109. package/ui/SnackbarModel.js +56 -0
  110. package/ui/Tooltip.d.ts +1 -1
  111. package/ui/index.js +24 -24
  112. package/ui/theme.js +5 -5
  113. package/util/QuickLRU.d.ts +1 -1
  114. package/util/QuickLRU.js +3 -3
  115. package/util/aborting.d.ts +1 -1
  116. package/util/aborting.js +10 -11
  117. package/util/analytics.d.ts +2 -2
  118. package/util/analytics.js +20 -7
  119. package/util/blockTypes.d.ts +11 -6
  120. package/util/blockTypes.js +7 -1
  121. package/util/color/cssColorsLevel4.js +1 -1
  122. package/util/color/index.js +5 -5
  123. package/util/compositeMap.js +3 -3
  124. package/util/index.d.ts +6 -16
  125. package/util/index.js +76 -100
  126. package/util/io/RemoteFileWithRangeCache.d.ts +17 -0
  127. package/util/io/RemoteFileWithRangeCache.js +266 -0
  128. package/util/io/index.d.ts +4 -2
  129. package/util/io/index.js +134 -25
  130. package/util/jexl.js +4 -1
  131. package/util/layouts/BaseLayout.d.ts +3 -0
  132. package/util/layouts/GranularRectLayout.d.ts +19 -10
  133. package/util/layouts/GranularRectLayout.js +459 -100
  134. package/util/layouts/GranularRectLayout.test.js +57 -10
  135. package/util/layouts/PrecomputedLayout.js +2 -1
  136. package/util/layouts/index.d.ts +7 -0
  137. package/util/layouts/index.js +68 -0
  138. package/util/mst-reflection.js +3 -3
  139. package/util/offscreenCanvasPonyfill.js +1 -1
  140. package/util/range.js +1 -1
  141. package/util/simpleFeature.js +1 -1
  142. package/util/stats.js +2 -2
  143. package/util/tracks.d.ts +31 -362
  144. package/util/tracks.js +74 -190
  145. package/util/types/index.d.ts +54 -10
  146. package/util/types/index.js +110 -8
  147. package/util/types/mst.d.ts +46 -2
  148. package/util/types/mst.js +56 -8
  149. package/util/types/util.d.ts +1 -1
  150. package/util/when.js +1 -1
  151. package/assemblyManager/assemblyConfigSchemas.d.ts +0 -7
  152. package/ui/FileSelector.d.ts +0 -9
  153. package/ui/FileSelector.js +0 -150
  154. package/util/io/LocalFile.d.ts +0 -18
  155. package/util/io/LocalFile.js +0 -220
  156. package/util/io/rangeFetcher.d.ts +0 -3
  157. package/util/io/rangeFetcher.js +0 -236
  158. package/value.d.ts +0 -1
  159. package/value.js +0 -10
package/util/io/index.js CHANGED
@@ -5,28 +5,27 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ Object.defineProperty(exports, "RemoteFileWithRangeCache", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _RemoteFileWithRangeCache.RemoteFileWithRangeCache;
12
+ }
13
+ });
8
14
  exports.openLocation = openLocation;
9
- exports.openUrl = void 0;
10
-
11
- var _genericFilehandle = require("generic-filehandle");
12
15
 
13
- var _LocalFile = _interopRequireDefault(require("./LocalFile"));
16
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
14
17
 
15
- var _rangeFetcher = require("./rangeFetcher");
18
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
16
19
 
17
- var _tracks = require("../tracks");
20
+ var _genericFilehandle = require("generic-filehandle");
18
21
 
19
- var _util = require("../../util");
22
+ var _RemoteFileWithRangeCache = require("./RemoteFileWithRangeCache");
20
23
 
21
- var openUrl = function openUrl(arg) {
22
- return (0, _rangeFetcher.openUrl)(arg);
23
- };
24
+ var _types = require("../types");
24
25
 
25
- exports.openUrl = openUrl;
26
+ var _tracks = require("../tracks");
26
27
 
27
- function isUriLocation(location) {
28
- return 'uri' in location;
29
- }
28
+ var _detectNode = _interopRequireDefault(require("detect-node"));
30
29
 
31
30
  function isLocalPathLocation(location) {
32
31
  return 'localPath' in location;
@@ -36,7 +35,51 @@ function isBlobLocation(location) {
36
35
  return 'blobId' in location;
37
36
  }
38
37
 
39
- function openLocation(location) {
38
+ function openLocation(location, pluginManager) {
39
+ function checkAuthNeededFetch(_x, _x2) {
40
+ return _checkAuthNeededFetch.apply(this, arguments);
41
+ }
42
+
43
+ function _checkAuthNeededFetch() {
44
+ _checkAuthNeededFetch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url, opts) {
45
+ var response, authHeaders;
46
+ return _regenerator.default.wrap(function _callee$(_context) {
47
+ while (1) {
48
+ switch (_context.prev = _context.next) {
49
+ case 0:
50
+ _context.next = 2;
51
+ return fetch(url, opts);
52
+
53
+ case 2:
54
+ response = _context.sent;
55
+
56
+ if (!(response.status === 401)) {
57
+ _context.next = 7;
58
+ break;
59
+ }
60
+
61
+ authHeaders = response.headers.get('WWW-Authenticate');
62
+
63
+ if (!((0, _types.isUriLocation)(location) && authHeaders && authHeaders.includes('Basic'))) {
64
+ _context.next = 7;
65
+ break;
66
+ }
67
+
68
+ throw new _types.AuthNeededError('Accessing HTTPBasic resource without authentication', location);
69
+
70
+ case 7:
71
+ return _context.abrupt("return", response);
72
+
73
+ case 8:
74
+ case "end":
75
+ return _context.stop();
76
+ }
77
+ }
78
+ }, _callee);
79
+ }));
80
+ return _checkAuthNeededFetch.apply(this, arguments);
81
+ }
82
+
40
83
  if (!location) {
41
84
  throw new Error('must provide a location to openLocation');
42
85
  }
@@ -46,21 +89,13 @@ function openLocation(location) {
46
89
  throw new Error('No local path provided');
47
90
  }
48
91
 
49
- if (_util.isElectron || typeof jest !== 'undefined') {
50
- return new _LocalFile.default(location.localPath);
92
+ if (_detectNode.default) {
93
+ return new _genericFilehandle.LocalFile(location.localPath);
51
94
  } else {
52
95
  throw new Error("can't use local files in the browser");
53
96
  }
54
97
  }
55
98
 
56
- if (isUriLocation(location)) {
57
- if (!location.uri) {
58
- throw new Error('No URI provided');
59
- }
60
-
61
- return openUrl(location.baseUri ? new URL(location.uri, location.baseUri).href : location.uri);
62
- }
63
-
64
99
  if (isBlobLocation(location)) {
65
100
  // special case where blob is not directly stored on the model, use a getter
66
101
  var blob = (0, _tracks.getBlob)(location.blobId);
@@ -72,5 +107,79 @@ function openLocation(location) {
72
107
  return new _genericFilehandle.BlobFile(blob);
73
108
  }
74
109
 
110
+ if ((0, _types.isUriLocation)(location)) {
111
+ if (!location.uri) {
112
+ throw new Error('No URI provided');
113
+ }
114
+
115
+ if (location.internetAccountPreAuthorization) {
116
+ if (!pluginManager) {
117
+ throw new Error('need plugin manager to open locations with an internet account');
118
+ }
119
+
120
+ var rootModel = pluginManager.rootModel;
121
+
122
+ if (rootModel && !(0, _types.isAppRootModel)(rootModel)) {
123
+ throw new Error('This context does not support internet accounts');
124
+ }
125
+
126
+ var internetAccount;
127
+
128
+ if (rootModel) {
129
+ internetAccount = rootModel.findAppropriateInternetAccount(location);
130
+ } else {
131
+ var internetAccountType = pluginManager.getInternetAccountType(location.internetAccountPreAuthorization.internetAccountType);
132
+ internetAccount = internetAccountType.stateModel.create({
133
+ type: location.internetAccountPreAuthorization.internetAccountType,
134
+ configuration: location.internetAccountPreAuthorization.authInfo.configuration
135
+ });
136
+
137
+ if (!location.internetAccountPreAuthorization.authInfo.token) {
138
+ throw new Error('Failed to obtain token from internet account. Try reloading the page');
139
+ }
140
+ }
141
+
142
+ if (!internetAccount) {
143
+ throw new Error('Could not find associated internet account');
144
+ }
145
+
146
+ return internetAccount.openLocation(location);
147
+ } else if (location.internetAccountId) {
148
+ if (!pluginManager) {
149
+ throw new Error('need plugin manager to open locations with an internet account');
150
+ }
151
+
152
+ var _rootModel = pluginManager.rootModel;
153
+
154
+ if (_rootModel && !(0, _types.isAppRootModel)(_rootModel)) {
155
+ throw new Error('This context does not support internet accounts');
156
+ }
157
+
158
+ if (_rootModel) {
159
+ var modifiedLocation = JSON.parse(JSON.stringify(location));
160
+
161
+ var _internetAccount = _rootModel.findAppropriateInternetAccount(location);
162
+
163
+ if (!_internetAccount) {
164
+ throw new Error('Could not find associated internet account');
165
+ }
166
+
167
+ _internetAccount.getPreAuthorizationInformation(location).then( // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
+ function (preAuthInfo) {
169
+ return modifiedLocation.internetAccountPreAuthorization = preAuthInfo;
170
+ });
171
+
172
+ return _internetAccount.openLocation(modifiedLocation);
173
+ }
174
+
175
+ throw new Error('Could not pre-authorize location');
176
+ }
177
+
178
+ var url = location.baseUri ? new URL(location.uri, location.baseUri).href : location.uri;
179
+ return new _RemoteFileWithRangeCache.RemoteFileWithRangeCache(url, {
180
+ fetch: checkAuthNeededFetch
181
+ });
182
+ }
183
+
75
184
  throw new Error('invalid fileLocation');
76
185
  }
package/util/jexl.js CHANGED
@@ -9,7 +9,9 @@ exports.default = _default;
9
9
 
10
10
  var _jexl = _interopRequireDefault(require("jexl"));
11
11
 
12
- function _default() {
12
+ function
13
+ /* config?: any*/
14
+ _default() {
13
15
  var j = new _jexl.default.Jexl(); // someday will make sure all of configs callbacks are added in, including
14
16
  // ones passed in
15
17
  // below are core functions
@@ -40,6 +42,7 @@ function _default() {
40
42
  j.addFunction('floor', Math.floor);
41
43
  j.addFunction('round', Math.round);
42
44
  j.addFunction('abs', Math.abs);
45
+ j.addFunction('log10', Math.log10);
43
46
  j.addFunction('parseInt', Number.parseInt);
44
47
  j.addFunction('parseFloat', Number.parseFloat); // string
45
48
 
@@ -10,11 +10,14 @@ export interface Rectangle<T> {
10
10
  r: number;
11
11
  top: number | null;
12
12
  h: number;
13
+ originalHeight: number;
13
14
  data?: Record<string, T>;
14
15
  }
15
16
  export interface BaseLayout<T> {
16
17
  addRect(id: string, left: number, right: number, height: number, data?: Record<string, T>): number | null;
17
18
  collides(rect: Rectangle<T>, top: number): boolean;
19
+ addRectToBitmap(rect: Rectangle<T>, data: Record<string, T>): void;
20
+ getRectangles(): Map<string, RectTuple>;
18
21
  discardRange(left: number, right: number): void;
19
22
  serializeRegion(region: {
20
23
  start: number;
@@ -1,38 +1,47 @@
1
- import { RectTuple, SerializedLayout, BaseLayout } from './BaseLayout';
1
+ import { RectTuple, SerializedLayout, Rectangle, BaseLayout } from './BaseLayout';
2
2
  export default class GranularRectLayout<T> implements BaseLayout<T> {
3
+ private pitchX;
4
+ private pitchY;
5
+ private hardRowLimit;
6
+ private bitmap;
3
7
  private rectangles;
4
8
  maxHeightReached: boolean;
5
9
  private maxHeight;
6
- private rbush;
7
- private spacing;
10
+ private displayMode;
8
11
  private pTotalHeight;
9
- private pitchX;
10
- constructor({ maxHeight, spacing, pitchX, }?: {
11
- maxHeight?: number;
12
- spacing?: number;
12
+ constructor({ pitchX, pitchY, maxHeight, hardRowLimit, displayMode, }?: {
13
13
  pitchX?: number;
14
+ pitchY?: number;
15
+ maxHeight?: number;
16
+ displayMode?: string;
17
+ hardRowLimit?: number;
14
18
  });
15
19
  /**
16
20
  * @returns top position for the rect, or Null if laying
17
21
  * out the rect would exceed maxHeight
18
22
  */
19
23
  addRect(id: string, left: number, right: number, height: number, data?: Record<string, T>): number | null;
20
- collides(): boolean;
24
+ collides(rect: Rectangle<T>, top: number): boolean;
25
+ /**
26
+ * make a subarray if it does not exist
27
+ */
28
+ private autovivifyRow;
29
+ addRectToBitmap(rect: Rectangle<T>): void;
21
30
  /**
22
31
  * Given a range of X coordinates, deletes all data dealing with
23
32
  * the features.
24
33
  */
25
- discardRange(): void;
34
+ discardRange(left: number, right: number): void;
26
35
  hasSeen(id: string): boolean;
27
36
  getByCoord(x: number, y: number): Record<string, T> | string | undefined;
28
37
  getByID(id: string): RectTuple | undefined;
29
38
  cleanup(): void;
30
39
  getTotalHeight(): number;
31
40
  get totalHeight(): number;
41
+ getRectangles(): Map<string, RectTuple>;
32
42
  serializeRegion(region: {
33
43
  start: number;
34
44
  end: number;
35
45
  }): SerializedLayout;
36
- getRectangles(): Map<string, RectTuple>;
37
46
  toJSON(): SerializedLayout;
38
47
  }