@jbrowse/product-core 5.0.0-beta.2 → 5.0.0-beta.4

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,64 @@
1
+ import { displayDefaultChanges, resetDisplayDefault, } from './displayDefaultChanges.js';
2
+ const NON_MAP_PREFERENCES = [
3
+ {
4
+ head: 'theme',
5
+ change: s => s.themeName && s.themeName !== 'default'
6
+ ? { path: ['theme'], from: 'default', to: s.themeName }
7
+ : undefined,
8
+ reset: s => {
9
+ s.setThemeName('default');
10
+ },
11
+ },
12
+ {
13
+ head: 'stickyViewHeaders',
14
+ change: s => s.stickyViewHeaders
15
+ ? undefined
16
+ : { path: ['stickyViewHeaders'], from: true, to: false },
17
+ reset: s => {
18
+ s.setStickyViewHeaders(true);
19
+ },
20
+ },
21
+ {
22
+ head: 'useWorkspaces',
23
+ change: s => s.effectiveUseWorkspaces === s.defaultUseWorkspaces
24
+ ? undefined
25
+ : {
26
+ path: ['useWorkspaces'],
27
+ from: s.defaultUseWorkspaces,
28
+ to: s.effectiveUseWorkspaces,
29
+ },
30
+ reset: s => {
31
+ s.resetUseWorkspaces();
32
+ },
33
+ },
34
+ ];
35
+ const NON_MAP_HEADS = new Set(NON_MAP_PREFERENCES.map(p => p.head));
36
+ // Everything "Reset to defaults" reverts, as rows: the scalar overrides in the
37
+ // preference map, the promoted display-type defaults (same map, listed through
38
+ // the builder the Display defaults section uses so both surfaces read alike),
39
+ // and the preferences held outside the map.
40
+ export function collectPreferenceChanges(session, pluginManager) {
41
+ return [
42
+ ...session
43
+ .getPreferenceChanges()
44
+ .filter(c => !NON_MAP_HEADS.has(c.path[0])),
45
+ ...displayDefaultChanges(session, pluginManager),
46
+ ...NON_MAP_PREFERENCES.map(p => p.change(session)).filter(c => c !== undefined),
47
+ ];
48
+ }
49
+ export function resetAllPreferences(session) {
50
+ session.clearPreferenceOverrides();
51
+ for (const p of NON_MAP_PREFERENCES) {
52
+ p.reset(session);
53
+ }
54
+ }
55
+ export function resetPreferenceChange(session, change) {
56
+ const [head] = change.path;
57
+ const pref = NON_MAP_PREFERENCES.find(p => p.head === head);
58
+ if (pref) {
59
+ pref.reset(session);
60
+ }
61
+ else if (!resetDisplayDefault(session, change) && head) {
62
+ session.clearPreferenceOverride(head);
63
+ }
64
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/product-core",
3
- "version": "5.0.0-beta.2",
3
+ "version": "5.0.0-beta.4",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "JBrowse 2 code shared between products but not used by plugins",
@@ -30,8 +30,8 @@
30
30
  "@mui/material": "^9.4.0",
31
31
  "mobx": "^7.0.3",
32
32
  "mobx-react": "^10.0.2",
33
- "@jbrowse/core": "^5.0.0-beta.2",
34
- "@jbrowse/render-core": "^5.0.0-beta.2"
33
+ "@jbrowse/render-core": "^5.0.0-beta.4",
34
+ "@jbrowse/core": "^5.0.0-beta.4"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": ">=19.0.0",
@@ -1,18 +0,0 @@
1
- import type { IAnyStateTreeNode } from '@jbrowse/mobx-state-tree';
2
- /**
3
- * Free a tree an action has already let go of — a superseded session, a view
4
- * taken out of one, a superseded rootModel the React host has detached.
5
- *
6
- * A task rather than a microtask: the wait is for React to unmount the
7
- * components rendering it, which happens on the re-render that the action's own
8
- * reactions schedule. Deferring is acceptable here, and is not elsewhere,
9
- * because the node stays alive and detached until it fires — a late read gets a
10
- * live tree nobody is rendering. ADR-069.
11
- *
12
- * The destroy itself is not optional. `beforeDestroy` is a plugin-facing
13
- * contract (jbrowse-plugin-apollo aborts its in-flight fetches there) and core's
14
- * `BaseTrackModel` releases the `rpcSessionId` claim that lets
15
- * `CoreFreeResources` evict a parsed adapter from the worker — so detaching and
16
- * forgetting would trade a console warning for an unbounded leak.
17
- */
18
- export declare function scheduleDetachedDestroy(node: IAnyStateTreeNode): void;
@@ -1,24 +0,0 @@
1
- import { destroy, isAlive } from '@jbrowse/mobx-state-tree';
2
- /**
3
- * Free a tree an action has already let go of — a superseded session, a view
4
- * taken out of one, a superseded rootModel the React host has detached.
5
- *
6
- * A task rather than a microtask: the wait is for React to unmount the
7
- * components rendering it, which happens on the re-render that the action's own
8
- * reactions schedule. Deferring is acceptable here, and is not elsewhere,
9
- * because the node stays alive and detached until it fires — a late read gets a
10
- * live tree nobody is rendering. ADR-069.
11
- *
12
- * The destroy itself is not optional. `beforeDestroy` is a plugin-facing
13
- * contract (jbrowse-plugin-apollo aborts its in-flight fetches there) and core's
14
- * `BaseTrackModel` releases the `rpcSessionId` claim that lets
15
- * `CoreFreeResources` evict a parsed adapter from the worker — so detaching and
16
- * forgetting would trade a console warning for an unbounded leak.
17
- */
18
- export function scheduleDetachedDestroy(node) {
19
- setTimeout(() => {
20
- if (isAlive(node)) {
21
- destroy(node);
22
- }
23
- }, 0);
24
- }