@jbrowse/product-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 (43) hide show
  1. package/dist/RootModel/FormatAbout.d.ts +22 -0
  2. package/dist/RootModel/FormatAbout.js +29 -0
  3. package/dist/RootModel/FormatDetails.d.ts +32 -0
  4. package/dist/RootModel/FormatDetails.js +39 -0
  5. package/dist/RootModel/HierarchicalConfig.d.ts +45 -0
  6. package/dist/RootModel/HierarchicalConfig.js +52 -0
  7. package/dist/RootModel/index.d.ts +3 -0
  8. package/dist/RootModel/index.js +3 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +1 -0
  11. package/dist/rpcWorker.d.ts +6 -0
  12. package/dist/rpcWorker.js +74 -0
  13. package/esm/RootModel/FormatAbout.d.ts +22 -0
  14. package/esm/RootModel/FormatAbout.js +25 -0
  15. package/esm/RootModel/FormatDetails.d.ts +32 -0
  16. package/esm/RootModel/FormatDetails.js +35 -0
  17. package/esm/RootModel/HierarchicalConfig.d.ts +45 -0
  18. package/esm/RootModel/HierarchicalConfig.js +48 -0
  19. package/esm/RootModel/index.d.ts +3 -0
  20. package/esm/RootModel/index.js +3 -0
  21. package/esm/index.d.ts +1 -0
  22. package/esm/index.js +1 -0
  23. package/esm/rpcWorker.d.ts +6 -0
  24. package/esm/rpcWorker.js +67 -0
  25. package/package.json +7 -6
  26. package/src/RootModel/BaseRootModel.ts +0 -131
  27. package/src/RootModel/InternetAccounts.ts +0 -126
  28. package/src/RootModel/index.ts +0 -2
  29. package/src/Session/BaseSession.ts +0 -129
  30. package/src/Session/Connections.ts +0 -145
  31. package/src/Session/DialogQueue.ts +0 -63
  32. package/src/Session/DrawerWidgets.ts +0 -222
  33. package/src/Session/MultipleViews.ts +0 -151
  34. package/src/Session/ReferenceManagement.ts +0 -134
  35. package/src/Session/SessionTracks.ts +0 -98
  36. package/src/Session/Themes.ts +0 -85
  37. package/src/Session/Tracks.ts +0 -72
  38. package/src/Session/index.ts +0 -10
  39. package/src/index.ts +0 -3
  40. package/src/ui/AboutDialog.tsx +0 -31
  41. package/src/ui/AboutDialogContents.tsx +0 -88
  42. package/src/ui/FileInfoPanel.tsx +0 -75
  43. package/src/ui/index.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/product-core",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "sideEffects": false,
5
5
  "description": "JBrowse 2 code shared between products but not used by plugins",
