@jbrowse/core 2.10.0 → 2.10.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.
- package/BaseFeatureWidget/BaseFeatureDetail/index.d.ts +1 -1
- package/BaseFeatureWidget/BaseFeatureDetail/index.js +1 -1
- package/BaseFeatureWidget/BaseFeatureDetail/util.d.ts +0 -1
- package/BaseFeatureWidget/BaseFeatureDetail/util.js +1 -5
- package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeatureDetails.js +6 -6
- package/BaseFeatureWidget/SequenceFeatureDetails/index.js +12 -8
- package/ReExports/modules.js +5 -5
- package/package.json +3 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/ErrorMessage.js +33 -10
- package/ui/ErrorMessageStackTraceDialog.d.ts +5 -0
- package/ui/ErrorMessageStackTraceDialog.js +155 -0
- package/ui/RedErrorMessageBox.d.ts +4 -0
- package/ui/RedErrorMessageBox.js +17 -0
- package/ui/Snackbar.js +1 -1
- package/util/index.js +1 -1
package/ui/ErrorMessage.js
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 =
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const material_1 = require("@mui/material");
|
|
31
|
+
const RedErrorMessageBox_1 = __importDefault(require("./RedErrorMessageBox"));
|
|
32
|
+
const ErrorMessageStackTraceDialog = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./ErrorMessageStackTraceDialog'))));
|
|
7
33
|
function parseError(str) {
|
|
8
34
|
let snapshotError = '';
|
|
9
35
|
const findStr = 'is not assignable';
|
|
@@ -30,19 +56,16 @@ function parseError(str) {
|
|
|
30
56
|
const ErrorMessage = ({ error }) => {
|
|
31
57
|
const str = `${error}`;
|
|
32
58
|
const snapshotError = parseError(str);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
margin: 4,
|
|
36
|
-
overflow: 'auto',
|
|
37
|
-
maxHeight: 200,
|
|
38
|
-
background: '#f88',
|
|
39
|
-
border: '1px solid black',
|
|
40
|
-
} },
|
|
59
|
+
const [showStack, setShowStack] = (0, react_1.useState)(false);
|
|
60
|
+
return (react_1.default.createElement(RedErrorMessageBox_1.default, null,
|
|
41
61
|
str.slice(0, 10000),
|
|
62
|
+
typeof error === 'object' && error && 'stack' in error ? (react_1.default.createElement(material_1.Button, { style: { float: 'right' }, variant: "contained", onClick: () => setShowStack(!showStack) }, showStack ? 'Hide stack trace' : 'Show stack trace')) : null,
|
|
42
63
|
snapshotError ? (react_1.default.createElement("pre", { style: {
|
|
43
64
|
background: 'lightgrey',
|
|
44
65
|
border: '1px solid black',
|
|
45
66
|
margin: 20,
|
|
46
|
-
} }, JSON.stringify(JSON.parse(snapshotError), null, 2))) : null
|
|
67
|
+
} }, JSON.stringify(JSON.parse(snapshotError), null, 2))) : null,
|
|
68
|
+
showStack ? (react_1.default.createElement(react_1.Suspense, { fallback: null },
|
|
69
|
+
react_1.default.createElement(ErrorMessageStackTraceDialog, { error: error, onClose: () => setShowStack(false) }))) : null));
|
|
47
70
|
};
|
|
48
71
|
exports.default = ErrorMessage;
|
|
@@ -0,0 +1,155 @@
|
|
|
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 material_1 = require("@mui/material");
|
|
31
|
+
const source_map_js_1 = require("source-map-js");
|
|
32
|
+
const copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard"));
|
|
33
|
+
// locals
|
|
34
|
+
const Dialog_1 = __importDefault(require("./Dialog"));
|
|
35
|
+
const LoadingEllipses_1 = __importDefault(require("./LoadingEllipses"));
|
|
36
|
+
// produce a source-map resolved stack trace
|
|
37
|
+
// reference code https://stackoverflow.com/a/77158517/2129219
|
|
38
|
+
const sourceMaps = {};
|
|
39
|
+
async function getSourceMapFromUri(uri) {
|
|
40
|
+
var _a;
|
|
41
|
+
if (sourceMaps[uri] != undefined) {
|
|
42
|
+
return sourceMaps[uri];
|
|
43
|
+
}
|
|
44
|
+
const uriQuery = new URL(uri).search;
|
|
45
|
+
const currentScriptContent = await (await fetch(uri)).text();
|
|
46
|
+
let mapUri = ((_a = new RegExp(/\/\/# sourceMappingURL=(.*)/).exec(currentScriptContent)) === null || _a === void 0 ? void 0 : _a[1]) ||
|
|
47
|
+
'';
|
|
48
|
+
mapUri = new URL(mapUri, uri).href + uriQuery;
|
|
49
|
+
const map = await (await fetch(mapUri)).json();
|
|
50
|
+
sourceMaps[uri] = map;
|
|
51
|
+
return map;
|
|
52
|
+
}
|
|
53
|
+
async function mapStackTrace(stack) {
|
|
54
|
+
const stackLines = stack.split('\n');
|
|
55
|
+
const mappedStack = [];
|
|
56
|
+
for (const line of stackLines) {
|
|
57
|
+
const match = new RegExp(/(.*)(http:\/\/.*):(\d+):(\d+)/).exec(line);
|
|
58
|
+
if (match === null) {
|
|
59
|
+
mappedStack.push(line);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const uri = match[2];
|
|
63
|
+
const consumer = new source_map_js_1.SourceMapConsumer(await getSourceMapFromUri(uri));
|
|
64
|
+
const originalPosition = consumer.originalPositionFor({
|
|
65
|
+
line: parseInt(match[3]),
|
|
66
|
+
column: parseInt(match[4]),
|
|
67
|
+
});
|
|
68
|
+
if (originalPosition.source === null ||
|
|
69
|
+
originalPosition.line === null ||
|
|
70
|
+
originalPosition.column === null) {
|
|
71
|
+
mappedStack.push(line);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
mappedStack.push(`${originalPosition.source}:${originalPosition.line}:${originalPosition.column + 1}`);
|
|
75
|
+
}
|
|
76
|
+
return mappedStack.join('\n');
|
|
77
|
+
}
|
|
78
|
+
const MAX_ERR_LEN = 10000;
|
|
79
|
+
// Chrome has the error message in the stacktrace, firefox doesn't
|
|
80
|
+
function stripMessage(trace, error) {
|
|
81
|
+
if (trace.startsWith('Error:')) {
|
|
82
|
+
// remove the error message, which can be very long due to mobx-state-tree
|
|
83
|
+
// stuff, to get just the stack trace
|
|
84
|
+
const err = `${error}`;
|
|
85
|
+
return trace.slice(err.length);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return trace;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function ErrorMessageStackTraceDialog({ error, onClose, }) {
|
|
92
|
+
const [mappedStackTrace, setMappedStackTrace] = (0, react_1.useState)();
|
|
93
|
+
const [secondaryError, setSecondaryError] = (0, react_1.useState)();
|
|
94
|
+
const [clicked, setClicked] = (0, react_1.useState)(false);
|
|
95
|
+
const stackTracePreProcessed = `${error.stack}`;
|
|
96
|
+
const errorText = `${error}`;
|
|
97
|
+
const stackTrace = stripMessage(stackTracePreProcessed, errorText);
|
|
98
|
+
(0, react_1.useEffect)(() => {
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
100
|
+
;
|
|
101
|
+
(async () => {
|
|
102
|
+
try {
|
|
103
|
+
const res = await mapStackTrace(stackTrace);
|
|
104
|
+
setMappedStackTrace(res);
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
console.error(e);
|
|
108
|
+
setMappedStackTrace(stackTrace);
|
|
109
|
+
setSecondaryError(e);
|
|
110
|
+
}
|
|
111
|
+
})();
|
|
112
|
+
}, [stackTrace]);
|
|
113
|
+
const errorBoxText = [
|
|
114
|
+
secondaryError
|
|
115
|
+
? 'Error loading source map, showing raw stack trace below:'
|
|
116
|
+
: '',
|
|
117
|
+
errorText.length > MAX_ERR_LEN
|
|
118
|
+
? errorText.slice(0, MAX_ERR_LEN) + '...'
|
|
119
|
+
: errorText,
|
|
120
|
+
mappedStackTrace || 'No stack trace available',
|
|
121
|
+
// @ts-expect-error add version info at bottom if we are in jbrowse-web
|
|
122
|
+
window.JBrowseSession ? `JBrowse ${window.JBrowseSession.version}` : '',
|
|
123
|
+
].join('\n');
|
|
124
|
+
const err = encodeURIComponent('I got this error from JBrowse, here is the stack trace:\n\n```\n' +
|
|
125
|
+
errorBoxText +
|
|
126
|
+
'\n```\n');
|
|
127
|
+
const githubLink = `https://github.com/GMOD/jbrowse-components/issues/new?labels=bug&title=JBrowse+issue&body=${err}`;
|
|
128
|
+
const emailLink = `mailto:jbrowse2dev@gmail.com?subject=JBrowse%202%20error&body=${err}`;
|
|
129
|
+
return (react_1.default.createElement(Dialog_1.default, { open: true, onClose: onClose, title: "Stack trace", maxWidth: "xl" },
|
|
130
|
+
react_1.default.createElement(material_1.DialogContent, null, mappedStackTrace === undefined ? (react_1.default.createElement(LoadingEllipses_1.default, { variant: "h6" })) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
131
|
+
react_1.default.createElement(material_1.Typography, null,
|
|
132
|
+
"Post a new issue at",
|
|
133
|
+
' ',
|
|
134
|
+
react_1.default.createElement(material_1.Link, { href: githubLink, target: "_blank" }, "GitHub"),
|
|
135
|
+
' ',
|
|
136
|
+
"or send an email to",
|
|
137
|
+
' ',
|
|
138
|
+
react_1.default.createElement(material_1.Link, { href: emailLink, target: "_blank" }, "jbrowse2dev@gmail.com"),
|
|
139
|
+
' '),
|
|
140
|
+
react_1.default.createElement("pre", { style: {
|
|
141
|
+
background: 'lightgrey',
|
|
142
|
+
border: '1px solid black',
|
|
143
|
+
overflow: 'auto',
|
|
144
|
+
margin: 20,
|
|
145
|
+
maxHeight: 300,
|
|
146
|
+
} }, errorBoxText)))),
|
|
147
|
+
react_1.default.createElement(material_1.DialogActions, null,
|
|
148
|
+
react_1.default.createElement(material_1.Button, { variant: "contained", color: "secondary", onClick: () => {
|
|
149
|
+
(0, copy_to_clipboard_1.default)(errorBoxText);
|
|
150
|
+
setClicked(true);
|
|
151
|
+
setTimeout(() => setClicked(false), 1000);
|
|
152
|
+
} }, clicked ? 'Copied!' : 'Copy stack trace to clipboard'),
|
|
153
|
+
react_1.default.createElement(material_1.Button, { variant: "contained", color: "primary", onClick: onClose }, "Close"))));
|
|
154
|
+
}
|
|
155
|
+
exports.default = ErrorMessageStackTraceDialog;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
function RedErrorMessageBox({ children, }) {
|
|
8
|
+
return (react_1.default.createElement("div", { style: {
|
|
9
|
+
padding: 4,
|
|
10
|
+
margin: 4,
|
|
11
|
+
overflow: 'auto',
|
|
12
|
+
maxHeight: 200,
|
|
13
|
+
background: '#f88',
|
|
14
|
+
border: '1px solid black',
|
|
15
|
+
} }, children));
|
|
16
|
+
}
|
|
17
|
+
exports.default = RedErrorMessageBox;
|
package/ui/Snackbar.js
CHANGED
|
@@ -16,7 +16,7 @@ const Snackbar = (0, mobx_react_1.observer)(function ({ session }) {
|
|
|
16
16
|
session.popSnackbarMessage();
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
return
|
|
19
|
+
return latestMessage ? (react_1.default.createElement(material_1.Snackbar, { open: true, onClose: handleClose, anchorOrigin: { vertical: 'bottom', horizontal: 'center' } },
|
|
20
20
|
react_1.default.createElement(material_1.Alert, { onClose: handleClose, action: latestMessage.action ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
21
21
|
react_1.default.createElement(material_1.Button, { color: "inherit", onClick: e => {
|
|
22
22
|
var _a;
|
package/util/index.js
CHANGED
|
@@ -1150,7 +1150,7 @@ function renderToStaticMarkup(node, createRootFn) {
|
|
|
1150
1150
|
(0, react_dom_1.render)(node, div);
|
|
1151
1151
|
}
|
|
1152
1152
|
});
|
|
1153
|
-
return div.innerHTML
|
|
1153
|
+
return div.innerHTML;
|
|
1154
1154
|
}
|
|
1155
1155
|
exports.renderToStaticMarkup = renderToStaticMarkup;
|
|
1156
1156
|
var simpleFeature_1 = require("./simpleFeature");
|