@jbrowse/core 2.11.1 → 2.11.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.
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const react_1 = __importStar(require("react"));
30
30
  const material_1 = require("@mui/material");
31
+ const mui_1 = require("tss-react/mui");
31
32
  const source_map_js_1 = require("source-map-js");
32
33
  const copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard"));
33
34
  // locals
@@ -90,7 +91,7 @@ async function mapStackTrace(stack) {
90
91
  mappedStack.push(line);
91
92
  continue;
92
93
  }
93
- mappedStack.push(`${originalPosition.source}:${originalPosition.line}:${originalPosition.column + 1}`);
94
+ mappedStack.push(`${originalPosition.source}:${originalPosition.line}:${originalPosition.column + 1} (${match[1].trim()})`);
94
95
  }
95
96
  return mappedStack.join('\n');
96
97
  }
@@ -107,7 +108,17 @@ function stripMessage(trace, error) {
107
108
  return trace;
108
109
  }
109
110
  }
111
+ const useStyles = (0, mui_1.makeStyles)()(theme => ({
112
+ pre: {
113
+ background: (0, material_1.alpha)(theme.palette.error.main, 0.2),
114
+ border: `1px solid ${theme.palette.divider}`,
115
+ overflow: 'auto',
116
+ margin: 20,
117
+ maxHeight: 300,
118
+ },
119
+ }));
110
120
  function Contents({ text, extra }) {
121
+ const { classes } = useStyles();
111
122
  const err = encodeURIComponent([
112
123
  'I got this error from JBrowse, here is the stack trace:\n',
113
124
  '```',
@@ -129,13 +140,7 @@ function Contents({ text, extra }) {
129
140
  " or send an email to ",
130
141
  react_1.default.createElement(Link2, { href: emailLink }, email),
131
142
  ' '),
132
- react_1.default.createElement("pre", { style: {
133
- background: 'lightgrey',
134
- border: '1px solid black',
135
- overflow: 'auto',
136
- margin: 20,
137
- maxHeight: 300,
138
- } }, err2)));
143
+ react_1.default.createElement("pre", { className: classes.pre }, err2)));
139
144
  }
