@jbrowse/app-core 2.6.1 → 2.6.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/app-core",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "description": "JBrowse 2 code shared between the 'full featured' apps e.g. jbrowse-web and jbrowse-desktop",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -26,13 +26,12 @@
26
26
  "module": "esm/index.js",
27
27
  "files": [
28
28
  "dist",
29
- "esm",
30
- "src"
29
+ "esm"
31
30
  ],
32
31
  "scripts": {
33
32
  "build:esm": "tsc --build tsconfig.build.esm.json",
34
- "build:es5": "tsc --build tsconfig.build.es5.json",
35
- "build": "npm run build:esm && npm run build:es5",
33
+ "build:commonjs": "tsc --build tsconfig.build.commonjs.json",
34
+ "build": "npm run build:esm && npm run build:commonjs",
36
35
  "test": "cd ../..; jest packages/app-core",
37
36
  "clean": "rimraf dist esm *.tsbuildinfo",
38
37
  "prebuild": "yarn clean",
@@ -43,7 +42,7 @@
43
42
  },
44
43
  "dependencies": {
45
44
  "@babel/runtime": "^7.16.3",
46
- "@jbrowse/product-core": "^2.6.1",
45
+ "@jbrowse/product-core": "^2.6.2",
47
46
  "@mui/icons-material": "^5.0.0",
48
47
  "@mui/material": "^5.10.17",
49
48
  "copy-to-clipboard": "^3.3.1",
@@ -62,5 +61,5 @@
62
61
  "publishConfig": {
63
62
  "access": "public"
64
63
  },
65
- "gitHead": "1cbe7ba097fb2d2763c776e5e429e4670cdd583c"
64
+ "gitHead": "bbea587a402d9974acdd804a33f4b77f31a2fd5f"
66
65
  }
@@ -1,50 +0,0 @@
1
- import { types } from 'mobx-state-tree'
2
-
3
- import PluginManager from '@jbrowse/core/PluginManager'
4
- import { AnyConfiguration } from '@jbrowse/core/configuration'
5
- import { BaseSession } from '@jbrowse/product-core'
6
- import { BaseAssemblyConfigSchema } from '@jbrowse/core/assemblyManager'
7
-
8
- /**
9
- * #stateModel SessionAssembliesMixin
10
- * #category root
11
- */
12
- export function SessionAssembliesMixin(
13
- pluginManager: PluginManager,
14
- assemblyConfigSchemasType: BaseAssemblyConfigSchema,
15
- ) {
16
- return types
17
- .model({
18
- /**
19
- * #property
20
- */
21
- sessionAssemblies: types.array(assemblyConfigSchemasType),
22
- })
23
- .actions(s => {
24
- const self = s as typeof s & BaseSession
25
- return {
26
- /**
27
- * #action
28
- */
29
- addSessionAssembly(conf: AnyConfiguration) {
30
- const asm = self.sessionAssemblies.find(f => f.name === conf.name)
31
- if (asm) {
32
- console.warn(`Assembly ${conf.name} already exists`)
33
- return asm
34
- }
35
- const length = self.sessionAssemblies.push(conf)
36
- return self.sessionAssemblies[length - 1]
37
- },
38
-
39
- /**
40
- * #action
41
- */
42
- removeSessionAssembly(assemblyName: string) {
43
- const elt = self.sessionAssemblies.find(a => a.name === assemblyName)
44
- if (elt) {
45
- self.sessionAssemblies.remove(elt)
46
- }
47
- },
48
- }
49
- })
50
- }
@@ -1,51 +0,0 @@
1
- import { types } from 'mobx-state-tree'
2
-
3
- import PluginManager from '@jbrowse/core/PluginManager'
4
- import { AnyConfiguration } from '@jbrowse/core/configuration'
5
- import { BaseSession } from '@jbrowse/product-core'
6
-
7
- /**
8
- * #stateModel TemporaryAssembliesMixin
9
- * #category root
10
- */
11
- export function TemporaryAssembliesMixin(
12
- pluginManager: PluginManager,
13
- assemblyConfigSchemasType = types.frozen(),
14
- ) {
15
- return types
16
- .model({
17
- /**
18
- * #property
19
- */
20
- temporaryAssemblies: types.array(assemblyConfigSchemasType),
21
- })
22
-
23
- .actions(s => {
24
- const self = s as typeof s & BaseSession
25
- return {
26
- /**
27
- * #action
28
- * used for read vs ref type assemblies.
29
- */
30
- addTemporaryAssembly(conf: AnyConfiguration) {
31
- const asm = self.temporaryAssemblies.find(f => f.name === conf.name)
32
- if (asm) {
33
- console.warn(`Assembly ${conf.name} was already existing`)
34
- return asm
35
- }
36
- const length = self.temporaryAssemblies.push(conf)
37
- return self.temporaryAssemblies[length - 1]
38
- },
39
-
40
- /**
41
- * #action
42
- */
43
- removeTemporaryAssembly(name: string) {
44
- const elt = self.temporaryAssemblies.find(a => a.name === name)
45
- if (elt) {
46
- self.temporaryAssemblies.remove(elt)
47
- }
48
- },
49
- }
50
- })
51
- }
@@ -1,2 +0,0 @@
1
- export * from './SessionAssembliesMixin'
2
- export * from './TemporaryAssembliesMixin'
@@ -1,56 +0,0 @@
1
- import TimeTraveller from '@jbrowse/core/util/TimeTraveller'
2
- import type { BaseRootModel } from '@jbrowse/product-core'
3
- import { autorun } from 'mobx'
4
- import { addDisposer, types } from 'mobx-state-tree'
5
-
6
- /**
7
- * #stateModel HistoryManagementMixin
8
- * #category root
9
- */
10
- export function HistoryManagementMixin() {
11
- return types
12
- .model({
13
- /**
14
- * #property
15
- * used for undo/redo
16
- */
17
- history: types.optional(TimeTraveller, { targetPath: '../session' }),
18
- })
19
- .actions(self => ({
20
- afterCreate() {
21
- document.addEventListener('keydown', e => {
22
- if (
23
- self.history.canRedo &&
24
- // ctrl+shift+z or cmd+shift+z
25
- (((e.ctrlKey || e.metaKey) && e.shiftKey && e.code === 'KeyZ') ||
26
- // ctrl+y
27
- (e.ctrlKey && !e.shiftKey && e.code === 'KeyY'))
28
- ) {
29
- self.history.redo()
30
- }
31
- if (
32
- self.history.canUndo &&
33
- // ctrl+z or cmd+z
34
- (e.ctrlKey || e.metaKey) &&
35
- !e.shiftKey &&
36
- e.code === 'KeyZ'
37
- ) {
38
- self.history.undo()
39
- }
40
- })
41
- addDisposer(
42
- self,
43
- autorun(() => {
44
- const { session } = self as typeof self & BaseRootModel
45
- if (session) {
46
- // we use a specific initialization routine after session is
47
- // created to get it to start tracking itself sort of related
48
- // issue here
49
- // https://github.com/mobxjs/mobx-state-tree/issues/1089#issuecomment-441207911
50
- self.history.initialize()
51
- }
52
- }),
53
- )
54
- },
55
- }))
56
- }
@@ -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'