@jbrowse/app-core 4.2.1 → 5.0.0-beta.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.
Files changed (154) hide show
  1. package/esm/AppSession/AppRootModel.d.ts +30 -0
  2. package/esm/AppSession/AppRootModel.js +1 -0
  3. package/esm/AppSession/AppSessionMixin.d.ts +1598 -0
  4. package/esm/AppSession/AppSessionMixin.js +62 -0
  5. package/esm/AppSession/index.d.ts +2 -0
  6. package/esm/AppSession/index.js +1 -0
  7. package/esm/Assemblies/AssembliesMixin.d.ts +225 -0
  8. package/esm/Assemblies/AssembliesMixin.js +149 -0
  9. package/esm/Assemblies/index.d.ts +1 -2
  10. package/esm/Assemblies/index.js +1 -2
  11. package/esm/HistoryManagement/index.d.ts +19 -0
  12. package/esm/HistoryManagement/index.js +42 -5
  13. package/esm/JBrowseConfig/RootConfiguration.d.ts +167 -78
  14. package/esm/JBrowseConfig/RootConfiguration.js +85 -7
  15. package/esm/JBrowseConfig/index.d.ts +169 -84
  16. package/esm/JBrowseConfig/index.js +62 -2
  17. package/esm/JBrowseModel/index.d.ts +176 -95
  18. package/esm/JBrowseModel/index.js +122 -21
  19. package/esm/RootMenu/index.d.ts +77 -2
  20. package/esm/RootMenu/index.js +107 -61
  21. package/esm/SessionSpec/index.d.ts +6 -0
  22. package/esm/SessionSpec/index.js +3 -0
  23. package/esm/SessionSpec/lgvUrlInit.d.ts +79 -0
  24. package/esm/SessionSpec/lgvUrlInit.js +158 -0
  25. package/esm/SessionSpec/loadSessionSpec.d.ts +21 -0
  26. package/esm/SessionSpec/loadSessionSpec.js +311 -0
  27. package/esm/SessionSpec/parseSessionSpecUrl.d.ts +13 -0
  28. package/esm/SessionSpec/parseSessionSpecUrl.js +196 -0
  29. package/esm/SessionSpec/types.d.ts +33 -0
  30. package/esm/SessionSpec/types.js +1 -0
  31. package/esm/WorkspaceLayout/LayoutRenderer.d.ts +24 -0
  32. package/esm/WorkspaceLayout/LayoutRenderer.js +185 -0
  33. package/esm/WorkspaceLayout/PanelView.d.ts +13 -0
  34. package/esm/WorkspaceLayout/PanelView.js +99 -0
  35. package/esm/WorkspaceLayout/TabStrip.d.ts +14 -0
  36. package/esm/WorkspaceLayout/TabStrip.js +226 -0
  37. package/esm/WorkspaceLayout/WorkspaceContainer.d.ts +16 -0
  38. package/esm/WorkspaceLayout/WorkspaceContainer.js +105 -0
  39. package/esm/WorkspaceLayout/WorkspacePanelActions.d.ts +24 -0
  40. package/esm/WorkspaceLayout/WorkspacePanelActions.js +120 -0
  41. package/esm/WorkspaceLayout/WorkspaceTab.d.ts +27 -0
  42. package/esm/WorkspaceLayout/WorkspaceTab.js +109 -0
  43. package/esm/WorkspaceLayout/dockviewTheme.d.ts +69 -0
  44. package/esm/WorkspaceLayout/dockviewTheme.js +82 -0
  45. package/esm/WorkspaceLayout/dropZone.d.ts +105 -0
  46. package/esm/WorkspaceLayout/dropZone.js +113 -0
  47. package/esm/WorkspaceLayout/index.d.ts +8 -0
  48. package/esm/WorkspaceLayout/index.js +4 -0
  49. package/esm/WorkspaceLayout/model.d.ts +240 -0
  50. package/esm/WorkspaceLayout/model.js +527 -0
  51. package/esm/WorkspaceLayout/panelChrome.d.ts +19 -0
  52. package/esm/WorkspaceLayout/panelChrome.js +4 -0
  53. package/esm/WorkspaceLayout/spec.d.ts +58 -0
  54. package/esm/WorkspaceLayout/spec.js +153 -0
  55. package/esm/WorkspaceLayout/splitter.d.ts +25 -0
  56. package/esm/WorkspaceLayout/splitter.js +37 -0
  57. package/esm/WorkspaceLayout/tree.d.ts +158 -0
  58. package/esm/WorkspaceLayout/tree.js +379 -0
  59. package/esm/WorkspaceLayout/useLayoutDrag.d.ts +34 -0
  60. package/esm/WorkspaceLayout/useLayoutDrag.js +232 -0
  61. package/esm/index.d.ts +16 -9
  62. package/esm/index.js +13 -9
  63. package/esm/menus.d.ts +63 -62
  64. package/esm/menus.js +131 -84
  65. package/esm/queryParams.d.ts +9 -0
  66. package/esm/queryParams.js +92 -0
  67. package/esm/sessionModelFactory.d.ts +18 -0
  68. package/esm/sessionModelFactory.js +1 -0
  69. package/esm/ui/App/App.d.ts +3 -14
  70. package/esm/ui/App/App.js +30 -17
  71. package/esm/ui/App/AppFab.d.ts +12 -3
  72. package/esm/ui/App/AppFab.js +15 -8
  73. package/esm/ui/App/AppReadyMarker.d.ts +34 -0
  74. package/esm/ui/App/AppReadyMarker.js +56 -0
  75. package/esm/ui/App/AppToolbar.d.ts +2 -14
  76. package/esm/ui/App/AppToolbar.js +23 -24
  77. package/esm/ui/App/ClassicViewsContainer.d.ts +3 -9
  78. package/esm/ui/App/ClassicViewsContainer.js +9 -8
  79. package/esm/ui/App/DialogQueue.d.ts +17 -1
  80. package/esm/ui/App/DialogQueue.js +30 -1
  81. package/esm/ui/App/Drawer.d.ts +1 -1
  82. package/esm/ui/App/Drawer.js +10 -39
  83. package/esm/ui/App/DrawerControls.d.ts +1 -5
  84. package/esm/ui/App/DrawerControls.js +1 -25
  85. package/esm/ui/App/DrawerHeader.d.ts +2 -3
  86. package/esm/ui/App/DrawerHeader.js +24 -10
  87. package/esm/ui/App/DrawerHeaderHelpButton.d.ts +1 -1
  88. package/esm/ui/App/DrawerHeaderHelpButton.js +3 -3
  89. package/esm/ui/App/DrawerHeaderHelpDialog.d.ts +2 -2
  90. package/esm/ui/App/DrawerHeaderHelpDialog.js +3 -4
  91. package/esm/ui/App/DrawerWidget.d.ts +1 -1
  92. package/esm/ui/App/DrawerWidget.js +9 -21
  93. package/esm/ui/App/JBrowseTabMenu.d.ts +2 -3
  94. package/esm/ui/App/JBrowseTabMenu.js +24 -5
  95. package/esm/ui/App/ViewButtons.d.ts +2 -4
  96. package/esm/ui/App/ViewButtons.js +15 -3
  97. package/esm/ui/App/ViewContainer.d.ts +3 -2
  98. package/esm/ui/App/ViewContainer.js +144 -24
  99. package/esm/ui/App/ViewContainerTitle.d.ts +1 -1
  100. package/esm/ui/App/ViewContainerTitle.js +9 -2
  101. package/esm/ui/App/ViewErrorFallback.d.ts +18 -0
  102. package/esm/ui/App/ViewErrorFallback.js +42 -0
  103. package/esm/ui/App/ViewHeader.d.ts +3 -4
  104. package/esm/ui/App/ViewHeader.js +28 -17
  105. package/esm/ui/App/ViewLauncher.d.ts +2 -8
  106. package/esm/ui/App/ViewLauncher.js +7 -5
  107. package/esm/ui/App/ViewMenu.d.ts +3 -5
  108. package/esm/ui/App/ViewMenu.js +87 -92
  109. package/esm/ui/App/ViewStack.d.ts +7 -0
  110. package/esm/ui/App/ViewStack.js +42 -0
  111. package/esm/ui/App/ViewWrapper.d.ts +15 -1
  112. package/esm/ui/App/ViewWrapper.js +26 -10
  113. package/esm/ui/App/ViewsContainer.d.ts +3 -8
  114. package/esm/ui/App/ViewsContainer.js +9 -6
  115. package/esm/ui/App/copyView.js +1 -1
  116. package/esm/ui/App/index.d.ts +2 -1
  117. package/esm/ui/App/index.js +3 -2
  118. package/esm/ui/App/lazyChunk.d.ts +13 -0
  119. package/esm/ui/App/lazyChunk.js +91 -0
  120. package/esm/ui/App/types.d.ts +12 -3
  121. package/esm/ui/App/types.js +1 -1
  122. package/esm/ui/App/useViewVisibility.d.ts +34 -0
  123. package/esm/ui/App/useViewVisibility.js +87 -0
  124. package/esm/ui/App/viewTitle.d.ts +5 -0
  125. package/esm/ui/App/viewTitle.js +9 -0
  126. package/esm/ui/index.d.ts +1 -1
  127. package/esm/ui/index.js +1 -1
  128. package/package.json +12 -17
  129. package/esm/AppFocus/index.d.ts +0 -5
  130. package/esm/AppFocus/index.js +0 -12
  131. package/esm/Assemblies/SessionAssembliesMixin.d.ts +0 -92
  132. package/esm/Assemblies/SessionAssembliesMixin.js +0 -53
  133. package/esm/Assemblies/TemporaryAssembliesMixin.d.ts +0 -10
  134. package/esm/Assemblies/TemporaryAssembliesMixin.js +0 -37
  135. package/esm/DockviewLayout/index.d.ts +0 -35
  136. package/esm/DockviewLayout/index.js +0 -111
  137. package/esm/ui/App/DockviewContext.d.ts +0 -22
  138. package/esm/ui/App/DockviewContext.js +0 -29
  139. package/esm/ui/App/DockviewLeftHeaderActions.d.ts +0 -2
  140. package/esm/ui/App/DockviewLeftHeaderActions.js +0 -58
  141. package/esm/ui/App/DockviewRightHeaderActions.d.ts +0 -2
  142. package/esm/ui/App/DockviewRightHeaderActions.js +0 -100
  143. package/esm/ui/App/DrawerWidgetSelector.d.ts +0 -5
  144. package/esm/ui/App/DrawerWidgetSelector.js +0 -47
  145. package/esm/ui/App/JBrowseViewPanel.d.ts +0 -8
  146. package/esm/ui/App/JBrowseViewPanel.js +0 -40
  147. package/esm/ui/App/JBrowseViewTab.d.ts +0 -8
  148. package/esm/ui/App/JBrowseViewTab.js +0 -97
  149. package/esm/ui/App/ModalWidget.d.ts +0 -6
  150. package/esm/ui/App/ModalWidget.js +0 -48
  151. package/esm/ui/App/TiledViewsContainer.d.ts +0 -6
  152. package/esm/ui/App/TiledViewsContainer.js +0 -366
  153. package/esm/ui/App/dockviewUtils.d.ts +0 -46
  154. package/esm/ui/App/dockviewUtils.js +0 -55
