@apollo-annotation/jbrowse-plugin-apollo 0.3.12 → 1.0.0

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 (192) hide show
  1. package/dist/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.d.ts +1 -1
  2. package/dist/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.d.ts.map +1 -1
  3. package/dist/BackendDrivers/BackendDriver.d.ts +29 -4
  4. package/dist/BackendDrivers/BackendDriver.d.ts.map +1 -1
  5. package/dist/BackendDrivers/CollaborationServerDriver.d.ts +3 -1
  6. package/dist/BackendDrivers/CollaborationServerDriver.d.ts.map +1 -1
  7. package/dist/BackendDrivers/LocalDriver/LocalDriver.d.ts +22 -0
  8. package/dist/BackendDrivers/LocalDriver/LocalDriver.d.ts.map +1 -0
  9. package/dist/BackendDrivers/LocalDriver/db.d.ts +4 -0
  10. package/dist/BackendDrivers/LocalDriver/db.d.ts.map +1 -0
  11. package/dist/BackendDrivers/index.d.ts +1 -2
  12. package/dist/BackendDrivers/index.d.ts.map +1 -1
  13. package/dist/ChangeManager.d.ts +3 -3
  14. package/dist/ChangeManager.d.ts.map +1 -1
  15. package/dist/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.d.ts +0 -6
  16. package/dist/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.d.ts.map +1 -1
  17. package/dist/FeatureDetailsWidget/TranscriptWidgetEditLocation.d.ts.map +1 -1
  18. package/dist/FeatureDetailsWidget/model.d.ts +0 -2
  19. package/dist/FeatureDetailsWidget/model.d.ts.map +1 -1
  20. package/dist/LinearApolloDisplay/components/CheckResultWarnings.d.ts.map +1 -1
  21. package/dist/LinearApolloDisplay/components/LinearApolloDisplay.d.ts.map +1 -1
  22. package/dist/LinearApolloDisplay/components/OverlayCanvas.d.ts +7 -0
  23. package/dist/LinearApolloDisplay/components/OverlayCanvas.d.ts.map +1 -0
  24. package/dist/LinearApolloDisplay/components/Tooltip.d.ts +10 -0
  25. package/dist/LinearApolloDisplay/components/Tooltip.d.ts.map +1 -0
  26. package/dist/LinearApolloDisplay/glyphs/BoxGlyph.d.ts +0 -1
  27. package/dist/LinearApolloDisplay/glyphs/BoxGlyph.d.ts.map +1 -1
  28. package/dist/LinearApolloDisplay/glyphs/CDSGlyph.d.ts +3 -0
  29. package/dist/LinearApolloDisplay/glyphs/CDSGlyph.d.ts.map +1 -0
  30. package/dist/LinearApolloDisplay/glyphs/ExonGlyph.d.ts +3 -0
  31. package/dist/LinearApolloDisplay/glyphs/ExonGlyph.d.ts.map +1 -0
  32. package/dist/LinearApolloDisplay/glyphs/GeneGlyph.d.ts.map +1 -1
  33. package/dist/LinearApolloDisplay/glyphs/GenericChildGlyph.d.ts.map +1 -1
  34. package/dist/LinearApolloDisplay/glyphs/Glyph.d.ts +26 -20
  35. package/dist/LinearApolloDisplay/glyphs/Glyph.d.ts.map +1 -1
  36. package/dist/LinearApolloDisplay/glyphs/TranscriptGlyph.d.ts +3 -0
  37. package/dist/LinearApolloDisplay/glyphs/TranscriptGlyph.d.ts.map +1 -0
  38. package/dist/LinearApolloDisplay/glyphs/util.d.ts +13 -0
  39. package/dist/LinearApolloDisplay/glyphs/util.d.ts.map +1 -1
  40. package/dist/LinearApolloDisplay/stateModel/base.d.ts +17 -0
  41. package/dist/LinearApolloDisplay/stateModel/base.d.ts.map +1 -1
  42. package/dist/LinearApolloDisplay/stateModel/index.d.ts +35 -17
  43. package/dist/LinearApolloDisplay/stateModel/index.d.ts.map +1 -1
  44. package/dist/LinearApolloDisplay/stateModel/layouts.d.ts +29 -7
  45. package/dist/LinearApolloDisplay/stateModel/layouts.d.ts.map +1 -1
  46. package/dist/LinearApolloDisplay/stateModel/mouseEvents.d.ts +69 -23
  47. package/dist/LinearApolloDisplay/stateModel/mouseEvents.d.ts.map +1 -1
  48. package/dist/LinearApolloDisplay/stateModel/rendering.d.ts +26 -9
  49. package/dist/LinearApolloDisplay/stateModel/rendering.d.ts.map +1 -1
  50. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/base.d.ts +6 -0
  51. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/base.d.ts.map +1 -1
  52. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/index.d.ts +6 -0
  53. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/index.d.ts.map +1 -1
  54. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/rendering.d.ts +6 -0
  55. package/dist/LinearApolloReferenceSequenceDisplay/stateModel/rendering.d.ts.map +1 -1
  56. package/dist/LinearApolloSixFrameDisplay/components/LinearApolloSixFrameDisplay.d.ts.map +1 -1
  57. package/dist/LinearApolloSixFrameDisplay/glyphs/GeneGlyph.d.ts.map +1 -1
  58. package/dist/LinearApolloSixFrameDisplay/glyphs/Glyph.d.ts +1 -1
  59. package/dist/LinearApolloSixFrameDisplay/glyphs/Glyph.d.ts.map +1 -1
  60. package/dist/LinearApolloSixFrameDisplay/stateModel/layouts.d.ts.map +1 -1
  61. package/dist/LinearApolloSixFrameDisplay/stateModel/rendering.d.ts.map +1 -1
  62. package/dist/OntologyManager/OntologyStore/fulltext.d.ts +1 -1
  63. package/dist/OntologyManager/OntologyStore/fulltext.d.ts.map +1 -1
  64. package/dist/OntologyManager/OntologyStore/index.d.ts +2 -2
  65. package/dist/OntologyManager/OntologyStore/index.d.ts.map +1 -1
  66. package/dist/OntologyManager/OntologyStore/indexeddb-storage.d.ts +1 -1
  67. package/dist/OntologyManager/OntologyStore/indexeddb-storage.d.ts.map +1 -1
  68. package/dist/OntologyManager/OntologyStore/types.d.ts +18 -0
  69. package/dist/OntologyManager/OntologyStore/types.d.ts.map +1 -0
  70. package/dist/TabularEditor/HybridGrid/featureContextMenuItems.d.ts.map +1 -1
  71. package/dist/components/AddChildFeature.d.ts.map +1 -1
  72. package/dist/components/ColorFeature.d.ts +13 -0
  73. package/dist/components/ColorFeature.d.ts.map +1 -0
  74. package/dist/components/CreateApolloAnnotation.d.ts.map +1 -1
  75. package/dist/components/DownloadGFF3.d.ts +4 -1
  76. package/dist/components/DownloadGFF3.d.ts.map +1 -1
  77. package/dist/components/DuplicateTranscript.d.ts.map +1 -1
  78. package/dist/components/ViewChangeLog.d.ts +2 -1
  79. package/dist/components/ViewChangeLog.d.ts.map +1 -1
  80. package/dist/components/ViewCheckResults.d.ts +2 -1
  81. package/dist/components/ViewCheckResults.d.ts.map +1 -1
  82. package/dist/components/index.d.ts +1 -1
  83. package/dist/components/index.d.ts.map +1 -1
  84. package/dist/config.d.ts +4 -0
  85. package/dist/config.d.ts.map +1 -0
  86. package/dist/extensions/annotationFromJBrowseFeature.d.ts.map +1 -1
  87. package/dist/extensions/annotationFromPileup.d.ts.map +1 -1
  88. package/dist/index.d.ts +11 -0
  89. package/dist/index.d.ts.map +1 -0
  90. package/dist/index.esm.js +6325 -5997
  91. package/dist/index.esm.js.map +1 -1
  92. package/dist/jbrowse-plugin-apollo.cjs.development.js +5869 -5541
  93. package/dist/jbrowse-plugin-apollo.cjs.development.js.map +1 -1
  94. package/dist/jbrowse-plugin-apollo.cjs.production.min.js +1 -1
  95. package/dist/jbrowse-plugin-apollo.cjs.production.min.js.map +1 -1
  96. package/dist/jbrowse-plugin-apollo.umd.development.js +16782 -25897
  97. package/dist/jbrowse-plugin-apollo.umd.development.js.map +1 -1
  98. package/dist/jbrowse-plugin-apollo.umd.production.min.js +1 -1
  99. package/dist/jbrowse-plugin-apollo.umd.production.min.js.map +1 -1
  100. package/dist/makeDisplayComponent.d.ts.map +1 -1
  101. package/dist/menus/Icons.d.ts +3 -0
  102. package/dist/menus/Icons.d.ts.map +1 -0
  103. package/dist/menus/topLevelMenu.d.ts.map +1 -1
  104. package/dist/session/changeHandlers.d.ts +9 -0
  105. package/dist/session/changeHandlers.d.ts.map +1 -0
  106. package/dist/util/annotationFeatureUtils.d.ts +2 -1
  107. package/dist/util/annotationFeatureUtils.d.ts.map +1 -1
  108. package/dist/util/glyphUtils.d.ts +3 -3
  109. package/dist/util/glyphUtils.d.ts.map +1 -1
  110. package/dist/util/index.d.ts +0 -1
  111. package/dist/util/index.d.ts.map +1 -1
  112. package/package.json +4 -4
  113. package/src/ApolloInternetAccount/model.ts +68 -4
  114. package/src/ApolloRefNameAliasAdapter/ApolloRefNameAliasAdapter.ts +6 -3
  115. package/src/ApolloTextSearchAdapter/ApolloTextSearchAdapter.ts +1 -1
  116. package/src/BackendDrivers/BackendDriver.ts +36 -3
  117. package/src/BackendDrivers/CollaborationServerDriver.ts +78 -23
  118. package/src/BackendDrivers/LocalDriver/LocalDriver.ts +367 -0
  119. package/src/BackendDrivers/LocalDriver/db.ts +37 -0
  120. package/src/BackendDrivers/index.ts +1 -2
  121. package/src/ChangeManager.ts +27 -25
  122. package/src/FeatureDetailsWidget/ApolloTranscriptDetailsWidget.tsx +1 -1
  123. package/src/FeatureDetailsWidget/TranscriptWidgetEditLocation.tsx +69 -53
  124. package/src/LinearApolloDisplay/components/CheckResultWarnings.tsx +1 -5
  125. package/src/LinearApolloDisplay/components/LinearApolloDisplay.tsx +95 -115
  126. package/src/LinearApolloDisplay/components/OverlayCanvas.tsx +76 -0
  127. package/src/LinearApolloDisplay/components/Tooltip.tsx +42 -0
  128. package/src/LinearApolloDisplay/glyphs/BoxGlyph.ts +60 -302
  129. package/src/LinearApolloDisplay/glyphs/CDSGlyph.ts +145 -0
  130. package/src/LinearApolloDisplay/glyphs/ExonGlyph.ts +212 -0
  131. package/src/LinearApolloDisplay/glyphs/GeneGlyph.ts +65 -999
  132. package/src/LinearApolloDisplay/glyphs/GenericChildGlyph.ts +71 -181
  133. package/src/LinearApolloDisplay/glyphs/Glyph.ts +42 -66
  134. package/src/LinearApolloDisplay/glyphs/TranscriptGlyph.ts +291 -0
  135. package/src/LinearApolloDisplay/glyphs/util.ts +87 -0
  136. package/src/LinearApolloDisplay/stateModel/base.ts +83 -0
  137. package/src/LinearApolloDisplay/stateModel/layouts.ts +198 -138
  138. package/src/LinearApolloDisplay/stateModel/mouseEvents.ts +252 -158
  139. package/src/LinearApolloDisplay/stateModel/rendering.ts +103 -21
  140. package/src/LinearApolloReferenceSequenceDisplay/drawSequenceOverlay.ts +3 -3
  141. package/src/LinearApolloReferenceSequenceDisplay/stateModel/base.ts +20 -2
  142. package/src/LinearApolloSixFrameDisplay/components/LinearApolloSixFrameDisplay.tsx +7 -2
  143. package/src/LinearApolloSixFrameDisplay/glyphs/GeneGlyph.ts +8 -13
  144. package/src/LinearApolloSixFrameDisplay/glyphs/Glyph.ts +1 -1
  145. package/src/LinearApolloSixFrameDisplay/stateModel/layouts.ts +4 -3
  146. package/src/LinearApolloSixFrameDisplay/stateModel/mouseEvents.ts +1 -1
  147. package/src/LinearApolloSixFrameDisplay/stateModel/rendering.ts +2 -1
  148. package/src/OntologyManager/OntologyStore/__snapshots__/index.test.ts.snap +18262 -8519
  149. package/src/OntologyManager/OntologyStore/fulltext.ts +1 -2
  150. package/src/OntologyManager/OntologyStore/index.test.ts +5 -2
  151. package/src/OntologyManager/OntologyStore/index.ts +7 -8
  152. package/src/OntologyManager/OntologyStore/indexeddb-storage.ts +2 -2
  153. package/src/OntologyManager/OntologyStore/types.ts +27 -0
  154. package/src/OntologyManager/index.ts +15 -26
  155. package/src/TabularEditor/HybridGrid/featureContextMenuItems.ts +4 -5
  156. package/src/components/AddChildFeature.tsx +15 -8
  157. package/src/components/ColorFeature.tsx +167 -0
  158. package/src/components/CreateApolloAnnotation.tsx +35 -9
  159. package/src/components/DownloadGFF3.tsx +92 -121
  160. package/src/components/DuplicateTranscript.tsx +10 -0
  161. package/src/components/ViewChangeLog.tsx +123 -83
  162. package/src/components/ViewCheckResults.tsx +15 -73
  163. package/src/components/index.ts +1 -1
  164. package/src/config.ts +37 -19
  165. package/src/extensions/annotationFromJBrowseFeature.test.ts +1 -1
  166. package/src/extensions/annotationFromJBrowseFeature.ts +91 -63
  167. package/src/extensions/annotationFromPileup.ts +40 -40
  168. package/src/index.ts +45 -1
  169. package/src/makeDisplayComponent.tsx +10 -3
  170. package/src/menus/Icons.tsx +49 -0
  171. package/src/menus/topLevelMenu.ts +24 -96
  172. package/src/session/ClientDataStore.ts +16 -17
  173. package/src/session/changeHandlers.ts +261 -0
  174. package/src/session/session.ts +77 -46
  175. package/src/util/annotationFeatureUtils.ts +29 -1
  176. package/src/util/glyphUtils.ts +74 -31
  177. package/src/util/index.ts +0 -1
  178. package/dist/BackendDrivers/DesktopFileDriver.d.ts +0 -160
  179. package/dist/BackendDrivers/DesktopFileDriver.d.ts.map +0 -1
  180. package/dist/BackendDrivers/InMemoryFileDriver.d.ts +0 -162
  181. package/dist/BackendDrivers/InMemoryFileDriver.d.ts.map +0 -1
  182. package/dist/LinearApolloDisplay/glyphs/index.d.ts +0 -4
  183. package/dist/LinearApolloDisplay/glyphs/index.d.ts.map +0 -1
  184. package/dist/components/OpenLocalFile.d.ts +0 -15
  185. package/dist/components/OpenLocalFile.d.ts.map +0 -1
  186. package/dist/util/loadAssemblyIntoClient.d.ts +0 -5
  187. package/dist/util/loadAssemblyIntoClient.d.ts.map +0 -1
  188. package/src/BackendDrivers/DesktopFileDriver.ts +0 -184
  189. package/src/BackendDrivers/InMemoryFileDriver.ts +0 -107
  190. package/src/LinearApolloDisplay/glyphs/index.ts +0 -3
  191. package/src/components/OpenLocalFile.tsx +0 -189
  192. package/src/util/loadAssemblyIntoClient.ts +0 -94
