@jbrowse/product-core 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/LICENSE +201 -0
  2. package/dist/RootModel/BaseRootModel.d.ts +607 -0
  3. package/dist/RootModel/BaseRootModel.js +101 -0
  4. package/dist/RootModel/InternetAccounts.d.ts +31 -0
  5. package/dist/RootModel/InternetAccounts.js +99 -0
  6. package/dist/RootModel/index.d.ts +2 -0
  7. package/dist/RootModel/index.js +18 -0
  8. package/dist/Session/BaseSession.d.ts +99 -0
  9. package/dist/Session/BaseSession.js +112 -0
  10. package/dist/Session/Connections.d.ts +174 -0
  11. package/dist/Session/Connections.js +113 -0
  12. package/dist/Session/DialogQueue.d.ts +34 -0
  13. package/dist/Session/DialogQueue.js +55 -0
  14. package/dist/Session/DrawerWidgets.d.ts +88 -0
  15. package/dist/Session/DrawerWidgets.js +167 -0
  16. package/dist/Session/MultipleViews.d.ts +1798 -0
  17. package/dist/Session/MultipleViews.js +105 -0
  18. package/dist/Session/ReferenceManagement.d.ts +34 -0
  19. package/dist/Session/ReferenceManagement.js +91 -0
  20. package/dist/Session/SessionTracks.d.ts +1866 -0
  21. package/dist/Session/SessionTracks.js +75 -0
  22. package/dist/Session/Themes.d.ts +38 -0
  23. package/dist/Session/Themes.js +64 -0
  24. package/dist/Session/Tracks.d.ts +1821 -0
  25. package/dist/Session/Tracks.js +51 -0
  26. package/dist/Session/index.d.ts +10 -0
  27. package/dist/Session/index.js +26 -0
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.js +19 -0
  30. package/dist/ui/AboutDialog.d.ts +6 -0
  31. package/dist/ui/AboutDialog.js +20 -0
  32. package/dist/ui/AboutDialogContents.d.ts +5 -0
  33. package/dist/ui/AboutDialogContents.js +70 -0
  34. package/dist/ui/FileInfoPanel.d.ts +5 -0
  35. package/dist/ui/FileInfoPanel.js +76 -0
  36. package/dist/ui/index.d.ts +1 -0
  37. package/dist/ui/index.js +17 -0
  38. package/esm/RootModel/BaseRootModel.d.ts +607 -0
  39. package/esm/RootModel/BaseRootModel.js +93 -0
  40. package/esm/RootModel/InternetAccounts.d.ts +31 -0
  41. package/esm/RootModel/InternetAccounts.js +95 -0
  42. package/esm/RootModel/index.d.ts +2 -0
  43. package/esm/RootModel/index.js +2 -0
  44. package/esm/Session/BaseSession.d.ts +99 -0
  45. package/esm/Session/BaseSession.js +103 -0
  46. package/esm/Session/Connections.d.ts +174 -0
  47. package/esm/Session/Connections.js +108 -0
  48. package/esm/Session/DialogQueue.d.ts +34 -0
  49. package/esm/Session/DialogQueue.js +50 -0
  50. package/esm/Session/DrawerWidgets.d.ts +88 -0
  51. package/esm/Session/DrawerWidgets.js +162 -0
  52. package/esm/Session/MultipleViews.d.ts +1798 -0
  53. package/esm/Session/MultipleViews.js +100 -0
  54. package/esm/Session/ReferenceManagement.d.ts +34 -0
  55. package/esm/Session/ReferenceManagement.js +86 -0
  56. package/esm/Session/SessionTracks.d.ts +1866 -0
  57. package/esm/Session/SessionTracks.js +70 -0
  58. package/esm/Session/Themes.d.ts +38 -0
  59. package/esm/Session/Themes.js +59 -0
  60. package/esm/Session/Tracks.d.ts +1821 -0
  61. package/esm/Session/Tracks.js +46 -0
  62. package/esm/Session/index.d.ts +10 -0
  63. package/esm/Session/index.js +10 -0
  64. package/esm/index.d.ts +3 -0
  65. package/esm/index.js +3 -0
  66. package/esm/ui/AboutDialog.d.ts +6 -0
  67. package/esm/ui/AboutDialog.js +13 -0
  68. package/esm/ui/AboutDialogContents.d.ts +5 -0
  69. package/esm/ui/AboutDialogContents.js +41 -0
  70. package/esm/ui/FileInfoPanel.d.ts +5 -0
  71. package/esm/ui/FileInfoPanel.js +47 -0
  72. package/esm/ui/index.d.ts +1 -0
  73. package/esm/ui/index.js +1 -0
  74. package/package.json +66 -0
  75. package/src/RootModel/BaseRootModel.ts +131 -0
  76. package/src/RootModel/InternetAccounts.ts +126 -0
  77. package/src/RootModel/index.ts +2 -0
  78. package/src/Session/BaseSession.ts +129 -0
  79. package/src/Session/Connections.ts +145 -0
  80. package/src/Session/DialogQueue.ts +63 -0
  81. package/src/Session/DrawerWidgets.ts +222 -0
  82. package/src/Session/MultipleViews.ts +151 -0
  83. package/src/Session/ReferenceManagement.ts +134 -0
  84. package/src/Session/SessionTracks.ts +98 -0
  85. package/src/Session/Themes.ts +85 -0
  86. package/src/Session/Tracks.ts +72 -0
  87. package/src/Session/index.ts +10 -0
  88. package/src/index.ts +3 -0
  89. package/src/ui/AboutDialog.tsx +31 -0
  90. package/src/ui/AboutDialogContents.tsx +88 -0
  91. package/src/ui/FileInfoPanel.tsx +75 -0
  92. package/src/ui/index.ts +1 -0
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSessionWithConnections = exports.ConnectionManagementSessionMixin = void 0;
4
+ const configuration_1 = require("@jbrowse/core/configuration");
5
+ const mobx_state_tree_1 = require("mobx-state-tree");
6
+ const BaseSession_1 = require("./BaseSession");
7
+ /**
8
+ * #stateModel ConnectionManagementSessionMixin
9
+ */
10
+ function ConnectionManagementSessionMixin(pluginManager) {
11
+ return mobx_state_tree_1.types
12
+ .model({
13
+ /**
14
+ * #property
15
+ */
16
+ connectionInstances: mobx_state_tree_1.types.array(pluginManager.pluggableMstType('connection', 'stateModel')),
17
+ })
18
+ .views(self => ({
19
+ /**
20
+ * #getter
21
+ */
22
+ get connections() {
23
+ const { jbrowse } = self;
24
+ return jbrowse.connections;
25
+ },
26
+ }))
27
+ .actions(self => ({
28
+ /**
29
+ * #action
30
+ */
31
+ makeConnection(configuration, initialSnapshot = {}) {
32
+ const type = configuration.type;
33
+ if (!type) {
34
+ throw new Error('track configuration has no `type` listed');
35
+ }
36
+ const name = (0, configuration_1.readConfObject)(configuration, 'name');
37
+ const connectionType = pluginManager.getConnectionType(type);
38
+ if (!connectionType) {
39
+ throw new Error(`unknown connection type ${type}`);
40
+ }
41
+ const length = self.connectionInstances.push({
42
+ ...initialSnapshot,
43
+ name,
44
+ // @ts-expect-error unsure why ts doesn't like `type` here, but is
45
+ // needed
46
+ type,
47
+ configuration,
48
+ });
49
+ return self.connectionInstances[length - 1];
50
+ },
51
+ /**
52
+ * #action
53
+ */
54
+ prepareToBreakConnection(configuration) {
55
+ const root = self;
56
+ const callbacksToDeref = [];
57
+ const derefTypeCount = {};
58
+ const name = (0, configuration_1.readConfObject)(configuration, 'name');
59
+ const connection = self.connectionInstances.find(c => c.name === name);
60
+ if (!connection) {
61
+ return undefined;
62
+ }
63
+ for (const track of connection.tracks) {
64
+ const ref = root.getReferring(track);
65
+ root.removeReferring(ref, track, callbacksToDeref, derefTypeCount);
66
+ }
67
+ return [
68
+ () => {
69
+ callbacksToDeref.forEach(cb => cb());
70
+ this.breakConnection(configuration);
71
+ },
72
+ derefTypeCount,
73
+ ];
74
+ },
75
+ /**
76
+ * #action
77
+ */
78
+ breakConnection(configuration) {
79
+ const name = (0, configuration_1.readConfObject)(configuration, 'name');
80
+ const connection = self.connectionInstances.find(c => c.name === name);
81
+ if (!connection) {
82
+ throw new Error(`no connection found with name ${name}`);
83
+ }
84
+ self.connectionInstances.remove(connection);
85
+ },
86
+ /**
87
+ * #action
88
+ */
89
+ deleteConnection(configuration) {
90
+ const { jbrowse } = self;
91
+ return jbrowse.deleteConnectionConf(configuration);
92
+ },
93
+ /**
94
+ * #action
95
+ */
96
+ addConnectionConf(connectionConf) {
97
+ const { jbrowse } = self;
98
+ return jbrowse.addConnectionConf(connectionConf);
99
+ },
100
+ /**
101
+ * #action
102
+ */
103
+ clearConnections() {
104
+ self.connectionInstances.clear();
105
+ },
106
+ }));
107
+ }
108
+ exports.ConnectionManagementSessionMixin = ConnectionManagementSessionMixin;
109
+ /** Type guard for SessionWithConnections */
110
+ function isSessionWithConnections(session) {
111
+ return (0, BaseSession_1.isBaseSession)(session) && 'connectionInstances' in session;
112
+ }
113
+ exports.isSessionWithConnections = isSessionWithConnections;
@@ -0,0 +1,34 @@
1
+ /** MST mixin for managing a queue of dialogs at the level of the session */
2
+ import PluginManager from '@jbrowse/core/PluginManager';
3
+ import { DialogComponentType } from '@jbrowse/core/util';
4
+ import { IAnyStateTreeNode, Instance } from 'mobx-state-tree';
5
+ /**
6
+ * #stateModel DialogQueueSessionMixin
7
+ */
8
+ export declare function DialogQueueSessionMixin(pluginManager: PluginManager): import("mobx-state-tree").IModelType<{}, {
9
+ queueOfDialogs: [DialogComponentType, unknown][];
10
+ } & {
11
+ /**
12
+ * #getter
13
+ */
14
+ readonly DialogComponent: DialogComponentType;
15
+ /**
16
+ * #getter
17
+ */
18
+ readonly DialogProps: unknown;
19
+ } & {
20
+ /**
21
+ * #action
22
+ */
23
+ removeActiveDialog(): void;
24
+ /**
25
+ * #action
26
+ */
27
+ queueDialog(cb: (doneCallback: () => void) => [DialogComponentType, unknown]): void;
28
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
29
+ /** Session mixin MST type for a session that has `queueOfDialogs`, etc. */
30
+ export type SessionWithDialogsType = ReturnType<typeof DialogQueueSessionMixin>;
31
+ /** Instance of a session that has dialogs */
32
+ export type SessionWithDialogs = Instance<SessionWithDialogsType>;
33
+ /** Type guard for SessionWithDialogs */
34
+ export declare function isSessionWithDialogs(session: IAnyStateTreeNode): session is SessionWithDialogs;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /** MST mixin for managing a queue of dialogs at the level of the session */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.isSessionWithDialogs = exports.DialogQueueSessionMixin = void 0;
5
+ const mobx_state_tree_1 = require("mobx-state-tree");
6
+ const BaseSession_1 = require("./BaseSession");
7
+ /**
8
+ * #stateModel DialogQueueSessionMixin
9
+ */
10
+ function DialogQueueSessionMixin(pluginManager) {
11
+ return mobx_state_tree_1.types
12
+ .model('DialogQueueSessionMixin', {})
13
+ .volatile(() => ({
14
+ queueOfDialogs: [],
15
+ }))
16
+ .views(self => ({
17
+ /**
18
+ * #getter
19
+ */
20
+ get DialogComponent() {
21
+ var _a;
22
+ return (_a = self.queueOfDialogs[0]) === null || _a === void 0 ? void 0 : _a[0];
23
+ },
24
+ /**
25
+ * #getter
26
+ */
27
+ get DialogProps() {
28
+ var _a;
29
+ return (_a = self.queueOfDialogs[0]) === null || _a === void 0 ? void 0 : _a[1];
30
+ },
31
+ }))
32
+ .actions(self => ({
33
+ /**
34
+ * #action
35
+ */
36
+ removeActiveDialog() {
37
+ self.queueOfDialogs = self.queueOfDialogs.slice(1);
38
+ },
39
+ /**
40
+ * #action
41
+ */
42
+ queueDialog(cb) {
43
+ const [component, props] = cb(() => {
44
+ this.removeActiveDialog();
45
+ });
46
+ self.queueOfDialogs = [...self.queueOfDialogs, [component, props]];
47
+ },
48
+ }));
49
+ }
50
+ exports.DialogQueueSessionMixin = DialogQueueSessionMixin;
51
+ /** Type guard for SessionWithDialogs */
52
+ function isSessionWithDialogs(session) {
53
+ return (0, BaseSession_1.isBaseSession)(session) && 'queueOfDialogs' in session;
54
+ }
55
+ exports.isSessionWithDialogs = isSessionWithDialogs;
@@ -0,0 +1,88 @@
1
+ import { IAnyStateTreeNode, Instance } from 'mobx-state-tree';
2
+ import PluginManager from '@jbrowse/core/PluginManager';
3
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration';
4
+ /**
5
+ * #stateModel DrawerWidgetSessionMixin
6
+ */
7
+ export declare function DrawerWidgetSessionMixin(pluginManager: PluginManager): import("mobx-state-tree").IModelType<{
8
+ /**
9
+ * #property
10
+ */
11
+ drawerPosition: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
12
+ /**
13
+ * #property
14
+ */
15
+ drawerWidth: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<number>, [undefined]>;
16
+ /**
17
+ * #property
18
+ */
19
+ widgets: import("mobx-state-tree").IMapType<import("mobx-state-tree").IAnyType>;
20
+ /**
21
+ * #property
22
+ */
23
+ activeWidgets: import("mobx-state-tree").IMapType<import("mobx-state-tree").IMaybe<import("mobx-state-tree").IReferenceType<import("mobx-state-tree").IAnyType>>>;
24
+ /**
25
+ * #property
26
+ */
27
+ minimized: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
28
+ }, {
29
+ /**
30
+ * #getter
31
+ */
32
+ readonly visibleWidget: any;
33
+ } & {
34
+ /**
35
+ * #action
36
+ */
37
+ setDrawerPosition(arg: string): void;
38
+ /**
39
+ * #action
40
+ */
41
+ updateDrawerWidth(drawerWidth: number): number;
42
+ /**
43
+ * #action
44
+ */
45
+ resizeDrawer(distance: number): number;
46
+ /**
47
+ * #action
48
+ */
49
+ addWidget(typeName: string, id: string, initialState?: {}, conf?: unknown): any;
50
+ /**
51
+ * #action
52
+ */
53
+ showWidget(widget: any): void;
54
+ /**
55
+ * #action
56
+ */
57
+ hasWidget(widget: any): boolean;
58
+ /**
59
+ * #action
60
+ */
61
+ hideWidget(widget: any): void;
62
+ /**
63
+ * #action
64
+ */
65
+ minimizeWidgetDrawer(): void;
66
+ /**
67
+ * #action
68
+ */
69
+ showWidgetDrawer(): void;
70
+ /**
71
+ * #action
72
+ */
73
+ hideAllWidgets(): void;
74
+ /**
75
+ * #action
76
+ * opens a configuration editor to configure the given thing,
77
+ * and sets the current task to be configuring it
78
+ * @param configuration -
79
+ */
80
+ editConfiguration(configuration: AnyConfigurationModel): void;
81
+ afterAttach(): void;
82
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
83
+ /** Session mixin MST type for a session that manages drawer widgets */
84
+ export type SessionWithDrawerWidgetsType = ReturnType<typeof DrawerWidgetSessionMixin>;
85
+ /** Instance of a session that manages drawer widgets */
86
+ export type SessionWithDrawerWidgets = Instance<SessionWithDrawerWidgetsType>;
87
+ /** Type guard for SessionWithDrawerWidgets */
88
+ export declare function isSessionWithDrawerWidgets(session: IAnyStateTreeNode): session is SessionWithDrawerWidgets;
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSessionWithDrawerWidgets = exports.DrawerWidgetSessionMixin = void 0;
4
+ const mobx_state_tree_1 = require("mobx-state-tree");
5
+ const util_1 = require("@jbrowse/core/util");
6
+ const mobx_1 = require("mobx");
7
+ const configuration_1 = require("@jbrowse/core/configuration");
8
+ const BaseSession_1 = require("./BaseSession");
9
+ const minDrawerWidth = 128;
10
+ /**
11
+ * #stateModel DrawerWidgetSessionMixin
12
+ */
13
+ function DrawerWidgetSessionMixin(pluginManager) {
14
+ const widgetStateModelType = pluginManager.pluggableMstType('widget', 'stateModel');
15
+ return mobx_state_tree_1.types
16
+ .model({
17
+ /**
18
+ * #property
19
+ */
20
+ drawerPosition: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.string, () => (0, util_1.localStorageGetItem)('drawerPosition') || 'right'),
21
+ /**
22
+ * #property
23
+ */
24
+ drawerWidth: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.refinement(mobx_state_tree_1.types.integer, width => width >= minDrawerWidth), 384),
25
+ /**
26
+ * #property
27
+ */
28
+ widgets: mobx_state_tree_1.types.map(widgetStateModelType),
29
+ /**
30
+ * #property
31
+ */
32
+ activeWidgets: mobx_state_tree_1.types.map(mobx_state_tree_1.types.safeReference(widgetStateModelType)),
33
+ /**
34
+ * #property
35
+ */
36
+ minimized: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.boolean, false),
37
+ })
38
+ .views(self => ({
39
+ /**
40
+ * #getter
41
+ */
42
+ get visibleWidget() {
43
+ if ((0, mobx_state_tree_1.isAlive)(self)) {
44
+ // returns most recently added item in active widgets
45
+ return [...self.activeWidgets.values()][self.activeWidgets.size - 1];
46
+ }
47
+ return undefined;
48
+ },
49
+ }))
50
+ .actions(self => ({
51
+ /**
52
+ * #action
53
+ */
54
+ setDrawerPosition(arg) {
55
+ self.drawerPosition = arg;
56
+ localStorage.setItem('drawerPosition', arg);
57
+ },
58
+ /**
59
+ * #action
60
+ */
61
+ updateDrawerWidth(drawerWidth) {
62
+ if (drawerWidth === self.drawerWidth) {
63
+ return self.drawerWidth;
64
+ }
65
+ let newDrawerWidth = drawerWidth;
66
+ if (newDrawerWidth < minDrawerWidth) {
67
+ newDrawerWidth = minDrawerWidth;
68
+ }
69
+ self.drawerWidth = newDrawerWidth;
70
+ return newDrawerWidth;
71
+ },
72
+ /**
73
+ * #action
74
+ */
75
+ resizeDrawer(distance) {
76
+ if (self.drawerPosition === 'left') {
77
+ distance *= -1;
78
+ }
79
+ const oldDrawerWidth = self.drawerWidth;
80
+ const newDrawerWidth = this.updateDrawerWidth(oldDrawerWidth - distance);
81
+ return oldDrawerWidth - newDrawerWidth;
82
+ },
83
+ /**
84
+ * #action
85
+ */
86
+ addWidget(typeName, id, initialState = {}, conf) {
87
+ const typeDefinition = pluginManager.getElementType('widget', typeName);
88
+ if (!typeDefinition) {
89
+ throw new Error(`unknown widget type ${typeName}`);
90
+ }
91
+ const data = {
92
+ ...initialState,
93
+ id,
94
+ type: typeName,
95
+ configuration: conf || { type: typeName },
96
+ };
97
+ self.widgets.set(id, data);
98
+ return self.widgets.get(id);
99
+ },
100
+ /**
101
+ * #action
102
+ */
103
+ showWidget(widget) {
104
+ if (self.activeWidgets.has(widget.id)) {
105
+ self.activeWidgets.delete(widget.id);
106
+ }
107
+ self.activeWidgets.set(widget.id, widget);
108
+ self.minimized = false;
109
+ },
110
+ /**
111
+ * #action
112
+ */
113
+ hasWidget(widget) {
114
+ return self.activeWidgets.has(widget.id);
115
+ },
116
+ /**
117
+ * #action
118
+ */
119
+ hideWidget(widget) {
120
+ self.activeWidgets.delete(widget.id);
121
+ },
122
+ /**
123
+ * #action
124
+ */
125
+ minimizeWidgetDrawer() {
126
+ self.minimized = true;
127
+ },
128
+ /**
129
+ * #action
130
+ */
131
+ showWidgetDrawer() {
132
+ self.minimized = false;
133
+ },
134
+ /**
135
+ * #action
136
+ */
137
+ hideAllWidgets() {
138
+ self.activeWidgets.clear();
139
+ },
140
+ /**
141
+ * #action
142
+ * opens a configuration editor to configure the given thing,
143
+ * and sets the current task to be configuring it
144
+ * @param configuration -
145
+ */
146
+ editConfiguration(configuration) {
147
+ if (!(0, configuration_1.isConfigurationModel)(configuration)) {
148
+ throw new Error('must pass a configuration model to editConfiguration');
149
+ }
150
+ const editor = this.addWidget('ConfigurationEditorWidget', 'configEditor', { target: configuration });
151
+ this.showWidget(editor);
152
+ },
153
+ afterAttach() {
154
+ (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
155
+ (0, util_1.localStorageSetItem)('drawerPosition', self.drawerPosition);
156
+ }));
157
+ },
158
+ }));
159
+ }
160
+ exports.DrawerWidgetSessionMixin = DrawerWidgetSessionMixin;
161
+ /** Type guard for SessionWithDrawerWidgets */
162
+ function isSessionWithDrawerWidgets(session) {
163
+ return ((0, BaseSession_1.isBaseSession)(session) &&
164
+ 'widgets' in session &&
165
+ 'drawerPosition' in session);
166
+ }
167
+ exports.isSessionWithDrawerWidgets = isSessionWithDrawerWidgets;