140
145
  function ErrorMessageStackTraceDialog({ error, onClose, extra, }) {
141
146
  const [mappedStackTrace, setMappedStackTrace] = (0, react_1.useState)();
@@ -21,6 +21,7 @@ export declare class BlockSet {
21
21
  get totalBp(): number;
22
22
  }
23
23
  export declare class BaseBlock {
24
+ type: string;
24
25
  regionNumber?: number;
25
26
  reversed?: boolean;
26
27
  refName: string;
@@ -45,12 +46,14 @@ export declare class BaseBlock {
45
46
  };
46
47
  }
47
48
  export declare class ContentBlock extends BaseBlock {
49
+ type: string;
48
50
  }
49
51
  /**
50
52
  * marker block representing one or more blocks that are
51
53
  * too small to be shown at the current zoom level
52
54
  */
53
55
  export declare class ElidedBlock extends BaseBlock {
56
+ type: string;
54
57
  widthPx: number;
55
58
  elidedBlockCount: number;
56
59
  constructor(data: Record<string, any>);
@@ -61,5 +64,6 @@ export declare class ElidedBlock extends BaseBlock {
61
64
  * and provides a thick border between them
62
65
  */
63
66
  export declare class InterRegionPaddingBlock extends BaseBlock {
67
+ type: string;
64
68
  }
65
69
  export {};
@@ -7,9 +7,10 @@ class BlockSet {
7
7
  this.blocks = blocks;
8
8
  }
9
9
  push(block) {
10
- if (block instanceof ElidedBlock && this.blocks.length > 0) {
10
+ if (block.type === 'ElidedBlock' && this.blocks.length > 0) {
11
11
  const lastBlock = this.blocks.at(-1);
12
- if (lastBlock instanceof ElidedBlock) {
12
+ if ((lastBlock === null || lastBlock === void 0 ? void 0 : lastBlock.type) === 'ElidedBlock') {
13
+ ;
13
14
  lastBlock.push(block);
14
15
  return;
15
16
  }
@@ -49,7 +50,7 @@ class BlockSet {
49
50
  return this.blocks.length > 0 ? this.blocks[0].offsetPx : 0;
50
51
  }
51
52
  get contentBlocks() {
52
- return this.blocks.filter(block => block instanceof ContentBlock);
53
+ return this.blocks.filter(block => block.type === 'ContentBlock');
53
54
  }
54
55
  get totalBp() {
55
56
  return (0, _1.sum)(this.contentBlocks.map(block => block.end - block.start));
@@ -62,6 +63,7 @@ class BaseBlock {
62
63
  */
63
64
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
65
  constructor(data) {
66
+ this.type = 'BaseBlock';
65
67
  this.widthPx = 0;
66
68
  Object.assign(this, data);
67
69
  this.assemblyName = data.assemblyName;
@@ -83,6 +85,10 @@ class BaseBlock {
83
85
  }
84
86
  exports.BaseBlock = BaseBlock;
85
87
  class ContentBlock extends BaseBlock {
88
+ constructor() {
89
+ super(...arguments);
90
+ this.type = 'ContentBlock';
91
+ }
86
92
  }
87
93
  exports.ContentBlock = ContentBlock;
88
94
  /**
@@ -93,6 +99,7 @@ class ElidedBlock extends BaseBlock {
93
99
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
100
  constructor(data) {
95
101
  super(data);
102
+ this.type = 'ElidedBlock';
96
103
  this.elidedBlockCount = 0;
97
104
  this.widthPx = data.widthPx;
98
105
  }
@@ -112,5 +119,9 @@ exports.ElidedBlock = ElidedBlock;
112
119
  * and provides a thick border between them
113
120
  */
114
121
  class InterRegionPaddingBlock extends BaseBlock {
122
+ constructor() {
123
+ super(...arguments);
124
+ this.type = 'InterRegionPaddingBlock';
125
+ }
115
126
  }
116
127
  exports.InterRegionPaddingBlock = InterRegionPaddingBlock;
@@ -38,10 +38,9 @@ function calculateDynamicBlocks(model, padding = true, elision = true) {
38
38
  const displayedRegionRightPx = displayedRegionLeftPx + (regionEnd - regionStart) / bpPerPx;
39
39
  const regionWidthPx = (regionEnd - regionStart) / bpPerPx;
40
40
  const parentRegion = (0, mobx_state_tree_1.isStateTreeNode)(region) ? (0, mobx_state_tree_1.getSnapshot)(region) : region;
41
- if (displayedRegionLeftPx < windowRightPx &&
42
- displayedRegionRightPx > windowLeftPx) {
41
+ const [leftPx, rightPx] = (0, range_1.intersection2)(windowLeftPx, windowRightPx, displayedRegionLeftPx, displayedRegionRightPx);
42
+ if (leftPx !== undefined && rightPx !== undefined) {
43
43
  // this displayed region overlaps the view, so make a record for it
44
- const [leftPx, rightPx] = (0, range_1.intersection2)(windowLeftPx, windowRightPx, displayedRegionLeftPx, displayedRegionRightPx);
45
44
  let start;
46
45
  let end;
47
46
  let isLeftEndOfDisplayedRegion;
package/util/range.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @returns array of [left, right], or [] if the ranges do not intersect. the choice of [] is because it allows destructuring array assignment without check for undefined return
7
7
  */
8
- export declare function intersection2(left1: number, right1: number, left2: number, right2: number): number[];
8
+ export declare function intersection2(left1: number, right1: number, left2: number, right2: number): [number, number] | [];
9
9
  /**
10
10
  * Return whether 2 interbase coordinate ranges intersect.
11
11
  *
package/ui/ResizeBar.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- export default function ResizeBar({ widths, setWidths, checkbox, scrollLeft, }: {
3
- widths: number[];
4
- setWidths: (arg: number[]) => void;
5
- checkbox?: boolean;
6
- scrollLeft?: number;
7
- }): React.JSX.Element;
package/ui/ResizeBar.js DELETED
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const react_1 = __importStar(require("react"));
30
- const mui_1 = require("tss-react/mui");
31
- // locals
32
- const ResizeHandle_1 = __importDefault(require("./ResizeHandle"));
33
- const useStyles = (0, mui_1.makeStyles)()(theme => ({
34
- resizeBar: {
35
- background: theme.palette.action.disabledBackground,
36
- height: 12,
37
- position: 'relative',
38
- overflow: 'hidden',
39
- },
40
- tick: {
41
- position: 'absolute',
42
- height: '100%',
43
- pointerEvents: 'none',
44
- background: theme.palette.action.disabled,
45
- width: 1,
46
- },
47
- hiddenTick: {
48
- position: 'absolute',
49
- height: '100%',
50
- width: 5,
51
- },
52
- }));
53
- function Tick({ left, scrollLeft, idx, onDrag, onMouseDown, }) {
54
- const { classes } = useStyles();
55
- const onDragCallback = (0, react_1.useCallback)((lastFrameDistance, totalDistance) => onDrag(lastFrameDistance, totalDistance, idx), [idx, onDrag]);
56
- // has an invisible wider than tick mark (1px) clickable area (5px)
57
- return (react_1.default.createElement(react_1.default.Fragment, null,
58
- react_1.default.createElement(ResizeHandle_1.default, { onDrag: onDragCallback, onMouseDown: onMouseDown, vertical: true, className: classes.hiddenTick, style: { left: left - scrollLeft - 2.5 } }),
59
- react_1.default.createElement("div", { style: { left: left - scrollLeft }, className: classes.tick })));
60
- }
61
- function ResizeBar({ widths, setWidths, checkbox, scrollLeft = 0, }) {
62
- const { classes } = useStyles();
63
- const offsets = [];
64
- const [initial, setInitial] = (0, react_1.useState)();
65
- let init = checkbox ? 52 : 0;
66
- for (let i = 0; i < widths.length; i++) {
67
- const width = widths[i];
68
- offsets[i] = width + init;
69
- init += width;
70
- }
71
- return (react_1.default.createElement("div", { className: classes.resizeBar }, offsets.map((left, i) => (react_1.default.createElement(Tick, { key: i, onMouseDown: () => {
72
- setInitial([...widths]);
73
- }, left: i === offsets.length - 1 ? left - 3 : left, onDrag: (_, totalDistance, idx) => {
74
- const newWidths = [...widths];
75
- // mui doesn't allow columns smaller than 50
76
- newWidths[idx] = Math.max(initial[idx] - totalDistance, 50);
77
- setWidths(newWidths);
78
- }, idx: i, scrollLeft: scrollLeft })))));
79
- }
80
- exports.default = ResizeBar;