@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,100 @@
1
+ import { getSnapshot, types, } from 'mobx-state-tree';
2
+ import { readConfObject } from '@jbrowse/core/configuration';
3
+ import { DrawerWidgetSessionMixin } from './DrawerWidgets';
4
+ // locals
5
+ import { BaseSessionModel, isBaseSession } from './BaseSession';
6
+ /**
7
+ * #stateModel MultipleViewsSessionMixin
8
+ */
9
+ export function MultipleViewsSessionMixin(pluginManager) {
10
+ return types
11
+ .compose(BaseSessionModel(pluginManager), DrawerWidgetSessionMixin(pluginManager))
12
+ .props({
13
+ /**
14
+ * #property
15
+ */
16
+ views: types.array(pluginManager.pluggableMstType('view', 'stateModel')),
17
+ })
18
+ .actions(self => ({
19
+ /**
20
+ * #action
21
+ */
22
+ moveViewUp(id) {
23
+ const idx = self.views.findIndex(v => v.id === id);
24
+ if (idx === -1) {
25
+ return;
26
+ }
27
+ if (idx > 0) {
28
+ self.views.splice(idx - 1, 2, self.views[idx], self.views[idx - 1]);
29
+ }
30
+ },
31
+ /**
32
+ * #action
33
+ */
34
+ moveViewDown(id) {
35
+ const idx = self.views.findIndex(v => v.id === id);
36
+ if (idx === -1) {
37
+ return;
38
+ }
39
+ if (idx < self.views.length - 1) {
40
+ self.views.splice(idx, 2, self.views[idx + 1], self.views[idx]);
41
+ }
42
+ },
43
+ /**
44
+ * #action
45
+ */
46
+ addView(typeName, initialState = {}) {
47
+ const typeDefinition = pluginManager.getElementType('view', typeName);
48
+ if (!typeDefinition) {
49
+ throw new Error(`unknown view type ${typeName}`);
50
+ }
51
+ const length = self.views.push({
52
+ ...initialState,
53
+ type: typeName,
54
+ });
55
+ return self.views[length - 1];
56
+ },
57
+ /**
58
+ * #action
59
+ */
60
+ removeView(view) {
61
+ for (const [, widget] of self.activeWidgets) {
62
+ if (widget.view && widget.view.id === view.id) {
63
+ self.hideWidget(widget);
64
+ }
65
+ }
66
+ self.views.remove(view);
67
+ },
68
+ /**
69
+ * #action
70
+ */
71
+ addLinearGenomeViewOfAssembly(assemblyName, initialState = {}) {
72
+ return this.addViewOfAssembly('LinearGenomeView', assemblyName, initialState);
73
+ },
74
+ /**
75
+ * #action
76
+ */
77
+ addViewOfAssembly(viewType, assemblyName, initialState = {}) {
78
+ const asm = self.assemblies.find(s => readConfObject(s, 'name') === assemblyName);
79
+ if (!asm) {
80
+ throw new Error(`Could not add view of assembly "${assemblyName}", assembly name not found`);
81
+ }
82
+ return this.addView(viewType, {
83
+ ...initialState,
84
+ displayRegionsFromAssemblyName: readConfObject(asm, 'name'),
85
+ });
86
+ },
87
+ /**
88
+ * #action
89
+ */
90
+ addViewFromAnotherView(viewType, otherView, initialState = {}) {
91
+ const state = { ...initialState };
92
+ state.displayedRegions = getSnapshot(otherView.displayedRegions);
93
+ return this.addView(viewType, state);
94
+ },
95
+ }));
96
+ }
97
+ /** Type guard for SessionWithMultipleViews */
98
+ export function isSessionWithMultipleViews(session) {
99
+ return isBaseSession(session) && 'views' in session;
100
+ }
@@ -0,0 +1,34 @@
1
+ /** MST props, views, actions, etc related to managing connections */
2
+ import PluginManager from '@jbrowse/core/PluginManager';
3
+ import { IAnyStateTreeNode, Instance } from 'mobx-state-tree';
4
+ import type { BaseTrackConfig } from '@jbrowse/core/pluggableElementTypes';
5
+ export interface ReferringNode {
6
+ node: IAnyStateTreeNode;
7
+ key: string;
8
+ }
9
+ /**
10
+ * #stateModel ReferenceManagementSessionMixin
11
+ */
12
+ export declare function ReferenceManagementSessionMixin(pluginManager: PluginManager): import("mobx-state-tree").IModelType<{}, {
13
+ /**
14
+ * #method
15
+ * See if any MST nodes currently have a types.reference to this object.
16
+ *
17
+ * @param object - object
18
+ * @returns An array where the first element is the node referring
19
+ * to the object and the second element is they property name the node is
20
+ * using to refer to the object
21
+ */
22
+ getReferring(object: IAnyStateTreeNode): ReferringNode[];
23
+ } & {
24
+ /**
25
+ * #action
26
+ */
27
+ removeReferring(referring: ReferringNode[], track: BaseTrackConfig, callbacks: Function[], dereferenceTypeCount: Record<string, number>): void;
28
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
29
+ /** Session mixin MST type for a session that manages multiple views */
30
+ export type SessionWithReferenceManagementType = ReturnType<typeof ReferenceManagementSessionMixin>;
31
+ /** Instance of a session with MST reference management (`getReferring()`, `removeReferring()`) */
32
+ export type SessionWithReferenceManagement = Instance<SessionWithReferenceManagementType>;
33
+ /** Type guard for SessionWithReferenceManagement */
34
+ export declare function isSessionWithReferenceManagement(thing: IAnyStateTreeNode): thing is SessionWithReferenceManagement;
@@ -0,0 +1,86 @@
1
+ /** MST props, views, actions, etc related to managing connections */
2
+ import { getContainingView, isSessionModelWithWidgets, } from '@jbrowse/core/util';
3
+ import { getMembers, getParent, getSnapshot, getType, isModelType, isReferenceType, types, walk, } from 'mobx-state-tree';
4
+ // locals
5
+ import { isBaseSession } from './BaseSession';
6
+ /**
7
+ * #stateModel ReferenceManagementSessionMixin
8
+ */
9
+ export function ReferenceManagementSessionMixin(pluginManager) {
10
+ return types
11
+ .model('ReferenceManagementSessionMixin', {})
12
+ .views(self => ({
13
+ /**
14
+ * #method
15
+ * See if any MST nodes currently have a types.reference to this object.
16
+ *
17
+ * @param object - object
18
+ * @returns An array where the first element is the node referring
19
+ * to the object and the second element is they property name the node is
20
+ * using to refer to the object
21
+ */
22
+ getReferring(object) {
23
+ const refs = [];
24
+ walk(getParent(self), node => {
25
+ if (isModelType(getType(node))) {
26
+ const members = getMembers(node);
27
+ Object.entries(members.properties).forEach(([key, value]) => {
28
+ if (isReferenceType(value) && node[key] === object) {
29
+ refs.push({ node, key });
30
+ }
31
+ });
32
+ }
33
+ });
34
+ return refs;
35
+ },
36
+ }))
37
+ .actions(self => ({
38
+ /**
39
+ * #action
40
+ */
41
+ removeReferring(referring, track, callbacks, dereferenceTypeCount) {
42
+ referring.forEach(({ node }) => {
43
+ let dereferenced = false;
44
+ try {
45
+ // If a view is referring to the track config, remove the track
46
+ // from the view
47
+ const type = 'open track(s)';
48
+ const view = getContainingView(node);
49
+ callbacks.push(() => view.hideTrack(track.trackId));
50
+ dereferenced = true;
51
+ if (!dereferenceTypeCount[type]) {
52
+ dereferenceTypeCount[type] = 0;
53
+ }
54
+ dereferenceTypeCount[type] += 1;
55
+ }
56
+ catch (err1) {
57
+ // ignore
58
+ }
59
+ if (isSessionModelWithWidgets(self) && self.widgets.has(node.id)) {
60
+ // If a configuration editor widget has the track config
61
+ // open, close the widget
62
+ const type = 'configuration editor widget(s)';
63
+ if (isSessionModelWithWidgets(self)) {
64
+ callbacks.push(() => self.hideWidget(node));
65
+ }
66
+ dereferenced = true;
67
+ if (!dereferenceTypeCount[type]) {
68
+ dereferenceTypeCount[type] = 0;
69
+ }
70
+ dereferenceTypeCount[type] += 1;
71
+ }
72
+ if (!dereferenced) {
73
+ throw new Error(`Error when closing this connection, the following node is still referring to a track configuration: ${JSON.stringify(getSnapshot(node))}`);
74
+ }
75
+ });
76
+ },
77
+ }));
78
+ }
79
+ /** Type guard for SessionWithReferenceManagement */
80
+ export function isSessionWithReferenceManagement(thing) {
81
+ return (isBaseSession(thing) &&
82
+ 'getReferring' in thing &&
83
+ typeof thing.getReferring === 'function' &&
84
+ 'removeReferring' in thing &&
85
+ typeof thing.removeReferring === 'function');
86
+ }