jbrowse-plugin-msaview 3.0.0 → 3.2.0

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 (67) hide show
  1. package/dist/LaunchMsaView/components/BlastQuery/BlastAutomaticPanel.js +1 -1
  2. package/dist/LaunchMsaView/components/BlastQuery/BlastManualPanel.d.ts +11 -0
  3. package/dist/LaunchMsaView/components/BlastQuery/BlastManualPanel.js +73 -16
  4. package/dist/LaunchMsaView/components/BlastQuery/blastLaunchView.js +6 -4
  5. package/dist/LaunchMsaView/components/BlastQuery/consts.d.ts +8 -1
  6. package/dist/LaunchMsaView/components/BlastQuery/consts.js +8 -1
  7. package/dist/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.js +8 -15
  8. package/dist/LaunchMsaView/components/ManualMSALoader/launchView.js +4 -2
  9. package/dist/LaunchMsaView/components/OrthologQuery/OrthologPanel.js +1 -1
  10. package/dist/LaunchMsaView/components/OrthologQuery/orthologLaunchView.js +4 -2
  11. package/dist/LaunchMsaView/components/PreLoadedMSA/PreLoadedMSADataPanel.js +1 -1
  12. package/dist/LaunchMsaView/components/PreLoadedMSA/preCalculatedLaunchView.js +4 -2
  13. package/dist/LaunchMsaView/components/QueryRowSelector.d.ts +16 -0
  14. package/dist/LaunchMsaView/components/QueryRowSelector.js +38 -0
  15. package/dist/LaunchMsaView/components/SubmitCancelActions.d.ts +4 -1
  16. package/dist/LaunchMsaView/components/SubmitCancelActions.js +34 -10
  17. package/dist/LaunchMsaView/components/SubmitCancelActions.test.d.ts +1 -0
  18. package/dist/LaunchMsaView/components/SubmitCancelActions.test.js +55 -0
  19. package/dist/LaunchMsaView/detectQueryRow.d.ts +23 -0
  20. package/dist/LaunchMsaView/detectQueryRow.js +94 -0
  21. package/dist/LaunchMsaView/detectQueryRow.test.d.ts +1 -0
  22. package/dist/LaunchMsaView/detectQueryRow.test.js +65 -0
  23. package/dist/LaunchMsaView/useQueryRowName.d.ts +15 -0
  24. package/dist/LaunchMsaView/useQueryRowName.js +26 -0
  25. package/dist/LaunchMsaViewExtensionPoint/index.js +2 -2
  26. package/dist/MsaViewPanel/afterCreateAutoruns.d.ts +27 -11
  27. package/dist/MsaViewPanel/afterCreateAutoruns.js +96 -47
  28. package/dist/MsaViewPanel/observeProteinHighlights.test.d.ts +1 -0
  29. package/dist/MsaViewPanel/observeProteinHighlights.test.js +209 -0
  30. package/dist/MsaViewPanel/structureConnection.d.ts +6 -0
  31. package/dist/index.js +4 -1
  32. package/dist/jbrowse-plugin-msaview.umd.production.min.js +28 -28
  33. package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +4 -4
  34. package/dist/utils/launchMsaView.d.ts +19 -0
  35. package/dist/utils/launchMsaView.js +13 -0
  36. package/dist/utils/workspaces.d.ts +34 -0
  37. package/dist/utils/workspaces.js +100 -0
  38. package/dist/utils/workspaces.test.d.ts +1 -0
  39. package/dist/utils/workspaces.test.js +100 -0
  40. package/dist/version.d.ts +1 -1
  41. package/dist/version.js +1 -1
  42. package/package.json +6 -1
  43. package/src/LaunchMsaView/components/BlastQuery/BlastAutomaticPanel.tsx +1 -0
  44. package/src/LaunchMsaView/components/BlastQuery/BlastManualPanel.tsx +127 -30
  45. package/src/LaunchMsaView/components/BlastQuery/blastLaunchView.ts +7 -4
  46. package/src/LaunchMsaView/components/BlastQuery/consts.ts +8 -1
  47. package/src/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.tsx +8 -37
  48. package/src/LaunchMsaView/components/ManualMSALoader/launchView.ts +5 -2
  49. package/src/LaunchMsaView/components/OrthologQuery/OrthologPanel.tsx +1 -1
  50. package/src/LaunchMsaView/components/OrthologQuery/orthologLaunchView.ts +5 -2
  51. package/src/LaunchMsaView/components/PreLoadedMSA/PreLoadedMSADataPanel.tsx +1 -0
  52. package/src/LaunchMsaView/components/PreLoadedMSA/preCalculatedLaunchView.ts +5 -2
  53. package/src/LaunchMsaView/components/QueryRowSelector.tsx +93 -0
  54. package/src/LaunchMsaView/components/SubmitCancelActions.test.tsx +95 -0
  55. package/src/LaunchMsaView/components/SubmitCancelActions.tsx +80 -22
  56. package/src/LaunchMsaView/detectQueryRow.test.ts +79 -0
  57. package/src/LaunchMsaView/detectQueryRow.ts +132 -0
  58. package/src/LaunchMsaView/useQueryRowName.ts +33 -0
  59. package/src/LaunchMsaViewExtensionPoint/index.ts +21 -2
  60. package/src/MsaViewPanel/afterCreateAutoruns.ts +106 -51
  61. package/src/MsaViewPanel/observeProteinHighlights.test.ts +264 -0
  62. package/src/MsaViewPanel/structureConnection.ts +7 -0
  63. package/src/index.ts +4 -1
  64. package/src/utils/launchMsaView.ts +30 -0
  65. package/src/utils/workspaces.test.ts +132 -0
  66. package/src/utils/workspaces.ts +146 -0
  67. package/src/version.ts +1 -1
