@jbrowse/plugin-config 5.0.0-beta.10 → 5.0.0-beta.11

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.
@@ -9,6 +9,7 @@ export default function registerConfigurationEditorWidget(pluginManager) {
9
9
  pluginManager.addWidgetType(() => {
10
10
  return new WidgetType({
11
11
  name: 'ConfigurationEditorWidget',
12
+ discardOnClose: true,
12
13
  HeadingComponent,
13
14
  configSchema,
14
15
  stateModel: stateModelFactory(pluginManager),
@@ -15,4 +15,5 @@ export default function stateModelFactory(_pluginManager: PluginManager): import
15
15
  setTarget(newTarget: AnyConfigurationModel | undefined): void;
16
16
  setExpandedDisplayId(displayId: string | undefined): void;
17
17
  afterCreate(): void;
18
+ beforeDetach(): void;
18
19
  }, import("@jbrowse/mobx-state-tree")._NotCustomized, import("@jbrowse/mobx-state-tree")._NotCustomized>;
@@ -23,49 +23,54 @@ export default function stateModelFactory(_pluginManager) {
23
23
  // (incompatible/inactive) displays start collapsed
24
24
  expandedDisplayId: undefined,
25
25
  }))
26
- .actions(self => ({
27
- setTarget(newTarget) {
28
- self.target = newTarget;
29
- },
30
- setExpandedDisplayId(displayId) {
31
- self.expandedDisplayId = displayId;
32
- },
33
- afterCreate() {
34
- let timeout;
35
- // Auto-save configuration changes with 400ms debounce. The autorun
36
- // reacts to any changes in the target configuration model and persists
37
- // them back to the session after a short delay via
38
- // updateTrackConfiguration, which routes admin edits to the jbrowse
39
- // config in place and everyone else's to a shareable per-track delta
40
- // (trackConfigDeltas) against the admin base. It keys off trackId; in
41
- // practice the widget is only opened on track configs. A config with no
42
- // trackId (assembly/connection) degrades gracefully: updateTrackConfiguration
43
- // finds no base/session/connection home and the edit just applies to the
44
- // live MST node in memory for this session.
45
- //
46
- // BaseTrackModel's afterAttach runs a sibling debounced save (a reaction
47
- // on the same config node) for direct setSlot quick-edits on a *shown*
48
- // track. Both intentionally coexist: this widget also handles an unshown
49
- // track edited from the selector, which has no BaseTrackModel. When both
50
- // fire they compute an identical delta, deduped in updateTrackConfiguration
51
- // — don't drop one to "simplify".
52
- addDisposer(self, autorun(() => {
53
- if (self.target) {
54
- // track configs (the practical case) carry a trackId; a
55
- // trackId-less snapshot degrades to an in-memory edit (see above)
56
- const snapshot = getSnapshot(self.target);
26
+ .actions(self => {
27
+ let timeout;
28
+ let unsaved;
29
+ function save() {
30
+ clearTimeout(timeout);
31
+ if (unsaved) {
32
+ const session = getSession(self);
33
+ session.updateTrackConfiguration(unsaved);
34
+ unsaved = undefined;
35
+ }
36
+ }
37
+ return {
38
+ setTarget(newTarget) {
39
+ self.target = newTarget;
40
+ },
41
+ setExpandedDisplayId(displayId) {
42
+ self.expandedDisplayId = displayId;
43
+ },
44
+ afterCreate() {
45
+ // Auto-save configuration changes with 400ms debounce, through
46
+ // updateTrackConfiguration, which routes admin edits to the jbrowse
47
+ // config in place and everyone else's to a shareable per-track delta
48
+ // (trackConfigDeltas) against the admin base. A config with no
49
+ // trackId (assembly/connection) finds no home there, so the edit
50
+ // stays on the live MST node for this session.
51
+ //
52
+ // BaseTrackModel's afterAttach runs a sibling debounced save for
53
+ // direct setSlot quick-edits on a *shown* track. Both intentionally
54
+ // coexist: this widget also handles an unshown track edited from the
55
+ // selector, which has no BaseTrackModel. When both fire they compute
56
+ // an identical delta, deduped in updateTrackConfiguration — don't
57
+ // drop one to "simplify".
58
+ addDisposer(self, autorun(() => {
59
+ if (self.target) {
60
+ unsaved = getSnapshot(self.target);
61
+ clearTimeout(timeout);
62
+ timeout = setTimeout(save, 400);
63
+ }
64
+ }));
65
+ addDisposer(self, () => {
57
66
  clearTimeout(timeout);
58
- timeout = setTimeout(() => {
59
- const session = getSession(self);
60
- session.updateTrackConfiguration(snapshot);
61
- }, 400);
62
- }
63
- }));
64
- // ensure a pending debounced save can't fire after disposal, where
65
- // getSession(self) would throw on the now-detached node
66
- addDisposer(self, () => {
67
- clearTimeout(timeout);
68
- });
69
- },
70
- }));
67
+ });
68
+ },
69
+ // closing the editor detaches it from the session, so an edit still
70
+ // inside the debounce saves now, while getSession(self) resolves
71
+ beforeDetach() {
72
+ save();
73
+ },
74
+ };
75
+ });
71
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-config",
3
- "version": "5.0.0-beta.10",
3
+ "version": "5.0.0-beta.11",
4
4
  "type": "module",
5
5
  "description": "JBrowse 2 config utilities",
6
6
  "keywords": [
@@ -21,13 +21,13 @@
21
21
  "esm"
22
22
  ],
23
23
  "dependencies": {
24
- "@jbrowse/mobx-state-tree": "^6.6.1",
24
+ "@jbrowse/mobx-state-tree": "^6.7.0",
25
25
  "@mui/icons-material": "^9.4.0",
26
26
  "@mui/material": "^9.4.0",
27
27
  "mobx": "^7.0.5",
28
28
  "mobx-react": "^10.0.2",
29
29
  "rxjs": "^7.8.2",
30
- "@jbrowse/core": "^5.0.0-beta.10"
30
+ "@jbrowse/core": "^5.0.0-beta.11"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=19.0.0",