@@ -0,0 +1,49 @@
1
+ import { SvgIcon, type SvgIconProps } from '@mui/material'
2
+ import React from 'react'
3
+
4
+ // Icon source: https://developers.google.com/identity/branding-guidelines
5
+ export function Apollo(props: SvgIconProps) {
6
+ return (
7
+ <SvgIcon
8
+ viewBox="0 0 856 855"
9
+ style={{ fontSize: 18, marginRight: 4 }}
10
+ {...props}
11
+ >
12
+ <g>
13
+ <path
14
+ style={{ opacity: 0.68, fill: '#AEAEAE' }}
15
+ d="M276.7,656.9l85-148h102.9c23.1,0,16.1-16,11.1-25l-134-238.5l85-148l185,315.6c0,0-15-26.3,0,0
16
+ c53,92.9-24,243.9-132,243.9c-6,0-4,0-6.4,0H276.7z"
17
+ />
18
+ <polygon
19
+ style={{ opacity: 0.85, fill: '#717171' }}
20
+ points="49.7,756.9 219.1,756.9 513.7,246.9 425.7,99.9 "
21
+ />
22
+ <polygon
23
+ style={{ opacity: 0.85, fill: '#717171' }}
24
+ points="630,756.9 806.4,756.9 513.7,246.9 425.1,400.2 "
25
+ />
26
+ <polygon
27
+ style={{ fill: '#C6C6C6' }}
28
+ points="175.7,657.3 195.6,657.3 277.9,508.9 254.1,508.9 170.6,657.3 "
29
+ />
30
+ <polygon
31
+ style={{ fill: '#C6C6C6' }}
32
+ points="369.7,657.3 389.6,657.3 471.9,508.9 448.1,508.9 364.6,657.3 "
33
+ />
34
+ <polygon
35
+ style={{ fill: '#C6C6C6' }}
36
+ points="321.7,657.3 341.6,657.3 423.9,508.9 400.1,508.9 316.6,657.3 "
37
+ />
38
+ <polygon
39
+ style={{ fill: '#C6C6C6' }}
40
+ points="224.7,657.3 244.6,657.3 326.9,508.9 303.1,508.9 219.6,657.3 "
41
+ />
42
+ <polygon
43
+ style={{ fill: '#C6C6C6' }}
44
+ points="273.7,657.3 293.6,657.3 375.9,508.9 352.1,508.9 268.6,657.3 "
45
+ />
46
+ </g>
47
+ </SvgIcon>
48
+ )
49
+ }
@@ -2,22 +2,13 @@ import type {
2
2
  AbstractMenuManager,
3
3
  AbstractSessionModel,
4
4
  } from '@jbrowse/core/util'
