@jbrowse/core 1.7.11 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +20 -4
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +313 -558
  3. package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -473
  4. package/BaseFeatureWidget/index.d.ts +2 -2
  5. package/BaseFeatureWidget/index.js +88 -124
  6. package/BaseFeatureWidget/types.d.ts +1 -0
  7. package/BaseFeatureWidget/types.js +1 -4
  8. package/BaseFeatureWidget/util.js +40 -75
  9. package/CorePlugin.js +55 -94
  10. package/Plugin.js +9 -34
  11. package/PluginLoader.js +153 -422
  12. package/PluginManager.d.ts +84 -117
  13. package/PluginManager.js +377 -666
  14. package/ReExports/Attributes.d.ts +2 -0
  15. package/ReExports/Attributes.js +5 -0
  16. package/ReExports/BaseCard.d.ts +2 -0
  17. package/ReExports/BaseCard.js +5 -0
  18. package/ReExports/DataGrid.d.ts +2 -0
  19. package/ReExports/DataGrid.js +6 -0
  20. package/ReExports/FeatureDetails.d.ts +2 -0
  21. package/ReExports/FeatureDetails.js +5 -0
  22. package/ReExports/index.js +6 -12
  23. package/ReExports/list.d.ts +5 -0
  24. package/ReExports/list.js +271 -7
  25. package/ReExports/material-ui-colors.d.ts +1 -19
  26. package/ReExports/material-ui-colors.js +16 -158
  27. package/ReExports/modules.d.ts +68 -109
  28. package/ReExports/modules.js +455 -244
  29. package/TextSearch/BaseResults.js +51 -123
  30. package/TextSearch/TextSearchManager.d.ts +3 -1
  31. package/TextSearch/TextSearchManager.js +66 -144
  32. package/assemblyManager/assembly.js +280 -554
  33. package/assemblyManager/assemblyConfigSchema.js +47 -64
  34. package/assemblyManager/assemblyManager.d.ts +12 -10
  35. package/assemblyManager/assemblyManager.js +126 -270
  36. package/assemblyManager/index.js +9 -22
  37. package/configuration/configurationSchema.js +167 -203
  38. package/configuration/configurationSlot.js +248 -326
  39. package/configuration/index.js +19 -35
  40. package/configuration/util.d.ts +1 -1
  41. package/configuration/util.js +131 -173
  42. package/data_adapters/BaseAdapter.d.ts +2 -2
  43. package/data_adapters/BaseAdapter.js +132 -521
  44. package/data_adapters/CytobandAdapter.js +40 -126
  45. package/data_adapters/dataAdapterCache.js +77 -158
  46. package/package.json +16 -18
  47. package/pluggableElementTypes/AdapterType.js +24 -79
  48. package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
  49. package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
  50. package/pluggableElementTypes/ConnectionType.js +22 -65
  51. package/pluggableElementTypes/DisplayType.js +35 -82
  52. package/pluggableElementTypes/InternetAccountType.js +23 -64
  53. package/pluggableElementTypes/PluggableElementBase.js +8 -20
  54. package/pluggableElementTypes/RpcMethodType.js +85 -427
  55. package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
  56. package/pluggableElementTypes/TrackType.js +26 -70
  57. package/pluggableElementTypes/ViewType.js +21 -63
  58. package/pluggableElementTypes/WidgetType.js +21 -64
  59. package/pluggableElementTypes/index.d.ts +4 -3
  60. package/pluggableElementTypes/index.js +42 -125
  61. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
  62. package/pluggableElementTypes/models/BaseDisplayModel.d.ts +10 -10
  63. package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
  64. package/pluggableElementTypes/models/BaseTrackModel.d.ts +1 -1
  65. package/pluggableElementTypes/models/BaseTrackModel.js +139 -200
  66. package/pluggableElementTypes/models/BaseViewModel.js +24 -40
  67. package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
  68. package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
  69. package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
  70. package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
  71. package/pluggableElementTypes/models/index.js +21 -70
  72. package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
  73. package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
  74. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
  75. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
  76. package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -255
  77. package/pluggableElementTypes/renderers/RendererType.js +31 -105
  78. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
  79. package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +2 -2
  80. package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
  81. package/pluggableElementTypes/renderers/index.js +19 -62
  82. package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
  83. package/rpc/BaseRpcDriver.js +169 -405
  84. package/rpc/MainThreadRpcDriver.js +27 -150
  85. package/rpc/RpcManager.js +58 -159
  86. package/rpc/WebWorkerRpcDriver.js +54 -171
  87. package/rpc/configSchema.js +25 -49
  88. package/rpc/coreRpcMethods.d.ts +1 -3
  89. package/rpc/coreRpcMethods.js +221 -959
  90. package/rpc/remoteAbortSignals.js +46 -70
  91. package/tsconfig.build.tsbuildinfo +1 -1
  92. package/ui/AboutDialog.js +107 -158
  93. package/ui/App.js +157 -261
  94. package/ui/AssemblySelector.d.ts +1 -1
  95. package/ui/AssemblySelector.js +59 -115
  96. package/ui/CascadingMenu.js +100 -199
  97. package/ui/ColorPicker.d.ts +16 -0
  98. package/ui/ColorPicker.js +97 -0
  99. package/ui/Drawer.js +28 -58
  100. package/ui/DrawerWidget.js +109 -209
  101. package/ui/DropDownMenu.d.ts +0 -8
  102. package/ui/DropDownMenu.js +60 -97
  103. package/ui/EditableTypography.d.ts +1 -1
  104. package/ui/EditableTypography.js +87 -155
  105. package/ui/ErrorMessage.js +41 -66
  106. package/ui/FactoryResetDialog.js +24 -57
  107. package/ui/FatalErrorDialog.js +59 -91
  108. package/ui/FileSelector/FileSelector.js +123 -189
  109. package/ui/FileSelector/LocalFileChooser.js +44 -71
  110. package/ui/FileSelector/UrlChooser.js +17 -38
  111. package/ui/FileSelector/index.js +6 -12
  112. package/ui/Icons.d.ts +1 -1
  113. package/ui/Icons.js +45 -69
  114. package/ui/Logo.js +57 -110
  115. package/ui/Menu.d.ts +1 -1
  116. package/ui/Menu.js +232 -355
  117. package/ui/PrerenderedCanvas.js +63 -78
  118. package/ui/ResizeHandle.js +87 -114
  119. package/ui/ReturnToImportFormDialog.js +32 -59
  120. package/ui/SanitizedHTML.js +63 -52
  121. package/ui/Snackbar.js +74 -99
  122. package/ui/SnackbarModel.js +37 -51
  123. package/ui/Tooltip.d.ts +3 -1
  124. package/ui/Tooltip.js +49 -74
  125. package/ui/ViewContainer.js +113 -183
  126. package/ui/colors.d.ts +10 -0
  127. package/ui/colors.js +78 -0
  128. package/ui/index.js +51 -181
  129. package/ui/react-colorful.d.ts +17 -0
  130. package/ui/react-colorful.js +455 -0
  131. package/ui/theme.d.ts +279 -131
  132. package/ui/theme.js +197 -225
  133. package/util/Base1DUtils.d.ts +32 -0
  134. package/util/Base1DUtils.js +174 -0
  135. package/util/Base1DViewModel.d.ts +16 -37
  136. package/util/Base1DViewModel.js +116 -295
  137. package/util/QuickLRU.js +84 -332
  138. package/util/TimeTraveller.d.ts +19 -0
  139. package/util/TimeTraveller.js +86 -0
  140. package/util/aborting.js +49 -127
  141. package/util/analytics.js +91 -154
  142. package/util/blockTypes.js +106 -240
  143. package/util/calculateDynamicBlocks.js +98 -128
  144. package/util/calculateStaticBlocks.js +105 -125
  145. package/util/color/cssColorsLevel4.js +156 -160
  146. package/util/color/index.js +33 -55
  147. package/util/compositeMap.js +49 -333
  148. package/util/formatFastaStrings.js +9 -14
  149. package/util/idMaker.js +18 -31
  150. package/util/index.d.ts +18 -39
  151. package/util/index.js +743 -1236
  152. package/util/io/RemoteFileWithRangeCache.js +88 -257
  153. package/util/io/index.js +95 -169
  154. package/util/jexl.js +60 -115
  155. package/util/jexlStrings.js +24 -29
  156. package/util/layouts/BaseLayout.js +1 -4
  157. package/util/layouts/GranularRectLayout.js +388 -557
  158. package/util/layouts/MultiLayout.js +41 -109
  159. package/util/layouts/PrecomputedLayout.js +56 -114
  160. package/util/layouts/PrecomputedMultiLayout.js +22 -59
  161. package/util/layouts/SceneGraph.js +127 -197
  162. package/util/layouts/index.js +29 -66
  163. package/util/mst-reflection.js +55 -71
  164. package/util/offscreenCanvasPonyfill.js +66 -134
  165. package/util/offscreenCanvasUtils.d.ts +2 -7
  166. package/util/offscreenCanvasUtils.js +49 -146
  167. package/util/range.js +29 -40
  168. package/util/rxjs.js +20 -27
  169. package/util/simpleFeature.js +88 -152
  170. package/util/stats.js +91 -151
  171. package/util/tracks.js +130 -171
  172. package/util/types/index.d.ts +3 -3
  173. package/util/types/index.js +110 -179
  174. package/util/types/mst.d.ts +3 -3
  175. package/util/types/mst.js +91 -142
  176. package/util/types/util.js +1 -4
  177. package/util/when.js +54 -101
  178. package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
  179. package/BaseFeatureWidget/index.test.js +0 -51
  180. package/TextSearch/BaseResults.test.js +0 -42
  181. package/configuration/configurationSchema.test.js +0 -266
  182. package/configuration/configurationSlot.test.js +0 -69
  183. package/configuration/util.test.js +0 -39
  184. package/data_adapters/BaseAdapter.test.js +0 -200
  185. package/declare.d.js +0 -1
  186. package/pluggableElementTypes/RpcMethodType.test.js +0 -118
  187. package/pluggableElementTypes/renderers/declare.d.js +0 -1
  188. package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
  189. package/rpc/BaseRpcDriver.test.js +0 -540
  190. package/rpc/declaration.d.js +0 -1
  191. package/ui/FatalErrorDialog.test.js +0 -82
  192. package/ui/SanitizedHTML.test.js +0 -36
  193. package/ui/theme.test.js +0 -111
  194. package/util/Base1DViewModel.test.js +0 -130
  195. package/util/calculateDynamicBlocks.test.js +0 -74
  196. package/util/calculateStaticBlocks.test.js +0 -297
  197. package/util/declare.d.js +0 -1
  198. package/util/formatFastaStrings.test.js +0 -40
  199. package/util/index.test.js +0 -213
  200. package/util/jexlStrings.test.js +0 -48
  201. package/util/layouts/GranularRectLayout.test.js +0 -99
  202. package/util/range.test.js +0 -64
  203. package/util/simpleFeature.test.js +0 -34
  204. package/util/stats.test.js +0 -172