@@ -0,0 +1,62 @@
1
+ import { getParent, types } from '@jbrowse/mobx-state-tree';
2
+ /**
3
+ * #stateModel AppSessionMixin
4
+ *
5
+ * Session getters shared by the "app" products (desktop + web) that simply
6
+ * delegate to the root model — `version`, `history`, `menus`,
7
+ * `assemblyManager` — plus `renameCurrentSession`. Centralized here so the
8
+ * products compose one mixin instead of re-declaring (and diverging on) the
9
+ * same root delegations. The root must satisfy {@link AppRootModel}.
10
+ */
11
+ export function AppSessionMixin(_pluginManager) {
12
+ return types
13
+ .model({})
14
+ .views(self => ({
15
+ /**
16
+ * #getter
17
+ */
18
+ get root() {
19
+ return getParent(self);
20
+ },
21
+ }))
22
+ .views(self => ({
23
+ /**
24
+ * #getter
25
+ */
26
+ get version() {
27
+ return self.root.version;
28
+ },
29
+ /**
30
+ * #getter
31
+ */
32
+ get gitCommit() {
33
+ return self.root.gitCommit;
34
+ },
35
+ /**
36
+ * #getter
37
+ */
38
+ get history() {
39
+ return self.root.history;
40
+ },
41
+ /**
42
+ * #getter
43
+ */
44
+ get assemblyManager() {
45
+ return self.root.assemblyManager;
46
+ },
47
+ /**
48
+ * #method
49
+ */
50
+ menus() {
51
+ return self.root.menus();
52
+ },
53
+ }))
54
+ .actions(self => ({
55
+ /**
56
+ * #action
57
+ */
58
+ renameCurrentSession(sessionName) {
59
+ self.root.renameCurrentSession(sessionName);
60
+ },
61
+ }));
62
+ }
@@ -0,0 +1,2 @@
1
+ export { AppSessionMixin } from './AppSessionMixin.ts';
2
+ export type { AppRootModel } from './AppRootModel.ts';
@@ -0,0 +1 @@
1
+ export { AppSessionMixin } from './AppSessionMixin.js';
@@ -0,0 +1,225 @@
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ import type { BaseAssemblyConfigModel, BaseAssemblyConfigSchema } from '@jbrowse/core/assemblyManager';
3
+ import type { AnyConfiguration } from '@jbrowse/core/configuration';
4
+ /**
5
+ * #stateModel AssembliesMixin
6
+ * #category root
7
+ *
8
+ * Adds `sessionAssemblies` (admin-aware, persisted-with-session assemblies) and
9
+ * `temporaryAssemblies` (used for ad-hoc read-vs-ref style assemblies).
10
+ */
11
+ export declare function AssembliesMixin(_pluginManager: PluginManager, assemblyConfigSchemasType: BaseAssemblyConfigSchema): import("@jbrowse/mobx-state-tree").IModelType<{
12
+ /**
13
+ * #property
14
+ */
15
+ sessionAssemblies: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").IArrayType<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
16
+ readonly aliases: {
17
+ readonly type: "stringArray";
18
+ readonly defaultValue: readonly [];
19
+ readonly description: "Other possible names for the assembly";
20
+ };
21
+ readonly sequence: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
22
+ readonly refNameColors: {
23
+ readonly type: "stringArray";
24
+ readonly defaultValue: readonly [];
25
+ readonly description: "Define custom colors for each reference sequence. Will cycle through this list if there are not enough colors for every sequence.";
26
+ };
27
+ readonly geneticCodes: {
28
+ readonly type: "frozen";
29
+ readonly defaultValue: {};
30
+ readonly description: "Map of reference sequence name to NCBI genetic-code (translation table) id for sequences not using the standard code, e.g. { \"chrM\": 2 }";
31
+ };
32
+ readonly geneticCodesLocation: {
33
+ readonly type: "fileLocation";
34
+ readonly defaultValue: {
35
+ readonly uri: "";
36
+ readonly locationType: "UriLocation";
37
+ };
38
+ readonly description: "Optional TSV file of refName<TAB>geneticCodeId, an alternative to inlining the geneticCodes map";
39
+ };
40
+ readonly refNameAliases: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
41
+ readonly adapter: import("@jbrowse/mobx-state-tree").IAnyType;
42
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
43
+ readonly cytobands: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
44
+ readonly adapter: import("@jbrowse/mobx-state-tree").IAnyType;
45
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
46
+ readonly displayName: {
47
+ readonly type: "string";
48
+ readonly defaultValue: "";
49
+ readonly description: "A human readable display name for the assembly e.g. \"Homo sapiens (hg38)\" while the assembly name may just be \"hg38\"";
50
+ };
51
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "name">>>, [undefined]>;
52
+ /**
53
+ * #property
54
+ */
55
+ temporaryAssemblies: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").IArrayType<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
56
+ readonly aliases: {
57
+ readonly type: "stringArray";
58
+ readonly defaultValue: readonly [];
59
+ readonly description: "Other possible names for the assembly";
60
+ };
61
+ readonly sequence: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
62
+ readonly refNameColors: {
63
+ readonly type: "stringArray";
64
+ readonly defaultValue: readonly [];
65
+ readonly description: "Define custom colors for each reference sequence. Will cycle through this list if there are not enough colors for every sequence.";
66
+ };
67
+ readonly geneticCodes: {
68
+ readonly type: "frozen";
69
+ readonly defaultValue: {};
70
+ readonly description: "Map of reference sequence name to NCBI genetic-code (translation table) id for sequences not using the standard code, e.g. { \"chrM\": 2 }";
71
+ };
72
+ readonly geneticCodesLocation: {
73
+ readonly type: "fileLocation";
74
+ readonly defaultValue: {
75
+ readonly uri: "";
76
+ readonly locationType: "UriLocation";
77
+ };
78
+ readonly description: "Optional TSV file of refName<TAB>geneticCodeId, an alternative to inlining the geneticCodes map";
79
+ };
80
+ readonly refNameAliases: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
81
+ readonly adapter: import("@jbrowse/mobx-state-tree").IAnyType;
82
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
83
+ readonly cytobands: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
84
+ readonly adapter: import("@jbrowse/mobx-state-tree").IAnyType;
85
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
86
+ readonly displayName: {
87
+ readonly type: "string";
88
+ readonly defaultValue: "";
89
+ readonly description: "A human readable display name for the assembly e.g. \"Homo sapiens (hg38)\" while the assembly name may just be \"hg38\"";
90
+ };
91
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "name">>>, [undefined]>;
92
+ }, {
93
+ /**
94
+ * #method
95
+ * The assembly config already carrying `name`, from any of the three
96
+ * arrays the assemblyManager draws on, or undefined.
97
+ *
98
+ * One namespace, because `name` is the assembly config's MST
99
+ * identifier: a second config carrying a name one of the others
100
+ * already has doesn't fail at the add, it makes every
101
+ * `assembly.configuration` safeReference in the manager ambiguous, and
102
+ * MST then throws on every read of one — inside the manager's own
103
+ * autorun and inside `assemblyNameMap`, which takes the session down.
104
+ * So each add path checks all three, not just the array it pushes to.
105
+ */
106
+ findAssemblyConf(name: unknown): BaseAssemblyConfigModel | undefined;
107
+ } & {
108
+ /**
109
+ * #action
110
+ */
111
+ addSessionAssembly(conf: AnyConfiguration): (import("@jbrowse/mobx-state-tree").ModelInstanceTypeProps<Record<string, any>> & {
112
+ setSubschema(slotName: string, data: Record<string, unknown>): any;
113
+ setSlot(slotName: string, value: unknown): void;
114
+ } & import("@jbrowse/mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
115
+ readonly aliases: {
116
+ readonly type: "stringArray";
117
+ readonly defaultValue: readonly [];
118
+ readonly description: "Other possible names for the assembly";
119
+ };
120
+ readonly sequence: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
121
+ readonly refNameColors: {
122
+ readonly type: "stringArray";
123
+ readonly defaultValue: readonly [];
124
+ readonly description: "Define custom colors for each reference sequence. Will cycle through this list if there are not enough colors for every sequence.";
125
+ };
126
+ readonly geneticCodes: {
127
+ readonly type: "frozen";
128
+ readonly defaultValue: {};
129
+ readonly description: "Map of reference sequence name to NCBI genetic-code (translation table) id for sequences not using the standard code, e.g. { \"chrM\": 2 }";
130
+ };
131
+ readonly geneticCodesLocation: {
132
+ readonly type: "fileLocation";
133
+ readonly defaultValue: {
134
+ readonly uri: "";
135
+ readonly locationType: "UriLocation";
136
+ };
137
+ readonly description: "Optional TSV file of refName<TAB>geneticCodeId, an alternative to inlining the geneticCodes map";
138
+ };
139
+ readonly refNameAliases: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
140
+ readonly adapter: import("@jbrowse/mobx-state-tree").IAnyType;
141
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
142
+ readonly cytobands: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
143
+ readonly adapter: import("@jbrowse/mobx-state-tree").IAnyType;
144
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
145
+ readonly displayName: {
146
+ readonly type: "string";
147
+ readonly defaultValue: "";
148
+ readonly description: "A human readable display name for the assembly e.g. \"Homo sapiens (hg38)\" while the assembly name may just be \"hg38\"";
149
+ };
150
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "name">>>) | undefined;
151
+ /**
152
+ * #action
153
+ */
154
+ addAssembly(conf: AnyConfiguration): void;
155
+ /**
156
+ * #action
157
+ */
158
+ removeAssembly(name: string): void;
159
+ /**
160
+ * #action
161
+ */
162
+ removeSessionAssembly(assemblyName: string): void;
163
+ /**
164
+ * #action
165
+ * used for read vs ref type assemblies.
166
+ */
167
+ addTemporaryAssembly(conf: AnyConfiguration): (import("@jbrowse/mobx-state-tree").ModelInstanceTypeProps<Record<string, any>> & {
168
+ setSubschema(slotName: string, data: Record<string, unknown>): any;
169
+ setSlot(slotName: string, value: unknown): void;
170
+ } & import("@jbrowse/mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
171
+ readonly aliases: {
172
+ readonly type: "stringArray";
173
+ readonly defaultValue: readonly [];
174
+ readonly description: "Other possible names for the assembly";
175
+ };
176
+ readonly sequence: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
177
+ readonly refNameColors: {
178
+ readonly type: "stringArray";
179
+ readonly defaultValue: readonly [];
180
+ readonly description: "Define custom colors for each reference sequence. Will cycle through this list if there are not enough colors for every sequence.";
181
+ };
182
+ readonly geneticCodes: {
183
+ readonly type: "frozen";
184
+ readonly defaultValue: {};
185
+ readonly description: "Map of reference sequence name to NCBI genetic-code (translation table) id for sequences not using the standard code, e.g. { \"chrM\": 2 }";
186
+ };
187
+ readonly geneticCodesLocation: {
188
+ readonly type: "fileLocation";
189
+ readonly defaultValue: {
190
+ readonly uri: "";
191
+ readonly locationType: "UriLocation";
192
+ };
193
+ readonly description: "Optional TSV file of refName<TAB>geneticCodeId, an alternative to inlining the geneticCodes map";
194
+ };
195
+ readonly refNameAliases: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
196
+ readonly adapter: import("@jbrowse/mobx-state-tree").IAnyType;
197
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
198
+ readonly cytobands: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
199
+ readonly adapter: import("@jbrowse/mobx-state-tree").IAnyType;
200
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
201
+ readonly displayName: {
202
+ readonly type: "string";
203
+ readonly defaultValue: "";
204
+ readonly description: "A human readable display name for the assembly e.g. \"Homo sapiens (hg38)\" while the assembly name may just be \"hg38\"";
205
+ };
206
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "name">>>) | undefined;
207
+ /**
208
+ * #action
209
+ */
210
+ removeTemporaryAssembly(name: string): void;
211
+ } & {
212
+ /**
213
+ * #getter
214
+ * sessionAssemblies plus jbrowse config assemblies. Does not include
215
+ * temporaryAssemblies; this is the list shown in the AssemblySelector
216
+ * dropdown.
217
+ */
218
+ readonly assemblies: BaseAssemblyConfigModel[];
219
+ } & {
220
+ /**
221
+ * #getter
222
+ * names of the assemblies returned by the `assemblies` getter
223
+ */
224
+ readonly assemblyNames: string[];
225
+ }, import("@jbrowse/mobx-state-tree")._NotCustomized, import("@jbrowse/mobx-state-tree")._NotCustomized>;
@@ -0,0 +1,149 @@
1
+ import { readConfObject } from '@jbrowse/core/configuration';
2
+ import { types } from '@jbrowse/mobx-state-tree';
3
+ import { asSession } from '@jbrowse/product-core';
4
+ /**
5
+ * #stateModel AssembliesMixin
6
+ * #category root
7
+ *
8
+ * Adds `sessionAssemblies` (admin-aware, persisted-with-session assemblies) and
9
+ * `temporaryAssemblies` (used for ad-hoc read-vs-ref style assemblies).
10
+ */
11
+ export function AssembliesMixin(_pluginManager, assemblyConfigSchemasType) {
12
+ return types
13
+ .model({
14
+ /**
15
+ * #property
16
+ */
17
+ sessionAssemblies: types.stripDefault(types.array(assemblyConfigSchemasType), []),
18
+ /**
19
+ * #property
20
+ */
21
+ temporaryAssemblies: types.stripDefault(types.array(assemblyConfigSchemasType), []),
22
+ })
23
+ .views(s => {
24
+ const self = asSession(s);
25
+ return {
26
+ /**
27
+ * #method
28
+ * The assembly config already carrying `name`, from any of the three
29
+ * arrays the assemblyManager draws on, or undefined.
30
+ *
31
+ * One namespace, because `name` is the assembly config's MST
32
+ * identifier: a second config carrying a name one of the others
33
+ * already has doesn't fail at the add, it makes every
34
+ * `assembly.configuration` safeReference in the manager ambiguous, and
35
+ * MST then throws on every read of one — inside the manager's own
36
+ * autorun and inside `assemblyNameMap`, which takes the session down.
37
+ * So each add path checks all three, not just the array it pushes to.
38
+ */
39
+ findAssemblyConf(name) {
40
+ return [
41
+ ...self.jbrowse.assemblies,
42
+ ...self.sessionAssemblies,
43
+ ...self.temporaryAssemblies,
44
+ ].find(f => f.name === name);
45
+ },
46
+ };
47
+ })
48
+ .actions(s => {
49
+ const self = asSession(s);
50
+ return {
51
+ /**
52
+ * #action
53
+ */
54
+ addSessionAssembly(conf) {
55
+ const asm = self.findAssemblyConf(conf.name);
56
+ if (asm) {
57
+ console.warn(`Assembly ${conf.name} already exists`);
58
+ return asm;
59
+ }
60
+ const length = self.sessionAssemblies.push(conf);
61
+ return self.sessionAssemblies[length - 1];
62
+ },
63
+ /**
64
+ * #action
65
+ */
66
+ addAssembly(conf) {
67
+ // checked here rather than left to jbrowse.addAssemblyConf, which
68
+ // sees only its own array: in admin mode the name still has to clear
69
+ // the session-scoped arrays as well
70
+ const asm = self.findAssemblyConf(conf.name);
71
+ if (asm) {
72
+ console.warn(`Assembly ${conf.name} already exists`);
73
+ return;
74
+ }
75
+ if (self.adminMode) {
76
+ self.jbrowse.addAssemblyConf(conf);
77
+ }
78
+ else {
79
+ this.addSessionAssembly(conf);
80
+ }
81
+ },
82
+ /**
83
+ * #action
84
+ */
85
+ removeAssembly(name) {
86
+ if (self.adminMode) {
87
+ self.jbrowse.removeAssemblyConf(name);
88
+ }
89
+ else {
90
+ this.removeSessionAssembly(name);
91
+ }
92
+ },
93
+ /**
94
+ * #action
95
+ */
96
+ removeSessionAssembly(assemblyName) {
97
+ const elt = self.sessionAssemblies.find(a => a.name === assemblyName);
98
+ if (elt) {
99
+ self.sessionAssemblies.remove(elt);
100
+ }
101
+ },
102
+ /**
103
+ * #action
104
+ * used for read vs ref type assemblies.
105
+ */
106
+ addTemporaryAssembly(conf) {
107
+ const asm = self.findAssemblyConf(conf.name);
108
+ if (asm) {
109
+ console.warn(`Assembly ${conf.name} already exists`);
110
+ return asm;
111
+ }
112
+ const length = self.temporaryAssemblies.push(conf);
113
+ return self.temporaryAssemblies[length - 1];
114
+ },
115
+ /**
116
+ * #action
117
+ */
118
+ removeTemporaryAssembly(name) {
119
+ const elt = self.temporaryAssemblies.find(a => a.name === name);
120
+ if (elt) {
121
+ self.temporaryAssemblies.remove(elt);
122
+ }
123
+ },
124
+ };
125
+ })
126
+ .views(s => {
127
+ const self = asSession(s);
128
+ return {
129
+ /**
130
+ * #getter
131
+ * sessionAssemblies plus jbrowse config assemblies. Does not include
132
+ * temporaryAssemblies; this is the list shown in the AssemblySelector
133
+ * dropdown.
134
+ */
135
+ get assemblies() {
136
+ return [...self.jbrowse.assemblies, ...self.sessionAssemblies];
137
+ },
138
+ };
139
+ })
140
+ .views(self => ({
141
+ /**
142
+ * #getter
143
+ * names of the assemblies returned by the `assemblies` getter
144
+ */
145
+ get assemblyNames() {
146
+ return self.assemblies.map(a => readConfObject(a, 'name'));
147
+ },
148
+ }));
149
+ }
@@ -1,2 +1 @@
1
- export * from './SessionAssembliesMixin.ts';
2
- export * from './TemporaryAssembliesMixin.ts';
1
+ export { AssembliesMixin } from './AssembliesMixin.ts';
@@ -1,2 +1 @@
1
- export * from "./SessionAssembliesMixin.js";
2
- export * from "./TemporaryAssembliesMixin.js";
1
+ export { AssembliesMixin } from './AssembliesMixin.js';
@@ -1,4 +1,23 @@
1
+ /**
2
+ * Whether the user is typing into something with an undo stack of its own.
3
+ *
4
+ * Session undo must not steal the text editor's. The keydown listener below is
5
+ * on `document`, so it sees ctrl+z no matter what has focus — including the
6
+ * multiline TextFields the config editor, the jexl/JSON monospace field, and
7
+ * the paste-config workflows are built from. Those render a `<textarea>`, not
8
+ * an `<input>`, so an INPUT-only check let a keystroke meant to undo typing
9
+ * roll back the whole session instead.
10
+ */
11
+ export declare function isTextEntryFocused(): boolean;
12
+ /**
13
+ * #stateModel HistoryManagementMixin
14
+ * #category root
15
+ */
1
16
  export declare function HistoryManagementMixin(): import("@jbrowse/mobx-state-tree").IModelType<{
17
+ /**
18
+ * #property
19
+ * used for undo/redo
20
+ */
2
21
  history: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").IModelType<{
3
22
  undoIdx: import("@jbrowse/mobx-state-tree").IType<number | undefined, number, number>;
4
23
  targetPath: import("@jbrowse/mobx-state-tree").IType<string | undefined, string, string>;
@@ -1,24 +1,57 @@
1
1
  import TimeTraveller from '@jbrowse/core/util/TimeTraveller';
2
2
  import { addDisposer, types } from '@jbrowse/mobx-state-tree';
3
+ import { asRoot } from '@jbrowse/product-core';
3
4
  import { autorun } from 'mobx';
5
+ /**
6
+ * Whether the user is typing into something with an undo stack of its own.
7
+ *
8
+ * Session undo must not steal the text editor's. The keydown listener below is
9
+ * on `document`, so it sees ctrl+z no matter what has focus — including the
10
+ * multiline TextFields the config editor, the jexl/JSON monospace field, and
11
+ * the paste-config workflows are built from. Those render a `<textarea>`, not
12
+ * an `<input>`, so an INPUT-only check let a keystroke meant to undo typing
13
+ * roll back the whole session instead.
14
+ */
15
+ export function isTextEntryFocused() {
16
+ const el = document.activeElement;
17
+ if (!(el instanceof HTMLElement)) {
18
+ return false;
19
+ }
20
+ const tag = el.tagName.toUpperCase();
21
+ // coerced: isContentEditable is declared boolean but is undefined in jsdom,
22
+ // so the raw expression returns undefined for an ordinary focused element
23
+ return tag === 'INPUT' || tag === 'TEXTAREA' || !!el.isContentEditable;
24
+ }
25
+ /**
26
+ * #stateModel HistoryManagementMixin
27
+ * #category root
28
+ */
4
29
  export function HistoryManagementMixin() {
5
30
  return types
6
31
  .model({
32
+ /**
33
+ * #property
34
+ * used for undo/redo
35
+ */
7
36
  history: types.optional(TimeTraveller, { targetPath: '../session' }),
8
37
  })
9
38
  .actions(self => {
10
39
  const keydownListener = (e) => {
40
+ if (isTextEntryFocused()) {
41
+ return;
42
+ }
11
43
  if (self.history.canRedo &&
44
+ // ctrl+shift+z or cmd+shift+z
12
45
  (((e.ctrlKey || e.metaKey) && e.shiftKey && e.code === 'KeyZ') ||
13
- (e.ctrlKey && !e.shiftKey && e.code === 'KeyY')) &&
14
- document.activeElement?.tagName.toUpperCase() !== 'INPUT') {
46
+ // ctrl+y
47
+ (e.ctrlKey && !e.shiftKey && e.code === 'KeyY'))) {
15
48
  self.history.redo();
16
49
  }
17
50
  if (self.history.canUndo &&
51
+ // ctrl+z or cmd+z
18
52
  (e.ctrlKey || e.metaKey) &&
19
53
  !e.shiftKey &&
20
- e.code === 'KeyZ' &&
21
- document.activeElement?.tagName.toUpperCase() !== 'INPUT') {
54
+ e.code === 'KeyZ') {
22
55
  self.history.undo();
23
56
  }
24
57
  };
@@ -26,8 +59,12 @@ export function HistoryManagementMixin() {
26
59
  afterCreate() {
27
60
  document.addEventListener('keydown', keydownListener);
28
61
  addDisposer(self, autorun(function historyInitAutorun() {
29
- const { session } = self;
62
+ const { session } = asRoot(self);
30
63
  if (session) {
64
+ // we use a specific initialization routine after session is
65
+ // created to get it to start tracking itself sort of related
66
+ // issue here
67
+ // https://github.com/mobxjs/mobx-state-tree/issues/1089#issuecomment-441207911
31
68
  self.history.initialize();
32
69
  }
33
70
  }, { name: 'HistoryInit' }));