5
- import DownloadIcon from '@mui/icons-material/Download'
6
- import FactCheckIcon from '@mui/icons-material/FactCheck'
7
- import FileOpenIcon from '@mui/icons-material/FileOpen'
8
5
  import LogoutIcon from '@mui/icons-material/Logout'
9
6
  import RedoIcon from '@mui/icons-material/Redo'
10
- import TrackChangesIcon from '@mui/icons-material/TrackChanges'
11
7
  import UndoIcon from '@mui/icons-material/Undo'
12
8
 
13
- import {
14
- DownloadGFF3,
15
- LogOut,
16
- OpenLocalFile,
17
- ViewChangeLog,
18
- ViewCheckResults,
19
- } from '../components'
9
+ import { LogOut } from '../components'
20
10
  import type { ApolloSessionModel } from '../session'
11
+ import { type ApolloRootModel, isApolloInternetAccount } from '../types'
21
12
 
22
13
  export function addTopLevelMenus(rootModel: AbstractMenuManager) {
23
14
  rootModel.insertInMenu(
@@ -45,96 +36,33 @@ export function addTopLevelMenus(rootModel: AbstractMenuManager) {
45
36
  0,
46
37
  )
47
38
 
48
- rootModel.appendToMenu('Apollo', {
49
- label: 'Download GFF3',
50
- icon: DownloadIcon,
51
- onClick: (session: ApolloSessionModel) => {
52
- ;(session as unknown as AbstractSessionModel).queueDialog(
53
- (doneCallback) => [
54
- DownloadGFF3,
55
- {
56
- session,
57
- handleClose: () => {
58
- doneCallback()
59
- },
60
- },
61
- ],
62
- )
63
- },
64
- })
65
- rootModel.appendToMenu('Apollo', {
66
- label: 'View Change Log',
67
- icon: TrackChangesIcon,
68
- onClick: (session: ApolloSessionModel) => {
69
- ;(session as unknown as AbstractSessionModel).queueDialog(
70
- (doneCallback) => [
71
- ViewChangeLog,
72
- {
73
- session,
74
- handleClose: () => {
75
- doneCallback()
76
- },
77
- },
78
- ],
79
- )
80
- },
81
- })
82
- rootModel.appendToMenu('Apollo', {
83
- label: 'Open local GFF3 file',
84
- icon: FileOpenIcon,
85
- onClick: (session: ApolloSessionModel) => {
86
- ;(session as unknown as AbstractSessionModel).queueDialog(
87
- (doneCallback) => [
88
- OpenLocalFile,
89
- {
90
- session,
91
- handleClose: () => {
92
- doneCallback()
93
- },
94
- inMemoryFileDriver: session.apolloDataStore.inMemoryFileDriver,
95
- },
96
- ],
97
- )
98
- },
99
- })
100
- rootModel.appendToMenu('Apollo', {
101
- label: 'View check results',
102
- icon: FactCheckIcon,
103
- onClick: (session: ApolloSessionModel) => {
104
- ;(session as unknown as AbstractSessionModel).queueDialog(
105
- (doneCallback) => [
106
- ViewCheckResults,
107
- {
108
- session,
109
- handleClose: () => {
110
- doneCallback()
111
- },
112
- },
113
- ],
114
- )
115
- },
116
- })
117
39
  rootModel.appendToMenu('Apollo', {
118
40
  label: 'Lock/Unlock session',
119
41
  onClick: (session: ApolloSessionModel) => {
120
42
  session.toggleLocked()
121
43
  },
122
44
  })
123
- rootModel.appendToMenu('Apollo', {
124
- label: 'Log out',
125
- icon: LogoutIcon,
126
- onClick: (session: ApolloSessionModel) => {
127
- ;(session as unknown as AbstractSessionModel).queueDialog(
128
- (doneCallback) => [
129
- LogOut,
130
- {
131
- session,
132
- handleClose: () => {
133
- doneCallback()
45
+ const { internetAccounts } = rootModel as unknown as ApolloRootModel
46
+ const hasApolloInternetAccount = internetAccounts.some((ia) =>
47
+ isApolloInternetAccount(ia),
48
+ )
49
+ if (hasApolloInternetAccount) {
50
+ rootModel.appendToMenu('Apollo', {
51
+ label: 'Log out',
52
+ icon: LogoutIcon,
53
+ onClick: (session: ApolloSessionModel) => {
54
+ ;(session as unknown as AbstractSessionModel).queueDialog(
55
+ (doneCallback) => [
56
+ LogOut,
57
+ {
58
+ session,
59
+ handleClose: () => {
60
+ doneCallback()
61
+ },
134
62
  },
135
- },
136
- ],
137
- )
138
- },
139
- })
63
+ ],
64
+ )
65
+ },
66
+ })
67
+ }
140
68
  }
@@ -2,7 +2,6 @@
2
2
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
3
3
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
4
4
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
5
- import type { ClientDataStore as ClientDataStoreType } from '@apollo-annotation/common'
6
5
  import {
7
6
  type AnnotationFeatureModel,
8
7
  type AnnotationFeatureSnapshot,
@@ -18,7 +17,7 @@ import {
18
17
  getConf,
19
18
  readConfObject,
20
19
  } from '@jbrowse/core/configuration'
21
- import { type Region, getSession, isElectron } from '@jbrowse/core/util'
20
+ import { type Region, getSession } from '@jbrowse/core/util'
22
21
  import type {
23
22
  LocalPathLocation,
24
23
  UriLocation,
@@ -38,8 +37,7 @@ import {
38
37
  type ApolloInternetAccount,
39
38
  type BackendDriver,
40
39
  CollaborationServerDriver,
41
- DesktopFileDriver,
42
- InMemoryFileDriver,
40
+ LocalDriver,
43
41
  } from '../BackendDrivers'
44
42
  import { ChangeManager } from '../ChangeManager'
45
43
  import {
@@ -158,16 +156,11 @@ export function clientDataStoreFactory(
158
156
  },
159
157
  }))
160
158
  .volatile((self) => ({
161
- changeManager: new ChangeManager(self as unknown as ClientDataStoreType),
159
+ changeManager: new ChangeManager(self as ClientDataStoreModel),
162
160
  collaborationServerDriver: new CollaborationServerDriver(
163
- self as unknown as ClientDataStoreType,
161
+ self as ClientDataStoreModel,
164
162
  ),
165
- inMemoryFileDriver: new InMemoryFileDriver(
166
- self as unknown as ClientDataStoreType,
167
- ),
168
- desktopFileDriver: isElectron
169
- ? new DesktopFileDriver(self as unknown as ClientDataStoreType)
170
- : undefined,
163
+ localDriver: new LocalDriver(self as ClientDataStoreModel),
171
164
  }))
172
165
  .actions((self) => ({
173
166
  afterCreate() {
@@ -245,17 +238,14 @@ export function clientDataStoreFactory(
245
238
  if (!assembly) {
246
239
  return
247
240
  }
248
- const { file, internetAccountConfigId } = getConf(assembly, [
241
+ const { internetAccountConfigId } = getConf(assembly, [
249
242
  'sequence',
250
243
  'metadata',
251
244
  ]) as { internetAccountConfigId?: string; file: string }
252
- if (isElectron && file) {
253
- return self.desktopFileDriver
254
- }
255
245
  if (internetAccountConfigId) {
256
246
  return self.collaborationServerDriver
257
247
  }
258
- return self.inMemoryFileDriver
248
+ return self.localDriver
259
249
  },
260
250
  getInternetAccount(assemblyName?: string, internetAccountId?: string) {
261
251
  if (!(assemblyName ?? internetAccountId)) {
@@ -347,3 +337,12 @@ export function clientDataStoreFactory(
347
337
  }),
348
338
  }))
349
339
  }
340
+
341
+ export type ClientDataStoreStateModel = ReturnType<
342
+ typeof clientDataStoreFactory
343
+ >
344
+ // eslint disable because of
345
+ // https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
346
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
347
+ export interface ClientDataStoreModel
348
+ extends Instance<ClientDataStoreStateModel> {}
@@ -0,0 +1,261 @@
1
+ /* eslint-disable @typescript-eslint/require-await */
2
+ import {
3
+ attributesToRecords,
4
+ type localChanges,
5
+ stringifyAttributes,
6
+ } from '@apollo-annotation/shared'
7
+
8
+ import type { ClientDataStoreModel } from './ClientDataStore'
9
+
10
+ type ChangeHandlers = {
11
+ [K in keyof typeof localChanges]: (
12
+ dataStore: ClientDataStoreModel,
13
+ change: InstanceType<(typeof localChanges)[K]>,
14
+ ) => Promise<void>
15
+ }
16
+
17
+ export function isLocalChange(
18
+ changeName: string,
19
+ ): changeName is keyof typeof localChanges {
20
+ return changeName in changeHandlers
21
+ }
22
+
23
+ export const changeHandlers: ChangeHandlers = {
24
+ async AddFeatureChange(dataStore, change) {
25
+ const { assembly, changes } = change
26
+ for (const c of changes) {
27
+ const { addedFeature, parentFeatureId } = c
28
+ if (parentFeatureId) {
29
+ let parentFeature = dataStore.getFeature(parentFeatureId)
30
+ // maybe the parent feature hasn't been loaded yet
31
+ if (!parentFeature) {
32
+ await dataStore.loadFeatures([
33
+ {
34
+ assemblyName: assembly,
35
+ refName: addedFeature.refSeq,
36
+ start: addedFeature.min,
37
+ end: addedFeature.max,
38
+ },
39
+ ])
40
+ parentFeature = dataStore.getFeature(parentFeatureId)
41
+ if (!parentFeature) {
42
+ throw new Error(
43
+ `Could not find parent feature "${parentFeatureId}"`,
44
+ )
45
+ }
46
+ }
47
+ // create an ID for the parent feature if it does not have one
48
+ if (!parentFeature.attributes.get('_id')) {
49
+ parentFeature.setAttribute('_id', [parentFeature._id])
50
+ }
51
+ parentFeature.addChild(addedFeature)
52
+ } else {
53
+ dataStore.addFeature(assembly, addedFeature)
54
+ }
55
+ }
56
+ },
57
+
58
+ async DeleteFeatureChange(dataStore, change) {
59
+ for (const c of change.changes) {
60
+ const { deletedFeature, parentFeatureId } = c
61
+ if (parentFeatureId) {
62
+ const parentFeature = dataStore.getFeature(parentFeatureId)
63
+ if (!parentFeature) {
64
+ throw new Error(`Could not find parent feature "${parentFeatureId}"`)
65
+ }
66
+ parentFeature.deleteChild(deletedFeature._id)
67
+ } else {
68
+ if (dataStore.getFeature(deletedFeature._id)) {
69
+ dataStore.deleteFeature(deletedFeature._id)
70
+ }
71
+ }
72
+ }
73
+ },
74
+
75
+ async FeatureAttributeChange(dataStore, change) {
76
+ for (const [idx, changedId] of change.changedIds.entries()) {
77
+ const feature = dataStore.getFeature(changedId)
78
+ if (!feature) {
79
+ throw new Error(`Could not find feature with identifier "${changedId}"`)
80
+ }
81
+ feature.setAttributes(
82
+ new Map(Object.entries(change.changes[idx].newAttributes)),
83
+ )
84
+ }
85
+ },
86
+
87
+ async LocationEndChange(dataStore, change) {
88
+ for (const c of change.changes) {
89
+ const { featureId, newEnd } = c
90
+ const feature = dataStore.getFeature(featureId)
91
+ if (!feature) {
92
+ throw new Error(`Could not find feature with identifier "${featureId}"`)
93
+ }
94
+ feature.setMax(newEnd)
95
+ }
96
+ },
97
+
98
+ async LocationStartChange(dataStore, change) {
99
+ for (const c of change.changes) {
100
+ const { featureId, newStart } = c
101
+ const feature = dataStore.getFeature(featureId)
102
+ if (!feature) {
103
+ throw new Error(`Could not find feature with identifier "${featureId}"`)
104
+ }
105
+ feature.setMin(newStart)
106
+ }
107
+ },
108
+
109
+ async MergeExonsChange(dataStore, change) {
110
+ for (const c of change.changes) {
111
+ const { firstExon, secondExon } = c
112
+ const mergedExon = dataStore.getFeature(firstExon._id)
113
+ if (!mergedExon) {
114
+ throw new Error(
115
+ `Could not find feature with identifier "${firstExon._id}"`,
116
+ )
117
+ }
118
+ mergedExon.setMin(Math.min(firstExon.min, secondExon.min))
119
+ mergedExon.setMax(Math.max(firstExon.max, secondExon.max))
120
+
121
+ const mrg = mergedExon.attributes.get('merged_with')?.slice() ?? []
122
+ const mergedWith = stringifyAttributes(
123
+ attributesToRecords(secondExon.attributes),
124
+ )
125
+ if (!mrg.includes(mergedWith)) {
126
+ mrg.push(mergedWith)
127
+ }
128
+ mergedExon.setAttribute('merged_with', mrg)
129
+
130
+ mergedExon.parent?.deleteChild(secondExon._id)
131
+ }
132
+ },
133
+
134
+ async SplitExonChange(dataStore, change) {
135
+ for (const [idx] of change.changedIds.entries()) {
136
+ const {
137
+ exonToBeSplit,
138
+ parentFeatureId,
139
+ upstreamCut,
140
+ downstreamCut,
141
+ leftExonId,
142
+ rightExonId,
143
+ } = change.changes[idx]
144
+ if (!parentFeatureId) {
145
+ throw new Error('TODO: Split exon without parent')
146
+ }
147
+
148
+ const [leftExon, rightExon] = change.makeSplitExons(
149
+ exonToBeSplit,
150
+ upstreamCut,
151
+ downstreamCut,
152
+ leftExonId,
153
+ rightExonId,
154
+ )
155
+
156
+ const parentFeature = dataStore.getFeature(parentFeatureId)
157
+ if (!parentFeature) {
158
+ throw new Error(`Could not find parent feature "${parentFeatureId}"`)
159
+ }
160
+
161
+ parentFeature.addChild(leftExon)
162
+ parentFeature.addChild(rightExon)
163
+ if (dataStore.getFeature(exonToBeSplit._id)) {
164
+ dataStore.deleteFeature(exonToBeSplit._id)
165
+ }
166
+ }
167
+ },
168
+
169
+ async MergeTranscriptsChange(dataStore, change) {
170
+ for (const [idx, changedId] of change.changedIds.entries()) {
171
+ const { firstTranscript, secondTranscript } = change.changes[idx]
172
+ const mergedTranscript = dataStore.getFeature(firstTranscript._id)
173
+ if (!mergedTranscript) {
174
+ throw new Error(`Could not find feature with identifier "${changedId}"`)
175
+ }
176
+ change.mergeTranscriptsOnClient(mergedTranscript, secondTranscript)
177
+ mergedTranscript.parent?.deleteChild(secondTranscript._id)
178
+ }
179
+ },
180
+
181
+ async UndoMergeExonsChange(dataStore, change) {
182
+ for (const c of change.changes) {
183
+ const { exonsToRestore, parentFeatureId } = c
184
+ if (!parentFeatureId) {
185
+ throw new Error('Parent ID is missing')
186
+ }
187
+ const parentFeature = dataStore.getFeature(parentFeatureId)
188
+ if (!parentFeature) {
189
+ throw new Error(`Could not find parent feature "${parentFeatureId}"`)
190
+ }
191
+ // create an ID for the parent feature if it does not have one
192
+ if (!parentFeature.attributes.get('_id')) {
193
+ parentFeature.setAttribute('_id', [parentFeature._id])
194
+ }
195
+ for (const exon of exonsToRestore) {
196
+ parentFeature.addChild(exon)
197
+ }
198
+ }
199
+ },
200
+
201
+ async UndoSplitExonChange(dataStore, change) {
202
+ for (const c of change.changes) {
203
+ const { exonToRestore, parentFeatureId, idsToDelete } = c
204
+ if (!parentFeatureId) {
205
+ throw new Error('Parent ID is missing')
206
+ }
207
+ const parentFeature = dataStore.getFeature(parentFeatureId)
208
+ if (!parentFeature) {
209
+ throw new Error(`Could not find parent feature "${parentFeatureId}"`)
210
+ }
211
+ // create an ID for the parent feature if it does not have one
212
+ if (!parentFeature.attributes.get('_id')) {
213
+ parentFeature.setAttribute('_id', [parentFeature._id])
214
+ }
215
+ parentFeature.addChild(exonToRestore)
216
+ idsToDelete.map((id) => {
217
+ parentFeature.deleteChild(id)
218
+ })
219
+ }
220
+ },
221
+
222
+ async UndoMergeTranscriptsChange(dataStore, change) {
223
+ for (const c of change.changes) {
224
+ const { transcriptsToRestore, parentFeatureId } = c
225
+ if (!parentFeatureId) {
226
+ throw new Error('Parent ID is missing')
227
+ }
228
+ const parentFeature = dataStore.getFeature(parentFeatureId)
229
+ if (!parentFeature) {
230
+ throw new Error(`Could not find parent feature "${parentFeatureId}"`)
231
+ }
232
+ // create an ID for the parent feature if it does not have one
233
+ if (!parentFeature.attributes.get('_id')) {
234
+ parentFeature.setAttribute('_id', [parentFeature._id])
235
+ }
236
+ for (const transcript of transcriptsToRestore) {
237
+ parentFeature.addChild(transcript)
238
+ }
239
+ }
240
+ },
241
+
242
+ async StrandChange(dataStore, change) {
243
+ for (const [idx, changedId] of change.changedIds.entries()) {
244
+ const feature = dataStore.getFeature(changedId)
245
+ if (!feature) {
246
+ throw new Error(`Could not find feature with identifier "${changedId}"`)
247
+ }
248
+ feature.setStrand(change.changes[idx].newStrand)
249
+ }
250
+ },
251
+
252
+ async TypeChange(dataStore, change) {
253
+ for (const [idx, changedId] of change.changedIds.entries()) {
254
+ const feature = dataStore.getFeature(changedId)
255
+ if (!feature) {
256
+ throw new Error(`Could not find feature with identifier "${changedId}"`)
257
+ }
258
+ feature.setType(change.changes[idx].newType)
259
+ }
260
+ },
261
+ }