6
6
  "keywords": [
@@ -27,13 +27,12 @@
27
27
  "module": "esm/index.js",
28
28
  "files": [
29
29
  "dist",
30
- "esm",
31
- "src"
30
+ "esm"
32
31
  ],
33
32
  "scripts": {
34
33
  "build:esm": "tsc --build tsconfig.build.esm.json",
35
- "build:es5": "tsc --build tsconfig.build.es5.json",
36
- "build": "npm run build:esm && npm run build:es5",
34
+ "build:commonjs": "tsc --build tsconfig.build.commonjs.json",
35
+ "build": "npm run build:esm && npm run build:commonjs",
37
36
  "test": "cd ../..; jest packages/product-core",
38
37
  "clean": "rimraf dist esm *.tsbuildinfo",
39
38
  "prebuild": "yarn clean",
@@ -47,7 +46,9 @@
47
46
  "@mui/icons-material": "^5.0.0",
48
47
  "@mui/material": "^5.10.17",
49
48
  "copy-to-clipboard": "^3.3.1",
49
+ "librpc-web-mod": "^1.0.0",
50
50
  "react-error-boundary": "^4.0.3",
51
+ "serialize-error": "^8.0.0",
51
52
  "shortid": "^2.2.15"
52
53
  },
53
54
  "peerDependencies": {
@@ -62,5 +63,5 @@
62
63
  "publishConfig": {
63
64
  "access": "public"
64
65
  },
65
- "gitHead": "1cbe7ba097fb2d2763c776e5e429e4670cdd583c"
66
+ "gitHead": "ed402c87efb0904858d602c363bd1757d5742129"
66
67
  }
@@ -1,131 +0,0 @@
1
- import PluginManager from '@jbrowse/core/PluginManager'
2
- import assemblyManagerFactory, {
3
- BaseAssemblyConfigSchema,
4
- } from '@jbrowse/core/assemblyManager'
5
- import RpcManager from '@jbrowse/core/rpc/RpcManager'
6
- import {
7
- IAnyType,
8
- Instance,
9
- SnapshotIn,
10
- cast,
11
- getSnapshot,
12
- isStateTreeNode,
13
- types,
14
- } from 'mobx-state-tree'
15
- import TextSearchManager from '@jbrowse/core/TextSearch/TextSearchManager'
16
-
17
- /**
18
- * #stateModel BaseRootModel
19
- * #category root
20
- * factory function for the Base-level root model shared by all products
21
- */
22
- export function BaseRootModelFactory({
23
- pluginManager,
24
- jbrowseModelType,
25
- sessionModelType,
26
- assemblyConfigSchema,
27
- }: {
28
- pluginManager: PluginManager
29
- jbrowseModelType: IAnyType
30
- sessionModelType: IAnyType
31
- assemblyConfigSchema: BaseAssemblyConfigSchema
32
- }) {
33
- return types
34
- .model('BaseRootModel', {
35
- /**
36
- * #property
37
- * `jbrowse` is a mapping of the config.json into the in-memory state
38
- * tree
39
- */
40
- jbrowse: jbrowseModelType,
41
-
42
- /**
43
- * #property
44
- * `session` encompasses the currently active state of the app, including
45
- * views open, tracks open in those views, etc.
46
- */
47
- session: types.maybe(sessionModelType),
48
- /**
49
- * #property
50
- */
51
- sessionPath: types.optional(types.string, ''),
52
-
53
- /**
54
- * #property
55
- */
56
- assemblyManager: types.optional(
57
- assemblyManagerFactory(assemblyConfigSchema, pluginManager),
58
- {},
59
- ),
60
- })
61
- .volatile(self => ({
62
- rpcManager: new RpcManager(
63
- pluginManager,
64
- self.jbrowse.configuration.rpc,
65
- {
66
- MainThreadRpcDriver: {},
67
- },
68
- ),
69
-
70
- adminMode: false,
71
- isAssemblyEditing: false,
72
- error: undefined as unknown,
73
- textSearchManager: new TextSearchManager(pluginManager),
74
- pluginManager,
75
- }))
76
- .actions(self => ({
77
- /**
78
- * #action
79
- */
80
- setError(error: unknown) {
81
- self.error = error
82
- },
83
- /**
84
- * #action
85
- */
86
- setSession(sessionSnapshot?: SnapshotIn<IAnyType>) {
87
- self.session = cast(sessionSnapshot)
88
- },
89
- /**
90
- * #action
91
- */
92
- setDefaultSession() {
93
- this.setSession(self.jbrowse.defaultSession)
94
- },
95
- /**
96
- * #action
97
- */
98
- setSessionPath(path: string) {
99
- self.sessionPath = path
100
- },
101
- /**
102
- * #action
103
- */
104
- renameCurrentSession(newName: string) {
105
- if (self.session) {
106
- const snapshot = JSON.parse(JSON.stringify(getSnapshot(self.session)))
107
- snapshot.name = newName
108
- this.setSession(snapshot)
109
- }
110
- },
111
- /**
112
- * #action
113
- */
114
- setAssemblyEditing(flag: boolean) {
115
- self.isAssemblyEditing = flag
116
- },
117
- }))
118
- }
119
-
120
- export type BaseRootModelType = ReturnType<typeof BaseRootModelFactory>
121
- export type BaseRootModel = Instance<BaseRootModelType>
122
-
123
- /** Type guard for checking if something is a JB root model */
124
- export function isRootModel(thing: unknown): thing is BaseRootModelType {
125
- return (
126
- isStateTreeNode(thing) &&
127
- 'session' in thing &&
128
- 'jbrowse' in thing &&
129
- 'assemblyManager' in thing
130
- )
131
- }
@@ -1,126 +0,0 @@
1
- import PluginManager from '@jbrowse/core/PluginManager'
2
- import { AnyConfigurationModel } from '@jbrowse/core/configuration'
3
- import { UriLocation } from '@jbrowse/core/util'
4
- import { autorun } from 'mobx'
5
- import { Instance, addDisposer, types } from 'mobx-state-tree'
6
- import { BaseRootModel } from './BaseRootModel'
7
-
8
- /**
9
- * #stateModel InternetAccountsMixin
10
- * #category root
11
- */
12
- export function InternetAccountsRootModelMixin(pluginManager: PluginManager) {
13
- return types
14
- .model({
15
- /**
16
- * #property
17
- */
18
- internetAccounts: types.array(
19
- pluginManager.pluggableMstType('internet account', 'stateModel'),
20
- ),
21
- })
22
- .actions(self => ({
23
- /**
24
- * #action
25
- */
26
- initializeInternetAccount(
27
- internetAccountConfig: AnyConfigurationModel,
28
- initialSnapshot = {},
29
- ) {
30
- const internetAccountType = pluginManager.getInternetAccountType(
31
- internetAccountConfig.type,
32
- )
33
- if (!internetAccountType) {
34
- throw new Error(
35
- `unknown internet account type ${internetAccountConfig.type}`,
36
- )
37
- }
38
-
39
- const length = self.internetAccounts.push({
40
- ...initialSnapshot,
41
- type: internetAccountConfig.type,
42
- configuration: internetAccountConfig,
43
- })
44
- return self.internetAccounts[length - 1]
45
- },
46
-
47
- /**
48
- * #action
49
- */
50
- createEphemeralInternetAccount(
51
- internetAccountId: string,
52
- initialSnapshot = {},
53
- url: string,
54
- ) {
55
- let hostUri
56
-
57
- try {
58
- hostUri = new URL(url).origin
59
- } catch (e) {
60
- // ignore
61
- }
62
- // id of a custom new internaccount is `${type}-${name}`
63
- const internetAccountSplit = internetAccountId.split('-')
64
- const configuration = {
65
- type: internetAccountSplit[0],
66
- internetAccountId: internetAccountId,
67
- name: internetAccountSplit.slice(1).join('-'),
68
- description: '',
69
- domains: hostUri ? [hostUri] : [],
70
- }
71
- const type = pluginManager.getInternetAccountType(configuration.type)
72
- const internetAccount = type.stateModel.create({
73
- ...initialSnapshot,
74
- type: configuration.type,
75
- configuration,
76
- })
77
- self.internetAccounts.push(internetAccount)
78
- return internetAccount
79
- },
80
- /**
81
- * #action
82
- */
83
- findAppropriateInternetAccount(location: UriLocation) {
84
- // find the existing account selected from menu
85
- const selectedId = location.internetAccountId
86
- if (selectedId) {
87
- const selectedAccount = self.internetAccounts.find(account => {
88
- return account.internetAccountId === selectedId
89
- })
90
- if (selectedAccount) {
91
- return selectedAccount
92
- }
93
- }
94
-
95
- // if no existing account or not found, try to find working account
96
- for (const account of self.internetAccounts) {
97
- const handleResult = account.handlesLocation(location)
98
- if (handleResult) {
99
- return account
100
- }
101
- }
102
-
103
- // if still no existing account, create ephemeral config to use
104
- return selectedId
105
- ? this.createEphemeralInternetAccount(selectedId, {}, location.uri)
106
- : null
107
- },
108
- }))
109
- .actions(self => ({
110
- afterCreate() {
111
- addDisposer(
112
- self,
113
- autorun(() => {
114
- const { jbrowse } = self as typeof self & BaseRootModel
115
- jbrowse.internetAccounts.forEach(self.initializeInternetAccount)
116
- }),
117
- )
118
- },
119
- }))
120
- }
121
-
122
- export type RootModelWithInternetAccountsType = ReturnType<
123
- typeof InternetAccountsRootModelMixin
124
- >
125
- export type RootModelWithInternetAccounts =
126
- Instance<RootModelWithInternetAccountsType>
@@ -1,2 +0,0 @@
1
- export * from './BaseRootModel'
2
- export * from './InternetAccounts'
@@ -1,129 +0,0 @@
1
- import shortid from 'shortid'
2
- import PluginManager from '@jbrowse/core/PluginManager'
3
- import {
4
- IAnyStateTreeNode,
5
- Instance,
6
- getParent,
7
- isStateTreeNode,
8
- types,
9
- } from 'mobx-state-tree'
10
- import { AnyConfigurationSchemaType } from '@jbrowse/core/configuration'
11
- import { BaseAssemblyConfigSchema } from '@jbrowse/core/assemblyManager'
12
-
13
- // locals
14
- import type { BaseRootModelType } from '../RootModel/BaseRootModel'
15
-
16
- /**
17
- * #stateModel BaseSessionModel
18
- * base session shared by **all** JBrowse products. Be careful what you include
19
- * here, everything will use it.
20
- */
21
- export function BaseSessionModel<
22
- ROOT_MODEL_TYPE extends BaseRootModelType,
23
- JB_CONFIG_SCHEMA extends AnyConfigurationSchemaType,
24
- >(pluginManager: PluginManager) {
25
- return types
26
- .model({
27
- /**
28
- * #property
29
- */
30
- id: types.optional(types.identifier, shortid()),
31
- /**
32
- * #property
33
- */
34
- name: types.string,
35
- /**
36
- * #property
37
- */
38
- margin: 0,
39
- })
40
- .volatile(() => ({
41
- /**
42
- * #volatile
43
- * this is the globally "selected" object. can be anything. code that
44
- * wants to deal with this should examine it to see what kind of thing it
45
- * is.
46
- */
47
- selection: undefined as unknown,
48
- }))
49
- .views(self => ({
50
- get root() {
51
- return getParent<ROOT_MODEL_TYPE>(self)
52
- },
53
- }))
54
- .views(self => ({
55
- /**
56
- * #getter
57
- */
58
- get jbrowse() {
59
- return self.root.jbrowse
60
- },
61
- /**
62
- * #getter
63
- */
64
- get rpcManager() {
65
- return self.root.rpcManager
66
- },
67
- /**
68
- * #getter
69
- */
70
- get configuration(): Instance<JB_CONFIG_SCHEMA> {
71
- return this.jbrowse.configuration
72
- },
73
- /**
74
- * #getter
75
- */
76
- get adminMode() {
77
- return self.root.adminMode
78
- },
79
-
80
- /**
81
- * #getter
82
- */
83
- get textSearchManager() {
84
- return self.root.textSearchManager
85
- },
86
- }))
87
- .views(self => ({
88
- /**
89
- * #getter
90
- */
91
- get assemblies(): Instance<BaseAssemblyConfigSchema>[] {
92
- return self.jbrowse.assemblies
93
- },
94
- }))
95
- .actions(self => ({
96
- /**
97
- * #action
98
- * set the global selection, i.e. the globally-selected object. can be a
99
- * feature, a view, just about anything
100
- */
101
- setSelection(thing: unknown) {
102
- self.selection = thing
103
- },
104
-
105
- /**
106
- * #action
107
- * clears the global selection
108
- */
109
- clearSelection() {
110
- self.selection = undefined
111
- },
112
- }))
113
- }
114
-
115
- /** Session mixin MST type for the most basic session */
116
- export type BaseSessionType = ReturnType<typeof BaseSessionModel>
117
-
118
- /** Instance of the most basic possible session */
119
- export type BaseSession = Instance<BaseSessionType>
120
-
121
- /** Type guard for BaseSession */
122
- export function isBaseSession(thing: IAnyStateTreeNode): thing is BaseSession {
123
- return 'id' in thing && 'name' in thing && 'root' in thing
124
- }
125
-
126
- /** Type guard for whether a thing is JBrowse session */
127
- export function isSession(thing: unknown): thing is BaseSession {
128
- return isStateTreeNode(thing) && isBaseSession(thing)
129
- }
@@ -1,145 +0,0 @@
1
- import PluginManager from '@jbrowse/core/PluginManager'
2
- import {
3
- AnyConfigurationModel,
4
- readConfObject,
5
- } from '@jbrowse/core/configuration'
6
- import { IAnyStateTreeNode, Instance, types } from 'mobx-state-tree'
7
- import { BaseConnectionConfigModel } from '@jbrowse/core/pluggableElementTypes/models/baseConnectionConfig'
8
- import { BaseConnectionModel } from '@jbrowse/core/pluggableElementTypes/models/BaseConnectionModelFactory'
9
-
10
- // locals
11
- import type { BaseRootModelType } from '../RootModel/BaseRootModel'
12
- import type { SessionWithReferenceManagementType } from './ReferenceManagement'
13
- import { isBaseSession } from './BaseSession'
14
-
15
- /**
16
- * #stateModel ConnectionManagementSessionMixin
17
- */
18
- export function ConnectionManagementSessionMixin(pluginManager: PluginManager) {
19
- return types
20
- .model({
21
- /**
22
- * #property
23
- */
24
- connectionInstances: types.array(
25
- pluginManager.pluggableMstType(
26
- 'connection',
27
- 'stateModel',
28
- ) as BaseConnectionModel,
29
- ),
30
- })
31
- .views(self => ({
32
- /**
33
- * #getter
34
- */
35
- get connections(): BaseConnectionConfigModel[] {
36
- const { jbrowse } = self as typeof self & Instance<BaseRootModelType>
37
- return jbrowse.connections
38
- },
39
- }))
40
- .actions(self => ({
41
- /**
42
- * #action
43
- */
44
- makeConnection(
45
- configuration: AnyConfigurationModel,
46
- initialSnapshot = {},
47
- ) {
48
- const type = configuration.type as string
49
- if (!type) {
50
- throw new Error('track configuration has no `type` listed')
51
- }
52
- const name = readConfObject(configuration, 'name')
53
- const connectionType = pluginManager.getConnectionType(type)
54
- if (!connectionType) {
55
- throw new Error(`unknown connection type ${type}`)
56
- }
57
- const length = self.connectionInstances.push({
58
- ...initialSnapshot,
59
- name,
60
- // @ts-expect-error unsure why ts doesn't like `type` here, but is
61
- // needed
62
- type,
63
- configuration,
64
- })
65
- return self.connectionInstances[length - 1]
66
- },
67
-
68
- /**
69
- * #action
70
- */
71
- prepareToBreakConnection(configuration: AnyConfigurationModel) {
72
- const root = self as typeof self &
73
- Instance<SessionWithReferenceManagementType>
74
- const callbacksToDeref: Function[] = []
75
- const derefTypeCount: Record<string, number> = {}
76
- const name = readConfObject(configuration, 'name')
77
- const connection = self.connectionInstances.find(c => c.name === name)
78
- if (!connection) {
79
- return undefined
80
- }
81
- for (const track of connection.tracks) {
82
- const ref = root.getReferring(track)
83
- root.removeReferring(ref, track, callbacksToDeref, derefTypeCount)
84
- }
85
- return [
86
- () => {
87
- callbacksToDeref.forEach(cb => cb())
88
- this.breakConnection(configuration)
89
- },
90
- derefTypeCount,
91
- ]
92
- },
93
-
94
- /**
95
- * #action
96
- */
97
- breakConnection(configuration: AnyConfigurationModel) {
98
- const name = readConfObject(configuration, 'name')
99
- const connection = self.connectionInstances.find(c => c.name === name)
100
- if (!connection) {
101
- throw new Error(`no connection found with name ${name}`)
102
- }
103
- self.connectionInstances.remove(connection)
104
- },
105
-
106
- /**
107
- * #action
108
- */
109
- deleteConnection(configuration: AnyConfigurationModel) {
110
- const { jbrowse } = self as typeof self & Instance<BaseRootModelType>
111
- return jbrowse.deleteConnectionConf(configuration)
112
- },
113
-
114
- /**
115
- * #action
116
- */
117
- addConnectionConf(connectionConf: BaseConnectionConfigModel) {
118
- const { jbrowse } = self as typeof self & Instance<BaseRootModelType>
119
- return jbrowse.addConnectionConf(connectionConf)
120
- },
121
-
122
- /**
123
- * #action
124
- */
125
- clearConnections() {
126
- self.connectionInstances.clear()
127
- },
128
- }))
129
- }
130
-
131
- /** Session mixin MST type for a session that has connections */
132
- export type SessionWithConnectionsType = ReturnType<
133
- typeof ConnectionManagementSessionMixin
134
- >
135
-
136
- /** Instance of a session that has connections: `connectionInstances`,
137
- * `makeConnection()`, etc. */
138
- export type SessionWithConnections = Instance<SessionWithConnectionsType>
139
-
140
- /** Type guard for SessionWithConnections */
141
- export function isSessionWithConnections(
142
- session: IAnyStateTreeNode,
143
- ): session is SessionWithConnections {
144
- return isBaseSession(session) && 'connectionInstances' in session
145
- }
@@ -1,63 +0,0 @@
1
- /** MST mixin for managing a queue of dialogs at the level of the session */
2
-
3
- import PluginManager from '@jbrowse/core/PluginManager'
4
- import { DialogComponentType } from '@jbrowse/core/util'
5
- import { IAnyStateTreeNode, Instance, types } from 'mobx-state-tree'
6
- import { isBaseSession } from './BaseSession'
7
-
8
- /**
9
- * #stateModel DialogQueueSessionMixin
10
- */
11
- export function DialogQueueSessionMixin(pluginManager: PluginManager) {
12
- return types
13
- .model('DialogQueueSessionMixin', {})
14
- .volatile(() => ({
15
- queueOfDialogs: [] as [DialogComponentType, unknown][],
16
- }))
17
- .views(self => ({
18
- /**
19
- * #getter
20
- */
21
- get DialogComponent() {
22
- return self.queueOfDialogs[0]?.[0]
23
- },
24
- /**
25
- * #getter
26
- */
27
- get DialogProps() {
28
- return self.queueOfDialogs[0]?.[1]
29
- },
30
- }))
31
- .actions(self => ({
32
- /**
33
- * #action
34
- */
35
- removeActiveDialog() {
36
- self.queueOfDialogs = self.queueOfDialogs.slice(1)
37
- },
38
- /**
39
- * #action
40
- */
41
- queueDialog(
42
- cb: (doneCallback: () => void) => [DialogComponentType, unknown],
43
- ) {
44
- const [component, props] = cb(() => {
45
- this.removeActiveDialog()
46
- })
47
- self.queueOfDialogs = [...self.queueOfDialogs, [component, props]]
48
- },
49
- }))
50
- }
51
-
52
- /** Session mixin MST type for a session that has `queueOfDialogs`, etc. */
53
- export type SessionWithDialogsType = ReturnType<typeof DialogQueueSessionMixin>
54
-
55
- /** Instance of a session that has dialogs */
56
- export type SessionWithDialogs = Instance<SessionWithDialogsType>
57
-
58
- /** Type guard for SessionWithDialogs */
59
- export function isSessionWithDialogs(
60
- session: IAnyStateTreeNode,
61
- ): session is SessionWithDialogs {
62
- return isBaseSession(session) && 'queueOfDialogs' in session
63
- }