@@ -1,127 +1,91 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.InternetAccount = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
-
16
- var _mobxStateTree = require("mobx-state-tree");
17
-
18
- var _configuration = require("../../configuration");
19
-
20
- var _io = require("../../util/io");
21
-
22
- var _mst = require("../../util/types/mst");
23
-
24
- 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; }
25
-
26
- 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; }
27
-
28
- var inWebWorker = typeof sessionStorage === 'undefined';
29
-
30
- var InternetAccount = _mobxStateTree.types.model('InternetAccount', {
31
- id: _mst.ElementId,
32
- type: _mobxStateTree.types.string
33
- }).views(function (self) {
34
- return {
4
+ const mobx_state_tree_1 = require("mobx-state-tree");
5
+ const configuration_1 = require("../../configuration");
6
+ const io_1 = require("../../util/io");
7
+ const mst_1 = require("../../util/types/mst");
8
+ const inWebWorker = typeof sessionStorage === 'undefined';
9
+ exports.InternetAccount = mobx_state_tree_1.types
10
+ .model('InternetAccount', {
11
+ id: mst_1.ElementId,
12
+ type: mobx_state_tree_1.types.string,
13
+ })
14
+ .views(self => ({
35
15
  get name() {
36
- return (0, _configuration.getConf)(self, 'name');
16
+ return (0, configuration_1.getConf)(self, 'name');
37
17
  },
38
-
39
18
  get description() {
40
- return (0, _configuration.getConf)(self, 'description');
19
+ return (0, configuration_1.getConf)(self, 'description');
41
20
  },
42
-
43
21
  get internetAccountId() {
44
- return (0, _configuration.getConf)(self, 'internetAccountId');
22
+ return (0, configuration_1.getConf)(self, 'internetAccountId');
45
23
  },
46
-
47
24
  get authHeader() {
48
- return (0, _configuration.getConf)(self, 'authHeader');
25
+ return (0, configuration_1.getConf)(self, 'authHeader');
49
26
  },
50
-
51
27
  get tokenType() {
52
- return (0, _configuration.getConf)(self, 'tokenType');
28
+ return (0, configuration_1.getConf)(self, 'tokenType');
53
29
  },
54
-
55
30
  get domains() {
56
- return (0, _configuration.getConf)(self, 'domains');
31
+ return (0, configuration_1.getConf)(self, 'domains');
57
32
  },
58
-
59
33
  /**
60
34
  * Can use this to customize what is displayed in fileSelector's toggle box
61
35
  */
62
36
  get toggleContents() {
63
- return null;
37
+ return null;
64
38
  },
65
-
66
39
  /**
67
40
  * Can use this to customize what the fileSelector. It takes a prop called
68
41
  * `setLocation` that should be used to set a UriLocation
69
42
  */
70
43
  get SelectorComponent() {
71
- return undefined;
44
+ return undefined;
72
45
  },
73
-
74
46
  /**
75
47
  * Can use this to add a label to the UrlChooser. Has no effect if a custom
76
48
  * SelectorComponent is supplied
77
49
  */
78
50
  get selectorLabel() {
79
- return undefined;
80
- }
81
-
82
- };
83
- }).views(function (self) {
84
- return {
51
+ return undefined;
52
+ },
53
+ }))
54
+ .views(self => ({
85
55
  /**
86
56
  * Determine whether this internetAccount provides credentials for a URL
87
57
  * @param location - UriLocation of resource
88
58
  * @returns true or false
89
59
  */
90
- handlesLocation: function handlesLocation(location) {
91
- return self.domains.some(function (domain) {
92
- return location === null || location === void 0 ? void 0 : location.uri.includes(domain);
93
- });
60
+ handlesLocation(location) {
61
+ return self.domains.some((domain) => location === null || location === void 0 ? void 0 : location.uri.includes(domain));
94
62
  },
95
-
96
63
  /**
97
64
  * The key used to store this internetAccount's token in sessionStorage
98
65
  */
99
66
  get tokenKey() {
100
- return "".concat(self.internetAccountId, "-token");
101
- }
102
-
103
- };
104
- }).actions(function (self) {
105
- return {
67
+ return `${self.internetAccountId}-token`;
68
+ },
69
+ }))
70
+ .actions(self => ({
106
71
  /**
107
72
  * Must be implemented by a model extending or composing this one. Pass the
108
73
  * user's token to `resolve`.
109
74
  * @param resolve - Pass the token to this function
110
75
  * @param reject - If there is an error getting the token, call this function
111
76
  */
112
- getTokenFromUser: function getTokenFromUser(resolve, reject) {
113
- throw new Error('getTokenFromUser must be implemented by extending model');
77
+ getTokenFromUser(resolve, reject) {
78
+ throw new Error('getTokenFromUser must be implemented by extending model');
114
79
  },
115
- storeToken: function storeToken(token) {
116
- sessionStorage.setItem(self.tokenKey, token);
80
+ storeToken(token) {
81
+ sessionStorage.setItem(self.tokenKey, token);
117
82
  },
118
- removeToken: function removeToken() {
119
- sessionStorage.removeItem(self.tokenKey);
83
+ removeToken() {
84
+ sessionStorage.removeItem(self.tokenKey);
120
85
  },
121
- retrieveToken: function retrieveToken() {
122
- return sessionStorage.getItem(self.tokenKey);
86
+ retrieveToken() {
87
+ return sessionStorage.getItem(self.tokenKey);
123
88
  },
124
-
125
89
  /**
126
90
  * This can be used by an internetAccount to validate a token works before
127
91
  * it is used. This is run when preAuthorizationInformation is requested, so
@@ -134,170 +98,85 @@ var InternetAccount = _mobxStateTree.types.model('InternetAccount', {
134
98
  * @param location - UriLocation of the resource
135
99
  * @returns - Valid auth token
136
100
  */
137
- validateToken: function validateToken(token, location) {
138
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
139
- return _regenerator.default.wrap(function _callee$(_context) {
140
- while (1) {
141
- switch (_context.prev = _context.next) {
142
- case 0:
143
- return _context.abrupt("return", token);
144
-
145
- case 1:
146
- case "end":
147
- return _context.stop();
101
+ async validateToken(token, location) {
102
+ return token;
103
+ },
104
+ }))
105
+ .actions(self => {
106
+ let tokenPromise = undefined;
107
+ return {
108
+ /**
109
+ * Try to get the token from the location pre-auth, from local storage,
110
+ * or from a previously cached promise. If token is not available, uses
111
+ * `getTokenFromUser`.
112
+ * @param location - UriLocation of the resource
113
+ * @returns A promise for the token
114
+ */
115
+ async getToken(location) {
116
+ var _a, _b;
117
+ if (tokenPromise) {
118
+ return tokenPromise;
148
119
  }
149
- }
150
- }, _callee);
151
- }))();
152
- }
153
- };
154
- }).actions(function (self) {
155
- var tokenPromise = undefined;
156
- return {
157
- /**
158
- * Try to get the token from the location pre-auth, from local storage,
159
- * or from a previously cached promise. If token is not available, uses
160
- * `getTokenFromUser`.
161
- * @param location - UriLocation of the resource
162
- * @returns A promise for the token
163
- */
164
- getToken: function getToken(location) {
165
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
166
- var _location$internetAcc, _location$internetAcc2;
167
-
168
- var token;
169
- return _regenerator.default.wrap(function _callee2$(_context2) {
170
- while (1) {
171
- switch (_context2.prev = _context2.next) {
172
- case 0:
173
- if (!tokenPromise) {
174
- _context2.next = 2;
175
- break;
176
- }
177
-
178
- return _context2.abrupt("return", tokenPromise);
179
-
180
- case 2:
181
- token = location === null || location === void 0 ? void 0 : (_location$internetAcc = location.internetAccountPreAuthorization) === null || _location$internetAcc === void 0 ? void 0 : (_location$internetAcc2 = _location$internetAcc.authInfo) === null || _location$internetAcc2 === void 0 ? void 0 : _location$internetAcc2.token;
182
-
183
- if (!token) {
184
- _context2.next = 6;
185
- break;
186
- }
187
-
120
+ let token = (_b = (_a = location === null || location === void 0 ? void 0 : location.internetAccountPreAuthorization) === null || _a === void 0 ? void 0 : _a.authInfo) === null || _b === void 0 ? void 0 : _b.token;
121
+ if (token) {
188
122
  tokenPromise = Promise.resolve(token);
189
- return _context2.abrupt("return", tokenPromise);
190
-
191
- case 6:
192
- if (!inWebWorker) {
193
- _context2.next = 8;
194
- break;
195
- }
196
-
123
+ return tokenPromise;
124
+ }
125
+ if (inWebWorker) {
197
126
  throw new Error('Did not get internet account pre-authorization info in worker');
198
-
199
- case 8:
200
- token = self.retrieveToken();
201
-
202
- if (!token) {
203
- _context2.next = 12;
204
- break;
205
- }
206
-
127
+ }
128
+ token = self.retrieveToken();
129
+ if (token) {
207
130
  tokenPromise = Promise.resolve(token);
208
- return _context2.abrupt("return", tokenPromise);
209
-
210
- case 12:
211
- tokenPromise = new Promise(function (r, x) {
212
- function resolve(token) {
131
+ return tokenPromise;
132
+ }
133
+ tokenPromise = new Promise((r, x) => {
134
+ function resolve(token) {
213
135
  self.storeToken(token);
214
136
  r(token);
215
- }
216
-
217
- function reject(error) {
137
+ }
138
+ function reject(error) {
218
139
  self.removeToken();
219
140
  x(error);
220
- }
221
-
222
- self.getTokenFromUser(resolve, reject);
223
- });
224
- return _context2.abrupt("return", tokenPromise);
225
-
226
- case 14:
227
- case "end":
228
- return _context2.stop();
229
- }
230
- }
231
- }, _callee2);
232
- }))();
233
- }
234
- };
235
- }).actions(function (self) {
236
- return {
237
- addAuthHeaderToInit: function addAuthHeaderToInit() {
238
- var init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
239
- var token = arguments.length > 1 ? arguments[1] : undefined;
240
- var tokenInfoString = self.tokenType ? "".concat(self.tokenType, " ").concat(token) : token;
241
- var newHeaders = new Headers(init.headers || {});
242
- newHeaders.append(self.authHeader, tokenInfoString);
243
- return _objectSpread(_objectSpread({}, init), {}, {
244
- headers: newHeaders
245
- });
141
+ }
142
+ self.getTokenFromUser(resolve, reject);
143
+ });
144
+ return tokenPromise;
145
+ },
146
+ };
147
+ })
148
+ .actions(self => ({
149
+ addAuthHeaderToInit(init = {}, token) {
150
+ const tokenInfoString = self.tokenType
151
+ ? `${self.tokenType} ${token}`
152
+ : token;
153
+ const newHeaders = new Headers(init.headers || {});
154
+ newHeaders.append(self.authHeader, tokenInfoString);
155
+ return { ...init, headers: newHeaders };
246
156
  },
247
-
248
157
  /**
249
158
  * Gets the token and returns it along with the information needed to
250
159
  * create a new internetAccount.
251
160
  * @param location - UriLocation of the resource
252
161
  * @returns
253
162
  */
254
- getPreAuthorizationInformation: function getPreAuthorizationInformation(location) {
255
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
256
- var authToken, validatedToken;
257
- return _regenerator.default.wrap(function _callee3$(_context3) {
258
- while (1) {
259
- switch (_context3.prev = _context3.next) {
260
- case 0:
261
- _context3.next = 2;
262
- return self.getToken(location);
263
-
264
- case 2:
265
- authToken = _context3.sent;
266
- _context3.prev = 3;
267
- _context3.next = 6;
268
- return self.validateToken(authToken, location);
269
-
270
- case 6:
271
- validatedToken = _context3.sent;
272
- _context3.next = 13;
273
- break;
274
-
275
- case 9:
276
- _context3.prev = 9;
277
- _context3.t0 = _context3["catch"](3);
278
- self.removeToken();
279
- throw _context3.t0;
280
-
281
- case 13:
282
- return _context3.abrupt("return", {
283
- internetAccountType: self.type,
284
- authInfo: {
285
- token: validatedToken,
286
- configuration: (0, _configuration.getConf)(self)
287
- }
288
- });
289
-
290
- case 14:
291
- case "end":
292
- return _context3.stop();
293
- }
294
- }
295
- }, _callee3, null, [[3, 9]]);
296
- }))();
297
- }
298
- };
299
- }).actions(function (self) {
300
- return {
163
+ async getPreAuthorizationInformation(location) {
164
+ const authToken = await self.getToken(location);
165
+ let validatedToken;
166
+ try {
167
+ validatedToken = await self.validateToken(authToken, location);
168
+ }
169
+ catch (error) {
170
+ self.removeToken();
171
+ throw error;
172
+ }
173
+ return {
174
+ internetAccountType: self.type,
175
+ authInfo: { token: validatedToken, configuration: (0, configuration_1.getConf)(self) },
176
+ };
177
+ },
178
+ }))
179
+ .actions(self => ({
301
180
  /**
302
181
  * Get a fetch method that will add any needed authentication headers to
303
182
  * the request before sending it. If location is provided, it will be
@@ -305,49 +184,23 @@ var InternetAccount = _mobxStateTree.types.model('InternetAccount', {
305
184
  * @param location - UriLocation of the resource
306
185
  * @returns A function that can be used to fetch
307
186
  */
308
- getFetcher: function getFetcher(location) {
309
- return /*#__PURE__*/function () {
310
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(input, init) {
311
- var authToken, newInit;
312
- return _regenerator.default.wrap(function _callee4$(_context4) {
313
- while (1) {
314
- switch (_context4.prev = _context4.next) {
315
- case 0:
316
- _context4.next = 2;
317
- return self.getToken(location);
318
-
319
- case 2:
320
- authToken = _context4.sent;
321
- newInit = self.addAuthHeaderToInit(init, authToken);
322
- return _context4.abrupt("return", fetch(input, newInit));
323
-
324
- case 5:
325
- case "end":
326
- return _context4.stop();
327
- }
328
- }
329
- }, _callee4);
330
- }));
331
-
332
- return function (_x, _x2) {
333
- return _ref.apply(this, arguments);
187
+ getFetcher(location) {
188
+ return async (input, init) => {
189
+ const authToken = await self.getToken(location);
190
+ const newInit = self.addAuthHeaderToInit(init, authToken);
191
+ return fetch(input, newInit);
334
192
  };
335
- }();
336
- }
337
- };
338
- }).actions(function (self) {
339
- return {
193
+ },
194
+ }))
195
+ .actions(self => ({
340
196
  /**
341
197
  * Gets a filehandle that uses a fetch that adds auth headers
342
198
  * @param location - UriLocation of the resource
343
199
  * @returns A filehandle
344
200
  */
345
- openLocation: function openLocation(location) {
346
- return new _io.RemoteFileWithRangeCache(location.uri, {
347
- fetch: self.getFetcher(location)
348
- });
349
- }
350
- };
351
- });
352
-
353
- exports.InternetAccount = InternetAccount;
201
+ openLocation(location) {
202
+ return new io_1.RemoteFileWithRangeCache(location.uri, {
203
+ fetch: self.getFetcher(location),
204
+ });
205
+ },
206
+ }));
@@ -1,26 +1,15 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _configuration = require("../../configuration");
9
-
10
- var _default = (0, _configuration.ConfigurationSchema)('BaseConnection', {
11
- name: {
12
- type: 'string',
13
- defaultValue: 'nameOfConnection',
14
- description: 'a unique name for this connection'
15
- },
16
- assemblyNames: {
17
- type: 'stringArray',
18
- defaultValue: [],
19
- description: 'optional list of names of assemblies in this connection'
20
- }
21
- }, {
22
- explicitlyTyped: true,
23
- explicitIdentifier: 'connectionId'
24
- });
25
-
26
- exports.default = _default;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const configuration_1 = require("../../configuration");
4
+ exports.default = (0, configuration_1.ConfigurationSchema)('BaseConnection', {
5
+ name: {
6
+ type: 'string',
7
+ defaultValue: 'nameOfConnection',
8
+ description: 'a unique name for this connection',
9
+ },
10
+ assemblyNames: {
11
+ type: 'stringArray',
12
+ defaultValue: [],
13
+ description: 'optional list of names of assemblies in this connection',
14
+ },
15
+ }, { explicitlyTyped: true, explicitIdentifier: 'connectionId' });
@@ -1,40 +1,31 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.BaseInternetAccountConfig = void 0;
7
-
8
- var _configuration = require("../../configuration");
9
-
10
- var BaseInternetAccountConfig = (0, _configuration.ConfigurationSchema)('InternetAccount', {
11
- name: {
12
- description: 'descriptive name of the internet account',
13
- type: 'string',
14
- defaultValue: ''
15
- },
16
- description: {
17
- description: 'a description of the internet account',
18
- type: 'string',
19
- defaultValue: ''
20
- },
21
- authHeader: {
22
- description: 'request header for credentials',
23
- type: 'string',
24
- defaultValue: 'Authorization'
25
- },
26
- tokenType: {
27
- description: 'a custom name for a token to include in the header',
28
- type: 'string',
29
- defaultValue: ''
30
- },
31
- domains: {
32
- description: 'array of valid domains the url can contain to use this account',
33
- type: 'stringArray',
34
- defaultValue: []
35
- }
36
- }, {
37
- explicitIdentifier: 'internetAccountId',
38
- explicitlyTyped: true
39
- });
40
- exports.BaseInternetAccountConfig = BaseInternetAccountConfig;
4
+ const configuration_1 = require("../../configuration");
5
+ exports.BaseInternetAccountConfig = (0, configuration_1.ConfigurationSchema)('InternetAccount', {
6
+ name: {
7
+ description: 'descriptive name of the internet account',
8
+ type: 'string',
9
+ defaultValue: '',
10
+ },
11
+ description: {
12
+ description: 'a description of the internet account',
13
+ type: 'string',
14
+ defaultValue: '',
15
+ },
16
+ authHeader: {
17
+ description: 'request header for credentials',
18
+ type: 'string',
19
+ defaultValue: 'Authorization',
20
+ },
21
+ tokenType: {
22
+ description: 'a custom name for a token to include in the header',
23
+ type: 'string',
24
+ defaultValue: '',
25
+ },
26
+ domains: {
27
+ description: 'array of valid domains the url can contain to use this account',
28
+ type: 'stringArray',
29
+ defaultValue: [],
30
+ },
31
+ }, { explicitIdentifier: 'internetAccountId', explicitlyTyped: true });