@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.
- package/BaseFeatureWidget/BaseFeatureDetail.d.ts +20 -4
- package/BaseFeatureWidget/BaseFeatureDetail.js +313 -558
- package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -473
- package/BaseFeatureWidget/index.d.ts +2 -2
- package/BaseFeatureWidget/index.js +88 -124
- package/BaseFeatureWidget/types.d.ts +1 -0
- package/BaseFeatureWidget/types.js +1 -4
- package/BaseFeatureWidget/util.js +40 -75
- package/CorePlugin.js +55 -94
- package/Plugin.js +9 -34
- package/PluginLoader.js +153 -422
- package/PluginManager.d.ts +84 -117
- package/PluginManager.js +377 -666
- package/ReExports/Attributes.d.ts +2 -0
- package/ReExports/Attributes.js +5 -0
- package/ReExports/BaseCard.d.ts +2 -0
- package/ReExports/BaseCard.js +5 -0
- package/ReExports/DataGrid.d.ts +2 -0
- package/ReExports/DataGrid.js +6 -0
- package/ReExports/FeatureDetails.d.ts +2 -0
- package/ReExports/FeatureDetails.js +5 -0
- package/ReExports/index.js +6 -12
- package/ReExports/list.d.ts +5 -0
- package/ReExports/list.js +271 -7
- package/ReExports/material-ui-colors.d.ts +1 -19
- package/ReExports/material-ui-colors.js +16 -158
- package/ReExports/modules.d.ts +68 -109
- package/ReExports/modules.js +455 -244
- package/TextSearch/BaseResults.js +51 -123
- package/TextSearch/TextSearchManager.d.ts +3 -1
- package/TextSearch/TextSearchManager.js +66 -144
- package/assemblyManager/assembly.js +280 -554
- package/assemblyManager/assemblyConfigSchema.js +47 -64
- package/assemblyManager/assemblyManager.d.ts +12 -10
- package/assemblyManager/assemblyManager.js +126 -270
- package/assemblyManager/index.js +9 -22
- package/configuration/configurationSchema.js +167 -203
- package/configuration/configurationSlot.js +248 -326
- package/configuration/index.js +19 -35
- package/configuration/util.d.ts +1 -1
- package/configuration/util.js +131 -173
- package/data_adapters/BaseAdapter.d.ts +2 -2
- package/data_adapters/BaseAdapter.js +132 -521
- package/data_adapters/CytobandAdapter.js +40 -126
- package/data_adapters/dataAdapterCache.js +77 -158
- package/package.json +16 -18
- package/pluggableElementTypes/AdapterType.js +24 -79
- package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
- package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
- package/pluggableElementTypes/ConnectionType.js +22 -65
- package/pluggableElementTypes/DisplayType.js +35 -82
- package/pluggableElementTypes/InternetAccountType.js +23 -64
- package/pluggableElementTypes/PluggableElementBase.js +8 -20
- package/pluggableElementTypes/RpcMethodType.js +85 -427
- package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
- package/pluggableElementTypes/TrackType.js +26 -70
- package/pluggableElementTypes/ViewType.js +21 -63
- package/pluggableElementTypes/WidgetType.js +21 -64
- package/pluggableElementTypes/index.d.ts +4 -3
- package/pluggableElementTypes/index.js +42 -125
- package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
- package/pluggableElementTypes/models/BaseDisplayModel.d.ts +10 -10
- package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
- package/pluggableElementTypes/models/BaseTrackModel.d.ts +1 -1
- package/pluggableElementTypes/models/BaseTrackModel.js +139 -200
- package/pluggableElementTypes/models/BaseViewModel.js +24 -40
- package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
- package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
- package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
- package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
- package/pluggableElementTypes/models/index.js +21 -70
- package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
- package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
- package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
- package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
- package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -255
- package/pluggableElementTypes/renderers/RendererType.js +31 -105
- package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
- package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +2 -2
- package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
- package/pluggableElementTypes/renderers/index.js +19 -62
- package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
- package/rpc/BaseRpcDriver.js +169 -405
- package/rpc/MainThreadRpcDriver.js +27 -150
- package/rpc/RpcManager.js +58 -159
- package/rpc/WebWorkerRpcDriver.js +54 -171
- package/rpc/configSchema.js +25 -49
- package/rpc/coreRpcMethods.d.ts +1 -3
- package/rpc/coreRpcMethods.js +221 -959
- package/rpc/remoteAbortSignals.js +46 -70
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/AboutDialog.js +107 -158
- package/ui/App.js +157 -261
- package/ui/AssemblySelector.d.ts +1 -1
- package/ui/AssemblySelector.js +59 -115
- package/ui/CascadingMenu.js +100 -199
- package/ui/ColorPicker.d.ts +16 -0
- package/ui/ColorPicker.js +97 -0
- package/ui/Drawer.js +28 -58
- package/ui/DrawerWidget.js +109 -209
- package/ui/DropDownMenu.d.ts +0 -8
- package/ui/DropDownMenu.js +60 -97
- package/ui/EditableTypography.d.ts +1 -1
- package/ui/EditableTypography.js +87 -155
- package/ui/ErrorMessage.js +41 -66
- package/ui/FactoryResetDialog.js +24 -57
- package/ui/FatalErrorDialog.js +59 -91
- package/ui/FileSelector/FileSelector.js +123 -189
- package/ui/FileSelector/LocalFileChooser.js +44 -71
- package/ui/FileSelector/UrlChooser.js +17 -38
- package/ui/FileSelector/index.js +6 -12
- package/ui/Icons.d.ts +1 -1
- package/ui/Icons.js +45 -69
- package/ui/Logo.js +57 -110
- package/ui/Menu.d.ts +1 -1
- package/ui/Menu.js +232 -355
- package/ui/PrerenderedCanvas.js +63 -78
- package/ui/ResizeHandle.js +87 -114
- package/ui/ReturnToImportFormDialog.js +32 -59
- package/ui/SanitizedHTML.js +63 -52
- package/ui/Snackbar.js +74 -99
- package/ui/SnackbarModel.js +37 -51
- package/ui/Tooltip.d.ts +3 -1
- package/ui/Tooltip.js +49 -74
- package/ui/ViewContainer.js +113 -183
- package/ui/colors.d.ts +10 -0
- package/ui/colors.js +78 -0
- package/ui/index.js +51 -181
- package/ui/react-colorful.d.ts +17 -0
- package/ui/react-colorful.js +455 -0
- package/ui/theme.d.ts +279 -131
- package/ui/theme.js +197 -225
- package/util/Base1DUtils.d.ts +32 -0
- package/util/Base1DUtils.js +174 -0
- package/util/Base1DViewModel.d.ts +16 -37
- package/util/Base1DViewModel.js +116 -295
- package/util/QuickLRU.js +84 -332
- package/util/TimeTraveller.d.ts +19 -0
- package/util/TimeTraveller.js +86 -0
- package/util/aborting.js +49 -127
- package/util/analytics.js +91 -154
- package/util/blockTypes.js +106 -240
- package/util/calculateDynamicBlocks.js +98 -128
- package/util/calculateStaticBlocks.js +105 -125
- package/util/color/cssColorsLevel4.js +156 -160
- package/util/color/index.js +33 -55
- package/util/compositeMap.js +49 -333
- package/util/formatFastaStrings.js +9 -14
- package/util/idMaker.js +18 -31
- package/util/index.d.ts +18 -39
- package/util/index.js +743 -1236
- package/util/io/RemoteFileWithRangeCache.js +88 -257
- package/util/io/index.js +95 -169
- package/util/jexl.js +60 -115
- package/util/jexlStrings.js +24 -29
- package/util/layouts/BaseLayout.js +1 -4
- package/util/layouts/GranularRectLayout.js +388 -557
- package/util/layouts/MultiLayout.js +41 -109
- package/util/layouts/PrecomputedLayout.js +56 -114
- package/util/layouts/PrecomputedMultiLayout.js +22 -59
- package/util/layouts/SceneGraph.js +127 -197
- package/util/layouts/index.js +29 -66
- package/util/mst-reflection.js +55 -71
- package/util/offscreenCanvasPonyfill.js +66 -134
- package/util/offscreenCanvasUtils.d.ts +2 -7
- package/util/offscreenCanvasUtils.js +49 -146
- package/util/range.js +29 -40
- package/util/rxjs.js +20 -27
- package/util/simpleFeature.js +88 -152
- package/util/stats.js +91 -151
- package/util/tracks.js +130 -171
- package/util/types/index.d.ts +3 -3
- package/util/types/index.js +110 -179
- package/util/types/mst.d.ts +3 -3
- package/util/types/mst.js +91 -142
- package/util/types/util.js +1 -4
- package/util/when.js +54 -101
- package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
- package/BaseFeatureWidget/index.test.js +0 -51
- package/TextSearch/BaseResults.test.js +0 -42
- package/configuration/configurationSchema.test.js +0 -266
- package/configuration/configurationSlot.test.js +0 -69
- package/configuration/util.test.js +0 -39
- package/data_adapters/BaseAdapter.test.js +0 -200
- package/declare.d.js +0 -1
- package/pluggableElementTypes/RpcMethodType.test.js +0 -118
- package/pluggableElementTypes/renderers/declare.d.js +0 -1
- package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
- package/rpc/BaseRpcDriver.test.js +0 -540
- package/rpc/declaration.d.js +0 -1
- package/ui/FatalErrorDialog.test.js +0 -82
- package/ui/SanitizedHTML.test.js +0 -36
- package/ui/theme.test.js +0 -111
- package/util/Base1DViewModel.test.js +0 -130
- package/util/calculateDynamicBlocks.test.js +0 -74
- package/util/calculateStaticBlocks.test.js +0 -297
- package/util/declare.d.js +0 -1
- package/util/formatFastaStrings.test.js +0 -40
- package/util/index.test.js +0 -213
- package/util/jexlStrings.test.js +0 -48
- package/util/layouts/GranularRectLayout.test.js +0 -99
- package/util/range.test.js +0 -64
- package/util/simpleFeature.test.js +0 -34
- package/util/stats.test.js +0 -172
|
@@ -1,352 +1,274 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = ConfigSlot;
|
|
9
|
-
|
|
10
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
-
|
|
12
|
-
var _mobxStateTree = require("mobx-state-tree");
|
|
13
|
-
|
|
14
|
-
var _jexlStrings = require("../util/jexlStrings");
|
|
15
|
-
|
|
16
|
-
var _mst = require("../util/types/mst");
|
|
17
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
5
|
+
const jexlStrings_1 = require("../util/jexlStrings");
|
|
6
|
+
const mst_1 = require("../util/types/mst");
|
|
7
|
+
function isValidColorString( /* str */) {
|
|
8
|
+
// TODO: check all the crazy cases for whether it's a valid HTML/CSS color string
|
|
9
|
+
return true;
|
|
24
10
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
frozen: _mobxStateTree.types.frozen()
|
|
38
|
-
}; // default values we use if the defaultValue is malformed or does not work
|
|
39
|
-
|
|
40
|
-
var fallbackDefaults = {
|
|
41
|
-
stringArray: [],
|
|
42
|
-
stringArrayMap: {},
|
|
43
|
-
numberMap: {},
|
|
44
|
-
boolean: true,
|
|
45
|
-
color: 'black',
|
|
46
|
-
integer: 1,
|
|
47
|
-
number: 1,
|
|
48
|
-
string: '',
|
|
49
|
-
text: '',
|
|
50
|
-
fileLocation: {
|
|
51
|
-
uri: '/path/to/resource.txt',
|
|
52
|
-
locationType: 'UriLocation'
|
|
53
|
-
},
|
|
54
|
-
frozen: {}
|
|
11
|
+
const typeModels = {
|
|
12
|
+
stringArray: mobx_state_tree_1.types.array(mobx_state_tree_1.types.string),
|
|
13
|
+
stringArrayMap: mobx_state_tree_1.types.map(mobx_state_tree_1.types.array(mobx_state_tree_1.types.string)),
|
|
14
|
+
numberMap: mobx_state_tree_1.types.map(mobx_state_tree_1.types.number),
|
|
15
|
+
boolean: mobx_state_tree_1.types.boolean,
|
|
16
|
+
color: mobx_state_tree_1.types.refinement('Color', mobx_state_tree_1.types.string, isValidColorString),
|
|
17
|
+
integer: mobx_state_tree_1.types.integer,
|
|
18
|
+
number: mobx_state_tree_1.types.number,
|
|
19
|
+
string: mobx_state_tree_1.types.string,
|
|
20
|
+
text: mobx_state_tree_1.types.string,
|
|
21
|
+
fileLocation: mst_1.FileLocation,
|
|
22
|
+
frozen: mobx_state_tree_1.types.frozen(),
|
|
55
23
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
24
|
+
// default values we use if the defaultValue is malformed or does not work
|
|
25
|
+
const fallbackDefaults = {
|
|
26
|
+
stringArray: [],
|
|
27
|
+
stringArrayMap: {},
|
|
28
|
+
numberMap: {},
|
|
29
|
+
boolean: true,
|
|
30
|
+
color: 'black',
|
|
31
|
+
integer: 1,
|
|
32
|
+
number: 1,
|
|
33
|
+
string: '',
|
|
34
|
+
text: '',
|
|
35
|
+
fileLocation: { uri: '/path/to/resource.txt', locationType: 'UriLocation' },
|
|
36
|
+
frozen: {},
|
|
66
37
|
};
|
|
67
|
-
|
|
68
|
-
var objectJSON = function objectJSON(self) {
|
|
69
|
-
return {
|
|
38
|
+
const literalJSON = (self) => ({
|
|
70
39
|
views: {
|
|
71
|
-
get valueJSON() {
|
|
72
|
-
return JSON.stringify(self.value);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}; // custom actions for modifying the value models
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var typeModelExtensions = {
|
|
81
|
-
fileLocation: objectJSON,
|
|
82
|
-
number: literalJSON,
|
|
83
|
-
integer: literalJSON,
|
|
84
|
-
boolean: literalJSON,
|
|
85
|
-
frozen: objectJSON,
|
|
86
|
-
// special actions for working with stringArray slots
|
|
87
|
-
stringArray: function stringArray(self) {
|
|
88
|
-
return {
|
|
89
|
-
views: {
|
|
90
40
|
get valueJSON() {
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
actions: {
|
|
96
|
-
add: function add(val) {
|
|
97
|
-
self.value.push(val);
|
|
98
|
-
},
|
|
99
|
-
removeAtIndex: function removeAtIndex(idx) {
|
|
100
|
-
self.value.splice(idx, 1);
|
|
41
|
+
return self.value;
|
|
101
42
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
stringArrayMap: function stringArrayMap(self) {
|
|
109
|
-
return {
|
|
110
|
-
views: {
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const objectJSON = (self) => ({
|
|
46
|
+
views: {
|
|
111
47
|
get valueJSON() {
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
actions: {
|
|
117
|
-
add: function add(key, val) {
|
|
118
|
-
self.value.set(key, val);
|
|
48
|
+
return JSON.stringify(self.value);
|
|
119
49
|
},
|
|
120
|
-
|
|
121
|
-
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
// custom actions for modifying the value models
|
|
53
|
+
const typeModelExtensions = {
|
|
54
|
+
fileLocation: objectJSON,
|
|
55
|
+
number: literalJSON,
|
|
56
|
+
integer: literalJSON,
|
|
57
|
+
boolean: literalJSON,
|
|
58
|
+
frozen: objectJSON,
|
|
59
|
+
// special actions for working with stringArray slots
|
|
60
|
+
stringArray: (self) => ({
|
|
61
|
+
views: {
|
|
62
|
+
get valueJSON() {
|
|
63
|
+
return JSON.stringify(self.value);
|
|
64
|
+
},
|
|
122
65
|
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
66
|
+
actions: {
|
|
67
|
+
add(val) {
|
|
68
|
+
self.value.push(val);
|
|
69
|
+
},
|
|
70
|
+
removeAtIndex(idx) {
|
|
71
|
+
self.value.splice(idx, 1);
|
|
72
|
+
},
|
|
73
|
+
setAtIndex(idx, val) {
|
|
74
|
+
self.value[idx] = val;
|
|
75
|
+
},
|
|
131
76
|
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
ar.splice(idx, 1);
|
|
77
|
+
}),
|
|
78
|
+
stringArrayMap: (self) => ({
|
|
79
|
+
views: {
|
|
80
|
+
get valueJSON() {
|
|
81
|
+
return JSON.stringify(self.value);
|
|
82
|
+
},
|
|
140
83
|
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
84
|
+
actions: {
|
|
85
|
+
add(key, val) {
|
|
86
|
+
self.value.set(key, val);
|
|
87
|
+
},
|
|
88
|
+
remove(key) {
|
|
89
|
+
self.value.delete(key);
|
|
90
|
+
},
|
|
91
|
+
addToKey(key, val) {
|
|
92
|
+
const ar = self.value.get(key);
|
|
93
|
+
if (!ar) {
|
|
94
|
+
throw new Error(`${key} not found`);
|
|
95
|
+
}
|
|
96
|
+
ar.push(val);
|
|
97
|
+
},
|
|
98
|
+
removeAtKeyIndex(key, idx) {
|
|
99
|
+
const ar = self.value.get(key);
|
|
100
|
+
if (!ar) {
|
|
101
|
+
throw new Error(`${key} not found`);
|
|
102
|
+
}
|
|
103
|
+
ar.splice(idx, 1);
|
|
104
|
+
},
|
|
105
|
+
setAtKeyIndex(key, idx, val) {
|
|
106
|
+
const ar = self.value.get(key);
|
|
107
|
+
if (!ar) {
|
|
108
|
+
throw new Error(`${key} not found`);
|
|
109
|
+
}
|
|
110
|
+
ar[idx] = val;
|
|
111
|
+
},
|
|
164
112
|
},
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
113
|
+
}),
|
|
114
|
+
numberMap: (self) => ({
|
|
115
|
+
views: {
|
|
116
|
+
get valueJSON() {
|
|
117
|
+
return JSON.stringify(self.value);
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
actions: {
|
|
121
|
+
add(key, val) {
|
|
122
|
+
self.value.set(key, val);
|
|
123
|
+
},
|
|
124
|
+
remove(key) {
|
|
125
|
+
self.value.delete(key);
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
};
|
|
130
|
+
// const FunctionStringType = types.refinement(
|
|
172
131
|
// 'FunctionString',
|
|
173
132
|
// types.string,
|
|
174
133
|
// str => functionRegexp.test(str),
|
|
175
134
|
// )
|
|
176
|
-
|
|
177
|
-
var JexlStringType = _mobxStateTree.types.refinement('JexlString', _mobxStateTree.types.string, function (str) {
|
|
178
|
-
return str.startsWith('jexl:');
|
|
179
|
-
});
|
|
180
|
-
|
|
135
|
+
const JexlStringType = mobx_state_tree_1.types.refinement('JexlString', mobx_state_tree_1.types.string, str => str.startsWith('jexl:'));
|
|
181
136
|
/**
|
|
182
137
|
* builds a MST model for a configuration slot
|
|
183
138
|
*
|
|
184
139
|
* @param slotName -
|
|
185
140
|
* @param definition -
|
|
186
141
|
*/
|
|
187
|
-
function ConfigSlot(slotName,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
model = _ref.model,
|
|
191
|
-
type = _ref.type,
|
|
192
|
-
defaultValue = _ref.defaultValue,
|
|
193
|
-
_ref$contextVariable = _ref.contextVariable,
|
|
194
|
-
contextVariable = _ref$contextVariable === void 0 ? [] : _ref$contextVariable;
|
|
195
|
-
|
|
196
|
-
if (!type) {
|
|
197
|
-
throw new Error('type name required');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (!model) {
|
|
201
|
-
model = typeModels[type];
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (!model) {
|
|
205
|
-
throw new Error("no builtin config slot type \"".concat(type, "\", and no 'model' param provided"));
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (defaultValue === undefined) {
|
|
209
|
-
throw new Error("no 'defaultValue' provided");
|
|
210
|
-
} // if the `type` is something like `color`, then the model name
|
|
211
|
-
// here will be `ColorConfigSlot`
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
var configSlotModelName = "".concat(slotName.charAt(0).toUpperCase()).concat(slotName.slice(1), "ConfigSlot");
|
|
215
|
-
|
|
216
|
-
var slot = _mobxStateTree.types.model(configSlotModelName, {
|
|
217
|
-
name: _mobxStateTree.types.literal(slotName),
|
|
218
|
-
description: _mobxStateTree.types.literal(description),
|
|
219
|
-
type: _mobxStateTree.types.literal(type),
|
|
220
|
-
value: _mobxStateTree.types.optional(_mobxStateTree.types.union(JexlStringType, model), defaultValue)
|
|
221
|
-
}).volatile(function () {
|
|
222
|
-
return {
|
|
223
|
-
contextVariable: contextVariable
|
|
224
|
-
};
|
|
225
|
-
}).views(function (self) {
|
|
226
|
-
return {
|
|
227
|
-
get isCallback() {
|
|
228
|
-
return String(self.value).startsWith('jexl:');
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
};
|
|
232
|
-
}).views(function (self) {
|
|
233
|
-
return {
|
|
234
|
-
get expr() {
|
|
235
|
-
if (self.isCallback) {
|
|
236
|
-
// compile as jexl function
|
|
237
|
-
var _getEnv = (0, _mobxStateTree.getEnv)(self),
|
|
238
|
-
pluginManager = _getEnv.pluginManager;
|
|
239
|
-
|
|
240
|
-
if (!pluginManager && typeof jest === 'undefined') {
|
|
241
|
-
console.warn('no pluginManager detected on config env (if you dynamically instantiate a config, for example in renderProps for your display model, check that you add the env argument)');
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return (0, _jexlStrings.stringToJexlExpression)(String(self.value), pluginManager === null || pluginManager === void 0 ? void 0 : pluginManager.jexl);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return {
|
|
248
|
-
evalSync: function evalSync() {
|
|
249
|
-
return self.value;
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
// JS representation of the value of this slot, suitable
|
|
255
|
-
// for embedding in either JSON or a JS function string.
|
|
256
|
-
// many of the data types override this in typeModelExtensions
|
|
257
|
-
get valueJSON() {
|
|
258
|
-
if (self.isCallback) {
|
|
259
|
-
return undefined;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function json(value) {
|
|
263
|
-
if (value && value.toJSON) {
|
|
264
|
-
return value.toJSON();
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return "\"".concat(value, "\"");
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return json(self.value);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
};
|
|
274
|
-
}).preProcessSnapshot(function (val) {
|
|
275
|
-
return (0, _typeof2.default)(val) === 'object' && val.name === slotName ? val : {
|
|
276
|
-
name: slotName,
|
|
277
|
-
description: description,
|
|
278
|
-
type: type,
|
|
279
|
-
value: val
|
|
280
|
-
};
|
|
281
|
-
}).postProcessSnapshot(function (snap) {
|
|
282
|
-
if ((0, _typeof2.default)(snap.value) === 'object') {
|
|
283
|
-
return JSON.stringify(snap.value) !== JSON.stringify(defaultValue) ? snap.value : undefined;
|
|
142
|
+
function ConfigSlot(slotName, { description = '', model, type, defaultValue, contextVariable = [], }) {
|
|
143
|
+
if (!type) {
|
|
144
|
+
throw new Error('type name required');
|
|
284
145
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
146
|
+
if (!model) {
|
|
147
|
+
model = typeModels[type];
|
|
148
|
+
}
|
|
149
|
+
if (!model) {
|
|
150
|
+
throw new Error(`no builtin config slot type "${type}", and no 'model' param provided`);
|
|
151
|
+
}
|
|
152
|
+
if (defaultValue === undefined) {
|
|
153
|
+
throw new Error("no 'defaultValue' provided");
|
|
154
|
+
}
|
|
155
|
+
// if the `type` is something like `color`, then the model name
|
|
156
|
+
// here will be `ColorConfigSlot`
|
|
157
|
+
const configSlotModelName = `${slotName
|
|
158
|
+
.charAt(0)
|
|
159
|
+
.toUpperCase()}${slotName.slice(1)}ConfigSlot`;
|
|
160
|
+
let slot = mobx_state_tree_1.types
|
|
161
|
+
.model(configSlotModelName, {
|
|
162
|
+
name: mobx_state_tree_1.types.literal(slotName),
|
|
163
|
+
description: mobx_state_tree_1.types.literal(description),
|
|
164
|
+
type: mobx_state_tree_1.types.literal(type),
|
|
165
|
+
value: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.union(JexlStringType, model), defaultValue),
|
|
166
|
+
})
|
|
167
|
+
.volatile(() => ({
|
|
168
|
+
contextVariable,
|
|
169
|
+
}))
|
|
170
|
+
.views(self => ({
|
|
171
|
+
get isCallback() {
|
|
172
|
+
return String(self.value).startsWith('jexl:');
|
|
173
|
+
},
|
|
174
|
+
}))
|
|
175
|
+
.views(self => ({
|
|
176
|
+
get expr() {
|
|
177
|
+
if (self.isCallback) {
|
|
178
|
+
// compile as jexl function
|
|
179
|
+
const { pluginManager } = (0, mobx_state_tree_1.getEnv)(self);
|
|
180
|
+
if (!pluginManager && typeof jest === 'undefined') {
|
|
181
|
+
console.warn('no pluginManager detected on config env (if you dynamically instantiate a config, for example in renderProps for your display model, check that you add the env argument)');
|
|
182
|
+
}
|
|
183
|
+
return (0, jexlStrings_1.stringToJexlExpression)(String(self.value), pluginManager === null || pluginManager === void 0 ? void 0 : pluginManager.jexl);
|
|
184
|
+
}
|
|
185
|
+
return { evalSync: () => self.value };
|
|
186
|
+
},
|
|
187
|
+
// JS representation of the value of this slot, suitable
|
|
188
|
+
// for embedding in either JSON or a JS function string.
|
|
189
|
+
// many of the data types override this in typeModelExtensions
|
|
190
|
+
get valueJSON() {
|
|
191
|
+
if (self.isCallback) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
function json(value) {
|
|
195
|
+
if (value && value.toJSON) {
|
|
196
|
+
return value.toJSON();
|
|
197
|
+
}
|
|
198
|
+
return `"${value}"`;
|
|
199
|
+
}
|
|
200
|
+
return json(self.value);
|
|
201
|
+
},
|
|
202
|
+
}))
|
|
203
|
+
.preProcessSnapshot(val => typeof val === 'object' && val.name === slotName
|
|
204
|
+
? val
|
|
205
|
+
: {
|
|
206
|
+
name: slotName,
|
|
207
|
+
description,
|
|
208
|
+
type,
|
|
209
|
+
value: val,
|
|
210
|
+
})
|
|
211
|
+
.postProcessSnapshot(snap => {
|
|
212
|
+
if (typeof snap.value === 'object') {
|
|
213
|
+
return JSON.stringify(snap.value) !== JSON.stringify(defaultValue)
|
|
214
|
+
? snap.value
|
|
215
|
+
: undefined;
|
|
329
216
|
}
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
217
|
+
return snap.value !== defaultValue ? snap.value : undefined;
|
|
218
|
+
})
|
|
219
|
+
.actions(self => ({
|
|
220
|
+
set(newVal) {
|
|
221
|
+
self.value = newVal;
|
|
222
|
+
},
|
|
223
|
+
reset() {
|
|
224
|
+
self.value = defaultValue;
|
|
225
|
+
},
|
|
226
|
+
convertToCallback() {
|
|
227
|
+
if (self.isCallback) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
self.value = `jexl:${self.valueJSON || "''"}`;
|
|
231
|
+
},
|
|
232
|
+
convertToValue() {
|
|
233
|
+
if (!self.isCallback) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
// try calling it with no arguments
|
|
237
|
+
try {
|
|
238
|
+
const funcResult = self.expr.evalSync();
|
|
239
|
+
if (funcResult !== undefined) {
|
|
240
|
+
self.value = funcResult;
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
catch (e) {
|
|
245
|
+
/* ignore */
|
|
246
|
+
}
|
|
247
|
+
self.value = defaultValue;
|
|
248
|
+
// if it is still a callback (happens if the defaultValue is a callback),
|
|
249
|
+
// then use the last-resort fallback default
|
|
250
|
+
// if defaultValue has jexl: string, run this part
|
|
251
|
+
if (self.isCallback) {
|
|
252
|
+
if (!(type in fallbackDefaults)) {
|
|
253
|
+
throw new Error(`no fallbackDefault defined for type ${type}`);
|
|
254
|
+
}
|
|
255
|
+
self.value = fallbackDefaults[type];
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
}));
|
|
259
|
+
// if there are any type-specific extensions (views or actions)
|
|
260
|
+
// to the slot, add those in
|
|
261
|
+
if (typeModelExtensions[type]) {
|
|
262
|
+
slot = slot.extend(typeModelExtensions[type]);
|
|
263
|
+
}
|
|
264
|
+
const completeModel = mobx_state_tree_1.types.optional(slot, {
|
|
265
|
+
name: slotName,
|
|
266
|
+
type,
|
|
267
|
+
description,
|
|
268
|
+
value: defaultValue,
|
|
269
|
+
});
|
|
270
|
+
const m = completeModel;
|
|
271
|
+
Object.defineProperty(m, 'isJBrowseConfigurationSlot', { value: true });
|
|
272
|
+
return m;
|
|
273
|
+
}
|
|
274
|
+
exports.default = ConfigSlot;
|
package/configuration/index.js
CHANGED
|
@@ -1,37 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ConfigurationSchema: true,
|
|
8
|
-
ConfigurationReference: true
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "ConfigurationReference", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _configurationSchema.ConfigurationReference;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(exports, "ConfigurationSchema", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function get() {
|
|
19
|
-
return _configurationSchema.ConfigurationSchema;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
var _configurationSchema = require("./configurationSchema");
|
|
24
|
-
|
|
25
|
-
var _util = require("./util");
|
|
26
|
-
|
|
27
|
-
Object.keys(_util).forEach(function (key) {
|
|
28
|
-
if (key === "default" || key === "__esModule") return;
|
|
29
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
30
|
-
if (key in exports && exports[key] === _util[key]) return;
|
|
31
|
-
Object.defineProperty(exports, key, {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function get() {
|
|
34
|
-
return _util[key];
|
|
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]; } };
|
|
35
7
|
}
|
|
36
|
-
|
|
37
|
-
})
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ConfigurationReference = exports.ConfigurationSchema = void 0;
|
|
18
|
+
var configurationSchema_1 = require("./configurationSchema");
|
|
19
|
+
Object.defineProperty(exports, "ConfigurationSchema", { enumerable: true, get: function () { return configurationSchema_1.ConfigurationSchema; } });
|
|
20
|
+
Object.defineProperty(exports, "ConfigurationReference", { enumerable: true, get: function () { return configurationSchema_1.ConfigurationReference; } });
|
|
21
|
+
__exportStar(require("./util"), exports);
|
package/configuration/util.d.ts
CHANGED
|
@@ -27,6 +27,6 @@ export declare function getConf(model: unknown, slotPath?: string[] | string | u
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function getTypeNamesFromExplicitlyTypedUnion(maybeUnionType: unknown): string[];
|
|
29
29
|
export declare function isBareConfigurationSchemaType(thing: unknown): thing is AnyConfigurationSchemaType;
|
|
30
|
-
export declare function isConfigurationSchemaType(thing: unknown):
|
|
30
|
+
export declare function isConfigurationSchemaType(thing: unknown): thing is AnyConfigurationSchemaType;
|
|
31
31
|
export declare function isConfigurationModel(thing: unknown): thing is AnyConfigurationModel;
|
|
32
32
|
export declare function isConfigurationSlotType(thing: unknown): boolean;
|