@jbrowse/product-core 2.11.1 → 2.12.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.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
- export default function AboutContents({ config, }: {
3
+ declare const AboutDialogContents: ({ config, }: {
4
4
  config: AnyConfigurationModel;
5
- }): React.JSX.Element;
5
+ }) => React.JSX.Element;
6
+ export default AboutDialogContents;
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const react_1 = __importStar(require("react"));
30
+ const mobx_react_1 = require("mobx-react");
30
31
  const clone_1 = __importDefault(require("clone"));
31
32
  const copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard"));
32
33
  const material_1 = require("@mui/material");
@@ -35,10 +36,14 @@ const configuration_1 = require("@jbrowse/core/configuration");
35
36
  const util_1 = require("@jbrowse/core/util");
36
37
  const BaseFeatureDetail_1 = require("@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail");
37
38
  const FileInfoPanel_1 = __importDefault(require("./FileInfoPanel"));
39
+ const RefNameInfoDialog_1 = __importDefault(require("./RefNameInfoDialog"));
38
40
  const useStyles = (0, mui_1.makeStyles)()({
39
41
  content: {
40
42
  minWidth: 800,
41
43
  },
44
+ button: {
45
+ float: 'right',
46
+ },
42
47
  });
43
48
  function removeAttr(obj, attr) {
44
49
  for (const prop in obj) {
@@ -51,11 +56,12 @@ function removeAttr(obj, attr) {
51
56
  }
52
57
  return obj;
53
58
  }
54
- function AboutContents({ config, }) {
59
+ const AboutDialogContents = (0, mobx_react_1.observer)(function ({ config, }) {
55
60
  const [copied, setCopied] = (0, react_1.useState)(false);
56
61
  const conf = (0, configuration_1.readConfObject)(config);
57
62
  const session = (0, util_1.getSession)(config);
58
63
  const { classes } = useStyles();
64
+ const [showRefNames, setShowRefNames] = (0, react_1.useState)(false);
59
65
  const hideUris = (0, configuration_1.getConf)(session, ['formatAbout', 'hideUris']) ||
60
66
  (0, configuration_1.readConfObject)(config, ['formatAbout', 'hideUris']);
61
67
  const { pluginManager } = (0, util_1.getEnv)(session);
@@ -69,15 +75,18 @@ function AboutContents({ config, }) {
69
75
  const ExtraPanel = pluginManager.evaluateExtensionPoint('Core-extraAboutPanel', null, { session, config });
70
76
  return (react_1.default.createElement("div", { className: classes.content },
71
77
  react_1.default.createElement(BaseFeatureDetail_1.BaseCard, { title: "Configuration" },
72
- !hideUris ? (react_1.default.createElement(material_1.Button, { variant: "contained", style: { float: 'right' }, onClick: () => {
73
- const snap = removeAttr((0, clone_1.default)(conf), 'baseUri');
74
- (0, copy_to_clipboard_1.default)(JSON.stringify(snap, null, 2));
75
- setCopied(true);
76
- setTimeout(() => setCopied(false), 1000);
77
- } }, copied ? 'Copied to clipboard!' : 'Copy config')) : null,
78
+ !hideUris ? (react_1.default.createElement("span", { className: classes.button },
79
+ react_1.default.createElement(material_1.Button, { variant: "contained", color: "secondary", onClick: () => setShowRefNames(true) }, "Show ref names"),
80
+ react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => {
81
+ const snap = removeAttr((0, clone_1.default)(conf), 'baseUri');
82
+ (0, copy_to_clipboard_1.default)(JSON.stringify(snap, null, 2));
83
+ setCopied(true);
84
+ setTimeout(() => setCopied(false), 1000);
85
+ } }, copied ? 'Copied to clipboard!' : 'Copy config'))) : null,
78
86
  react_1.default.createElement(BaseFeatureDetail_1.Attributes, { attributes: confPostExt, omit: ['displays', 'baseUri', 'refNames', 'formatAbout'], hideUris: hideUris })),
79
87
  ExtraPanel ? (react_1.default.createElement(BaseFeatureDetail_1.BaseCard, { title: ExtraPanel.name },
80
88
  react_1.default.createElement(ExtraPanel.Component, { config: config }))) : null,
81
- react_1.default.createElement(FileInfoPanel_1.default, { config: config })));
82
- }
83
- exports.default = AboutContents;
89
+ react_1.default.createElement(FileInfoPanel_1.default, { config: config }),
90
+ showRefNames ? (react_1.default.createElement(RefNameInfoDialog_1.default, { config: config, onClose: () => setShowRefNames(false) })) : null));
91
+ });
92
+ exports.default = AboutDialogContents;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
+ declare const RefNameInfoDialog: ({ config, onClose, }: {
4
+ config: AnyConfigurationModel;
5
+ onClose: () => void;
6
+ }) => React.JSX.Element;
7
+ export default RefNameInfoDialog;
@@ -0,0 +1,110 @@
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 configuration_1 = require("@jbrowse/core/configuration");
32
+ const ui_1 = require("@jbrowse/core/ui");
33
+ const util_1 = require("@jbrowse/core/util");
34
+ const tracks_1 = require("@jbrowse/core/util/tracks");
35
+ const mobx_react_1 = require("mobx-react");
36
+ const mui_1 = require("tss-react/mui");
37
+ const copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard"));
38
+ const MAX_REF_NAMES = 10000;
39
+ const useStyles = (0, mui_1.makeStyles)()(theme => ({
40
+ container: {
41
+ minWidth: 800,
42
+ },
43
+ refNames: {
44
+ maxHeight: 300,
45
+ width: '100%',
46
+ overflow: 'auto',
47
+ flexGrow: 1,
48
+ background: theme.palette.background.default,
49
+ },
50
+ }));
51
+ const RefNameInfoDialog = (0, mobx_react_1.observer)(function ({ config, onClose, }) {
52
+ const [error, setError] = (0, react_1.useState)();
53
+ const [refNames, setRefNames] = (0, react_1.useState)();
54
+ const [copied, setCopied] = (0, react_1.useState)(false);
55
+ const { classes } = useStyles();
56
+ const session = (0, util_1.getSession)(config);
57
+ const { rpcManager } = session;
58
+ (0, react_1.useEffect)(() => {
59
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
60
+ ;
61
+ (async () => {
62
+ try {
63
+ const map = await Promise.all([...new Set((0, tracks_1.getConfAssemblyNames)(config))].map(async (assemblyName) => {
64
+ const adapterConfig = (0, configuration_1.readConfObject)(config, 'adapter');
65
+ return [
66
+ assemblyName,
67
+ (await rpcManager.call(config.trackId, 'CoreGetRefNames', {
68
+ adapterConfig,
69
+ // hack for synteny adapters
70
+ regions: [{ assemblyName }],
71
+ })),
72
+ ];
73
+ }));
74
+ setRefNames(Object.fromEntries(map));
75
+ }
76
+ catch (e) {
77
+ console.error(e);
78
+ setError(e);
79
+ }
80
+ })();
81
+ }, [config, rpcManager]);
82
+ const names = refNames ? Object.entries(refNames) : [];
83
+ const result = names
84
+ .flatMap(([assemblyName, refNames]) => {
85
+ return [
86
+ `--- ${assemblyName} ---`,
87
+ ...refNames.slice(0, MAX_REF_NAMES),
88
+ `${refNames.length > MAX_REF_NAMES
89
+ ? `\nToo many refNames to show in browser for ${assemblyName}, use "Copy ref names" button to copy to clipboard`
90
+ : ''}`,
91
+ ];
92
+ })
93
+ .filter(f => !!f)
94
+ .join('\n');
95
+ return (react_1.default.createElement(ui_1.Dialog, { open: true, title: "Reference sequence names used in track", onClose: onClose },
96
+ react_1.default.createElement(material_1.DialogContent, { className: classes.container }, error ? (react_1.default.createElement(material_1.Typography, { color: "error" }, `${error}`)) : refNames === undefined ? (react_1.default.createElement(ui_1.LoadingEllipses, { message: "Loading refNames" })) : (react_1.default.createElement(react_1.default.Fragment, null,
97
+ react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => {
98
+ (0, copy_to_clipboard_1.default)(names
99
+ .flatMap(([assemblyName, refNames]) => [
100
+ `--- ${assemblyName} ---`,
101
+ ...refNames,
102
+ ])
103
+ .filter(f => !!f)
104
+ .join('\n'));
105
+ setCopied(true);
106
+ setTimeout(() => setCopied(false), 1000);
107
+ } }, copied ? 'Copied to clipboard!' : 'Copy ref names'),
108
+ react_1.default.createElement("pre", { className: classes.refNames }, result))))));
109
+ });
110
+ exports.default = RefNameInfoDialog;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
- export default function AboutContents({ config, }: {
3
+ declare const AboutDialogContents: ({ config, }: {
4
4
  config: AnyConfigurationModel;
5
- }): React.JSX.Element;
5
+ }) => React.JSX.Element;
6
+ export default AboutDialogContents;
@@ -1,4 +1,5 @@
1
1
  import React, { useState } from 'react';
