react-msaview 5.1.1 → 5.2.1
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.
- package/README.md +41 -8
- package/bundle/index.js +17 -17
- package/bundle/index.js.LICENSE.txt +1 -1
- package/bundle/index.js.map +1 -1
- package/dist/calculateBlocks.d.ts +4 -10
- package/dist/calculateBlocks.js +12 -20
- package/dist/calculateBlocks.js.map +1 -1
- package/dist/components/ConservationTrack.js +20 -37
- package/dist/components/ConservationTrack.js.map +1 -1
- package/dist/components/MSAView.js +8 -1
- package/dist/components/MSAView.js.map +1 -1
- package/dist/components/ResizeHandles.d.ts +3 -0
- package/dist/components/ResizeHandles.js +60 -105
- package/dist/components/ResizeHandles.js.map +1 -1
- package/dist/components/TextTrack.js +25 -34
- package/dist/components/TextTrack.js.map +1 -1
- package/dist/components/Track.js +1 -1
- package/dist/components/Track.js.map +1 -1
- package/dist/components/VerticalScrollbar.js +2 -2
- package/dist/components/VerticalScrollbar.js.map +1 -1
- package/dist/components/dialogs/ExportSVGDialog.js +20 -20
- package/dist/components/dialogs/ExportSVGDialog.js.map +1 -1
- package/dist/components/dialogs/InterProScanDialog.js +6 -1
- package/dist/components/dialogs/InterProScanDialog.js.map +1 -1
- package/dist/components/dialogs/UserProvidedDomainsDialog.js +1 -2
- package/dist/components/dialogs/UserProvidedDomainsDialog.js.map +1 -1
- package/dist/components/header/ColorSchemeMenu.js +1 -1
- package/dist/components/header/ColorSchemeMenu.js.map +1 -1
- package/dist/components/header/FileMenu.js +3 -2
- package/dist/components/header/FileMenu.js.map +1 -1
- package/dist/components/header/Header.js +1 -1
- package/dist/components/header/HeaderInfoArea.js +28 -8
- package/dist/components/header/HeaderInfoArea.js.map +1 -1
- package/dist/components/header/MSASettingsMenu.js +1 -1
- package/dist/components/header/MSASettingsMenu.js.map +1 -1
- package/dist/components/header/TreeSettingsMenu.js +1 -1
- package/dist/components/header/TreeSettingsMenu.js.map +1 -1
- package/dist/components/header/ZoomControls.js +7 -2
- package/dist/components/header/ZoomControls.js.map +1 -1
- package/dist/components/header/ZoomMenu.js +9 -0
- package/dist/components/header/ZoomMenu.js.map +1 -1
- package/dist/components/header/settingsMenuItems.js +24 -8
- package/dist/components/header/settingsMenuItems.js.map +1 -1
- package/dist/components/minimap/Minimap.js +6 -17
- package/dist/components/minimap/Minimap.js.map +1 -1
- package/dist/components/minimap/MinimapSVG.js +7 -17
- package/dist/components/minimap/MinimapSVG.js.map +1 -1
- package/dist/components/minimap/minimapLayout.d.ts +9 -0
- package/dist/components/minimap/minimapLayout.js +15 -0
- package/dist/components/minimap/minimapLayout.js.map +1 -0
- package/dist/components/msa/MSACanvas.js +6 -1
- package/dist/components/msa/MSACanvas.js.map +1 -1
- package/dist/components/msa/MSACanvasBlock.js +5 -1
- package/dist/components/msa/MSACanvasBlock.js.map +1 -1
- package/dist/components/msa/MSAMouseoverCanvas.js +2 -2
- package/dist/components/msa/MSAMouseoverCanvas.js.map +1 -1
- package/dist/components/msa/getVisibleLeaves.d.ts +6 -0
- package/dist/components/msa/getVisibleLeaves.js +9 -0
- package/dist/components/msa/getVisibleLeaves.js.map +1 -0
- package/dist/components/msa/renderBoxFeatureCanvasBlock.d.ts +2 -1
- package/dist/components/msa/renderBoxFeatureCanvasBlock.js +5 -6
- package/dist/components/msa/renderBoxFeatureCanvasBlock.js.map +1 -1
- package/dist/components/msa/renderMSABlock.d.ts +2 -1
- package/dist/components/msa/renderMSABlock.js +100 -88
- package/dist/components/msa/renderMSABlock.js.map +1 -1
- package/dist/components/msa/renderMSAMouseover.js +5 -4
- package/dist/components/msa/renderMSAMouseover.js.map +1 -1
- package/dist/components/msa/visibleColRange.d.ts +8 -0
- package/dist/components/msa/visibleColRange.js +10 -0
- package/dist/components/msa/visibleColRange.js.map +1 -0
- package/dist/components/renderCtx.d.ts +7 -0
- package/dist/components/renderCtx.js +2 -0
- package/dist/components/renderCtx.js.map +1 -0
- package/dist/components/tracks/renderTracksSvg.d.ts +6 -5
- package/dist/components/tracks/renderTracksSvg.js +13 -5
- package/dist/components/tracks/renderTracksSvg.js.map +1 -1
- package/dist/components/tree/TreeCanvas.js.map +1 -1
- package/dist/components/tree/TreeCanvasBlock.js +2 -10
- package/dist/components/tree/TreeCanvasBlock.js.map +1 -1
- package/dist/components/tree/renderTreeCanvas.d.ts +5 -4
- package/dist/components/tree/renderTreeCanvas.js +18 -26
- package/dist/components/tree/renderTreeCanvas.js.map +1 -1
- package/dist/components/util.d.ts +0 -14
- package/dist/components/util.js +0 -58
- package/dist/components/util.js.map +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +7 -0
- package/dist/constants.js.map +1 -1
- package/dist/flatToTree.js +6 -0
- package/dist/flatToTree.js.map +1 -1
- package/dist/hierarchy.d.ts +3 -1
- package/dist/hierarchy.js +142 -89
- package/dist/hierarchy.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/launchInterProScan.js +22 -9
- package/dist/launchInterProScan.js.map +1 -1
- package/dist/measureTextCanvas.js +2 -1
- package/dist/measureTextCanvas.js.map +1 -1
- package/dist/model.d.ts +234 -176
- package/dist/model.js +285 -259
- package/dist/model.js.map +1 -1
- package/dist/parseAsn1.js +8 -2
- package/dist/parseAsn1.js.map +1 -1
- package/dist/renderToSvg.d.ts +1 -1
- package/dist/renderToSvg.js +43 -46
- package/dist/renderToSvg.js.map +1 -1
- package/dist/rowCoordinateCalculations.d.ts +0 -9
- package/dist/rowCoordinateCalculations.js +0 -20
- package/dist/rowCoordinateCalculations.js.map +1 -1
- package/dist/setFontSize.d.ts +3 -0
- package/dist/setFontSize.js +14 -0
- package/dist/setFontSize.js.map +1 -0
- package/dist/useDevicePixelRatio.d.ts +1 -0
- package/dist/useDevicePixelRatio.js +27 -0
- package/dist/useDevicePixelRatio.js.map +1 -0
- package/dist/useWheelScroll.d.ts +3 -1
- package/dist/useWheelScroll.js +64 -22
- package/dist/useWheelScroll.js.map +1 -1
- package/dist/util.d.ts +5 -0
- package/dist/util.js +59 -1
- package/dist/util.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/webpack.js +0 -1
- package/dist/webpack.js.map +1 -1
- package/dist/wheelZoom.d.ts +4 -0
- package/dist/wheelZoom.js +43 -0
- package/dist/wheelZoom.js.map +1 -0
- package/package.json +5 -5
- package/src/calculateBlocks.ts +18 -51
- package/src/components/ConservationTrack.tsx +20 -45
- package/src/components/MSAView.tsx +10 -1
- package/src/components/ResizeHandles.tsx +101 -113
- package/src/components/TextTrack.tsx +31 -38
- package/src/components/Track.tsx +1 -1
- package/src/components/VerticalScrollbar.tsx +2 -2
- package/src/components/dialogs/ExportSVGDialog.tsx +27 -17
- package/src/components/dialogs/InterProScanDialog.tsx +6 -1
- package/src/components/dialogs/UserProvidedDomainsDialog.tsx +1 -2
- package/src/components/header/ColorSchemeMenu.tsx +1 -0
- package/src/components/header/FileMenu.tsx +3 -1
- package/src/components/header/Header.tsx +1 -1
- package/src/components/header/HeaderInfoArea.tsx +32 -7
- package/src/components/header/MSASettingsMenu.tsx +1 -0
- package/src/components/header/TreeSettingsMenu.tsx +1 -0
- package/src/components/header/ZoomControls.tsx +14 -1
- package/src/components/header/ZoomMenu.tsx +10 -0
- package/src/components/header/settingsMenuItems.ts +24 -8
- package/src/components/minimap/Minimap.tsx +6 -20
- package/src/components/minimap/MinimapSVG.tsx +10 -27
- package/src/components/minimap/minimapLayout.ts +17 -0
- package/src/components/msa/MSACanvas.tsx +9 -0
- package/src/components/msa/MSACanvasBlock.tsx +7 -1
- package/src/components/msa/MSAMouseoverCanvas.tsx +4 -3
- package/src/components/msa/getVisibleLeaves.ts +21 -0
- package/src/components/msa/renderBoxFeatureCanvasBlock.ts +9 -9
- package/src/components/msa/renderMSABlock.ts +123 -125
- package/src/components/msa/renderMSAMouseover.ts +5 -4
- package/src/components/msa/visibleColRange.ts +17 -0
- package/src/components/renderCtx.ts +29 -0
- package/src/components/tracks/renderTracksSvg.ts +20 -10
- package/src/components/tree/TreeCanvas.tsx +3 -1
- package/src/components/tree/TreeCanvasBlock.tsx +2 -12
- package/src/components/tree/renderTreeCanvas.ts +27 -30
- package/src/components/util.ts +0 -81
- package/src/constants.ts +8 -0
- package/src/flatToTree.test.ts +30 -0
- package/src/flatToTree.ts +10 -1
- package/src/hierarchy.test.ts +53 -1
- package/src/hierarchy.ts +153 -100
- package/src/index.ts +8 -0
- package/src/launchInterProScan.ts +33 -11
- package/src/measureTextCanvas.ts +3 -1
- package/src/model.ts +359 -306
- package/src/parseAsn1.test.ts +6 -0
- package/src/parseAsn1.ts +11 -3
- package/src/renderToSvg.tsx +99 -95
- package/src/rowCoordinateCalculations.test.ts +0 -51
- package/src/rowCoordinateCalculations.ts +0 -23
- package/src/setFontSize.test.ts +33 -0
- package/src/setFontSize.ts +20 -0
- package/src/useDevicePixelRatio.ts +29 -0
- package/src/useWheelScroll.ts +79 -21
- package/src/util.ts +60 -1
- package/src/version.ts +1 -1
- package/src/webpack.ts +0 -1
- package/src/wheelZoom.test.ts +46 -0
- package/src/wheelZoom.ts +47 -0
package/src/util.ts
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
import { colord, extend } from 'colord'
|
|
2
|
+
import a11yPlugin from 'colord/plugins/a11y'
|
|
2
3
|
import namesPlugin from 'colord/plugins/names'
|
|
3
4
|
|
|
4
5
|
import type { Theme } from '@mui/material'
|
|
5
6
|
|
|
6
|
-
extend([namesPlugin])
|
|
7
|
+
extend([namesPlugin, a11yPlugin])
|
|
8
|
+
|
|
9
|
+
const contrastAdjustCache = new Map<string, string>()
|
|
10
|
+
|
|
11
|
+
// Adjusts a background-tile color until it meets WCAG AA (4.5:1) contrast
|
|
12
|
+
// against `bg`, so it can be used as letter text in letter-color mode.
|
|
13
|
+
// Darkens on light backgrounds, lightens on dark backgrounds.
|
|
14
|
+
export function adjustColorForContrast(color: string, bg: string): string {
|
|
15
|
+
const cacheKey = `${color}|${bg}`
|
|
16
|
+
const cached = contrastAdjustCache.get(cacheKey)
|
|
17
|
+
if (cached !== undefined) {
|
|
18
|
+
return cached
|
|
19
|
+
}
|
|
20
|
+
let c = colord(color)
|
|
21
|
+
if (!c.isReadable(bg)) {
|
|
22
|
+
const bgIsDark = colord(bg).luminance() < 0.5
|
|
23
|
+
for (let i = 0; i < 40 && !c.isReadable(bg); i++) {
|
|
24
|
+
c = bgIsDark ? c.lighten(0.05) : c.darken(0.05)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const result = c.toHex()
|
|
28
|
+
contrastAdjustCache.set(cacheKey, result)
|
|
29
|
+
return result
|
|
30
|
+
}
|
|
7
31
|
|
|
8
32
|
export function transform<T>(
|
|
9
33
|
obj: Record<string, T>,
|
|
@@ -40,6 +64,41 @@ export function skipBlanks(blanks: number[], str: string) {
|
|
|
40
64
|
return chunks.join('')
|
|
41
65
|
}
|
|
42
66
|
|
|
67
|
+
export function computeRowInsertions(blanks: number[], seq: string) {
|
|
68
|
+
const insertions: { pos: number; letters: string }[] = []
|
|
69
|
+
const blanksLen = blanks.length
|
|
70
|
+
let displayPos = 0
|
|
71
|
+
let blankIdx = 0
|
|
72
|
+
let currentInsertPos = -1
|
|
73
|
+
let letterChars: string[] = []
|
|
74
|
+
for (let i = 0; i < seq.length; i++) {
|
|
75
|
+
if (blankIdx < blanksLen && blanks[blankIdx] === i) {
|
|
76
|
+
// bit trick: (code - 45) >>> 0 <= 1 checks for '-' (45) or '.' (46)
|
|
77
|
+
if (!((seq.charCodeAt(i) - 45) >>> 0 <= 1)) {
|
|
78
|
+
if (currentInsertPos === displayPos) {
|
|
79
|
+
letterChars.push(seq[i]!)
|
|
80
|
+
} else {
|
|
81
|
+
if (letterChars.length > 0) {
|
|
82
|
+
insertions.push({
|
|
83
|
+
pos: currentInsertPos,
|
|
84
|
+
letters: letterChars.join(''),
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
currentInsertPos = displayPos
|
|
88
|
+
letterChars = [seq[i]!]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
blankIdx++
|
|
92
|
+
} else {
|
|
93
|
+
displayPos++
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (letterChars.length > 0) {
|
|
97
|
+
insertions.push({ pos: currentInsertPos, letters: letterChars.join('') })
|
|
98
|
+
}
|
|
99
|
+
return insertions
|
|
100
|
+
}
|
|
101
|
+
|
|
43
102
|
export function len(a: { end: number; start: number }) {
|
|
44
103
|
return a.end - a.start
|
|
45
104
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.2.1'
|
package/src/webpack.ts
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getZoomNormalizer,
|
|
5
|
+
normalizeWheelDelta,
|
|
6
|
+
zoomFactorFromAccum,
|
|
7
|
+
} from './wheelZoom.ts'
|
|
8
|
+
|
|
9
|
+
describe('normalizeWheelDelta', () => {
|
|
10
|
+
test('pixel mode passes through', () => {
|
|
11
|
+
expect(normalizeWheelDelta(120, 0)).toBe(120)
|
|
12
|
+
})
|
|
13
|
+
test('line mode scales to pixels', () => {
|
|
14
|
+
expect(normalizeWheelDelta(3, 1)).toBe(48)
|
|
15
|
+
})
|
|
16
|
+
test('page mode scales to pixels', () => {
|
|
17
|
+
expect(normalizeWheelDelta(2, 2)).toBe(200)
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('getZoomNormalizer', () => {
|
|
22
|
+
test('tiny pinch deltas get the smallest divisor (largest step)', () => {
|
|
23
|
+
expect(getZoomNormalizer(3)).toBe(25)
|
|
24
|
+
})
|
|
25
|
+
test('large mouse notches get the largest divisor (finest step)', () => {
|
|
26
|
+
expect(getZoomNormalizer(200)).toBe(500)
|
|
27
|
+
})
|
|
28
|
+
test('medium deltas land in between', () => {
|
|
29
|
+
expect(getZoomNormalizer(50)).toBe(150)
|
|
30
|
+
expect(getZoomNormalizer(20)).toBe(75)
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe('zoomFactorFromAccum', () => {
|
|
35
|
+
test('negative accum zooms in (factor > 1)', () => {
|
|
36
|
+
expect(zoomFactorFromAccum(-0.1, 16.67)).toBeCloseTo(1.1)
|
|
37
|
+
})
|
|
38
|
+
test('positive accum zooms out (factor < 1)', () => {
|
|
39
|
+
expect(zoomFactorFromAccum(0.1, 16.67)).toBeCloseTo(1 / 1.1)
|
|
40
|
+
})
|
|
41
|
+
test('rate-limits a big burst to ~0.2 per frame', () => {
|
|
42
|
+
// a huge accumulated delta cannot zoom more than the per-frame cap
|
|
43
|
+
expect(zoomFactorFromAccum(99, 16.67)).toBeCloseTo(1 / 1.2, 2)
|
|
44
|
+
expect(zoomFactorFromAccum(-99, 16.67)).toBeCloseTo(1.2, 2)
|
|
45
|
+
})
|
|
46
|
+
})
|
package/src/wheelZoom.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Wheel / trackpad-pinch delta handling, adapted from @jbrowse/core's
|
|
2
|
+
// util/wheelZoom (not yet in our pinned @jbrowse/core). Turns raw wheel deltas
|
|
3
|
+
// into a per-frame zoom factor that feels consistent across fine trackpad
|
|
4
|
+
// pinches and coarse mouse notches.
|
|
5
|
+
|
|
6
|
+
// Fixed divisor for plain-wheel scroll-zoom mode, where deltas are big notches.
|
|
7
|
+
export const SCROLL_ZOOM_DIVISOR = 500
|
|
8
|
+
|
|
9
|
+
// Cap the zoom change per millisecond so a burst of momentum-scroll events
|
|
10
|
+
// coalesced into one frame can't jump the zoom level (0.2 per ~60fps frame).
|
|
11
|
+
const MAX_ZOOM_RATE_PER_MS = 0.2 / 16.67
|
|
12
|
+
|
|
13
|
+
// Convert a wheel delta to pixels regardless of the browser's deltaMode; some
|
|
14
|
+
// browsers/mice report lines or pages instead of pixels.
|
|
15
|
+
export function normalizeWheelDelta(delta: number, mode: number) {
|
|
16
|
+
if (mode === 1) {
|
|
17
|
+
return delta * 16 // DOM_DELTA_LINE
|
|
18
|
+
}
|
|
19
|
+
if (mode === 2) {
|
|
20
|
+
return delta * 100 // DOM_DELTA_PAGE
|
|
21
|
+
}
|
|
22
|
+
return delta // DOM_DELTA_PIXEL
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Adaptive divisor: tiny pinch deltas zoom in larger steps, big mouse notches
|
|
26
|
+
// in finer steps, so a trackpad pinch and a mouse wheel feel similar.
|
|
27
|
+
export function getZoomNormalizer(deltaY: number) {
|
|
28
|
+
const abs = Math.abs(deltaY)
|
|
29
|
+
if (abs < 6) {
|
|
30
|
+
return 25
|
|
31
|
+
}
|
|
32
|
+
if (abs > 150) {
|
|
33
|
+
return 500
|
|
34
|
+
}
|
|
35
|
+
if (abs > 30) {
|
|
36
|
+
return 150
|
|
37
|
+
}
|
|
38
|
+
return 75
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Turn accumulated, normalized zoom intent into a colWidth/rowHeight multiplier.
|
|
42
|
+
// Positive accum (wheel toward user) zooms out (factor < 1); negative zooms in.
|
|
43
|
+
export function zoomFactorFromAccum(zoomAccum: number, elapsedMs: number) {
|
|
44
|
+
const max = MAX_ZOOM_RATE_PER_MS * elapsedMs
|
|
45
|
+
const d = Math.max(-max, Math.min(max, zoomAccum))
|
|
46
|
+
return d > 0 ? 1 / (1 + d) : 1 - d
|
|
47
|
+
}
|