@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,108 @@
1
+ import { readConfObject, } from '@jbrowse/core/configuration';
2
+ import { types } from 'mobx-state-tree';
3
+ import { isBaseSession } from './BaseSession';
4
+ /**
5
+ * #stateModel ConnectionManagementSessionMixin
6
+ */
7
+ export function ConnectionManagementSessionMixin(pluginManager) {
8
+ return types
9
+ .model({
10
+ /**
11
+ * #property
12
+ */
13
+ connectionInstances: types.array(pluginManager.pluggableMstType('connection', 'stateModel')),
14
+ })
15
+ .views(self => ({
16
+ /**
17
+ * #getter
18
+ */
19
+ get connections() {
20
+ const { jbrowse } = self;
21
+ return jbrowse.connections;
22
+ },
23
+ }))
24
+ .actions(self => ({
25
+ /**
26
+ * #action
27
+ */
28
+ makeConnection(configuration, initialSnapshot = {}) {
29
+ const type = configuration.type;
30
+ if (!type) {
31
+ throw new Error('track configuration has no `type` listed');
32
+ }
33
+ const name = readConfObject(configuration, 'name');
34
+ const connectionType = pluginManager.getConnectionType(type);
35
+ if (!connectionType) {
36
+ throw new Error(`unknown connection type ${type}`);
37
+ }
38
+ const length = self.connectionInstances.push({
39
+ ...initialSnapshot,
40
+ name,
41
+ // @ts-expect-error unsure why ts doesn't like `type` here, but is
42
+ // needed
43
+ type,
44
+ configuration,
45
+ });
46
+ return self.connectionInstances[length - 1];
47
+ },
48
+ /**
49
+ * #action
50
+ */
51
+ prepareToBreakConnection(configuration) {
52
+ const root = self;
53
+ const callbacksToDeref = [];
54
+ const derefTypeCount = {};
55
+ const name = readConfObject(configuration, 'name');
56
+ const connection = self.connectionInstances.find(c => c.name === name);
57
+ if (!connection) {
58
+ return undefined;
59
+ }
60
+ for (const track of connection.tracks) {
61
+ const ref = root.getReferring(track);
62
+ root.removeReferring(ref, track, callbacksToDeref, derefTypeCount);
63
+ }
64
+ return [
65
+ () => {
66
+ callbacksToDeref.forEach(cb => cb());
67
+ this.breakConnection(configuration);
68
+ },
69
+ derefTypeCount,
70
+ ];
71
+ },
72
+ /**
73
+ * #action
74
+ */
75
+ breakConnection(configuration) {
76
+ const name = readConfObject(configuration, 'name');
77
+ const connection = self.connectionInstances.find(c => c.name === name);
78
+ if (!connection) {
79
+ throw new Error(`no connection found with name ${name}`);
80
+ }
81
+ self.connectionInstances.remove(connection);
82
+ },
83
+ /**
84
+ * #action
85
+ */
86
+ deleteConnection(configuration) {
87
+ const { jbrowse } = self;
88
+ return jbrowse.deleteConnectionConf(configuration);
89
+ },
90
+ /**
91
+ * #action
92
+ */
93
+ addConnectionConf(connectionConf) {
94
+ const { jbrowse } = self;
95
+ return jbrowse.addConnectionConf(connectionConf);
96
+ },
97
+ /**
98
+ * #action
99
+ */
100
+ clearConnections() {
101
+ self.connectionInstances.clear();
102
+ },
103
+ }));
104
+ }
105
+ /** Type guard for SessionWithConnections */
106
+ export function isSessionWithConnections(session) {
107
+ return isBaseSession(session) && 'connectionInstances' in session;
108
+ }
@@ -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,50 @@
1
+ /** MST mixin for managing a queue of dialogs at the level of the session */
2
+ import { types } from 'mobx-state-tree';
3
+ import { isBaseSession } from './BaseSession';
4
+ /**
5
+ * #stateModel DialogQueueSessionMixin
6
+ */
7
+ export function DialogQueueSessionMixin(pluginManager) {
8
+ return types
9
+ .model('DialogQueueSessionMixin', {})
10
+ .volatile(() => ({
11
+ queueOfDialogs: [],
12
+ }))
13
+ .views(self => ({
14
+ /**
15
+ * #getter
16
+ */
17
+ get DialogComponent() {
18
+ var _a;
19
+ return (_a = self.queueOfDialogs[0]) === null || _a === void 0 ? void 0 : _a[0];
20
+ },
21
+ /**
22
+ * #getter
23
+ */
24
+ get DialogProps() {
25
+ var _a;
26
+ return (_a = self.queueOfDialogs[0]) === null || _a === void 0 ? void 0 : _a[1];
27
+ },
28
+ }))
29
+ .actions(self => ({
30
+ /**
31
+ * #action
32
+ */
33
+ removeActiveDialog() {
34
+ self.queueOfDialogs = self.queueOfDialogs.slice(1);
35
+ },
36
+ /**
37
+ * #action
38
+ */
39
+ queueDialog(cb) {
40
+ const [component, props] = cb(() => {
41
+ this.removeActiveDialog();
42
+ });
43
+ self.queueOfDialogs = [...self.queueOfDialogs, [component, props]];
44
+ },
45
+ }));
46
+ }
47
+ /** Type guard for SessionWithDialogs */
48
+ export function isSessionWithDialogs(session) {
49
+ return isBaseSession(session) && 'queueOfDialogs' in session;
50
+ }
@@ -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,162 @@
1
+ import { addDisposer, isAlive, types, } from 'mobx-state-tree';
2
+ import { localStorageGetItem, localStorageSetItem } from '@jbrowse/core/util';
3
+ import { autorun } from 'mobx';
4
+ import { isConfigurationModel, } from '@jbrowse/core/configuration';
5
+ import { isBaseSession } from './BaseSession';
6
+ const minDrawerWidth = 128;
7
+ /**
8
+ * #stateModel DrawerWidgetSessionMixin
9
+ */
10
+ export function DrawerWidgetSessionMixin(pluginManager) {
11
+ const widgetStateModelType = pluginManager.pluggableMstType('widget', 'stateModel');
12
+ return types
13
+ .model({
14
+ /**
15
+ * #property
16
+ */
17
+ drawerPosition: types.optional(types.string, () => localStorageGetItem('drawerPosition') || 'right'),
18
+ /**
19
+ * #property
20
+ */
21
+ drawerWidth: types.optional(types.refinement(types.integer, width => width >= minDrawerWidth), 384),
22
+ /**
23
+ * #property
24
+ */
25
+ widgets: types.map(widgetStateModelType),
26
+ /**
27
+ * #property
28
+ */
29
+ activeWidgets: types.map(types.safeReference(widgetStateModelType)),
30
+ /**
31
+ * #property
32
+ */
33
+ minimized: types.optional(types.boolean, false),
34
+ })
35
+ .views(self => ({
36
+ /**
37
+ * #getter
38
+ */
39
+ get visibleWidget() {
40
+ if (isAlive(self)) {
41
+ // returns most recently added item in active widgets
42
+ return [...self.activeWidgets.values()][self.activeWidgets.size - 1];
43
+ }
44
+ return undefined;
45
+ },
46
+ }))
47
+ .actions(self => ({
48
+ /**
49
+ * #action
50
+ */
51
+ setDrawerPosition(arg) {
52
+ self.drawerPosition = arg;
53
+ localStorage.setItem('drawerPosition', arg);
54
+ },
55
+ /**
56
+ * #action
57
+ */
58
+ updateDrawerWidth(drawerWidth) {
59
+ if (drawerWidth === self.drawerWidth) {
60
+ return self.drawerWidth;
61
+ }
62
+ let newDrawerWidth = drawerWidth;
63
+ if (newDrawerWidth < minDrawerWidth) {
64
+ newDrawerWidth = minDrawerWidth;
65
+ }
66
+ self.drawerWidth = newDrawerWidth;
67
+ return newDrawerWidth;
68
+ },
69
+ /**
70
+ * #action
71
+ */
72
+ resizeDrawer(distance) {
73
+ if (self.drawerPosition === 'left') {
74
+ distance *= -1;
75
+ }
76
+ const oldDrawerWidth = self.drawerWidth;
77
+ const newDrawerWidth = this.updateDrawerWidth(oldDrawerWidth - distance);
78
+ return oldDrawerWidth - newDrawerWidth;
79
+ },
80
+ /**
81
+ * #action
82
+ */
83
+ addWidget(typeName, id, initialState = {}, conf) {
84
+ const typeDefinition = pluginManager.getElementType('widget', typeName);
85
+ if (!typeDefinition) {
86
+ throw new Error(`unknown widget type ${typeName}`);
87
+ }
88
+ const data = {
89
+ ...initialState,
90
+ id,
91
+ type: typeName,
92
+ configuration: conf || { type: typeName },
93
+ };
94
+ self.widgets.set(id, data);
95
+ return self.widgets.get(id);
96
+ },
97
+ /**
98
+ * #action
99
+ */
100
+ showWidget(widget) {
101
+ if (self.activeWidgets.has(widget.id)) {
102
+ self.activeWidgets.delete(widget.id);
103
+ }
104
+ self.activeWidgets.set(widget.id, widget);
105
+ self.minimized = false;
106
+ },
107
+ /**
108
+ * #action
109
+ */
110
+ hasWidget(widget) {
111
+ return self.activeWidgets.has(widget.id);
112
+ },
113
+ /**
114
+ * #action
115
+ */
116
+ hideWidget(widget) {
117
+ self.activeWidgets.delete(widget.id);
118
+ },
119
+ /**
120
+ * #action
121
+ */
122
+ minimizeWidgetDrawer() {
123
+ self.minimized = true;
124
+ },
125
+ /**
126
+ * #action
127
+ */
128
+ showWidgetDrawer() {
129
+ self.minimized = false;
130
+ },
131
+ /**
132
+ * #action
133
+ */
134
+ hideAllWidgets() {
135
+ self.activeWidgets.clear();
136
+ },
137
+ /**
138
+ * #action
139
+ * opens a configuration editor to configure the given thing,
140
+ * and sets the current task to be configuring it
141
+ * @param configuration -
142
+ */
143
+ editConfiguration(configuration) {
144
+ if (!isConfigurationModel(configuration)) {
145
+ throw new Error('must pass a configuration model to editConfiguration');
146
+ }
147
+ const editor = this.addWidget('ConfigurationEditorWidget', 'configEditor', { target: configuration });
148
+ this.showWidget(editor);
149
+ },
150
+ afterAttach() {
151
+ addDisposer(self, autorun(() => {
152
+ localStorageSetItem('drawerPosition', self.drawerPosition);
153
+ }));
154
+ },
155
+ }));
156
+ }
157
+ /** Type guard for SessionWithDrawerWidgets */
158
+ export function isSessionWithDrawerWidgets(session) {
159
+ return (isBaseSession(session) &&
160
+ 'widgets' in session &&
161
+ 'drawerPosition' in session);
162
+ }