@jbrowse/app-core 2.6.1 → 2.6.3

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 (36) hide show
  1. package/dist/HistoryManagement/index.js +5 -2
  2. package/dist/JBrowseConfig/index.d.ts +29 -18
  3. package/dist/JBrowseConfig/index.js +8 -47
  4. package/dist/JBrowseModel/index.d.ts +38 -9
  5. package/dist/ui/App/DrawerHeader.d.ts +7 -0
  6. package/dist/ui/App/DrawerHeader.js +114 -0
  7. package/dist/ui/App/DrawerWidget.js +2 -76
  8. package/esm/HistoryManagement/index.js +5 -2
  9. package/esm/JBrowseConfig/index.d.ts +29 -18
  10. package/esm/JBrowseConfig/index.js +8 -47
  11. package/esm/JBrowseModel/index.d.ts +38 -9
  12. package/esm/ui/App/DrawerHeader.d.ts +7 -0
  13. package/esm/ui/App/DrawerHeader.js +86 -0
  14. package/esm/ui/App/DrawerWidget.js +1 -75
  15. package/package.json +6 -7
  16. package/src/Assemblies/SessionAssembliesMixin.ts +0 -50
  17. package/src/Assemblies/TemporaryAssembliesMixin.ts +0 -51
  18. package/src/Assemblies/index.ts +0 -2
  19. package/src/HistoryManagement/index.ts +0 -56
  20. package/src/JBrowseConfig/index.ts +0 -173
  21. package/src/JBrowseModel/index.ts +0 -150
  22. package/src/RootMenu/index.ts +0 -157
  23. package/src/index.ts +0 -6
  24. package/src/ui/App/App.tsx +0 -117
  25. package/src/ui/App/AppFab.tsx +0 -45
  26. package/src/ui/App/AppToolbar.tsx +0 -89
  27. package/src/ui/App/DialogQueue.tsx +0 -22
  28. package/src/ui/App/Drawer.tsx +0 -56
  29. package/src/ui/App/DrawerWidget.tsx +0 -238
  30. package/src/ui/App/ViewContainer.tsx +0 -76
  31. package/src/ui/App/ViewContainerTitle.tsx +0 -55
  32. package/src/ui/App/ViewLauncher.tsx +0 -64
  33. package/src/ui/App/ViewMenu.tsx +0 -54
  34. package/src/ui/App/ViewPanel.tsx +0 -63
  35. package/src/ui/App/index.ts +0 -1
  36. package/src/ui/index.ts +0 -1
