@jbrowse/embedded-core 4.3.0 → 5.0.0-beta.10

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.
@@ -0,0 +1,61 @@
1
+ import { getParent, types } from '@jbrowse/mobx-state-tree';
2
+ import { BaseSessionModel, ConnectionManagementSessionMixin, DrawerWidgetSessionMixin, ReferenceManagementSessionMixin, TrackMenuSessionMixin, } from '@jbrowse/product-core';
3
+ import { EmbeddedSessionThemeMixin } from './EmbeddedSessionThemeMixin.js';
4
+ /**
5
+ * #stateModel EmbeddedSessionMixin
6
+ * Everything the two single-view embedded products' sessions
7
+ * (react-linear-genome-view, react-circular-genome-view) share: the mixin set
8
+ * they compose and the three getters that read the root model. The twin of
9
+ * {@link createEmbeddedRootModel} one level down.
10
+ *
11
+ * Each product composes this mixin. A factory taking the product's view type
12
+ * and tracks mixin as parameters does not typecheck usefully:
13
+ * `types.compose`'s overloads are declared over `IModelType<P, O, FC, FS>`, so
14
+ * a model passed as a naked type parameter gives nothing to infer those four
15
+ * from, and `session.view` becomes `any` at every embedder call site with no
16
+ * type error. Passing only concrete types to `compose` keeps the products'
17
+ * views typed.
18
+ *
19
+ * Each product therefore declares its tracks mixin, `view` prop, and the
20
+ * `views`/`addView`/`removeView` members that read `self.view`, because those
21
+ * members need its concrete view type.
22
+ */
23
+ export function EmbeddedSessionMixin(pluginManager) {
24
+ return types
25
+ .compose(BaseSessionModel(pluginManager), DrawerWidgetSessionMixin(pluginManager), ConnectionManagementSessionMixin(pluginManager),
26
+ // ReferenceManagementSessionMixin and either tracks mixin share no
27
+ // members, so their order relative to each other is not load-bearing
28
+ ReferenceManagementSessionMixin(pluginManager), TrackMenuSessionMixin(pluginManager), EmbeddedSessionThemeMixin(pluginManager))
29
+ .views(self => ({
30
+ /**
31
+ * #getter
32
+ * An embedded view is drawn with no title bar above it, so its menu lives
33
+ * in the view's own controls.
34
+ */
35
+ get viewTitleBars() {
36
+ return false;
37
+ },
38
+ /**
39
+ * #getter
40
+ */
41
+ get version() {
42
+ return getParent(self).version;
43
+ },
44
+ /**
45
+ * #getter
46
+ */
47
+ // `assemblies` and `connections` are intentionally omitted:
48
+ // BaseSessionModel and ConnectionManagementSessionMixin already resolve
49
+ // them through `self.jbrowse` (= root.config), so re-declaring here would
50
+ // just duplicate the base getters with looser types
51
+ get assemblyNames() {
52
+ return getParent(self).config.assemblyNames;
53
+ },
54
+ /**
55
+ * #getter
56
+ */
57
+ get assemblyManager() {
58
+ return getParent(self).assemblyManager;
59
+ },
60
+ }));
61
+ }