@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,222 +1,186 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
|
|
13
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
|
|
15
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
16
|
-
|
|
17
|
-
var _mobxStateTree = require("mobx-state-tree");
|
|
18
|
-
|
|
19
|
-
var _mst = require("../util/types/mst");
|
|
20
|
-
|
|
21
|
-
var _configurationSlot = _interopRequireDefault(require("./configurationSlot"));
|
|
22
|
-
|
|
23
|
-
var _util = require("./util");
|
|
24
|
-
|
|
25
|
-
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; }
|
|
26
|
-
|
|
27
|
-
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; }
|
|
28
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConfigurationReference = exports.ConfigurationSchema = void 0;
|
|
7
|
+
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
8
|
+
const mst_1 = require("../util/types/mst");
|
|
9
|
+
const configurationSlot_1 = __importDefault(require("./configurationSlot"));
|
|
10
|
+
const util_1 = require("./util");
|
|
29
11
|
function isEmptyObject(thing) {
|
|
30
|
-
|
|
12
|
+
return (typeof thing === 'object' &&
|
|
13
|
+
!Array.isArray(thing) &&
|
|
14
|
+
thing !== null &&
|
|
15
|
+
Object.keys(thing).length === 0);
|
|
31
16
|
}
|
|
32
|
-
|
|
33
17
|
function isEmptyArray(thing) {
|
|
34
|
-
|
|
18
|
+
return Array.isArray(thing) && thing.length === 0;
|
|
35
19
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
options: options
|
|
58
|
-
};
|
|
20
|
+
function preprocessConfigurationSchemaArguments(modelName, inputSchemaDefinition, inputOptions = {}) {
|
|
21
|
+
if (typeof modelName !== 'string') {
|
|
22
|
+
throw new Error('first arg must be string name of the model that this config schema goes with');
|
|
23
|
+
}
|
|
24
|
+
// if we have a base configuration schema that we are
|
|
25
|
+
// extending, grab the slot definitions from that
|
|
26
|
+
let schemaDefinition = inputSchemaDefinition;
|
|
27
|
+
let options = inputOptions;
|
|
28
|
+
if (inputOptions.baseConfiguration &&
|
|
29
|
+
inputOptions.baseConfiguration.jbrowseSchemaDefinition) {
|
|
30
|
+
schemaDefinition = {
|
|
31
|
+
...inputOptions.baseConfiguration.jbrowseSchemaDefinition,
|
|
32
|
+
...schemaDefinition,
|
|
33
|
+
};
|
|
34
|
+
options = {
|
|
35
|
+
...(inputOptions.baseConfiguration.jbrowseSchemaOptions || {}),
|
|
36
|
+
...inputOptions,
|
|
37
|
+
};
|
|
38
|
+
delete options.baseConfiguration;
|
|
39
|
+
}
|
|
40
|
+
return { schemaDefinition, options };
|
|
59
41
|
}
|
|
60
|
-
|
|
61
42
|
function makeConfigurationSchemaModel(modelName, schemaDefinition, options) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
modelDefinition.type = _mobxStateTree.types.optional(_mobxStateTree.types.literal(modelName), modelName);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (options.explicitIdentifier && options.implicitIdentifier) {
|
|
72
|
-
throw new Error("Cannot have both explicit and implicit identifiers in ".concat(modelName));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (options.explicitIdentifier) {
|
|
76
|
-
if (typeof options.explicitIdentifier === 'string') {
|
|
77
|
-
modelDefinition[options.explicitIdentifier] = _mobxStateTree.types.identifier;
|
|
78
|
-
identifier = options.explicitIdentifier;
|
|
79
|
-
} else {
|
|
80
|
-
modelDefinition.id = _mobxStateTree.types.identifier;
|
|
81
|
-
identifier = 'id';
|
|
82
|
-
}
|
|
83
|
-
} else if (options.implicitIdentifier) {
|
|
84
|
-
if (typeof options.implicitIdentifier === 'string') {
|
|
85
|
-
modelDefinition[options.implicitIdentifier] = _mst.ElementId;
|
|
86
|
-
identifier = options.implicitIdentifier;
|
|
87
|
-
} else {
|
|
88
|
-
modelDefinition.id = _mst.ElementId;
|
|
89
|
-
identifier = 'id';
|
|
43
|
+
// now assemble the MST model of the configuration schema
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
const modelDefinition = {};
|
|
46
|
+
let identifier;
|
|
47
|
+
if (options.explicitlyTyped) {
|
|
48
|
+
modelDefinition.type = mobx_state_tree_1.types.optional(mobx_state_tree_1.types.literal(modelName), modelName);
|
|
90
49
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var volatileConstants = {
|
|
95
|
-
isJBrowseConfigurationSchema: true,
|
|
96
|
-
jbrowseSchema: {
|
|
97
|
-
modelName: modelName,
|
|
98
|
-
definition: schemaDefinition,
|
|
99
|
-
options: options
|
|
50
|
+
if (options.explicitIdentifier && options.implicitIdentifier) {
|
|
51
|
+
throw new Error(`Cannot have both explicit and implicit identifiers in ${modelName}`);
|
|
100
52
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
modelDefinition[slotName] = slotDefinition;
|
|
111
|
-
} else if (typeof slotDefinition === 'string' || typeof slotDefinition === 'number') {
|
|
112
|
-
volatileConstants[slotName] = slotDefinition;
|
|
113
|
-
} else if ((0, _typeof2.default)(slotDefinition) === 'object') {
|
|
114
|
-
// this is a slot definition
|
|
115
|
-
if (!slotDefinition.type) {
|
|
116
|
-
throw new Error("no type set for config slot ".concat(modelName, ".").concat(slotName));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
modelDefinition[slotName] = (0, _configurationSlot.default)(slotName, slotDefinition);
|
|
121
|
-
} catch (e) {
|
|
122
|
-
throw new Error("invalid config slot definition for ".concat(modelName, ".").concat(slotName, ": ").concat(e));
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
throw new Error("invalid configuration schema definition, \"".concat(slotName, "\" must be either a valid configuration slot definition, a constant, or a nested configuration schema"));
|
|
53
|
+
if (options.explicitIdentifier) {
|
|
54
|
+
if (typeof options.explicitIdentifier === 'string') {
|
|
55
|
+
modelDefinition[options.explicitIdentifier] = mobx_state_tree_1.types.identifier;
|
|
56
|
+
identifier = options.explicitIdentifier;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
modelDefinition.id = mobx_state_tree_1.types.identifier;
|
|
60
|
+
identifier = 'id';
|
|
61
|
+
}
|
|
126
62
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
63
|
+
else if (options.implicitIdentifier) {
|
|
64
|
+
if (typeof options.implicitIdentifier === 'string') {
|
|
65
|
+
modelDefinition[options.implicitIdentifier] = mst_1.ElementId;
|
|
66
|
+
identifier = options.implicitIdentifier;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
modelDefinition.id = mst_1.ElementId;
|
|
70
|
+
identifier = 'id';
|
|
134
71
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
72
|
+
}
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
const volatileConstants = {
|
|
75
|
+
isJBrowseConfigurationSchema: true,
|
|
76
|
+
jbrowseSchema: {
|
|
77
|
+
modelName,
|
|
78
|
+
definition: schemaDefinition,
|
|
79
|
+
options,
|
|
80
|
+
},
|
|
140
81
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var identifierDefault = identifier ? (0, _defineProperty2.default)({}, identifier, 'placeholderId') : {};
|
|
164
|
-
var modelDefault = options.explicitlyTyped ? _objectSpread({
|
|
165
|
-
type: modelName
|
|
166
|
-
}, identifierDefault) : identifierDefault;
|
|
167
|
-
var defaultSnap = (0, _mobxStateTree.getSnapshot)(completeModel.create(modelDefault));
|
|
168
|
-
completeModel = completeModel.postProcessSnapshot(function (snap) {
|
|
169
|
-
var newSnap = {};
|
|
170
|
-
var matchesDefault = true; // let keyCount = 0
|
|
171
|
-
|
|
172
|
-
for (var _i = 0, _Object$entries = Object.entries(snap); _i < _Object$entries.length; _i++) {
|
|
173
|
-
var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
|
|
174
|
-
key = _Object$entries$_i[0],
|
|
175
|
-
value = _Object$entries$_i[1];
|
|
176
|
-
|
|
177
|
-
if (matchesDefault) {
|
|
178
|
-
if ((0, _typeof2.default)(defaultSnap[key]) === 'object' && (0, _typeof2.default)(value) === 'object') {
|
|
179
|
-
if (JSON.stringify(defaultSnap[key]) !== JSON.stringify(value)) {
|
|
180
|
-
matchesDefault = false;
|
|
181
|
-
}
|
|
182
|
-
} else if (defaultSnap[key] !== value) {
|
|
183
|
-
matchesDefault = false;
|
|
82
|
+
Object.entries(schemaDefinition).forEach(([slotName, slotDefinition]) => {
|
|
83
|
+
if (((0, mobx_state_tree_1.isType)(slotDefinition) && (0, mobx_state_tree_1.isLateType)(slotDefinition)) ||
|
|
84
|
+
(0, util_1.isConfigurationSchemaType)(slotDefinition)) {
|
|
85
|
+
// this is either an MST late() type (which we assume to be a sub-configuration),
|
|
86
|
+
// or an actual sub-configuration
|
|
87
|
+
modelDefinition[slotName] = slotDefinition;
|
|
88
|
+
}
|
|
89
|
+
else if (typeof slotDefinition === 'string' ||
|
|
90
|
+
typeof slotDefinition === 'number') {
|
|
91
|
+
volatileConstants[slotName] = slotDefinition;
|
|
92
|
+
}
|
|
93
|
+
else if (typeof slotDefinition === 'object') {
|
|
94
|
+
// this is a slot definition
|
|
95
|
+
if (!slotDefinition.type) {
|
|
96
|
+
throw new Error(`no type set for config slot ${modelName}.${slotName}`);
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
modelDefinition[slotName] = (0, configurationSlot_1.default)(slotName, slotDefinition);
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
throw new Error(`invalid config slot definition for ${modelName}.${slotName}: ${e}`);
|
|
103
|
+
}
|
|
184
104
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
105
|
+
else {
|
|
106
|
+
throw new Error(`invalid configuration schema definition, "${slotName}" must be either a valid configuration slot definition, a constant, or a nested configuration schema`);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
let completeModel = mobx_state_tree_1.types
|
|
110
|
+
.model(`${modelName}ConfigurationSchema`, modelDefinition)
|
|
111
|
+
.actions(self => ({
|
|
112
|
+
setSubschema(slotName, data) {
|
|
113
|
+
if (!(0, util_1.isConfigurationSchemaType)(modelDefinition[slotName])) {
|
|
114
|
+
throw new Error(`${slotName} is not a subschema, cannot replace`);
|
|
115
|
+
}
|
|
116
|
+
const newSchema = (0, mobx_state_tree_1.isStateTreeNode)(data)
|
|
117
|
+
? data
|
|
118
|
+
: modelDefinition[slotName].create(data);
|
|
119
|
+
self[slotName] = newSchema;
|
|
120
|
+
return newSchema;
|
|
121
|
+
},
|
|
122
|
+
}));
|
|
123
|
+
if (Object.keys(volatileConstants).length) {
|
|
124
|
+
completeModel = completeModel.volatile(( /* self */) => volatileConstants);
|
|
125
|
+
}
|
|
126
|
+
if (options.actions) {
|
|
127
|
+
completeModel = completeModel.actions(options.actions);
|
|
191
128
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return {};
|
|
129
|
+
if (options.views) {
|
|
130
|
+
completeModel = completeModel.views(options.views);
|
|
195
131
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
132
|
+
if (options.extend) {
|
|
133
|
+
completeModel = completeModel.extend(options.extend);
|
|
134
|
+
}
|
|
135
|
+
const identifierDefault = identifier ? { [identifier]: 'placeholderId' } : {};
|
|
136
|
+
const modelDefault = options.explicitlyTyped
|
|
137
|
+
? { type: modelName, ...identifierDefault }
|
|
138
|
+
: identifierDefault;
|
|
139
|
+
const defaultSnap = (0, mobx_state_tree_1.getSnapshot)(completeModel.create(modelDefault));
|
|
140
|
+
completeModel = completeModel.postProcessSnapshot(snap => {
|
|
141
|
+
const newSnap = {};
|
|
142
|
+
let matchesDefault = true;
|
|
143
|
+
// let keyCount = 0
|
|
144
|
+
for (const [key, value] of Object.entries(snap)) {
|
|
145
|
+
if (matchesDefault) {
|
|
146
|
+
if (typeof defaultSnap[key] === 'object' && typeof value === 'object') {
|
|
147
|
+
if (JSON.stringify(defaultSnap[key]) !== JSON.stringify(value)) {
|
|
148
|
+
matchesDefault = false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else if (defaultSnap[key] !== value) {
|
|
152
|
+
matchesDefault = false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (value !== undefined &&
|
|
156
|
+
volatileConstants[key] === undefined &&
|
|
157
|
+
!isEmptyObject(value) &&
|
|
158
|
+
!isEmptyArray(value)) {
|
|
159
|
+
// keyCount += 1
|
|
160
|
+
newSnap[key] = value;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (matchesDefault) {
|
|
164
|
+
return {};
|
|
165
|
+
}
|
|
166
|
+
return newSnap;
|
|
167
|
+
});
|
|
168
|
+
if (options.preProcessSnapshot) {
|
|
169
|
+
completeModel = completeModel.preProcessSnapshot(options.preProcessSnapshot);
|
|
170
|
+
}
|
|
171
|
+
return mobx_state_tree_1.types.optional(completeModel, modelDefault);
|
|
205
172
|
}
|
|
206
|
-
|
|
207
173
|
function ConfigurationSchema(modelName, inputSchemaDefinition, inputOptions) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
schemaType.jbrowseSchemaDefinition = schemaDefinition;
|
|
216
|
-
schemaType.jbrowseSchemaOptions = options;
|
|
217
|
-
return schemaType;
|
|
174
|
+
const { schemaDefinition, options } = preprocessConfigurationSchemaArguments(modelName, inputSchemaDefinition, inputOptions);
|
|
175
|
+
const schemaType = makeConfigurationSchemaModel(modelName, schemaDefinition, options);
|
|
176
|
+
// saving a couple of jbrowse-specific things in the type object. hope nobody gets mad.
|
|
177
|
+
schemaType.isJBrowseConfigurationSchema = true;
|
|
178
|
+
schemaType.jbrowseSchemaDefinition = schemaDefinition;
|
|
179
|
+
schemaType.jbrowseSchemaOptions = options;
|
|
180
|
+
return schemaType;
|
|
218
181
|
}
|
|
219
|
-
|
|
182
|
+
exports.ConfigurationSchema = ConfigurationSchema;
|
|
220
183
|
function ConfigurationReference(schemaType) {
|
|
221
|
-
|
|
222
|
-
}
|
|
184
|
+
return mobx_state_tree_1.types.union(mobx_state_tree_1.types.reference(schemaType), schemaType);
|
|
185
|
+
}
|
|
186
|
+
exports.ConfigurationReference = ConfigurationReference;
|