@jbrowse/core 2.17.0 → 2.18.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/ArrayValue.js +1 -2
- package/BaseFeatureWidget/BaseFeatureDetail/Attributes.js +4 -8
- package/BaseFeatureWidget/BaseFeatureDetail/BaseCard.d.ts +1 -1
- package/BaseFeatureWidget/BaseFeatureDetail/BaseCard.js +1 -2
- package/BaseFeatureWidget/BaseFeatureDetail/BasicValue.js +2 -3
- package/BaseFeatureWidget/BaseFeatureDetail/CoreDetails.d.ts +1 -1
- package/BaseFeatureWidget/BaseFeatureDetail/CoreDetails.js +2 -3
- package/BaseFeatureWidget/BaseFeatureDetail/DataGridDetails.js +22 -25
- package/BaseFeatureWidget/BaseFeatureDetail/FeatureDetails.d.ts +2 -2
- package/BaseFeatureWidget/BaseFeatureDetail/FeatureDetails.js +6 -8
- package/BaseFeatureWidget/BaseFeatureDetail/Position.d.ts +1 -1
- package/BaseFeatureWidget/BaseFeatureDetail/SimpleField.js +1 -1
- package/BaseFeatureWidget/BaseFeatureDetail/UriField.js +1 -1
- package/BaseFeatureWidget/BaseFeatureDetail/index.d.ts +1 -1
- package/BaseFeatureWidget/BaseFeatureDetail/index.js +1 -7
- package/BaseFeatureWidget/BaseFeatureDetail/util.js +0 -5
- package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeatureDetails.d.ts +2 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeatureDetails.js +0 -7
- package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeaturePanel.d.ts +2 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeaturePanel.js +1 -7
- package/BaseFeatureWidget/SequenceFeatureDetails/SequencePanel.d.ts +3 -3
- package/BaseFeatureWidget/SequenceFeatureDetails/SequencePanel.js +24 -33
- package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/HelpDialog.js +1 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SequenceDialog.d.ts +2 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SequenceDialog.js +3 -4
- package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SequenceFeatureMenu.d.ts +2 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SequenceFeatureMenu.js +3 -6
- package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SequenceTypeSelector.d.ts +1 -1
- package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SettingsDialog.d.ts +1 -1
- package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SettingsDialog.js +2 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/hooks.d.ts +2 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/hooks.js +1 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/model.d.ts +2 -56
- package/BaseFeatureWidget/SequenceFeatureDetails/model.js +1 -56
- package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/CDNASequence.d.ts +3 -3
- package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/CDSSequence.d.ts +2 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/CDSSequence.js +5 -6
- package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/GenomicSequence.d.ts +2 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/GenomicSequence.js +0 -1
- package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/ProteinSequence.d.ts +2 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/ProteinSequence.js +0 -2
- package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/SequenceDisplay.d.ts +1 -1
- package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/SequenceDisplay.js +1 -3
- package/BaseFeatureWidget/SequenceFeatureDetails/util.js +1 -5
- package/BaseFeatureWidget/stateModelFactory.d.ts +2 -93
- package/BaseFeatureWidget/stateModelFactory.js +3 -73
- package/BaseFeatureWidget/types.d.ts +3 -3
- package/BaseFeatureWidget/util.js +0 -4
- package/CorePlugin.d.ts +1 -1
- package/CorePlugin.js +2 -5
- package/Plugin.d.ts +2 -5
- package/Plugin.js +0 -3
- package/PluginLoader.d.ts +1 -1
- package/PluginLoader.js +2 -19
- package/PluginManager.d.ts +15 -31
- package/PluginManager.js +11 -39
- package/ReExports/DataGrid.js +0 -1
- package/ReExports/list.d.ts +0 -5
- package/ReExports/list.js +0 -5
- package/ReExports/modules.d.ts +22 -20
- package/ReExports/modules.js +16 -25
- package/TextSearch/BaseResults.d.ts +3 -3
- package/TextSearch/TextSearchManager.d.ts +4 -16
- package/TextSearch/TextSearchManager.js +1 -13
- package/assemblyManager/assembly.d.ts +5 -100
- package/assemblyManager/assembly.js +27 -143
- package/assemblyManager/assemblyConfigSchema.d.ts +1 -34
- package/assemblyManager/assemblyConfigSchema.js +12 -46
- package/assemblyManager/assemblyManager.d.ts +7 -57
- package/assemblyManager/assemblyManager.js +2 -57
- package/configuration/configurationSchema.d.ts +4 -4
- package/configuration/configurationSchema.js +2 -14
- package/configuration/configurationSlot.d.ts +1 -12
- package/configuration/configurationSlot.js +2 -32
- package/configuration/index.d.ts +2 -2
- package/configuration/index.js +2 -2
- package/configuration/types.d.ts +2 -3
- package/configuration/util.d.ts +1 -25
- package/configuration/util.js +19 -56
- package/data_adapters/BaseAdapter/BaseAdapter.d.ts +4 -14
- package/data_adapters/BaseAdapter/BaseAdapter.js +1 -10
- package/data_adapters/BaseAdapter/BaseFeatureDataAdapter.d.ts +5 -114
- package/data_adapters/BaseAdapter/BaseFeatureDataAdapter.js +3 -79
- package/data_adapters/BaseAdapter/BaseOptions.d.ts +2 -2
- package/data_adapters/BaseAdapter/BaseRefNameAliasAdapter.d.ts +2 -2
- package/data_adapters/BaseAdapter/BaseSequenceAdapter.d.ts +3 -6
- package/data_adapters/BaseAdapter/BaseTextSearchAdapter.d.ts +3 -3
- package/data_adapters/BaseAdapter/RegionsAdapter.d.ts +3 -3
- package/data_adapters/BaseAdapter/index.d.ts +4 -4
- package/data_adapters/BaseAdapter/types.d.ts +2 -2
- package/data_adapters/BaseAdapter/util.d.ts +6 -6
- package/data_adapters/CytobandAdapter/CytobandAdapter.d.ts +1 -1
- package/data_adapters/CytobandAdapter/CytobandAdapter.js +1 -2
- package/data_adapters/CytobandAdapter/configSchema.d.ts +0 -3
- package/data_adapters/CytobandAdapter/configSchema.js +1 -7
- package/data_adapters/CytobandAdapter/index.d.ts +1 -1
- package/data_adapters/CytobandAdapter/index.js +1 -1
- package/data_adapters/dataAdapterCache.d.ts +4 -21
- package/data_adapters/dataAdapterCache.js +0 -19
- package/package.json +3 -4
- package/pluggableElementTypes/AdapterType.d.ts +2 -2
- package/pluggableElementTypes/AddTrackWorkflowType.d.ts +2 -2
- package/pluggableElementTypes/ConnectionType.d.ts +3 -3
- package/pluggableElementTypes/DisplayType.d.ts +3 -9
- package/pluggableElementTypes/InternetAccountType.d.ts +2 -2
- package/pluggableElementTypes/PluggableElementBase.d.ts +1 -1
- package/pluggableElementTypes/PluggableElementBase.js +2 -2
- package/pluggableElementTypes/RpcMethodType.d.ts +5 -11
- package/pluggableElementTypes/RpcMethodType.js +7 -19
- package/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions.d.ts +9 -0
- package/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions.js +35 -0
- package/pluggableElementTypes/TextSearchAdapterType.d.ts +2 -2
- package/pluggableElementTypes/TrackType.d.ts +3 -3
- package/pluggableElementTypes/ViewType.d.ts +3 -3
- package/pluggableElementTypes/WidgetType.d.ts +4 -3
- package/pluggableElementTypes/index.d.ts +11 -11
- package/pluggableElementTypes/models/BaseConnectionModelFactory.d.ts +2 -29
- package/pluggableElementTypes/models/BaseConnectionModelFactory.js +1 -28
- package/pluggableElementTypes/models/BaseDisplayModel.d.ts +3 -83
- package/pluggableElementTypes/models/BaseDisplayModel.js +2 -69
- package/pluggableElementTypes/models/BaseTrackModel.d.ts +4 -46
- package/pluggableElementTypes/models/BaseTrackModel.js +0 -58
- package/pluggableElementTypes/models/BaseViewModel.d.ts +2 -42
- package/pluggableElementTypes/models/BaseViewModel.js +2 -38
- package/pluggableElementTypes/models/InternetAccountModel.d.ts +3 -119
- package/pluggableElementTypes/models/InternetAccountModel.js +3 -123
- package/pluggableElementTypes/models/baseConnectionConfig.d.ts +0 -6
- package/pluggableElementTypes/models/baseConnectionConfig.js +1 -13
- package/pluggableElementTypes/models/baseInternetAccountConfig.d.ts +0 -15
- package/pluggableElementTypes/models/baseInternetAccountConfig.js +1 -23
- package/pluggableElementTypes/models/baseTrackConfig.d.ts +2 -53
- package/pluggableElementTypes/models/baseTrackConfig.js +1 -58
- package/pluggableElementTypes/renderers/BoxRendererType.d.ts +7 -15
- package/pluggableElementTypes/renderers/BoxRendererType.js +3 -14
- package/pluggableElementTypes/renderers/CircularChordRendererType.d.ts +3 -2
- package/pluggableElementTypes/renderers/CircularChordRendererType.js +1 -6
- package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.d.ts +6 -21
- package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +2 -25
- package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +5 -47
- package/pluggableElementTypes/renderers/FeatureRendererType.js +15 -68
- package/pluggableElementTypes/renderers/RendererType.d.ts +4 -8
- package/pluggableElementTypes/renderers/RendererType.js +1 -5
- package/pluggableElementTypes/renderers/RpcRenderedSvgGroup.d.ts +2 -2
- package/pluggableElementTypes/renderers/RpcRenderedSvgGroup.js +3 -12
- package/pluggableElementTypes/renderers/ServerSideRenderedContent.d.ts +1 -1
- package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +6 -14
- package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +9 -49
- package/pluggableElementTypes/renderers/ServerSideRendererType.js +7 -57
- package/pluggableElementTypes/renderers/index.d.ts +1 -1
- package/pluggableElementTypes/renderers/util/serializableFilterChain.js +1 -3
- package/rpc/BaseRpcDriver.d.ts +3 -4
- package/rpc/BaseRpcDriver.js +20 -80
- package/rpc/MainThreadRpcDriver.d.ts +3 -7
- package/rpc/MainThreadRpcDriver.js +0 -5
- package/rpc/RpcManager.d.ts +3 -3
- package/rpc/RpcManager.js +2 -4
- package/rpc/WebWorkerRpcDriver.d.ts +3 -2
- package/rpc/WebWorkerRpcDriver.js +2 -13
- package/rpc/baseRpcConfig.d.ts +0 -3
- package/rpc/baseRpcConfig.js +1 -7
- package/rpc/configSchema.d.ts +0 -6
- package/rpc/configSchema.js +2 -11
- package/rpc/mainThreadRpcConfig.js +1 -7
- package/rpc/methods/CoreFreeResources.d.ts +0 -6
- package/rpc/methods/CoreFreeResources.js +2 -9
- package/rpc/methods/CoreGetFeatureDensityStats.d.ts +4 -5
- package/rpc/methods/CoreGetFeatureDensityStats.js +1 -1
- package/rpc/methods/CoreGetFeatureDetails.d.ts +2 -7
- package/rpc/methods/CoreGetFeatureDetails.js +0 -5
- package/rpc/methods/CoreGetFeatures.d.ts +5 -5
- package/rpc/methods/CoreGetFeatures.js +4 -5
- package/rpc/methods/CoreGetFileInfo.d.ts +1 -2
- package/rpc/methods/CoreGetFileInfo.js +1 -1
- package/rpc/methods/CoreGetMetadata.d.ts +1 -2
- package/rpc/methods/CoreGetMetadata.js +1 -1
- package/rpc/methods/CoreGetRefNames.d.ts +1 -2
- package/rpc/methods/CoreGetRefNames.js +1 -1
- package/rpc/methods/CoreRender.d.ts +2 -6
- package/rpc/methods/CoreRender.js +5 -7
- package/rpc/methods/util.d.ts +3 -3
- package/rpc/methods/util.js +0 -1
- package/rpc/webWorkerRpcConfig.js +1 -7
- package/stories/JBrowseCore.stories.d.ts +1 -1
- package/stories/JBrowseCore.stories.js +3 -3
- package/stories/examples/WithSequencePanel.d.ts +1 -1
- package/stories/examples/WithSequencePanel.js +3 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/AppLogo.d.ts +1 -1
- package/ui/AppLogo.js +0 -2
- package/ui/AssemblySelector.d.ts +2 -2
- package/ui/AssemblySelector.js +0 -3
- package/ui/BaseTooltip.js +2 -6
- package/ui/CascadingMenu.d.ts +2 -2
- package/ui/CascadingMenu.js +3 -4
- package/ui/CascadingMenuButton.d.ts +1 -1
- package/ui/CascadingMenuButton.js +1 -1
- package/ui/ColorPicker.js +1 -7
- package/ui/Dialog.d.ts +1 -1
- package/ui/Dialog.js +2 -6
- package/ui/DropDownMenu.d.ts +1 -1
- package/ui/DropDownMenu.js +2 -2
- package/ui/EditableTypography.d.ts +1 -1
- package/ui/EditableTypography.js +1 -5
- package/ui/ErrorBoundary.d.ts +2 -1
- package/ui/ErrorMessage.js +2 -9
- package/ui/ErrorMessageStackTraceDialog.js +2 -10
- package/ui/FactoryResetDialog.js +1 -1
- package/ui/FatalErrorDialog.js +1 -1
- package/ui/FileSelector/FileSelector.d.ts +4 -3
- package/ui/FileSelector/FileSelector.js +40 -40
- package/ui/FileSelector/LocalFileChooser.d.ts +1 -1
- package/ui/FileSelector/LocalFileChooser.js +0 -1
- package/ui/FileSelector/UrlChooser.d.ts +4 -3
- package/ui/FileSelector/UrlChooser.js +5 -3
- package/ui/Icons.d.ts +1 -1
- package/ui/Icons.js +1 -7
- package/ui/LoadingEllipses.d.ts +1 -1
- package/ui/LoadingEllipses.js +3 -3
- package/ui/Menu.d.ts +1 -1
- package/ui/Menu.js +3 -10
- package/ui/MenuButton.d.ts +1 -1
- package/ui/ResizeHandle.js +2 -2
- package/ui/ReturnToImportFormDialog.js +1 -1
- package/ui/SanitizedHTML.js +1 -21
- package/ui/Snackbar.d.ts +2 -2
- package/ui/Snackbar.js +1 -2
- package/ui/SnackbarModel.d.ts +1 -26
- package/ui/SnackbarModel.js +2 -30
- package/ui/colors.d.ts +1 -1
- package/ui/colors.js +1 -1
- package/ui/react-colorful.js +0 -3
- package/ui/theme.d.ts +1 -1
- package/ui/theme.js +0 -40
- package/util/Base1DUtils.d.ts +1 -1
- package/util/Base1DUtils.js +0 -12
- package/util/Base1DViewModel.d.ts +4 -81
- package/util/Base1DViewModel.js +4 -108
- package/util/QuickLRU.js +0 -9
- package/util/TimeTraveller.js +0 -4
- package/util/aborting.d.ts +0 -20
- package/util/aborting.js +0 -31
- package/util/analytics.js +1 -12
- package/util/blockTypes.d.ts +0 -11
- package/util/blockTypes.js +0 -13
- package/util/calculateDynamicBlocks.d.ts +1 -20
- package/util/calculateDynamicBlocks.js +1 -22
- package/util/calculateStaticBlocks.d.ts +2 -2
- package/util/calculateStaticBlocks.js +0 -2
- package/util/color/cssColorsLevel4.js +0 -1
- package/util/color/index.d.ts +0 -19
- package/util/color/index.js +0 -30
- package/util/compositeMap.js +0 -2
- package/util/dedupe.js +0 -1
- package/util/formatFastaStrings.d.ts +0 -13
- package/util/formatFastaStrings.js +0 -13
- package/util/idMaker.d.ts +1 -1
- package/util/idMaker.js +16 -12
- package/util/index.d.ts +16 -164
- package/util/index.js +22 -282
- package/util/io/RemoteFileWithRangeCache.d.ts +3 -2
- package/util/io/RemoteFileWithRangeCache.js +6 -10
- package/util/io/index.d.ts +3 -4
- package/util/io/index.js +3 -17
- package/util/jexl.js +3 -13
- package/util/jexlStrings.d.ts +0 -6
- package/util/jexlStrings.js +0 -8
- package/util/layouts/BaseLayout.d.ts +1 -1
- package/util/layouts/GranularRectLayout.d.ts +1 -17
- package/util/layouts/GranularRectLayout.js +4 -81
- package/util/layouts/MultiLayout.d.ts +1 -6
- package/util/layouts/MultiLayout.js +0 -6
- package/util/layouts/PrecomputedLayout.d.ts +1 -4
- package/util/layouts/PrecomputedLayout.js +0 -5
- package/util/layouts/PrecomputedMultiLayout.js +0 -2
- package/util/layouts/SceneGraph.d.ts +0 -12
- package/util/layouts/SceneGraph.js +0 -13
- package/util/makeAbortableReaction.d.ts +2 -0
- package/util/makeAbortableReaction.js +50 -0
- package/util/map-obj.js +0 -4
- package/util/mst-reflection.d.ts +1 -14
- package/util/mst-reflection.js +1 -28
- package/util/nanoid.js +0 -31
- package/util/nextTick.d.ts +1 -0
- package/util/nextTick.js +6 -0
- package/util/offscreenCanvasPonyfill.d.ts +0 -1
- package/util/offscreenCanvasPonyfill.js +1 -9
- package/util/offscreenCanvasUtils.js +1 -8
- package/util/range.d.ts +0 -25
- package/util/range.js +0 -34
- package/util/rxjs.d.ts +3 -7
- package/util/rxjs.js +2 -9
- package/util/simpleFeature.d.ts +0 -50
- package/util/simpleFeature.js +0 -35
- package/util/stats.d.ts +3 -26
- package/util/stats.js +0 -25
- package/util/stopToken.d.ts +3 -0
- package/util/stopToken.js +29 -0
- package/util/tracks.d.ts +3 -25
- package/util/tracks.js +0 -30
- package/util/types/index.d.ts +14 -30
- package/util/types/index.js +5 -14
- package/util/types/mst.js +0 -9
- package/util/types/util.d.ts +2 -9
- package/util/useMeasure.js +0 -1
- package/util/when.d.ts +1 -15
- package/util/when.js +3 -70
- package/rpc/remoteAbortSignals.d.ts +0 -36
- package/rpc/remoteAbortSignals.js +0 -79
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeAbortableReaction = makeAbortableReaction;
|
|
4
|
+
const mobx_1 = require("mobx");
|
|
5
|
+
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
6
|
+
const aborting_1 = require("./aborting");
|
|
7
|
+
const stopToken_1 = require("./stopToken");
|
|
8
|
+
function makeAbortableReaction(self, dataFunction, asyncReactionFunction, reactionOptions, startedFunction, successFunction, errorFunction) {
|
|
9
|
+
let inProgress;
|
|
10
|
+
function handleError(error) {
|
|
11
|
+
if (!(0, aborting_1.isAbortException)(error)) {
|
|
12
|
+
console.error(error);
|
|
13
|
+
if ((0, mobx_state_tree_1.isAlive)(self)) {
|
|
14
|
+
errorFunction(error);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
(0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.reaction)(() => {
|
|
19
|
+
try {
|
|
20
|
+
return dataFunction(self);
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
handleError(e);
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}, async (data, mobxReactionHandle) => {
|
|
27
|
+
if (inProgress) {
|
|
28
|
+
(0, stopToken_1.stopStopToken)(inProgress);
|
|
29
|
+
}
|
|
30
|
+
if (!(0, mobx_state_tree_1.isAlive)(self)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
inProgress = (0, stopToken_1.createStopToken)();
|
|
34
|
+
startedFunction(inProgress);
|
|
35
|
+
try {
|
|
36
|
+
const result = await asyncReactionFunction(data, inProgress, self, mobxReactionHandle);
|
|
37
|
+
if ((0, mobx_state_tree_1.isAlive)(self)) {
|
|
38
|
+
successFunction(result);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
handleError(e);
|
|
43
|
+
}
|
|
44
|
+
}, reactionOptions));
|
|
45
|
+
(0, mobx_state_tree_1.addDisposer)(self, () => {
|
|
46
|
+
if (inProgress) {
|
|
47
|
+
(0, stopToken_1.stopStopToken)(inProgress);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
package/util/map-obj.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = map;
|
|
4
|
-
// adapted from map-obj (MIT), with modifications to pass the "whole object"
|
|
5
|
-
// from an array of objects into itself
|
|
6
4
|
const isObject = (value) => typeof value === 'object' && value !== null;
|
|
7
|
-
// Customized for this use-case
|
|
8
5
|
const isObjectCustom = (value) => isObject(value) &&
|
|
9
6
|
!(value instanceof RegExp) &&
|
|
10
7
|
!(value instanceof Error) &&
|
|
11
8
|
!(value instanceof Date) &&
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
13
9
|
!(globalThis.Blob && value instanceof globalThis.Blob);
|
|
14
10
|
function map(object, mapper, isSeen = new WeakSet()) {
|
|
15
11
|
if (isSeen.has(object)) {
|
package/util/mst-reflection.d.ts
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
import { IAnyType, IModelReflectionPropertiesData,
|
|
1
|
+
import type { IAnyComplexType, IAnyType, IModelReflectionPropertiesData, ISimpleType, UnionStringArray } from 'mobx-state-tree';
|
|
2
2
|
export interface ILiteralType<T> extends ISimpleType<T> {
|
|
3
3
|
value: T;
|
|
4
4
|
}
|
|
5
|
-
/**
|
|
6
|
-
* get the inner type of an MST optional, array, or late type object
|
|
7
|
-
*/
|
|
8
5
|
export declare function getSubType(type: IAnyType): IAnyType;
|
|
9
|
-
/**
|
|
10
|
-
* get the array of the subtypes in a union
|
|
11
|
-
*/
|
|
12
6
|
export declare function getUnionSubTypes(unionType: IAnyType): IAnyType[];
|
|
13
|
-
/**
|
|
14
|
-
* get the type of one of the properties of the given MST model type
|
|
15
|
-
*/
|
|
16
7
|
export declare function getPropertyType(type: IModelReflectionPropertiesData, propertyName: string): IAnyType;
|
|
17
|
-
/**
|
|
18
|
-
* get the base type from inside an MST optional type
|
|
19
|
-
*/
|
|
20
8
|
export declare function getDefaultValue(type: IAnyType): any;
|
|
21
9
|
export type IEnumerationType<T extends string> = ISimpleType<UnionStringArray<T[]>>;
|
|
22
|
-
/** get the string values of an MST enumeration type */
|
|
23
10
|
export declare function getEnumerationValues(type: IAnyComplexType): string[];
|
|
24
11
|
export declare function resolveLateType(maybeLate: IAnyType): any;
|
package/util/mst-reflection.js
CHANGED
|
@@ -7,82 +7,55 @@ exports.getDefaultValue = getDefaultValue;
|
|
|
7
7
|
exports.getEnumerationValues = getEnumerationValues;
|
|
8
8
|
exports.resolveLateType = resolveLateType;
|
|
9
9
|
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
10
|
-
/**
|
|
11
|
-
* get the inner type of an MST optional, array, or late type object
|
|
12
|
-
*/
|
|
13
10
|
function getSubType(type) {
|
|
14
11
|
let t;
|
|
15
12
|
if ((0, mobx_state_tree_1.isOptionalType)(type)) {
|
|
16
|
-
// @ts-expect-error
|
|
17
13
|
t = type._subtype || type.type;
|
|
18
14
|
}
|
|
19
15
|
else if ((0, mobx_state_tree_1.isArrayType)(type) || (0, mobx_state_tree_1.isMapType)(type)) {
|
|
20
|
-
// @ts-expect-error
|
|
21
16
|
t = type._subtype || type._subType || type.subType;
|
|
22
|
-
// @ts-expect-error
|
|
23
17
|
}
|
|
24
18
|
else if (typeof type.getSubType === 'function') {
|
|
25
|
-
// @ts-expect-error
|
|
26
19
|
return type.getSubType();
|
|
27
20
|
}
|
|
28
21
|
else {
|
|
29
22
|
throw new TypeError('unsupported mst type');
|
|
30
23
|
}
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
32
24
|
if (!t) {
|
|
33
25
|
throw new Error('failed to get subtype');
|
|
34
26
|
}
|
|
35
27
|
return t;
|
|
36
28
|
}
|
|
37
|
-
/**
|
|
38
|
-
* get the array of the subtypes in a union
|
|
39
|
-
*/
|
|
40
29
|
function getUnionSubTypes(unionType) {
|
|
41
30
|
if (!(0, mobx_state_tree_1.isUnionType)(unionType)) {
|
|
42
31
|
throw new TypeError('not an MST union type');
|
|
43
32
|
}
|
|
44
|
-
const t =
|
|
45
|
-
// @ts-expect-error
|
|
46
|
-
unionType._types ||
|
|
47
|
-
// @ts-expect-error
|
|
33
|
+
const t = unionType._types ||
|
|
48
34
|
unionType.types ||
|
|
49
|
-
// @ts-expect-error
|
|
50
35
|
getSubType(unionType)._types ||
|
|
51
|
-
// @ts-expect-error
|
|
52
36
|
getSubType(unionType).types;
|
|
53
37
|
if (!t) {
|
|
54
|
-
// debugger
|
|
55
38
|
throw new Error('failed to extract subtypes from mst union');
|
|
56
39
|
}
|
|
57
40
|
return t;
|
|
58
41
|
}
|
|
59
|
-
/**
|
|
60
|
-
* get the type of one of the properties of the given MST model type
|
|
61
|
-
*/
|
|
62
42
|
function getPropertyType(type, propertyName) {
|
|
63
43
|
return type.properties[propertyName];
|
|
64
44
|
}
|
|
65
|
-
/**
|
|
66
|
-
* get the base type from inside an MST optional type
|
|
67
|
-
*/
|
|
68
45
|
function getDefaultValue(type) {
|
|
69
46
|
if (!(0, mobx_state_tree_1.isOptionalType)(type)) {
|
|
70
47
|
throw new TypeError('type must be an optional type');
|
|
71
48
|
}
|
|
72
|
-
// @ts-expect-error
|
|
73
49
|
return type._defaultValue || type.defaultValue;
|
|
74
50
|
}
|
|
75
|
-
/** get the string values of an MST enumeration type */
|
|
76
51
|
function getEnumerationValues(type) {
|
|
77
52
|
const subtypes = getUnionSubTypes(type);
|
|
78
|
-
// the subtypes should all be literals with a value member
|
|
79
53
|
return subtypes.map(t => t.value);
|
|
80
54
|
}
|
|
81
55
|
function resolveLateType(maybeLate) {
|
|
82
56
|
if (!(0, mobx_state_tree_1.isUnionType)(maybeLate) &&
|
|
83
57
|
!(0, mobx_state_tree_1.isArrayType)(maybeLate) &&
|
|
84
58
|
(0, mobx_state_tree_1.isLateType)(maybeLate)) {
|
|
85
|
-
// @ts-expect-error
|
|
86
59
|
return maybeLate.getSubType();
|
|
87
60
|
}
|
|
88
61
|
return maybeLate;
|
package/util/nanoid.js
CHANGED
|
@@ -1,42 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// This file replaces `index.js` in bundlers like webpack or Rollup,
|
|
3
|
-
// according to `browser` config in `package.json`.
|
|
4
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
3
|
exports.nanoid = exports.customAlphabet = exports.customRandom = exports.random = exports.urlAlphabet = void 0;
|
|
6
|
-
// This alphabet uses `A-Za-z0-9_-` symbols.
|
|
7
|
-
// The order of characters is optimized for better gzip and brotli compression.
|
|
8
|
-
// Same as in non-secure/index.js
|
|
9
4
|
exports.urlAlphabet = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
10
5
|
const random = bytes => crypto.getRandomValues(new Uint8Array(bytes));
|
|
11
6
|
exports.random = random;
|
|
12
7
|
const customRandom = (alphabet, defaultSize, getRandom) => {
|
|
13
|
-
// First, a bitmask is necessary to generate the ID. The bitmask makes bytes
|
|
14
|
-
// values closer to the alphabet size. The bitmask calculates the closest
|
|
15
|
-
// `2^31 - 1` number, which exceeds the alphabet size.
|
|
16
|
-
// For example, the bitmask for the alphabet size 30 is 31 (00011111).
|
|
17
|
-
// `Math.clz32` is not used, because it is not available in browsers.
|
|
18
8
|
const mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1;
|
|
19
|
-
// Though, the bitmask solution is not perfect since the bytes exceeding
|
|
20
|
-
// the alphabet size are refused. Therefore, to reliably generate the ID,
|
|
21
|
-
// the random bytes redundancy has to be satisfied.
|
|
22
|
-
// Note: every hardware random generator call is performance expensive,
|
|
23
|
-
// because the system call for entropy collection takes a lot of time.
|
|
24
|
-
// So, to avoid additional system calls, extra bytes are requested in advance.
|
|
25
|
-
// Next, a step determines how many random bytes to generate.
|
|
26
|
-
// The number of random bytes gets decided upon the ID size, mask,
|
|
27
|
-
// alphabet size, and magic number 1.6 (using 1.6 peaks at performance
|
|
28
|
-
// according to benchmarks).
|
|
29
|
-
// `-~f => Math.ceil(f)` if f is a float
|
|
30
|
-
// `-~i => i + 1` if i is an integer
|
|
31
9
|
const step = -~((1.6 * mask * defaultSize) / alphabet.length);
|
|
32
10
|
return (size = defaultSize) => {
|
|
33
11
|
let id = '';
|
|
34
12
|
while (true) {
|
|
35
13
|
const bytes = getRandom(step);
|
|
36
|
-
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
|
37
14
|
let j = step;
|
|
38
15
|
while (j--) {
|
|
39
|
-
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
|
40
16
|
id += alphabet[bytes[j] & mask] || '';
|
|
41
17
|
if (id.length === size) {
|
|
42
18
|
return id;
|
|
@@ -49,18 +25,11 @@ exports.customRandom = customRandom;
|
|
|
49
25
|
const customAlphabet = (alphabet, size = 21) => (0, exports.customRandom)(alphabet, size, exports.random);
|
|
50
26
|
exports.customAlphabet = customAlphabet;
|
|
51
27
|
const nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
52
|
-
// It is incorrect to use bytes exceeding the alphabet size.
|
|
53
|
-
// The following mask reduces the random byte in the 0-255 value
|
|
54
|
-
// range to the 0-63 value range. Therefore, adding hacks, such
|
|
55
|
-
// as empty string fallback or magic numbers, is unnecessary because
|
|
56
|
-
// the bitmask trims bytes down to the alphabet size.
|
|
57
28
|
byte &= 63;
|
|
58
29
|
if (byte < 36) {
|
|
59
|
-
// `0-9a-z`
|
|
60
30
|
id += byte.toString(36);
|
|
61
31
|
}
|
|
62
32
|
else if (byte < 62) {
|
|
63
|
-
// `A-Z`
|
|
64
33
|
id += (byte - 26).toString(36).toUpperCase();
|
|
65
34
|
}
|
|
66
35
|
else if (byte > 62) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function nextTickMod(): Promise<unknown>;
|
package/util/nextTick.js
ADDED
|
@@ -2,7 +2,6 @@ type AbstractCanvas = any;
|
|
|
2
2
|
type AbstractImageBitmap = any;
|
|
3
3
|
export declare let createCanvas: (width: number, height: number) => AbstractCanvas;
|
|
4
4
|
export declare let createImageBitmap: (canvas: AbstractCanvas) => Promise<AbstractImageBitmap>;
|
|
5
|
-
/** the JS class (constructor) for offscreen-generated image bitmap data */
|
|
6
5
|
export declare let ImageBitmapType: unknown;
|
|
7
6
|
export declare function drawImageOntoCanvasContext(imageData: any, context: CanvasRenderingContext2D): void;
|
|
8
7
|
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable react-refresh/only-export-components */
|
|
3
|
-
// This file is a ponyfill for the HTML5 OffscreenCanvas API.
|
|
4
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
4
|
};
|
|
7
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
6
|
exports.ImageBitmapType = exports.createImageBitmap = exports.createCanvas = void 0;
|
|
9
7
|
exports.drawImageOntoCanvasContext = drawImageOntoCanvasContext;
|
|
10
|
-
const detect_node_1 = __importDefault(require("detect-node"));
|
|
11
8
|
const canvas_sequencer_1 = require("canvas-sequencer");
|
|
9
|
+
const detect_node_1 = __importDefault(require("detect-node"));
|
|
12
10
|
function drawImageOntoCanvasContext(imageData, context) {
|
|
13
11
|
if (imageData.serializedCommands) {
|
|
14
12
|
const seq = new canvas_sequencer_1.CanvasSequence(imageData.serializedCommands);
|
|
@@ -24,23 +22,17 @@ const weHave = {
|
|
|
24
22
|
};
|
|
25
23
|
if (weHave.realOffscreenCanvas) {
|
|
26
24
|
exports.createCanvas = (width, height) => new OffscreenCanvas(width, height);
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
28
25
|
exports.createImageBitmap = window.createImageBitmap || self.createImageBitmap;
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
30
26
|
exports.ImageBitmapType = window.ImageBitmap || self.ImageBitmap;
|
|
31
27
|
}
|
|
32
28
|
else if (weHave.node) {
|
|
33
|
-
// use node-canvas if we are running in node (i.e. automated tests)
|
|
34
29
|
exports.createCanvas = (...args) => {
|
|
35
|
-
// @ts-expect-error
|
|
36
30
|
return nodeCreateCanvas(...args);
|
|
37
31
|
};
|
|
38
32
|
exports.createImageBitmap = async (canvas) => {
|
|
39
33
|
const dataUri = canvas.toDataURL();
|
|
40
|
-
// @ts-expect-error
|
|
41
34
|
const img = new nodeImage();
|
|
42
35
|
return new Promise((resolve, reject) => {
|
|
43
|
-
// need onload for jest
|
|
44
36
|
img.onload = () => {
|
|
45
37
|
resolve(img);
|
|
46
38
|
};
|
|
@@ -29,12 +29,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.renderToAbstractCanvas = renderToAbstractCanvas;
|
|
30
30
|
exports.getSerializedSvg = getSerializedSvg;
|
|
31
31
|
exports.ReactRendering = ReactRendering;
|
|
32
|
-
/* eslint-disable react-refresh/only-export-components */
|
|
33
32
|
const react_1 = __importDefault(require("react"));
|
|
34
33
|
const canvas_sequencer_1 = require("canvas-sequencer");
|
|
35
|
-
// locals
|
|
36
|
-
const offscreenCanvasPonyfill_1 = require("./offscreenCanvasPonyfill");
|
|
37
34
|
const blobToDataURL_1 = require("./blobToDataURL");
|
|
35
|
+
const offscreenCanvasPonyfill_1 = require("./offscreenCanvasPonyfill");
|
|
38
36
|
async function renderToAbstractCanvas(width, height, opts, cb) {
|
|
39
37
|
const { exportSVG, highResolutionScaling = 1 } = opts;
|
|
40
38
|
if (exportSVG) {
|
|
@@ -55,8 +53,6 @@ async function renderToAbstractCanvas(width, height, opts, cb) {
|
|
|
55
53
|
}
|
|
56
54
|
ctx.scale(s, s);
|
|
57
55
|
const result = await cb(ctx);
|
|
58
|
-
// two methods needed for converting canvas to PNG, one for webworker
|
|
59
|
-
// offscreen canvas, one for main thread
|
|
60
56
|
return {
|
|
61
57
|
...result,
|
|
62
58
|
reactElement: (react_1.default.createElement("image", { width: width, height: height, xlinkHref: 'convertToBlob' in canvas
|
|
@@ -81,13 +77,10 @@ async function renderToAbstractCanvas(width, height, opts, cb) {
|
|
|
81
77
|
}
|
|
82
78
|
async function getSerializedSvg(results) {
|
|
83
79
|
const { width, height, canvasRecordedData } = results;
|
|
84
|
-
// @ts-ignore needs to be ignore not expect error, produces error in build step
|
|
85
80
|
const C2S = await Promise.resolve().then(() => __importStar(require('canvas2svg')));
|
|
86
81
|
const ctx = new C2S.default(width, height);
|
|
87
82
|
const seq = new canvas_sequencer_1.CanvasSequence(canvasRecordedData);
|
|
88
83
|
seq.execute(ctx);
|
|
89
|
-
// innerHTML strips the outer <svg> element from returned data, we add
|
|
90
|
-
// our own <svg> element in the view's SVG export
|
|
91
84
|
return ctx.getSvg().innerHTML;
|
|
92
85
|
}
|
|
93
86
|
function ReactRendering({ rendering, }) {
|
package/util/range.d.ts
CHANGED
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* fast low-level intersection of 2 coordinate ranges. assumes interbase coordinates.
|
|
3
|
-
*
|
|
4
|
-
* assumes `left <= right` for both ranges
|
|
5
|
-
*
|
|
6
|
-
* @returns array of [left, right], or [] if the ranges do not intersect. the choice of [] is because it allows destructuring array assignment without check for undefined return
|
|
7
|
-
*/
|
|
8
1
|
export declare function intersection2(left1: number, right1: number, left2: number, right2: number): [number, number] | [];
|
|
9
|
-
/**
|
|
10
|
-
* Return whether 2 interbase coordinate ranges intersect.
|
|
11
|
-
*
|
|
12
|
-
* @param left1 -
|
|
13
|
-
* @param right1 -
|
|
14
|
-
* @param left2 -
|
|
15
|
-
* @param right2 -
|
|
16
|
-
*
|
|
17
|
-
* @returns true if the two ranges intersect
|
|
18
|
-
*/
|
|
19
2
|
export declare function doesIntersect2(left1: number, right1: number, left2: number, right2: number): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Return whether the first region is completely contained within the second region
|
|
22
|
-
*
|
|
23
|
-
* @param left1 - candidate inner region left
|
|
24
|
-
* @param right1 - candidate inner region right
|
|
25
|
-
* @param left2 - candidate outer region left
|
|
26
|
-
* @param right2 - candidate outer region right
|
|
27
|
-
*/
|
|
28
3
|
export declare function isContainedWithin(left1: number, right1: number, left2: number, right2: number): boolean;
|
package/util/range.js
CHANGED
|
@@ -3,58 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.intersection2 = intersection2;
|
|
4
4
|
exports.doesIntersect2 = doesIntersect2;
|
|
5
5
|
exports.isContainedWithin = isContainedWithin;
|
|
6
|
-
/**
|
|
7
|
-
* fast low-level intersection of 2 coordinate ranges. assumes interbase coordinates.
|
|
8
|
-
*
|
|
9
|
-
* assumes `left <= right` for both ranges
|
|
10
|
-
*
|
|
11
|
-
* @returns array of [left, right], or [] if the ranges do not intersect. the choice of [] is because it allows destructuring array assignment without check for undefined return
|
|
12
|
-
*/
|
|
13
6
|
function intersection2(left1, right1, left2, right2) {
|
|
14
|
-
// this code is verbose because "if" statements are faster than Math.min and Math.max
|
|
15
7
|
if (right1 > left2 && left1 < right2 && right2 - left2 && right1 - left1) {
|
|
16
8
|
if (left1 > left2) {
|
|
17
9
|
if (right1 < right2) {
|
|
18
|
-
// 1 |-------|
|
|
19
|
-
// |------------|
|
|
20
10
|
return [left1, right1];
|
|
21
11
|
}
|
|
22
|
-
// 2 |----|
|
|
23
|
-
// |------|
|
|
24
12
|
return [left1, right2];
|
|
25
13
|
}
|
|
26
14
|
if (right1 < right2) {
|
|
27
|
-
// 3 |-----|
|
|
28
|
-
// |------|
|
|
29
15
|
return [left2, right1];
|
|
30
16
|
}
|
|
31
|
-
// 4 |------------|
|
|
32
|
-
// |-------|
|
|
33
17
|
return [left2, right2];
|
|
34
18
|
}
|
|
35
19
|
return [];
|
|
36
20
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Return whether 2 interbase coordinate ranges intersect.
|
|
39
|
-
*
|
|
40
|
-
* @param left1 -
|
|
41
|
-
* @param right1 -
|
|
42
|
-
* @param left2 -
|
|
43
|
-
* @param right2 -
|
|
44
|
-
*
|
|
45
|
-
* @returns true if the two ranges intersect
|
|
46
|
-
*/
|
|
47
21
|
function doesIntersect2(left1, right1, left2, right2) {
|
|
48
22
|
return right1 > left2 && left1 < right2;
|
|
49
23
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Return whether the first region is completely contained within the second region
|
|
52
|
-
*
|
|
53
|
-
* @param left1 - candidate inner region left
|
|
54
|
-
* @param right1 - candidate inner region right
|
|
55
|
-
* @param left2 - candidate outer region left
|
|
56
|
-
* @param right2 - candidate outer region right
|
|
57
|
-
*/
|
|
58
24
|
function isContainedWithin(left1, right1, left2, right2) {
|
|
59
25
|
return left2 <= left1 && right2 >= right1;
|
|
60
26
|
}
|
package/util/rxjs.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { Observable
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* aborting support
|
|
5
|
-
* @param func - observer function, could be async
|
|
6
|
-
*/
|
|
7
|
-
export declare function ObservableCreate<T>(func: (arg: Observer<T>) => void | Promise<void>, signal?: AbortSignal): Observable<T>;
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import type { Observer } from 'rxjs';
|
|
3
|
+
export declare function ObservableCreate<T>(func: (arg: Observer<T>) => void | Promise<void>, _stopToken?: string): Observable<T>;
|
package/util/rxjs.js
CHANGED
|
@@ -2,14 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ObservableCreate = ObservableCreate;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
|
-
|
|
6
|
-
const _1 = require(".");
|
|
7
|
-
/**
|
|
8
|
-
* Wrapper for rxjs Observable.create with improved error handling and
|
|
9
|
-
* aborting support
|
|
10
|
-
* @param func - observer function, could be async
|
|
11
|
-
*/
|
|
12
|
-
function ObservableCreate(func, signal) {
|
|
5
|
+
function ObservableCreate(func, _stopToken) {
|
|
13
6
|
return new rxjs_1.Observable((observer) => {
|
|
14
7
|
try {
|
|
15
8
|
const ret = func(observer);
|
|
@@ -22,5 +15,5 @@ function ObservableCreate(func, signal) {
|
|
|
22
15
|
catch (error) {
|
|
23
16
|
observer.error(error);
|
|
24
17
|
}
|
|
25
|
-
})
|
|
18
|
+
});
|
|
26
19
|
}
|
package/util/simpleFeature.d.ts
CHANGED
|
@@ -1,39 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Abstract feature object
|
|
3
|
-
*/
|
|
4
1
|
export interface Feature {
|
|
5
|
-
/**
|
|
6
|
-
* Get a piece of data about the feature. All features must have
|
|
7
|
-
* 'start' and 'end', but everything else is optional.
|
|
8
|
-
*/
|
|
9
2
|
get(name: 'refName'): string;
|
|
10
3
|
get(name: 'start' | 'end'): number;
|
|
11
4
|
get(name: 'subfeatures'): Feature[] | undefined;
|
|
12
5
|
get(name: string): any;
|
|
13
|
-
/**
|
|
14
|
-
* Get the unique ID of this feature.
|
|
15
|
-
*/
|
|
16
6
|
id(): string;
|
|
17
|
-
/**
|
|
18
|
-
* Get this feature's parent feature, or undefined if none.
|
|
19
|
-
*/
|
|
20
7
|
parent(): Feature | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Get an array of child features, or undefined if none.
|
|
23
|
-
*/
|
|
24
8
|
children(): Feature[] | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Convert to JSON
|
|
27
|
-
*/
|
|
28
9
|
toJSON(): SimpleFeatureSerialized;
|
|
29
10
|
}
|
|
30
11
|
export declare function isFeature(thing: unknown): thing is Feature;
|
|
31
12
|
export interface SimpleFeatureArgs {
|
|
32
|
-
/** key-value data, must include 'start' and 'end' */
|
|
33
13
|
data: Record<string, unknown>;
|
|
34
|
-
/** optional parent feature */
|
|
35
14
|
parent?: Feature;
|
|
36
|
-
/** unique identifier. can also be in data.uniqueId */
|
|
37
15
|
id: string | number;
|
|
38
16
|
}
|
|
39
17
|
export interface SimpleFeatureSerializedNoId {
|
|
@@ -49,45 +27,17 @@ export interface SimpleFeatureSerialized extends SimpleFeatureSerializedNoId {
|
|
|
49
27
|
subfeatures?: SimpleFeatureSerializedNoId[];
|
|
50
28
|
uniqueId: string;
|
|
51
29
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Simple implementation of a feature object.
|
|
54
|
-
*/
|
|
55
30
|
export default class SimpleFeature implements Feature {
|
|
56
31
|
private data;
|
|
57
32
|
private subfeatures?;
|
|
58
33
|
private parentHandle?;
|
|
59
34
|
private uniqueId;
|
|
60
|
-
/**
|
|
61
|
-
* @param args - SimpleFeature args
|
|
62
|
-
*
|
|
63
|
-
* Note: args.data.subfeatures can be an array of these same args,
|
|
64
|
-
* which will be inflated to more instances of this class.
|
|
65
|
-
*/
|
|
66
35
|
constructor(args: SimpleFeatureArgs | SimpleFeatureSerialized);
|
|
67
|
-
/**
|
|
68
|
-
* Get a piece of data about the feature. All features must have
|
|
69
|
-
* 'start' and 'end', but everything else is optional.
|
|
70
|
-
*/
|
|
71
36
|
get(name: string): any;
|
|
72
|
-
/**
|
|
73
|
-
* Set an item of data.
|
|
74
|
-
*/
|
|
75
37
|
set(name: string, val: any): void;
|
|
76
|
-
/**
|
|
77
|
-
* Get an array listing which data keys are present in this feature.
|
|
78
|
-
*/
|
|
79
38
|
tags(): string[];
|
|
80
|
-
/**
|
|
81
|
-
* Get the unique ID of this feature.
|
|
82
|
-
*/
|
|
83
39
|
id(): string;
|
|
84
|
-
/**
|
|
85
|
-
* Get this feature's parent feature, or undefined if none.
|
|
86
|
-
*/
|
|
87
40
|
parent(): Feature | undefined;
|
|
88
|
-
/**
|
|
89
|
-
* Get an array of child features, or undefined if none.
|
|
90
|
-
*/
|
|
91
41
|
children(): Feature[] | undefined;
|
|
92
42
|
toJSON(): SimpleFeatureSerialized;
|
|
93
43
|
static fromJSON(json: SimpleFeatureSerialized): SimpleFeature;
|
package/util/simpleFeature.js
CHANGED
|
@@ -10,16 +10,7 @@ function isFeature(thing) {
|
|
|
10
10
|
function isSimpleFeatureSerialized(args) {
|
|
11
11
|
return 'uniqueId' in args && typeof args.data !== 'object';
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Simple implementation of a feature object.
|
|
15
|
-
*/
|
|
16
13
|
class SimpleFeature {
|
|
17
|
-
/**
|
|
18
|
-
* @param args - SimpleFeature args
|
|
19
|
-
*
|
|
20
|
-
* Note: args.data.subfeatures can be an array of these same args,
|
|
21
|
-
* which will be inflated to more instances of this class.
|
|
22
|
-
*/
|
|
23
14
|
constructor(args) {
|
|
24
15
|
var _a;
|
|
25
16
|
if (isSimpleFeatureSerialized(args)) {
|
|
@@ -27,16 +18,9 @@ class SimpleFeature {
|
|
|
27
18
|
}
|
|
28
19
|
else {
|
|
29
20
|
this.data = args.data;
|
|
30
|
-
// load handle from args.parent (not args.data.parent) this reason is
|
|
31
|
-
// because if args is an object, it likely isn't properly loaded with
|
|
32
|
-
// parent as a Feature reference (probably a raw parent ID or something
|
|
33
|
-
// instead)
|
|
34
21
|
this.parentHandle = args.parent;
|
|
35
22
|
}
|
|
36
|
-
// the feature id comes from args.id, args.data.uniqueId, or args.uniqueId
|
|
37
|
-
// due to this initialization
|
|
38
23
|
const id = isSimpleFeatureSerialized(args) ? args.uniqueId : args.id;
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
40
24
|
if (id === undefined || id === null) {
|
|
41
25
|
throw new Error('SimpleFeature requires a unique `id` or `data.uniqueId` attribute');
|
|
42
26
|
}
|
|
@@ -57,10 +41,6 @@ class SimpleFeature {
|
|
|
57
41
|
: f);
|
|
58
42
|
}
|
|
59
43
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Get a piece of data about the feature. All features must have
|
|
62
|
-
* 'start' and 'end', but everything else is optional.
|
|
63
|
-
*/
|
|
64
44
|
get(name) {
|
|
65
45
|
return name === 'subfeatures'
|
|
66
46
|
? this.subfeatures
|
|
@@ -68,33 +48,18 @@ class SimpleFeature {
|
|
|
68
48
|
? this.parent()
|
|
69
49
|
: this.data[name];
|
|
70
50
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Set an item of data.
|
|
73
|
-
*/
|
|
74
51
|
set(name, val) {
|
|
75
52
|
this.data[name] = val;
|
|
76
53
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Get an array listing which data keys are present in this feature.
|
|
79
|
-
*/
|
|
80
54
|
tags() {
|
|
81
55
|
return Object.keys(this.data);
|
|
82
56
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Get the unique ID of this feature.
|
|
85
|
-
*/
|
|
86
57
|
id() {
|
|
87
58
|
return this.uniqueId;
|
|
88
59
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Get this feature's parent feature, or undefined if none.
|
|
91
|
-
*/
|
|
92
60
|
parent() {
|
|
93
61
|
return this.parentHandle;
|
|
94
62
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Get an array of child features, or undefined if none.
|
|
97
|
-
*/
|
|
98
63
|
children() {
|
|
99
64
|
return this.get('subfeatures');
|
|
100
65
|
}
|
package/util/stats.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NoAssemblyRegion } from './types';
|
|
3
|
-
import {
|
|
1
|
+
import type { Feature } from './simpleFeature';
|
|
2
|
+
import type { NoAssemblyRegion } from './types';
|
|
3
|
+
import type { Observable } from 'rxjs';
|
|
4
4
|
export interface UnrectifiedQuantitativeStats {
|
|
5
5
|
scoreMin: number;
|
|
6
6
|
scoreMax: number;
|
|
@@ -15,30 +15,7 @@ export interface QuantitativeStats extends UnrectifiedQuantitativeStats {
|
|
|
15
15
|
scoreMean: number;
|
|
16
16
|
scoreStdDev: number;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
* calculate standard deviation using the 'shortcut method' that accepts
|
|
20
|
-
* the sum and the sum squares of the elements
|
|
21
|
-
*
|
|
22
|
-
* @param sum - sum(i, 1..n)
|
|
23
|
-
* @param sumSquares - sum(i^2, 1..n)
|
|
24
|
-
* @param n - number of elements
|
|
25
|
-
* @param population - boolean: use population instead of sample correction
|
|
26
|
-
* @returns - the estimated std deviation
|
|
27
|
-
*/
|
|
28
18
|
export declare function calcStdFromSums(sum: number, sumSquares: number, n: number, population?: boolean): number;
|
|
29
|
-
/**
|
|
30
|
-
* @param stats - a summary stats object with scoreSum, featureCount,
|
|
31
|
-
* scoreSumSquares, and basesCovered
|
|
32
|
-
* @returns - a summary stats object with
|
|
33
|
-
* scoreMean, scoreStdDev, and featureDensity added
|
|
34
|
-
*/
|
|
35
19
|
export declare function rectifyStats(s: UnrectifiedQuantitativeStats): QuantitativeStats;
|
|
36
|
-
/**
|
|
37
|
-
* transform a list of scores to summary statistics
|
|
38
|
-
*
|
|
39
|
-
* @param region - object with start, end
|
|
40
|
-
* @param features - array of features which are possibly summary features
|
|
41
|
-
* @returns - object with scoreMax, scoreMin, scoreSum, scoreSumSquares, etc
|
|
42
|
-
*/
|
|
43
20
|
export declare function scoresToStats(region: NoAssemblyRegion, feats: Observable<Feature>): Promise<QuantitativeStats>;
|
|
44
21
|
export declare function blankStats(): QuantitativeStats;
|