@@ -1,173 +0,0 @@
1
- import {
2
- AnyConfigurationSchemaType,
3
- ConfigurationSchema,
4
- } from '@jbrowse/core/configuration'
5
-
6
- import { PluginDefinition } from '@jbrowse/core/PluginLoader'
7
- import PluginManager from '@jbrowse/core/PluginManager'
8
- import RpcManager from '@jbrowse/core/rpc/RpcManager'
9
- import { types } from 'mobx-state-tree'
10
-
11
- /**
12
- * #config JBrowseRootConfig
13
- * #category root
14
- * configuration in a config.json/file.jbrowse
15
- */
16
- export function JBrowseConfigF({
17
- pluginManager,
18
- assemblyConfigSchema,
19
- }: {
20
- pluginManager: PluginManager
21
- assemblyConfigSchema: AnyConfigurationSchemaType
22
- }) {
23
- return types.model('JBrowseConfig', {
24
- configuration: ConfigurationSchema('Root', {
25
- /**
26
- * #slot configuration.rpc
27
- */
28
- rpc: RpcManager.configSchema,
29
-
30
- /**
31
- * #slot configuration.highResolutionScaling
32
- */
33
- highResolutionScaling: {
34
- type: 'number',
35
- defaultValue: 2,
36
- },
37
-
38
- formatDetails: ConfigurationSchema('FormatDetails', {
39
- /**
40
- * #slot configuration.formatDetails.feature
41
- */
42
- feature: {
43
- type: 'frozen',
44
- description: 'adds extra fields to the feature details',
45
- defaultValue: {},
46
- contextVariable: ['feature'],
47
- },
48
- /**
49
- * #slot configuration.formatDetails.subfeatures
50
- */
51
- subfeatures: {
52
- type: 'frozen',
53
- description: 'adds extra fields to the subfeatures of a feature',
54
- defaultValue: {},
55
- contextVariable: ['feature'],
56
- },
57
- /**
58
- * #slot configuration.formatDetails.depth
59
- */
60
- depth: {
61
- type: 'number',
62
- defaultValue: 2,
63
- description: 'depth to iterate on subfeatures',
64
- },
65
- }),
66
- formatAbout: ConfigurationSchema('FormatAbout', {
67
- /**
68
- * #slot configuration.formatAbout.config
69
- */
70
- config: {
71
- type: 'frozen',
72
- description: 'formats configuration object in about dialog',
73
- defaultValue: {},
74
- contextVariable: ['config'],
75
- },
76
- /**
77
- * #slot configuration.formatAbout.hideUris
78
- */
79
-
80
- hideUris: {
81
- type: 'boolean',
82
- defaultValue: false,
83
- },
84
- }),
85
-
86
- /*
87
- * #slot configuration.shareURL
88
- */
89
- shareURL: {
90
- type: 'string',
91
- defaultValue: 'https://share.jbrowse.org/api/v1/',
92
- },
93
- /**
94
- * #slot configuration.disableAnalytics
95
- */
96
- disableAnalytics: {
97
- type: 'boolean',
98
- defaultValue: false,
99
- },
100
- /**
101
- * #slot configuration.theme
102
- */
103
- theme: {
104
- type: 'frozen',
105
- defaultValue: {},
106
- },
107
- /**
108
- * #slot configuration.extraThemes
109
- */
110
- extraThemes: { type: 'frozen', defaultValue: {} },
111
- /**
112
- * #slot configuration.logoPath
113
- */
114
- logoPath: {
115
- type: 'fileLocation',
116
- defaultValue: { uri: '', locationType: 'UriLocation' },
117
- },
118
- ...pluginManager.pluginConfigurationSchemas(),
119
- }),
120
- /**
121
- * #slot
122
- * defines plugins of the format
123
- * ```typescript
124
- * type PluginDefinition=
125
- * { umdUrl: string, name:string } |
126
- * { url: string, name: string } |
127
- * { esmUrl: string } |
128
- * { cjsUrl: string } |
129
- * { umdLoc: { uri: string } } |
130
- * { esmLoc: { uri: string } } |
131
- * ```
132
- */
133
- plugins: types.array(types.frozen<PluginDefinition>()),
134
- /**
135
- * #slot
136
- * configuration of the assemblies in the instance, see BaseAssembly
137
- */
138
- assemblies: types.array(assemblyConfigSchema),
139
- /**
140
- * #slot
141
- * track configuration is an array of track config schemas. multiple
142
- * instances of a track can exist that use the same configuration
143
- */
144
- tracks: types.array(pluginManager.pluggableConfigSchemaType('track')),
145
- /**
146
- * #slot
147
- * configuration for internet accounts, see InternetAccounts
148
- */
149
- internetAccounts: types.array(
150
- pluginManager.pluggableConfigSchemaType('internet account'),
151
- ),
152
- /**
153
- * #slot
154
- */
155
- aggregateTextSearchAdapters: types.array(
156
- pluginManager.pluggableConfigSchemaType('text search adapter'),
157
- ),
158
-
159
- /**
160
- * #slot
161
- */
162
- connections: types.array(
163
- pluginManager.pluggableConfigSchemaType('connection'),
164
- ),
165
-
166
- /**
167
- * #slot
168
- */
169
- defaultSession: types.optional(types.frozen(), {
170
- name: `New Session`,
171
- }),
172
- })
173
- }
@@ -1,150 +0,0 @@
1
- import PluginManager from '@jbrowse/core/PluginManager'
2
- import { BaseAssemblyConfigSchema } from '@jbrowse/core/assemblyManager'
3
- import { cast, getParent } from 'mobx-state-tree'
4
- import RpcManager from '@jbrowse/core/rpc/RpcManager'
5
- import {
6
- AnyConfigurationModel,
7
- readConfObject,
8
- } from '@jbrowse/core/configuration'
9
- import { PluginDefinition } from '@jbrowse/core/PluginLoader'
10
-
11
- // locals
12
- import { JBrowseConfigF } from '../JBrowseConfig'
13
-
14
- export function JBrowseModelF({
15
- pluginManager,
16
- assemblyConfigSchema,
17
- }: {
18
- pluginManager: PluginManager
19
- assemblyConfigSchema: BaseAssemblyConfigSchema
20
- }) {
21
- return JBrowseConfigF({ pluginManager, assemblyConfigSchema })
22
- .views(self => ({
23
- /**
24
- * #getter
25
- */
26
- get assemblyNames(): string[] {
27
- return self.assemblies.map(assembly => readConfObject(assembly, 'name'))
28
- },
29
- /**
30
- * #getter
31
- */
32
- get rpcManager(): RpcManager {
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- return getParent<any>(self).rpcManager
35
- },
36
- }))
37
- .actions(self => ({
38
- /**
39
- * #action
40
- */
41
- addAssemblyConf(conf: AnyConfigurationModel) {
42
- const { name } = conf
43
- if (!name) {
44
- throw new Error('Can\'t add assembly with no "name"')
45
- }
46
- if (self.assemblyNames.includes(name)) {
47
- throw new Error(
48
- `Can't add assembly with name "${name}", an assembly with that name already exists`,
49
- )
50
- }
51
- const length = self.assemblies.push({
52
- ...conf,
53
- sequence: {
54
- type: 'ReferenceSequenceTrack',
55
- trackId: `${name}-${Date.now()}`,
56
- ...conf.sequence,
57
- },
58
- })
59
- return self.assemblies[length - 1]
60
- },
61
- /**
62
- * #action
63
- */
64
- removeAssemblyConf(assemblyName: string) {
65
- const toRemove = self.assemblies.find(a => a.name === assemblyName)
66
- if (toRemove) {
67
- self.assemblies.remove(toRemove)
68
- }
69
- },
70
- /**
71
- * #action
72
- */
73
- addTrackConf(trackConf: AnyConfigurationModel) {
74
- const { type } = trackConf
75
- if (!type) {
76
- throw new Error(`unknown track type ${type}`)
77
- }
78
- const length = self.tracks.push(trackConf)
79
- return self.tracks[length - 1]
80
- },
81
- /**
82
- * #action
83
- */
84
- addConnectionConf(connectionConf: AnyConfigurationModel) {
85
- const { type } = connectionConf
86
- if (!type) {
87
- throw new Error(`unknown connection type ${type}`)
88
- }
89
- const length = self.connections.push(connectionConf)
90
- return self.connections[length - 1]
91
- },
92
- /**
93
- * #action
94
- */
95
- deleteConnectionConf(configuration: AnyConfigurationModel) {
96
- const elt = self.connections.find(conn => conn.id === configuration.id)
97
- return self.connections.remove(elt)
98
- },
99
- /**
100
- * #action
101
- */
102
- deleteTrackConf(trackConf: AnyConfigurationModel) {
103
- const elt = self.tracks.find(t => t.trackId === trackConf.trackId)
104
- return self.tracks.remove(elt)
105
- },
106
- /**
107
- * #action
108
- */
109
- addPlugin(pluginDefinition: PluginDefinition) {
110
- self.plugins.push(pluginDefinition)
111
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
- const rootModel = getParent<any>(self)
113
- rootModel.setPluginsUpdated(true)
114
- },
115
- /**
116
- * #action
117
- */
118
- removePlugin(pluginDefinition: PluginDefinition) {
119
- self.plugins = cast(
120
- self.plugins.filter(
121
- plugin =>
122
- plugin.url !== pluginDefinition.url ||
123
- plugin.umdUrl !== pluginDefinition.umdUrl ||
124
- plugin.cjsUrl !== pluginDefinition.cjsUrl ||
125
- plugin.esmUrl !== pluginDefinition.esmUrl,
126
- ),
127
- )
128
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
- getParent<any>(self).setPluginsUpdated(true)
130
- },
131
- /**
132
- * #action
133
- */
134
- addInternetAccountConf(internetAccountConf: AnyConfigurationModel) {
135
- const { type } = internetAccountConf
136
- if (!type) {
137
- throw new Error(`unknown internetAccount type ${type}`)
138
- }
139
- const length = self.internetAccounts.push(internetAccountConf)
140
- return self.internetAccounts[length - 1]
141
- },
142
- /**
143
- * #action
144
- */
145
- deleteInternetAccountConf(configuration: AnyConfigurationModel) {
146
- const elt = self.internetAccounts.find(a => a.id === configuration.id)
147
- return self.internetAccounts.remove(elt)
148
- },
149
- }))
150
- }
@@ -1,157 +0,0 @@
1
- import { MenuItem } from '@jbrowse/core/ui/Menu'
2
- import { types } from 'mobx-state-tree'
3
-
4
- export interface Menu {
5
- label: string
6
- menuItems: MenuItem[]
7
- }
8
- export function RootAppMenuMixin() {
9
- return types.model({}).actions(s => {
10
- const self = s as { menus: Menu[] }
11
- return {
12
- /**
13
- * #action
14
- */
15
- setMenus(newMenus: Menu[]) {
16
- self.menus = newMenus
17
- },
18
- /**
19
- * #action
20
- * Add a top-level menu
21
- * @param menuName - Name of the menu to insert.
22
- * @returns The new length of the top-level menus array
23
- */
24
- appendMenu(menuName: string) {
25
- return self.menus.push({ label: menuName, menuItems: [] })
26
- },
27
- /**
28
- * #action
29
- * Insert a top-level menu
30
- * @param menuName - Name of the menu to insert.
31
- * @param position - Position to insert menu. If negative, counts from th
32
- * end, e.g. `insertMenu('My Menu', -1)` will insert the menu as the
33
- * second-to-last one.
34
- * @returns The new length of the top-level menus array
35
- */
36
- insertMenu(menuName: string, position: number) {
37
- self.menus.splice(
38
- (position < 0 ? self.menus.length : 0) + position,
39
- 0,
40
- {
41
- label: menuName,
42
- menuItems: [],
43
- },
44
- )
45
- return self.menus.length
46
- },
47
- /**
48
- * #action
49
- * Add a menu item to a top-level menu
50
- * @param menuName - Name of the top-level menu to append to.
51
- * @param menuItem - Menu item to append.
52
- * @returns The new length of the menu
53
- */
54
- appendToMenu(menuName: string, menuItem: MenuItem) {
55
- const menu = self.menus.find(m => m.label === menuName)
56
- if (!menu) {
57
- self.menus.push({ label: menuName, menuItems: [menuItem] })
58
- return 1
59
- }
60
- return menu.menuItems.push(menuItem)
61
- },
62
- /**
63
- * #action
64
- * Insert a menu item into a top-level menu
65
- * @param menuName - Name of the top-level menu to insert into
66
- * @param menuItem - Menu item to insert
67
- * @param position - Position to insert menu item. If negative, counts
68
- * from the end, e.g. `insertMenu('My Menu', -1)` will insert the menu as
69
- * the second-to-last one.
70
- * @returns The new length of the menu
71
- */
72
- insertInMenu(menuName: string, menuItem: MenuItem, position: number) {
73
- const menu = self.menus.find(m => m.label === menuName)
74
- if (!menu) {
75
- self.menus.push({ label: menuName, menuItems: [menuItem] })
76
- return 1
77
- }
78
- const insertPosition =
79
- position < 0 ? menu.menuItems.length + position : position
80
- menu.menuItems.splice(insertPosition, 0, menuItem)
81
- return menu.menuItems.length
82
- },
83
- /**
84
- * #action
85
- * Add a menu item to a sub-menu
86
- * @param menuPath - Path to the sub-menu to add to, starting with the
87
- * top-level menu (e.g. `['File', 'Insert']`).
88
- * @param menuItem - Menu item to append.
89
- * @returns The new length of the sub-menu
90
- */
91
- appendToSubMenu(menuPath: string[], menuItem: MenuItem) {
92
- let topMenu = self.menus.find(m => m.label === menuPath[0])
93
- if (!topMenu) {
94
- const idx = this.appendMenu(menuPath[0])
95
- topMenu = self.menus[idx - 1]
96
- }
97
- let { menuItems: subMenu } = topMenu
98
- const pathSoFar = [menuPath[0]]
99
- menuPath.slice(1).forEach(menuName => {
100
- pathSoFar.push(menuName)
101
- let sm = subMenu.find(mi => 'label' in mi && mi.label === menuName)
102
- if (!sm) {
103
- const idx = subMenu.push({ label: menuName, subMenu: [] })
104
- sm = subMenu[idx - 1]
105
- }
106
- if (!('subMenu' in sm)) {
107
- throw new Error(
108
- `"${menuName}" in path "${pathSoFar}" is not a subMenu`,
109
- )
110
- }
111
- subMenu = sm.subMenu
112
- })
113
- return subMenu.push(menuItem)
114
- },
115
- /**
116
- * #action
117
- * Insert a menu item into a sub-menu
118
- * @param menuPath - Path to the sub-menu to add to, starting with the
119
- * top-level menu (e.g. `['File', 'Insert']`).
120
- * @param menuItem - Menu item to insert.
121
- * @param position - Position to insert menu item. If negative, counts
122
- * from the end, e.g. `insertMenu('My Menu', -1)` will insert the menu as
123
- * the second-to-last one.
124
- * @returns The new length of the sub-menu
125
- */
126
- insertInSubMenu(
127
- menuPath: string[],
128
- menuItem: MenuItem,
129
- position: number,
130
- ) {
131
- let topMenu = self.menus.find(m => m.label === menuPath[0])
132
- if (!topMenu) {
133
- const idx = this.appendMenu(menuPath[0])
134
- topMenu = self.menus[idx - 1]
135
- }
136
- let { menuItems: subMenu } = topMenu
137
- const pathSoFar = [menuPath[0]]
138
- menuPath.slice(1).forEach(menuName => {
139
- pathSoFar.push(menuName)
140
- let sm = subMenu.find(mi => 'label' in mi && mi.label === menuName)
141
- if (!sm) {
142
- const idx = subMenu.push({ label: menuName, subMenu: [] })
143
- sm = subMenu[idx - 1]
144
- }
145
- if (!('subMenu' in sm)) {
146
- throw new Error(
147
- `"${menuName}" in path "${pathSoFar}" is not a subMenu`,
148
- )
149
- }
150
- subMenu = sm.subMenu
151
- })
152
- subMenu.splice(position, 0, menuItem)
153
- return subMenu.length
154
- },
155
- }
156
- })
157
- }
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './ui'
2
- export * from './HistoryManagement'
3
- export * from './JBrowseConfig'
4
- export * from './JBrowseModel'
5
- export * from './Assemblies'
6
- export * from './RootMenu'
@@ -1,117 +0,0 @@
1
- import React, { Suspense, lazy } from 'react'
2
- import { AppBar } from '@mui/material'
3
- import { makeStyles } from 'tss-react/mui'
4
- import { observer } from 'mobx-react'
5
- import { SessionWithDrawerWidgets } from '@jbrowse/core/util'
6
- import Snackbar from '@jbrowse/core/ui/Snackbar'
7
- import { SnackbarMessage } from '@jbrowse/core/ui/SnackbarModel'
8
- import { MenuItem as JBMenuItem } from '@jbrowse/core/ui/Menu'
9
-
10
- // locals
11
- import AppToolbar from './AppToolbar'
12
- import ViewLauncher from './ViewLauncher'
13
- import ViewPanel from './ViewPanel'
14
- import DialogQueue from './DialogQueue'
15
- import AppFab from './AppFab'
16
-
17
- const DrawerWidget = lazy(() => import('./DrawerWidget'))
18
-
19
- const useStyles = makeStyles()(theme => ({
20
- root: {
21
- display: 'grid',
22
- height: '100vh',
23
- width: '100%',
24
- colorScheme: theme.palette.mode,
25
- },
26
- appContainer: {
27
- gridColumn: 'main',
28
- display: 'grid',
29
- gridTemplateRows: '[menubar] min-content [components] auto',
30
- height: '100vh',
31
- },
32
- viewContainer: {
33
- overflowY: 'auto',
34
- gridRow: 'components',
35
- },
36
- appBar: {
37
- flexGrow: 1,
38
- gridRow: 'menubar',
39
- },
40
- }))
41
-
42
- type Props = {
43
- HeaderButtons?: React.ReactElement
44
- session: SessionWithDrawerWidgets & {
45
- savedSessionNames: string[]
46
- menus: { label: string; menuItems: JBMenuItem[] }[]
47
- renameCurrentSession: (arg: string) => void
48
- snackbarMessages: SnackbarMessage[]
49
- popSnackbarMessage: () => unknown
50
- }
51
- }
52
-
53
- const LazyDrawerWidget = observer(function (props: Props) {
54
- const { session } = props
55
- return (
56
- <Suspense fallback={<React.Fragment />}>
57
- <DrawerWidget session={session} />
58
- </Suspense>
59
- )
60
- })
61
-
62
- const ViewContainer = observer(function (props: Props) {
63
- const { session } = props
64
- const { views } = session
65
- const { classes } = useStyles()
66
- return (
67
- <div className={classes.viewContainer}>
68
- {views.length > 0 ? (
69
- views.map(view => (
70
- <ViewPanel key={`view-${view.id}`} view={view} session={session} />
71
- ))
72
- ) : (
73
- <ViewLauncher {...props} />
74
- )}
75
-
76
- {/* blank space at the bottom of screen allows scroll */}
77
- <div style={{ height: 300 }} />
78
- </div>
79
- )
80
- })
81
-
82
- const App = observer(function (props: Props) {
83
- const { session } = props
84
- const { classes } = useStyles()
85
- const { minimized, visibleWidget, drawerWidth, drawerPosition } = session
86
- const drawerVisible = visibleWidget && !minimized
87
- const d = drawerVisible ? `[drawer] ${drawerWidth}px` : undefined
88
- const grid =
89
- drawerPosition === 'right' ? ['[main] 1fr', d] : [d, '[main] 1fr']
90
-
91
- return (
92
- <div
93
- className={classes.root}
94
- style={{ gridTemplateColumns: grid?.filter(f => !!f).join(' ') }}
95
- >
96
- {drawerVisible && drawerPosition === 'left' ? (
97
- <LazyDrawerWidget session={session} />
98
- ) : null}
99
- <DialogQueue session={session} />
100
- <div className={classes.appContainer}>
101
- <AppBar className={classes.appBar} position="static">
102
- <AppToolbar {...props} />
103
- </AppBar>
104
- <ViewContainer {...props} />
105
- </div>
106
- <AppFab session={session} />
107
-
108
- {drawerVisible && drawerPosition === 'right' ? (
109
- <LazyDrawerWidget session={session} />
110
- ) : null}
111
-
112
- <Snackbar session={session} />
113
- </div>
114
- )
115
- })
116
-
117
- export { App }
@@ -1,45 +0,0 @@
1
- import React from 'react'
2
- import { Fab, Tooltip } from '@mui/material'
3
- import { makeStyles } from 'tss-react/mui'
4
- import { observer } from 'mobx-react'
5
- import { SessionWithDrawerWidgets } from '@jbrowse/core/util'
6
-
7
- // icons
8
- import LaunchIcon from '@mui/icons-material/Launch'
9
-
10
- const useStyles = makeStyles()(theme => ({
11
- left: {
12
- zIndex: 10000,
13
- position: 'fixed',
14
- bottom: theme.spacing(2),
15
- left: theme.spacing(2),
16
- },
17
- right: {
18
- zIndex: 10000,
19
- position: 'fixed',
20
- bottom: theme.spacing(2),
21
- right: theme.spacing(2),
22
- },
23
- }))
24
-
25
- export default observer(function AppFab({
26
- session,
27
- }: {
28
- session: SessionWithDrawerWidgets
29
- }) {
30
- const { minimized, activeWidgets, drawerPosition } = session
31
- const { classes } = useStyles()
32
-
33
- return activeWidgets.size > 0 && minimized ? (
34
- <Tooltip title="Open drawer widget">
35
- <Fab
36
- className={drawerPosition === 'right' ? classes.right : classes.left}
37
- color="primary"
38
- data-testid="drawer-maximize"
39
- onClick={() => session.showWidgetDrawer()}
40
- >
41
- <LaunchIcon />
42
- </Fab>
43
- </Tooltip>
44
- ) : null
45
- })