@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.
- package/LICENSE +201 -0
- package/dist/Assemblies/SessionAssembliesMixin.d.ts +72 -0
- package/dist/Assemblies/SessionAssembliesMixin.js +44 -0
- package/dist/Assemblies/TemporaryAssembliesMixin.d.ts +22 -0
- package/dist/Assemblies/TemporaryAssembliesMixin.js +45 -0
- package/dist/Assemblies/index.d.ts +2 -0
- package/dist/Assemblies/index.js +18 -0
- package/dist/HistoryManagement/index.d.ts +30 -0
- package/dist/HistoryManagement/index.js +54 -0
- package/dist/JBrowseConfig/index.d.ts +158 -0
- package/dist/JBrowseConfig/index.js +155 -0
- package/dist/JBrowseModel/index.d.ts +144 -0
- package/dist/JBrowseModel/index.js +132 -0
- package/dist/RootMenu/index.d.ts +68 -0
- package/dist/RootMenu/index.js +142 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +22 -0
- package/dist/ui/App/App.d.ts +19 -0
- package/dist/ui/App/App.js +95 -0
- package/dist/ui/App/AppFab.d.ts +6 -0
- package/dist/ui/App/AppFab.js +32 -0
- package/dist/ui/App/AppToolbar.d.ts +19 -0
- package/dist/ui/App/AppToolbar.js +54 -0
- package/dist/ui/App/DialogQueue.d.ts +6 -0
- package/dist/ui/App/DialogQueue.js +32 -0
- package/dist/ui/App/Drawer.d.ts +8 -0
- package/dist/ui/App/Drawer.js +34 -0
- package/dist/ui/App/DrawerWidget.d.ts +6 -0
- package/dist/ui/App/DrawerWidget.js +132 -0
- package/dist/ui/App/ViewContainer.d.ts +9 -0
- package/dist/ui/App/ViewContainer.js +76 -0
- package/dist/ui/App/ViewContainerTitle.d.ts +6 -0
- package/dist/ui/App/ViewContainerTitle.js +42 -0
- package/dist/ui/App/ViewLauncher.d.ts +18 -0
- package/dist/ui/App/ViewLauncher.js +50 -0
- package/dist/ui/App/ViewMenu.d.ts +9 -0
- package/dist/ui/App/ViewMenu.js +38 -0
- package/dist/ui/App/ViewPanel.d.ts +19 -0
- package/dist/ui/App/ViewPanel.js +50 -0
- package/dist/ui/App/index.d.ts +1 -0
- package/dist/ui/App/index.js +17 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +17 -0
- package/esm/Assemblies/SessionAssembliesMixin.d.ts +72 -0
- package/esm/Assemblies/SessionAssembliesMixin.js +40 -0
- package/esm/Assemblies/TemporaryAssembliesMixin.d.ts +22 -0
- package/esm/Assemblies/TemporaryAssembliesMixin.js +41 -0
- package/esm/Assemblies/index.d.ts +2 -0
- package/esm/Assemblies/index.js +2 -0
- package/esm/HistoryManagement/index.d.ts +30 -0
- package/esm/HistoryManagement/index.js +47 -0
- package/esm/JBrowseConfig/index.d.ts +158 -0
- package/esm/JBrowseConfig/index.js +148 -0
- package/esm/JBrowseModel/index.d.ts +144 -0
- package/esm/JBrowseModel/index.js +128 -0
- package/esm/RootMenu/index.d.ts +68 -0
- package/esm/RootMenu/index.js +138 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +6 -0
- package/esm/ui/App/App.d.ts +19 -0
- package/esm/ui/App/App.js +66 -0
- package/esm/ui/App/AppFab.d.ts +6 -0
- package/esm/ui/App/AppFab.js +27 -0
- package/esm/ui/App/AppToolbar.d.ts +19 -0
- package/esm/ui/App/AppToolbar.js +49 -0
- package/esm/ui/App/DialogQueue.d.ts +6 -0
- package/esm/ui/App/DialogQueue.js +7 -0
- package/esm/ui/App/Drawer.d.ts +8 -0
- package/esm/ui/App/Drawer.js +29 -0
- package/esm/ui/App/DrawerWidget.d.ts +6 -0
- package/esm/ui/App/DrawerWidget.js +104 -0
- package/esm/ui/App/ViewContainer.d.ts +9 -0
- package/esm/ui/App/ViewContainer.js +48 -0
- package/esm/ui/App/ViewContainerTitle.d.ts +6 -0
- package/esm/ui/App/ViewContainerTitle.js +37 -0
- package/esm/ui/App/ViewLauncher.d.ts +18 -0
- package/esm/ui/App/ViewLauncher.js +25 -0
- package/esm/ui/App/ViewMenu.d.ts +9 -0
- package/esm/ui/App/ViewMenu.js +33 -0
- package/esm/ui/App/ViewPanel.d.ts +19 -0
- package/esm/ui/App/ViewPanel.js +22 -0
- package/esm/ui/App/index.d.ts +1 -0
- package/esm/ui/App/index.js +1 -0
- package/esm/ui/index.d.ts +1 -0
- package/esm/ui/index.js +1 -0
- package/package.json +66 -0
- package/src/Assemblies/SessionAssembliesMixin.ts +50 -0
- package/src/Assemblies/TemporaryAssembliesMixin.ts +51 -0
- package/src/Assemblies/index.ts +2 -0
- package/src/HistoryManagement/index.ts +56 -0
- package/src/JBrowseConfig/index.ts +173 -0
- package/src/JBrowseModel/index.ts +150 -0
- package/src/RootMenu/index.ts +157 -0
- package/src/index.ts +6 -0
- package/src/ui/App/App.tsx +117 -0
- package/src/ui/App/AppFab.tsx +45 -0
- package/src/ui/App/AppToolbar.tsx +89 -0
- package/src/ui/App/DialogQueue.tsx +22 -0
- package/src/ui/App/Drawer.tsx +56 -0
- package/src/ui/App/DrawerWidget.tsx +238 -0
- package/src/ui/App/ViewContainer.tsx +76 -0
- package/src/ui/App/ViewContainerTitle.tsx +55 -0
- package/src/ui/App/ViewLauncher.tsx +64 -0
- package/src/ui/App/ViewMenu.tsx +54 -0
- package/src/ui/App/ViewPanel.tsx +63 -0
- package/src/ui/App/index.ts +1 -0
- package/src/ui/index.ts +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jbrowse/app-core",
|
|
3
|
+
"version": "2.6.1",
|
|
4
|
+
"description": "JBrowse 2 code shared between the 'full featured' apps e.g. jbrowse-web and jbrowse-desktop",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"jbrowse",
|
|
7
|
+
"jbrowse2",
|
|
8
|
+
"bionode",
|
|
9
|
+
"biojs",
|
|
10
|
+
"genomics"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"homepage": "https://jbrowse.org",
|
|
14
|
+
"bugs": "https://github.com/GMOD/jbrowse-components/issues",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/GMOD/jbrowse-components.git",
|
|
18
|
+
"directory": "packages/app-core"
|
|
19
|
+
},
|
|
20
|
+
"author": "JBrowse Team",
|
|
21
|
+
"distMain": "dist/index.js",
|
|
22
|
+
"distModule": "esm/index.js",
|
|
23
|
+
"srcMain": "src/index.ts",
|
|
24
|
+
"srcModule": "src/index.ts",
|
|
25
|
+
"main": "dist/index.js",
|
|
26
|
+
"module": "esm/index.js",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"esm",
|
|
30
|
+
"src"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"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",
|
|
36
|
+
"test": "cd ../..; jest packages/app-core",
|
|
37
|
+
"clean": "rimraf dist esm *.tsbuildinfo",
|
|
38
|
+
"prebuild": "yarn clean",
|
|
39
|
+
"prepack": "yarn build && yarn useDist",
|
|
40
|
+
"postpack": "yarn useSrc",
|
|
41
|
+
"useDist": "node ../../scripts/useDist.js",
|
|
42
|
+
"useSrc": "node ../../scripts/useSrc.js"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@babel/runtime": "^7.16.3",
|
|
46
|
+
"@jbrowse/product-core": "^2.6.1",
|
|
47
|
+
"@mui/icons-material": "^5.0.0",
|
|
48
|
+
"@mui/material": "^5.10.17",
|
|
49
|
+
"copy-to-clipboard": "^3.3.1",
|
|
50
|
+
"react-error-boundary": "^4.0.3",
|
|
51
|
+
"shortid": "^2.2.15"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"mobx": "^6.0.0",
|
|
55
|
+
"mobx-react": "^7.0.0",
|
|
56
|
+
"mobx-state-tree": "^5.0.0",
|
|
57
|
+
"react": "^17.0.0",
|
|
58
|
+
"react-dom": "^17.0.0",
|
|
59
|
+
"rxjs": "^7.0.0",
|
|
60
|
+
"tss-react": "^4.0.0"
|
|
61
|
+
},
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"gitHead": "1cbe7ba097fb2d2763c776e5e429e4670cdd583c"
|
|
66
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
}
|