@@ -0,0 +1,146 @@
1
+ import type { AbstractSessionModel } from '@jbrowse/core/util'
2
+
3
+ /**
4
+ * Where a launched MSA view lands. Every launch names one of these and stops
5
+ * there, so a host that arranges views differently is one function to teach.
6
+ *
7
+ * stack append below whatever is on screen
8
+ * splitRight its own cell to the right, beside the view it is connected to
9
+ * newTab its own tab in the current cell
10
+ */
11
+ export type MsaViewPlacement = 'stack' | 'splitRight' | 'newTab'
12
+
13
+ const PLACEMENTS: MsaViewPlacement[] = ['stack', 'splitRight', 'newTab']
14
+
15
+ /**
16
+ * What the dialog does unasked. Side-by-side, because a launch from a gene
17
+ * feature sets `connectedViewId`: the pair shares a hover and a highlight, and
18
+ * reads as a split. A session spec defaults to `stack` instead.
19
+ */
20
+ export const DEFAULT_LAUNCH_PLACEMENT: MsaViewPlacement = 'splitRight'
21
+
22
+ export const LAUNCH_PLACEMENT_KEY = 'msaView-launchPlacement'
23
+
24
+ /**
25
+ * The session actions that place a view in a tiled workspace. Only jbrowse-web
26
+ * and desktop have them, so feature-detect rather than import.
27
+ */
28
+ interface SessionWithWorkspaces {
29
+ setUseWorkspaces: (useWorkspaces: boolean) => void
30
+ setPendingMove: (move: {
31
+ type: 'newTab' | 'splitRight'
32
+ viewId: string
33
+ }) => void
34
+ }
35
+
36
+ function hasAction(session: AbstractSessionModel, name: string) {
37
+ return (
38
+ name in session &&
39
+ typeof (session as unknown as Record<string, unknown>)[name] === 'function'
40
+ )
41
+ }
42
+
43
+ // Warned at most once. This is a property of the host, so the answer is the
44
+ // same on every launch and a dialog the user reopens should not stack up noise.
45
+ let warnedPartial = false
46
+
47
+ export function resetWorkspacesWarning() {
48
+ warnedPartial = false
49
+ }
50
+
51
+ /**
52
+ * Whether this host can honor anything other than `stack`. Silent: the dialog
53
+ * asks on every render, and only a launch is worth warning about.
54
+ */
55
+ export function sessionSupportsPlacement(session: AbstractSessionModel) {
56
+ return (
57
+ hasAction(session, 'setUseWorkspaces') &&
58
+ hasAction(session, 'setPendingMove')
59
+ )
60
+ }
61
+
62
+ function isSessionWithWorkspaces(
63
+ session: AbstractSessionModel,
64
+ ): session is AbstractSessionModel & SessionWithWorkspaces {
65
+ const canEnable = hasAction(session, 'setUseWorkspaces')
66
+ const canPlace = hasAction(session, 'setPendingMove')
67
+
68
+ // Missing BOTH is an embedded session: it has no workspaces, there is nothing
69
+ // to ask for, and silence is the right answer.
70
+ //
71
+ // Missing ONE is a host that has workspaces but places views some other way,
72
+ // and silence there is how the same feature broke in jbrowse-plugin-protein3d
73
+ // — jbrowse-web folded `setPendingMove` into its layout `init`, the guard went
74
+ // false, and the plugin simply stopped asking: no error, no missing feature,
75
+ // two views quietly stacking, nobody noticed for weeks. Feature detection
76
+ // cannot ask a host to announce a change, but it can tell "not supported here"
77
+ // from "supported, and gone".
78
+ //
79
+ // Two very different hosts produce this one shape and nothing on the session
80
+ // tells them apart, so the message carries both rather than a guess:
81
+ //
82
+ // - releases through v4.3.0, where placement is `setPendingMoveToSplitRight`,
83
+ // a module function in @jbrowse/app-core rather than a session action.
84
+ // Nothing is wrong and nothing needs fixing
85
+ // - a newer host that moved the action out from under us, which is the
86
+ // regression this warning exists to catch
87
+ //
88
+ // Do not quiet the first case by sniffing the version. The alarm is only worth
89
+ // having if it fires on a shape it cannot explain, and these two are identical.
90
+ if (canEnable !== canPlace && !warnedPartial) {
91
+ warnedPartial = true
92
+ console.warn(
93
+ `jbrowse-plugin-msaview: this session supports workspaces but not ` +
94
+ `${canPlace ? 'setUseWorkspaces' : 'setPendingMove'}, so the MSA view ` +
95
+ `was stacked instead of tiled. Expected on releases through v4.3.0, ` +
96
+ `which place views through @jbrowse/app-core instead; on a newer host ` +
97
+ `it means the session API moved and the plugin needs updating to match.`,
98
+ )
99
+ }
100
+ return canEnable && canPlace
101
+ }
102
+
103
+ /**
104
+ * Put a freshly added view where the launch said to. `stack` is a placement
105
+ * rather than the absence of one, so no caller has to ask what host it is on.
106
+ */
107
+ export function placeMsaView(
108
+ session: AbstractSessionModel,
109
+ viewId: string,
110
+ placement: MsaViewPlacement,
111
+ ) {
112
+ if (placement === 'stack' || !isSessionWithWorkspaces(session)) {
113
+ return
114
+ }
115
+ session.setPendingMove({ type: placement, viewId })
116
+ // Session-scoped: turning workspaces on for this session leaves the user's
117
+ // own default alone, which is what `setUseWorkspaces` (as against
118
+ // `setUseWorkspacesPreference`) is for.
119
+ session.setUseWorkspaces(true)
120
+ }
121
+
122
+ function isPlacement(value: unknown): value is MsaViewPlacement {
123
+ return PLACEMENTS.includes(value as MsaViewPlacement)
124
+ }
125
+
126
+ /**
127
+ * The dialog's own remembered choice — not the host's preferences system, which
128
+ * records whether the user likes workspaces and does not exist everywhere.
129
+ */
130
+ export function readLaunchPlacement(): MsaViewPlacement {
131
+ try {
132
+ const stored = globalThis.localStorage.getItem(LAUNCH_PLACEMENT_KEY)
133
+ return isPlacement(stored) ? stored : DEFAULT_LAUNCH_PLACEMENT
134
+ } catch (error) {
135
+ console.error(error)
136
+ return DEFAULT_LAUNCH_PLACEMENT
137
+ }
138
+ }
139
+
140
+ export function writeLaunchPlacement(placement: MsaViewPlacement) {
141
+ try {
142
+ globalThis.localStorage.setItem(LAUNCH_PLACEMENT_KEY, placement)
143
+ } catch (error) {
144
+ console.error(error)
145
+ }
146
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '3.0.0'
1
+ export const version = '3.2.0'