@jbrowse/app-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 (107) hide show
  1. package/LICENSE +201 -0
  2. package/dist/Assemblies/SessionAssembliesMixin.d.ts +72 -0
  3. package/dist/Assemblies/SessionAssembliesMixin.js +44 -0
  4. package/dist/Assemblies/TemporaryAssembliesMixin.d.ts +22 -0
  5. package/dist/Assemblies/TemporaryAssembliesMixin.js +45 -0
  6. package/dist/Assemblies/index.d.ts +2 -0
  7. package/dist/Assemblies/index.js +18 -0
  8. package/dist/HistoryManagement/index.d.ts +30 -0
  9. package/dist/HistoryManagement/index.js +54 -0
  10. package/dist/JBrowseConfig/index.d.ts +158 -0
  11. package/dist/JBrowseConfig/index.js +155 -0
  12. package/dist/JBrowseModel/index.d.ts +144 -0
  13. package/dist/JBrowseModel/index.js +132 -0
  14. package/dist/RootMenu/index.d.ts +68 -0
  15. package/dist/RootMenu/index.js +142 -0
  16. package/dist/index.d.ts +6 -0
  17. package/dist/index.js +22 -0
  18. package/dist/ui/App/App.d.ts +19 -0
  19. package/dist/ui/App/App.js +95 -0
  20. package/dist/ui/App/AppFab.d.ts +6 -0
  21. package/dist/ui/App/AppFab.js +32 -0
  22. package/dist/ui/App/AppToolbar.d.ts +19 -0
  23. package/dist/ui/App/AppToolbar.js +54 -0
  24. package/dist/ui/App/DialogQueue.d.ts +6 -0
  25. package/dist/ui/App/DialogQueue.js +32 -0
  26. package/dist/ui/App/Drawer.d.ts +8 -0
  27. package/dist/ui/App/Drawer.js +34 -0
  28. package/dist/ui/App/DrawerWidget.d.ts +6 -0
  29. package/dist/ui/App/DrawerWidget.js +132 -0
  30. package/dist/ui/App/ViewContainer.d.ts +9 -0
  31. package/dist/ui/App/ViewContainer.js +76 -0
  32. package/dist/ui/App/ViewContainerTitle.d.ts +6 -0
  33. package/dist/ui/App/ViewContainerTitle.js +42 -0
  34. package/dist/ui/App/ViewLauncher.d.ts +18 -0
  35. package/dist/ui/App/ViewLauncher.js +50 -0
  36. package/dist/ui/App/ViewMenu.d.ts +9 -0
  37. package/dist/ui/App/ViewMenu.js +38 -0
  38. package/dist/ui/App/ViewPanel.d.ts +19 -0
  39. package/dist/ui/App/ViewPanel.js +50 -0
  40. package/dist/ui/App/index.d.ts +1 -0
  41. package/dist/ui/App/index.js +17 -0
  42. package/dist/ui/index.d.ts +1 -0
  43. package/dist/ui/index.js +17 -0
  44. package/esm/Assemblies/SessionAssembliesMixin.d.ts +72 -0
  45. package/esm/Assemblies/SessionAssembliesMixin.js +40 -0
  46. package/esm/Assemblies/TemporaryAssembliesMixin.d.ts +22 -0
  47. package/esm/Assemblies/TemporaryAssembliesMixin.js +41 -0
  48. package/esm/Assemblies/index.d.ts +2 -0
  49. package/esm/Assemblies/index.js +2 -0
  50. package/esm/HistoryManagement/index.d.ts +30 -0
  51. package/esm/HistoryManagement/index.js +47 -0
  52. package/esm/JBrowseConfig/index.d.ts +158 -0
  53. package/esm/JBrowseConfig/index.js +148 -0
  54. package/esm/JBrowseModel/index.d.ts +144 -0
  55. package/esm/JBrowseModel/index.js +128 -0
  56. package/esm/RootMenu/index.d.ts +68 -0
  57. package/esm/RootMenu/index.js +138 -0
  58. package/esm/index.d.ts +6 -0
  59. package/esm/index.js +6 -0
  60. package/esm/ui/App/App.d.ts +19 -0
  61. package/esm/ui/App/App.js +66 -0
  62. package/esm/ui/App/AppFab.d.ts +6 -0
  63. package/esm/ui/App/AppFab.js +27 -0
  64. package/esm/ui/App/AppToolbar.d.ts +19 -0
  65. package/esm/ui/App/AppToolbar.js +49 -0
  66. package/esm/ui/App/DialogQueue.d.ts +6 -0
  67. package/esm/ui/App/DialogQueue.js +7 -0
  68. package/esm/ui/App/Drawer.d.ts +8 -0
  69. package/esm/ui/App/Drawer.js +29 -0
  70. package/esm/ui/App/DrawerWidget.d.ts +6 -0
  71. package/esm/ui/App/DrawerWidget.js +104 -0
  72. package/esm/ui/App/ViewContainer.d.ts +9 -0
  73. package/esm/ui/App/ViewContainer.js +48 -0
  74. package/esm/ui/App/ViewContainerTitle.d.ts +6 -0
  75. package/esm/ui/App/ViewContainerTitle.js +37 -0
  76. package/esm/ui/App/ViewLauncher.d.ts +18 -0
  77. package/esm/ui/App/ViewLauncher.js +25 -0
  78. package/esm/ui/App/ViewMenu.d.ts +9 -0
  79. package/esm/ui/App/ViewMenu.js +33 -0
  80. package/esm/ui/App/ViewPanel.d.ts +19 -0
  81. package/esm/ui/App/ViewPanel.js +22 -0
  82. package/esm/ui/App/index.d.ts +1 -0
  83. package/esm/ui/App/index.js +1 -0
  84. package/esm/ui/index.d.ts +1 -0
  85. package/esm/ui/index.js +1 -0
  86. package/package.json +66 -0
  87. package/src/Assemblies/SessionAssembliesMixin.ts +50 -0
  88. package/src/Assemblies/TemporaryAssembliesMixin.ts +51 -0
  89. package/src/Assemblies/index.ts +2 -0
  90. package/src/HistoryManagement/index.ts +56 -0
  91. package/src/JBrowseConfig/index.ts +173 -0
  92. package/src/JBrowseModel/index.ts +150 -0
  93. package/src/RootMenu/index.ts +157 -0
  94. package/src/index.ts +6 -0
  95. package/src/ui/App/App.tsx +117 -0
  96. package/src/ui/App/AppFab.tsx +45 -0
  97. package/src/ui/App/AppToolbar.tsx +89 -0
  98. package/src/ui/App/DialogQueue.tsx +22 -0
  99. package/src/ui/App/Drawer.tsx +56 -0
  100. package/src/ui/App/DrawerWidget.tsx +238 -0
  101. package/src/ui/App/ViewContainer.tsx +76 -0
  102. package/src/ui/App/ViewContainerTitle.tsx +55 -0
  103. package/src/ui/App/ViewLauncher.tsx +64 -0
  104. package/src/ui/App/ViewMenu.tsx +54 -0
  105. package/src/ui/App/ViewPanel.tsx +63 -0
  106. package/src/ui/App/index.ts +1 -0
  107. package/src/ui/index.ts +1 -0
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.JBrowseConfigF = void 0;
7
+ const configuration_1 = require("@jbrowse/core/configuration");
8
+ const RpcManager_1 = __importDefault(require("@jbrowse/core/rpc/RpcManager"));
9
+ const mobx_state_tree_1 = require("mobx-state-tree");
10
+ /**
11
+ * #config JBrowseRootConfig
12
+ * #category root
13
+ * configuration in a config.json/file.jbrowse
14
+ */
15
+ function JBrowseConfigF({ pluginManager, assemblyConfigSchema, }) {
16
+ return mobx_state_tree_1.types.model('JBrowseConfig', {
17
+ configuration: (0, configuration_1.ConfigurationSchema)('Root', {
18
+ /**
19
+ * #slot configuration.rpc
20
+ */
21
+ rpc: RpcManager_1.default.configSchema,
22
+ /**
23
+ * #slot configuration.highResolutionScaling
24
+ */
25
+ highResolutionScaling: {
26
+ type: 'number',
27
+ defaultValue: 2,
28
+ },
29
+ formatDetails: (0, configuration_1.ConfigurationSchema)('FormatDetails', {
30
+ /**
31
+ * #slot configuration.formatDetails.feature
32
+ */
33
+ feature: {
34
+ type: 'frozen',
35
+ description: 'adds extra fields to the feature details',
36
+ defaultValue: {},
37
+ contextVariable: ['feature'],
38
+ },
39
+ /**
40
+ * #slot configuration.formatDetails.subfeatures
41
+ */
42
+ subfeatures: {
43
+ type: 'frozen',
44
+ description: 'adds extra fields to the subfeatures of a feature',
45
+ defaultValue: {},
46
+ contextVariable: ['feature'],
47
+ },
48
+ /**
49
+ * #slot configuration.formatDetails.depth
50
+ */
51
+ depth: {
52
+ type: 'number',
53
+ defaultValue: 2,
54
+ description: 'depth to iterate on subfeatures',
55
+ },
56
+ }),
57
+ formatAbout: (0, configuration_1.ConfigurationSchema)('FormatAbout', {
58
+ /**
59
+ * #slot configuration.formatAbout.config
60
+ */
61
+ config: {
62
+ type: 'frozen',
63
+ description: 'formats configuration object in about dialog',
64
+ defaultValue: {},
65
+ contextVariable: ['config'],
66
+ },
67
+ /**
68
+ * #slot configuration.formatAbout.hideUris
69
+ */
70
+ hideUris: {
71
+ type: 'boolean',
72
+ defaultValue: false,
73
+ },
74
+ }),
75
+ /*
76
+ * #slot configuration.shareURL
77
+ */
78
+ shareURL: {
79
+ type: 'string',
80
+ defaultValue: 'https://share.jbrowse.org/api/v1/',
81
+ },
82
+ /**
83
+ * #slot configuration.disableAnalytics
84
+ */
85
+ disableAnalytics: {
86
+ type: 'boolean',
87
+ defaultValue: false,
88
+ },
89
+ /**
90
+ * #slot configuration.theme
91
+ */
92
+ theme: {
93
+ type: 'frozen',
94
+ defaultValue: {},
95
+ },
96
+ /**
97
+ * #slot configuration.extraThemes
98
+ */
99
+ extraThemes: { type: 'frozen', defaultValue: {} },
100
+ /**
101
+ * #slot configuration.logoPath
102
+ */
103
+ logoPath: {
104
+ type: 'fileLocation',
105
+ defaultValue: { uri: '', locationType: 'UriLocation' },
106
+ },
107
+ ...pluginManager.pluginConfigurationSchemas(),
108
+ }),
109
+ /**
110
+ * #slot
111
+ * defines plugins of the format
112
+ * ```typescript
113
+ * type PluginDefinition=
114
+ * { umdUrl: string, name:string } |
115
+ * { url: string, name: string } |
116
+ * { esmUrl: string } |
117
+ * { cjsUrl: string } |
118
+ * { umdLoc: { uri: string } } |
119
+ * { esmLoc: { uri: string } } |
120
+ * ```
121
+ */
122
+ plugins: mobx_state_tree_1.types.array(mobx_state_tree_1.types.frozen()),
123
+ /**
124
+ * #slot
125
+ * configuration of the assemblies in the instance, see BaseAssembly
126
+ */
127
+ assemblies: mobx_state_tree_1.types.array(assemblyConfigSchema),
128
+ /**
129
+ * #slot
130
+ * track configuration is an array of track config schemas. multiple
131
+ * instances of a track can exist that use the same configuration
132
+ */
133
+ tracks: mobx_state_tree_1.types.array(pluginManager.pluggableConfigSchemaType('track')),
134
+ /**
135
+ * #slot
136
+ * configuration for internet accounts, see InternetAccounts
137
+ */
138
+ internetAccounts: mobx_state_tree_1.types.array(pluginManager.pluggableConfigSchemaType('internet account')),
139
+ /**
140
+ * #slot
141
+ */
142
+ aggregateTextSearchAdapters: mobx_state_tree_1.types.array(pluginManager.pluggableConfigSchemaType('text search adapter')),
143
+ /**
144
+ * #slot
145
+ */
146
+ connections: mobx_state_tree_1.types.array(pluginManager.pluggableConfigSchemaType('connection')),
147
+ /**
148
+ * #slot
149
+ */
150
+ defaultSession: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.frozen(), {
151
+ name: `New Session`,
152
+ }),
153
+ });
154
+ }
155
+ exports.JBrowseConfigF = JBrowseConfigF;
@@ -0,0 +1,144 @@
1
+ import PluginManager from '@jbrowse/core/PluginManager';
2
+ import { BaseAssemblyConfigSchema } from '@jbrowse/core/assemblyManager';
3
+ import RpcManager from '@jbrowse/core/rpc/RpcManager';
4
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration';
5
+ import { PluginDefinition } from '@jbrowse/core/PluginLoader';
6
+ export declare function JBrowseModelF({ pluginManager, assemblyConfigSchema, }: {
7
+ pluginManager: PluginManager;
8
+ assemblyConfigSchema: BaseAssemblyConfigSchema;
9
+ }): import("mobx-state-tree").IModelType<{
10
+ configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
11
+ rpc: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
12
+ defaultDriver: {
13
+ type: string;
14
+ description: string;
15
+ defaultValue: string;
16
+ };
17
+ drivers: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IMapType<import("mobx-state-tree").ITypeUnion<import("mobx-state-tree").ModelCreationType<import("mobx-state-tree/dist/internal").ExtractCFromProps<Record<string, any>>> | undefined, import("mobx-state-tree").ModelSnapshotType<Record<string, any>>, (Partial<import("mobx-state-tree/dist/internal").ExtractCFromProps<Record<string, any>>> & import("mobx-state-tree/dist/internal").NonEmptyObject) | undefined>>, [undefined]>;
18
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
19
+ highResolutionScaling: {
20
+ type: string;
21
+ defaultValue: number;
22
+ };
23
+ formatDetails: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
24
+ feature: {
25
+ type: string;
26
+ description: string;
27
+ defaultValue: {};
28
+ contextVariable: string[];
29
+ };
30
+ subfeatures: {
31
+ type: string;
32
+ description: string;
33
+ defaultValue: {};
34
+ contextVariable: string[];
35
+ };
36
+ depth: {
37
+ type: string;
38
+ defaultValue: number;
39
+ description: string;
40
+ };
41
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
42
+ formatAbout: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
43
+ config: {
44
+ type: string;
45
+ description: string;
46
+ defaultValue: {};
47
+ contextVariable: string[];
48
+ };
49
+ hideUris: {
50
+ type: string;
51
+ defaultValue: boolean;
52
+ };
53
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
54
+ shareURL: {
55
+ type: string;
56
+ defaultValue: string;
57
+ };
58
+ disableAnalytics: {
59
+ type: string;
60
+ defaultValue: boolean;
61
+ };
62
+ theme: {
63
+ type: string;
64
+ defaultValue: {}; /**
65
+ * #action
66
+ */
67
+ };
68
+ extraThemes: {
69
+ type: string;
70
+ defaultValue: {};
71
+ };
72
+ logoPath: {
73
+ type: string;
74
+ /**
75
+ * #action
76
+ */
77
+ defaultValue: {
78
+ uri: string;
79
+ locationType: string;
80
+ };
81
+ };
82
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
83
+ plugins: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<PluginDefinition, PluginDefinition, PluginDefinition>>;
84
+ assemblies: import("mobx-state-tree").IArrayType<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>;
85
+ tracks: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IAnyModelType>;
86
+ internetAccounts: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IAnyModelType>;
87
+ aggregateTextSearchAdapters: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IAnyModelType>;
88
+ connections: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IAnyModelType>;
89
+ defaultSession: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
90
+ }, {
91
+ /**
92
+ * #getter
93
+ */
94
+ readonly assemblyNames: string[];
95
+ /**
96
+ * #getter
97
+ */
98
+ readonly rpcManager: RpcManager;
99
+ } & {
100
+ /**
101
+ * #action
102
+ */
103
+ addAssemblyConf(conf: AnyConfigurationModel): {
104
+ [x: string]: any;
105
+ } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
106
+ setSubschema(slotName: string, data: unknown): any;
107
+ } & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>;
108
+ /**
109
+ * #action
110
+ */
111
+ removeAssemblyConf(assemblyName: string): void;
112
+ /**
113
+ * #action
114
+ */
115
+ addTrackConf(trackConf: AnyConfigurationModel): any;
116
+ /**
117
+ * #action
118
+ */
119
+ addConnectionConf(connectionConf: AnyConfigurationModel): any;
120
+ /**
121
+ * #action
122
+ */
123
+ deleteConnectionConf(configuration: AnyConfigurationModel): boolean;
124
+ /**
125
+ * #action
126
+ */
127
+ deleteTrackConf(trackConf: AnyConfigurationModel): boolean;
128
+ /**
129
+ * #action
130
+ */
131
+ addPlugin(pluginDefinition: PluginDefinition): void;
132
+ /**
133
+ * #action
134
+ */
135
+ removePlugin(pluginDefinition: PluginDefinition): void;
136
+ /**
137
+ * #action
138
+ */
139
+ addInternetAccountConf(internetAccountConf: AnyConfigurationModel): any;
140
+ /**
141
+ * #action
142
+ */
143
+ deleteInternetAccountConf(configuration: AnyConfigurationModel): boolean;
144
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JBrowseModelF = void 0;
4
+ const mobx_state_tree_1 = require("mobx-state-tree");
5
+ const configuration_1 = require("@jbrowse/core/configuration");
6
+ // locals
7
+ const JBrowseConfig_1 = require("../JBrowseConfig");
8
+ function JBrowseModelF({ pluginManager, assemblyConfigSchema, }) {
9
+ return (0, JBrowseConfig_1.JBrowseConfigF)({ pluginManager, assemblyConfigSchema })
10
+ .views(self => ({
11
+ /**
12
+ * #getter
13
+ */
14
+ get assemblyNames() {
15
+ return self.assemblies.map(assembly => (0, configuration_1.readConfObject)(assembly, 'name'));
16
+ },
17
+ /**
18
+ * #getter
19
+ */
20
+ get rpcManager() {
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ return (0, mobx_state_tree_1.getParent)(self).rpcManager;
23
+ },
24
+ }))
25
+ .actions(self => ({
26
+ /**
27
+ * #action
28
+ */
29
+ addAssemblyConf(conf) {
30
+ const { name } = conf;
31
+ if (!name) {
32
+ throw new Error('Can\'t add assembly with no "name"');
33
+ }
34
+ if (self.assemblyNames.includes(name)) {
35
+ throw new Error(`Can't add assembly with name "${name}", an assembly with that name already exists`);
36
+ }
37
+ const length = self.assemblies.push({
38
+ ...conf,
39
+ sequence: {
40
+ type: 'ReferenceSequenceTrack',
41
+ trackId: `${name}-${Date.now()}`,
42
+ ...conf.sequence,
43
+ },
44
+ });
45
+ return self.assemblies[length - 1];
46
+ },
47
+ /**
48
+ * #action
49
+ */
50
+ removeAssemblyConf(assemblyName) {
51
+ const toRemove = self.assemblies.find(a => a.name === assemblyName);
52
+ if (toRemove) {
53
+ self.assemblies.remove(toRemove);
54
+ }
55
+ },
56
+ /**
57
+ * #action
58
+ */
59
+ addTrackConf(trackConf) {
60
+ const { type } = trackConf;
61
+ if (!type) {
62
+ throw new Error(`unknown track type ${type}`);
63
+ }
64
+ const length = self.tracks.push(trackConf);
65
+ return self.tracks[length - 1];
66
+ },
67
+ /**
68
+ * #action
69
+ */
70
+ addConnectionConf(connectionConf) {
71
+ const { type } = connectionConf;
72
+ if (!type) {
73
+ throw new Error(`unknown connection type ${type}`);
74
+ }
75
+ const length = self.connections.push(connectionConf);
76
+ return self.connections[length - 1];
77
+ },
78
+ /**
79
+ * #action
80
+ */
81
+ deleteConnectionConf(configuration) {
82
+ const elt = self.connections.find(conn => conn.id === configuration.id);
83
+ return self.connections.remove(elt);
84
+ },
85
+ /**
86
+ * #action
87
+ */
88
+ deleteTrackConf(trackConf) {
89
+ const elt = self.tracks.find(t => t.trackId === trackConf.trackId);
90
+ return self.tracks.remove(elt);
91
+ },
92
+ /**
93
+ * #action
94
+ */
95
+ addPlugin(pluginDefinition) {
96
+ self.plugins.push(pluginDefinition);
97
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
+ const rootModel = (0, mobx_state_tree_1.getParent)(self);
99
+ rootModel.setPluginsUpdated(true);
100
+ },
101
+ /**
102
+ * #action
103
+ */
104
+ removePlugin(pluginDefinition) {
105
+ self.plugins = (0, mobx_state_tree_1.cast)(self.plugins.filter(plugin => plugin.url !== pluginDefinition.url ||
106
+ plugin.umdUrl !== pluginDefinition.umdUrl ||
107
+ plugin.cjsUrl !== pluginDefinition.cjsUrl ||
108
+ plugin.esmUrl !== pluginDefinition.esmUrl));
109
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
+ (0, mobx_state_tree_1.getParent)(self).setPluginsUpdated(true);
111
+ },
112
+ /**
113
+ * #action
114
+ */
115
+ addInternetAccountConf(internetAccountConf) {
116
+ const { type } = internetAccountConf;
117
+ if (!type) {
118
+ throw new Error(`unknown internetAccount type ${type}`);
119
+ }
120
+ const length = self.internetAccounts.push(internetAccountConf);
121
+ return self.internetAccounts[length - 1];
122
+ },
123
+ /**
124
+ * #action
125
+ */
126
+ deleteInternetAccountConf(configuration) {
127
+ const elt = self.internetAccounts.find(a => a.id === configuration.id);
128
+ return self.internetAccounts.remove(elt);
129
+ },
130
+ }));
131
+ }
132
+ exports.JBrowseModelF = JBrowseModelF;
@@ -0,0 +1,68 @@
1
+ import { MenuItem } from '@jbrowse/core/ui/Menu';
2
+ export interface Menu {
3
+ label: string;
4
+ menuItems: MenuItem[];
5
+ }
6
+ export declare function RootAppMenuMixin(): import("mobx-state-tree").IModelType<{}, {
7
+ /**
8
+ * #action
9
+ */
10
+ setMenus(newMenus: Menu[]): void;
11
+ /**
12
+ * #action
13
+ * Add a top-level menu
14
+ * @param menuName - Name of the menu to insert.
15
+ * @returns The new length of the top-level menus array
16
+ */
17
+ appendMenu(menuName: string): number;
18
+ /**
19
+ * #action
20
+ * Insert a top-level menu
21
+ * @param menuName - Name of the menu to insert.
22
+ * @param position - Position to insert menu. If negative, counts from th
23
+ * end, e.g. `insertMenu('My Menu', -1)` will insert the menu as the
24
+ * second-to-last one.
25
+ * @returns The new length of the top-level menus array
26
+ */
27
+ insertMenu(menuName: string, position: number): number;
28
+ /**
29
+ * #action
30
+ * Add a menu item to a top-level menu
31
+ * @param menuName - Name of the top-level menu to append to.
32
+ * @param menuItem - Menu item to append.
33
+ * @returns The new length of the menu
34
+ */
35
+ appendToMenu(menuName: string, menuItem: MenuItem): number;
36
+ /**
37
+ * #action
38
+ * Insert a menu item into a top-level menu
39
+ * @param menuName - Name of the top-level menu to insert into
40
+ * @param menuItem - Menu item to insert
41
+ * @param position - Position to insert menu item. If negative, counts
42
+ * from the end, e.g. `insertMenu('My Menu', -1)` will insert the menu as
43
+ * the second-to-last one.
44
+ * @returns The new length of the menu
45
+ */
46
+ insertInMenu(menuName: string, menuItem: MenuItem, position: number): number;
47
+ /**
48
+ * #action
49
+ * Add a menu item to a sub-menu
50
+ * @param menuPath - Path to the sub-menu to add to, starting with the
51
+ * top-level menu (e.g. `['File', 'Insert']`).
52
+ * @param menuItem - Menu item to append.
53
+ * @returns The new length of the sub-menu
54
+ */
55
+ appendToSubMenu(menuPath: string[], menuItem: MenuItem): number;
56
+ /**
57
+ * #action
58
+ * Insert a menu item into a sub-menu
59
+ * @param menuPath - Path to the sub-menu to add to, starting with the
60
+ * top-level menu (e.g. `['File', 'Insert']`).
61
+ * @param menuItem - Menu item to insert.
62
+ * @param position - Position to insert menu item. If negative, counts
63
+ * from the end, e.g. `insertMenu('My Menu', -1)` will insert the menu as
64
+ * the second-to-last one.
65
+ * @returns The new length of the sub-menu
66
+ */
67
+ insertInSubMenu(menuPath: string[], menuItem: MenuItem, position: number): number;
68
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RootAppMenuMixin = void 0;
4
+ const mobx_state_tree_1 = require("mobx-state-tree");
5
+ function RootAppMenuMixin() {
6
+ return mobx_state_tree_1.types.model({}).actions(s => {
7
+ const self = s;
8
+ return {
9
+ /**
10
+ * #action
11
+ */
12
+ setMenus(newMenus) {
13
+ self.menus = newMenus;
14
+ },
15
+ /**
16
+ * #action
17
+ * Add a top-level menu
18
+ * @param menuName - Name of the menu to insert.
19
+ * @returns The new length of the top-level menus array
20
+ */
21
+ appendMenu(menuName) {
22
+ return self.menus.push({ label: menuName, menuItems: [] });
23
+ },
24
+ /**
25
+ * #action
26
+ * Insert a top-level menu
27
+ * @param menuName - Name of the menu to insert.
28
+ * @param position - Position to insert menu. If negative, counts from th
29
+ * end, e.g. `insertMenu('My Menu', -1)` will insert the menu as the
30
+ * second-to-last one.
31
+ * @returns The new length of the top-level menus array
32
+ */
33
+ insertMenu(menuName, position) {
34
+ self.menus.splice((position < 0 ? self.menus.length : 0) + position, 0, {
35
+ label: menuName,
36
+ menuItems: [],
37
+ });
38
+ return self.menus.length;
39
+ },
40
+ /**
41
+ * #action
42
+ * Add a menu item to a top-level menu
43
+ * @param menuName - Name of the top-level menu to append to.
44
+ * @param menuItem - Menu item to append.
45
+ * @returns The new length of the menu
46
+ */
47
+ appendToMenu(menuName, menuItem) {
48
+ const menu = self.menus.find(m => m.label === menuName);
49
+ if (!menu) {
50
+ self.menus.push({ label: menuName, menuItems: [menuItem] });
51
+ return 1;
52
+ }
53
+ return menu.menuItems.push(menuItem);
54
+ },
55
+ /**
56
+ * #action
57
+ * Insert a menu item into a top-level menu
58
+ * @param menuName - Name of the top-level menu to insert into
59
+ * @param menuItem - Menu item to insert
60
+ * @param position - Position to insert menu item. If negative, counts
61
+ * from the end, e.g. `insertMenu('My Menu', -1)` will insert the menu as
62
+ * the second-to-last one.
63
+ * @returns The new length of the menu
64
+ */
65
+ insertInMenu(menuName, menuItem, position) {
66
+ const menu = self.menus.find(m => m.label === menuName);
67
+ if (!menu) {
68
+ self.menus.push({ label: menuName, menuItems: [menuItem] });
69
+ return 1;
70
+ }
71
+ const insertPosition = position < 0 ? menu.menuItems.length + position : position;
72
+ menu.menuItems.splice(insertPosition, 0, menuItem);
73
+ return menu.menuItems.length;
74
+ },
75
+ /**
76
+ * #action
77
+ * Add a menu item to a sub-menu
78
+ * @param menuPath - Path to the sub-menu to add to, starting with the
79
+ * top-level menu (e.g. `['File', 'Insert']`).
80
+ * @param menuItem - Menu item to append.
81
+ * @returns The new length of the sub-menu
82
+ */
83
+ appendToSubMenu(menuPath, menuItem) {
84
+ let topMenu = self.menus.find(m => m.label === menuPath[0]);
85
+ if (!topMenu) {
86
+ const idx = this.appendMenu(menuPath[0]);
87
+ topMenu = self.menus[idx - 1];
88
+ }
89
+ let { menuItems: subMenu } = topMenu;
90
+ const pathSoFar = [menuPath[0]];
91
+ menuPath.slice(1).forEach(menuName => {
92
+ pathSoFar.push(menuName);
93
+ let sm = subMenu.find(mi => 'label' in mi && mi.label === menuName);
94
+ if (!sm) {
95
+ const idx = subMenu.push({ label: menuName, subMenu: [] });
96
+ sm = subMenu[idx - 1];
97
+ }
98
+ if (!('subMenu' in sm)) {
99
+ throw new Error(`"${menuName}" in path "${pathSoFar}" is not a subMenu`);
100
+ }
101
+ subMenu = sm.subMenu;
102
+ });
103
+ return subMenu.push(menuItem);
104
+ },
105
+ /**
106
+ * #action
107
+ * Insert a menu item into a sub-menu
108
+ * @param menuPath - Path to the sub-menu to add to, starting with the
109
+ * top-level menu (e.g. `['File', 'Insert']`).
110
+ * @param menuItem - Menu item to insert.
111
+ * @param position - Position to insert menu item. If negative, counts
112
+ * from the end, e.g. `insertMenu('My Menu', -1)` will insert the menu as
113
+ * the second-to-last one.
114
+ * @returns The new length of the sub-menu
115
+ */
116
+ insertInSubMenu(menuPath, menuItem, position) {
117
+ let topMenu = self.menus.find(m => m.label === menuPath[0]);
118
+ if (!topMenu) {
119
+ const idx = this.appendMenu(menuPath[0]);
120
+ topMenu = self.menus[idx - 1];
121
+ }
122
+ let { menuItems: subMenu } = topMenu;
123
+ const pathSoFar = [menuPath[0]];
124
+ menuPath.slice(1).forEach(menuName => {
125
+ pathSoFar.push(menuName);
126
+ let sm = subMenu.find(mi => 'label' in mi && mi.label === menuName);
127
+ if (!sm) {
128
+ const idx = subMenu.push({ label: menuName, subMenu: [] });
129
+ sm = subMenu[idx - 1];
130
+ }
131
+ if (!('subMenu' in sm)) {
132
+ throw new Error(`"${menuName}" in path "${pathSoFar}" is not a subMenu`);
133
+ }
134
+ subMenu = sm.subMenu;
135
+ });
136
+ subMenu.splice(position, 0, menuItem);
137
+ return subMenu.length;
138
+ },
139
+ };
140
+ });
141
+ }
142
+ exports.RootAppMenuMixin = RootAppMenuMixin;
@@ -0,0 +1,6 @@
1
+ export * from './ui';
2
+ export * from './HistoryManagement';
3
+ export * from './JBrowseConfig';
4
+ export * from './JBrowseModel';
5
+ export * from './Assemblies';
6
+ export * from './RootMenu';
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ui"), exports);
18
+ __exportStar(require("./HistoryManagement"), exports);
19
+ __exportStar(require("./JBrowseConfig"), exports);
20
+ __exportStar(require("./JBrowseModel"), exports);
21
+ __exportStar(require("./Assemblies"), exports);
22
+ __exportStar(require("./RootMenu"), exports);