2
+ import { observer } from 'mobx-react';
2
3
  import clone from 'clone';
3
4
  import copy from 'copy-to-clipboard';
4
5
  import { Button } from '@mui/material';
@@ -7,10 +8,14 @@ import { getConf, readConfObject, } from '@jbrowse/core/configuration';
7
8
  import { getSession, getEnv } from '@jbrowse/core/util';
8
9
  import { BaseCard, Attributes, } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail';
9
10
  import FileInfoPanel from './FileInfoPanel';
11
+ import RefNameInfoDialog from './RefNameInfoDialog';
10
12
  const useStyles = makeStyles()({
11
13
  content: {
12
14
  minWidth: 800,
13
15
  },
16
+ button: {
17
+ float: 'right',
18
+ },
14
19
  });
15
20
  function removeAttr(obj, attr) {
16
21
  for (const prop in obj) {
@@ -23,11 +28,12 @@ function removeAttr(obj, attr) {
23
28
  }
24
29
  return obj;
25
30
  }
26
- export default function AboutContents({ config, }) {
31
+ const AboutDialogContents = observer(function ({ config, }) {
27
32
  const [copied, setCopied] = useState(false);
28
33
  const conf = readConfObject(config);
29
34
  const session = getSession(config);
30
35
  const { classes } = useStyles();
36
+ const [showRefNames, setShowRefNames] = useState(false);
31
37
  const hideUris = getConf(session, ['formatAbout', 'hideUris']) ||
32
38
  readConfObject(config, ['formatAbout', 'hideUris']);
33
39
  const { pluginManager } = getEnv(session);
@@ -41,14 +47,18 @@ export default function AboutContents({ config, }) {
41
47
  const ExtraPanel = pluginManager.evaluateExtensionPoint('Core-extraAboutPanel', null, { session, config });
42
48
  return (React.createElement("div", { className: classes.content },
43
49
  React.createElement(BaseCard, { title: "Configuration" },
44
- !hideUris ? (React.createElement(Button, { variant: "contained", style: { float: 'right' }, onClick: () => {
45
- const snap = removeAttr(clone(conf), 'baseUri');
46
- copy(JSON.stringify(snap, null, 2));
47
- setCopied(true);
48
- setTimeout(() => setCopied(false), 1000);
49
- } }, copied ? 'Copied to clipboard!' : 'Copy config')) : null,
50
+ !hideUris ? (React.createElement("span", { className: classes.button },
51
+ React.createElement(Button, { variant: "contained", color: "secondary", onClick: () => setShowRefNames(true) }, "Show ref names"),
52
+ React.createElement(Button, { variant: "contained", onClick: () => {
53
+ const snap = removeAttr(clone(conf), 'baseUri');
54
+ copy(JSON.stringify(snap, null, 2));
55
+ setCopied(true);
56
+ setTimeout(() => setCopied(false), 1000);
57
+ } }, copied ? 'Copied to clipboard!' : 'Copy config'))) : null,
50
58
  React.createElement(Attributes, { attributes: confPostExt, omit: ['displays', 'baseUri', 'refNames', 'formatAbout'], hideUris: hideUris })),
51
59
  ExtraPanel ? (React.createElement(BaseCard, { title: ExtraPanel.name },
52
60
  React.createElement(ExtraPanel.Component, { config: config }))) : null,
53
- React.createElement(FileInfoPanel, { config: config })));
54
- }
61
+ React.createElement(FileInfoPanel, { config: config }),
62
+ showRefNames ? (React.createElement(RefNameInfoDialog, { config: config, onClose: () => setShowRefNames(false) })) : null));
63
+ });
64
+ export default AboutDialogContents;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
+ declare const RefNameInfoDialog: ({ config, onClose, }: {
4
+ config: AnyConfigurationModel;
5
+ onClose: () => void;
6
+ }) => React.JSX.Element;
7
+ export default RefNameInfoDialog;
@@ -0,0 +1,82 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Button, DialogContent, Typography } from '@mui/material';
3
+ import { readConfObject, } from '@jbrowse/core/configuration';
4
+ import { Dialog, LoadingEllipses } from '@jbrowse/core/ui';
5
+ import { getSession } from '@jbrowse/core/util';
6
+ import { getConfAssemblyNames } from '@jbrowse/core/util/tracks';
7
+ import { observer } from 'mobx-react';
8
+ import { makeStyles } from 'tss-react/mui';
9
+ import copy from 'copy-to-clipboard';
10
+ const MAX_REF_NAMES = 10000;
11
+ const useStyles = makeStyles()(theme => ({
12
+ container: {
13
+ minWidth: 800,
14
+ },
15
+ refNames: {
16
+ maxHeight: 300,
17
+ width: '100%',
18
+ overflow: 'auto',
19
+ flexGrow: 1,
20
+ background: theme.palette.background.default,
21
+ },
22
+ }));
23
+ const RefNameInfoDialog = observer(function ({ config, onClose, }) {
24
+ const [error, setError] = useState();
25
+ const [refNames, setRefNames] = useState();
26
+ const [copied, setCopied] = useState(false);
27
+ const { classes } = useStyles();
28
+ const session = getSession(config);
29
+ const { rpcManager } = session;
30
+ useEffect(() => {
31
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
32
+ ;
33
+ (async () => {
34
+ try {
35
+ const map = await Promise.all([...new Set(getConfAssemblyNames(config))].map(async (assemblyName) => {
36
+ const adapterConfig = readConfObject(config, 'adapter');
37
+ return [
38
+ assemblyName,
39
+ (await rpcManager.call(config.trackId, 'CoreGetRefNames', {
40
+ adapterConfig,
41
+ // hack for synteny adapters
42
+ regions: [{ assemblyName }],
43
+ })),
44
+ ];
45
+ }));
46
+ setRefNames(Object.fromEntries(map));
47
+ }
48
+ catch (e) {
49
+ console.error(e);
50
+ setError(e);
51
+ }
52
+ })();
53
+ }, [config, rpcManager]);
54
+ const names = refNames ? Object.entries(refNames) : [];
55
+ const result = names
56
+ .flatMap(([assemblyName, refNames]) => {
57
+ return [
58
+ `--- ${assemblyName} ---`,
59
+ ...refNames.slice(0, MAX_REF_NAMES),
60
+ `${refNames.length > MAX_REF_NAMES
61
+ ? `\nToo many refNames to show in browser for ${assemblyName}, use "Copy ref names" button to copy to clipboard`
62
+ : ''}`,
63
+ ];
64
+ })
65
+ .filter(f => !!f)
66
+ .join('\n');
67
+ return (React.createElement(Dialog, { open: true, title: "Reference sequence names used in track", onClose: onClose },
68
+ React.createElement(DialogContent, { className: classes.container }, error ? (React.createElement(Typography, { color: "error" }, `${error}`)) : refNames === undefined ? (React.createElement(LoadingEllipses, { message: "Loading refNames" })) : (React.createElement(React.Fragment, null,
69
+ React.createElement(Button, { variant: "contained", onClick: () => {
70
+ copy(names
71
+ .flatMap(([assemblyName, refNames]) => [
72
+ `--- ${assemblyName} ---`,
73
+ ...refNames,
74
+ ])
75
+ .filter(f => !!f)
76
+ .join('\n'));
77
+ setCopied(true);
78
+ setTimeout(() => setCopied(false), 1000);
79
+ } }, copied ? 'Copied to clipboard!' : 'Copy ref names'),
80
+ React.createElement("pre", { className: classes.refNames }, result))))));
81
+ });
82
+ export default RefNameInfoDialog;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/product-core",
3
- "version": "2.11.1",
3
+ "version": "2.12.0",
4
4
  "sideEffects": false,
5
5
  "description": "JBrowse 2 code shared between products but not used by plugins",
6
6
  "keywords": [
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@babel/runtime": "^7.16.3",
46
- "@jbrowse/core": "^2.11.1",
46
+ "@jbrowse/core": "^2.12.0",
47
47
  "@mui/icons-material": "^5.0.0",
48
48
  "@mui/material": "^5.10.17",
49
49
  "copy-to-clipboard": "^3.3.1",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "11b28d66d782eb06f92ccb993108bb6c3c82819e"
66
+ "gitHead": "935f2602d29abc737bb1f493a922b6218d023ae2"
67
67
  }