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

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,54 @@
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
+ * A mixin the product composes, deliberately, rather than a factory taking the
12
+ * product's view type and tracks mixin as parameters. That factory is the
13
+ * obvious shape and it does not work: `types.compose`'s overloads are declared
14
+ * over `IModelType<P, O, FC, FS>`, so a model handed in as a naked type
15
+ * parameter has nothing to infer those four from and the composed result
16
+ * degrades — `session.view` becomes `any`, which typechecks at every embedder
17
+ * call site and is caught by nothing. Keeping every argument to `compose`
18
+ * concrete is what keeps the products' views typed.
19
+ *
20
+ * So each product still spells out its own tracks mixin, `view` prop, and the
21
+ * `views`/`addView`/`removeView` members that read `self.view` — those are the
22
+ * ones that need its concrete view type.
23
+ */
24
+ export function EmbeddedSessionMixin(pluginManager) {
25
+ return types
26
+ .compose(BaseSessionModel(pluginManager), DrawerWidgetSessionMixin(pluginManager), ConnectionManagementSessionMixin(pluginManager),
27
+ // ReferenceManagementSessionMixin and either tracks mixin share no
28
+ // members, so their order relative to each other is not load-bearing
29
+ ReferenceManagementSessionMixin(pluginManager), TrackMenuSessionMixin(pluginManager), EmbeddedSessionThemeMixin(pluginManager))
30
+ .views(self => ({
31
+ /**
32
+ * #getter
33
+ */
34
+ get version() {
35
+ return getParent(self).version;
36
+ },
37
+ /**
38
+ * #getter
39
+ */
40
+ // `assemblies` and `connections` are intentionally omitted:
41
+ // BaseSessionModel and ConnectionManagementSessionMixin already resolve
42
+ // them through `self.jbrowse` (= root.config), so re-declaring here would
43
+ // just duplicate the base getters with looser types
44
+ get assemblyNames() {
45
+ return [getParent(self).config.assemblyName];
46
+ },
47
+ /**
48
+ * #getter
49
+ */
50
+ get assemblyManager() {
51
+ return getParent(self).assemblyManager;
52
+ },
53
+ }));
54
+ }