diff --git a/packages/core/ReExports/list.ts b/packages/core/ReExports/list.ts index 6e4e4d60c9..9d8b0df3fb 100644 --- a/packages/core/ReExports/list.ts +++ b/packages/core/ReExports/list.ts @@ -1,11 +1,247 @@ +/** + * Used by plugin build systems to determine if a module is provided by JBrowse + * globally and thus doesn't need to be bundled. A check in ./modules.tsx makes + * sure this is in sync with the re-exported modules. + */ export default [ 'mobx', 'mobx-state-tree', 'react', 'react-dom', 'mobx-react', + '@mui/x-data-grid', + '@mui/material/utils', + '@material-ui/core/utils', + 'tss-react/mui', + '@material-ui/core', + '@mui/material', 'prop-types', + '@mui/material/styles', + '@material-ui/core/styles', + '@material-ui/core/Accordion', + '@material-ui/core/AccordionActions', + '@material-ui/core/AccordionDetails', + '@material-ui/core/Alert', + '@material-ui/core/AlertTitle', + '@material-ui/core/Autocomplete', + '@material-ui/core/Avatar', + '@material-ui/core/AvatarGroup', + '@material-ui/core/Backdrop', + '@material-ui/core/Badge', + '@material-ui/core/Box', + '@material-ui/core/Breadcrumbs', + '@material-ui/core/Button', + '@material-ui/core/ButtonGroup', + '@material-ui/core/Card', + '@material-ui/core/CardActions', + '@material-ui/core/CardActionArea', + '@material-ui/core/CardContent', + '@material-ui/core/CardHeader', + '@material-ui/core/CardMedia', + '@material-ui/core/CircularProgress', + '@material-ui/core/Collapse', + '@material-ui/core/ClickAwayListener', + '@material-ui/core/Chip', + '@material-ui/core/Checkbox', + '@material-ui/core/Container', + '@material-ui/core/Dialog', + '@material-ui/core/DialogActions', + '@material-ui/core/DialogTitle', + '@material-ui/core/DialogContent', + '@material-ui/core/DialogContentText', + '@material-ui/core/Divider', + '@material-ui/core/Drawer', + '@material-ui/core/Fab', + '@material-ui/core/Fade', + '@material-ui/core/FilledInput', + '@material-ui/core/FormLabel', + '@material-ui/core/FormControl', + '@material-ui/core/FormControlLabel', + '@material-ui/core/FormHelperText', + '@material-ui/core/FormGroup', + '@material-ui/core/Grid', + '@material-ui/core/Grow', + '@material-ui/core/Icon', + '@material-ui/core/IconButton', + '@material-ui/core/Input', + '@material-ui/core/InputBase', + '@material-ui/core/InputLabel', + '@material-ui/core/InputAdornment', + '@material-ui/core/Link', + '@material-ui/core/LinearProgress', + '@material-ui/core/List', + '@material-ui/core/ListItem', + '@material-ui/core/ListItemAvatar', + '@material-ui/core/ListItemSecondaryAction', + '@material-ui/core/ListItemIcon', + '@material-ui/core/ListSubheader', + '@material-ui/core/ListItemText', + '@material-ui/core/Menu', + '@material-ui/core/MenuItem', + '@material-ui/core/MenuList', + '@material-ui/core/Modal', + '@material-ui/core/NativeSelect', + '@material-ui/core/OutlinedInput', + '@material-ui/core/Pagination', + '@material-ui/core/PaginationItem', + '@material-ui/core/Paper', + '@material-ui/core/Popover', + '@material-ui/core/Popper', + '@material-ui/core/Portal', + '@material-ui/core/Radio', + '@material-ui/core/RadioGroup', + '@material-ui/core/Rating', + '@material-ui/core/ScopedCssBaseline', + '@material-ui/core/Select', + '@material-ui/core/Skeleton', + '@material-ui/core/Slider', + '@material-ui/core/Snackbar', + '@material-ui/core/SnackbarContent', + '@material-ui/core/SpeedDial', + '@material-ui/core/SpeedDialAction', + '@material-ui/core/SpeedDialIcon', + '@material-ui/core/Stack', + '@material-ui/core/Step', + '@material-ui/core/StepButton', + '@material-ui/core/StepConnector', + '@material-ui/core/StepLabel', + '@material-ui/core/StepIcon', + '@material-ui/core/Stepper', + '@material-ui/core/SvgIcon', + '@material-ui/core/Switch', + '@material-ui/core/Tab', + '@material-ui/core/Table', + '@material-ui/core/TableBody', + '@material-ui/core/TableCell', + '@material-ui/core/TableContainer', + '@material-ui/core/TableFooter', + '@material-ui/core/TableHead', + '@material-ui/core/TablePagination', + '@material-ui/core/TableRow', + '@material-ui/core/TableSortLabel', + '@material-ui/core/Tabs', + '@material-ui/core/TextField', + '@material-ui/core/TextareaAutosize', + '@material-ui/core/ToggleButton', + '@material-ui/core/ToggleButtonGroup', + '@material-ui/core/Toolbar', + '@material-ui/core/Tooltip', + '@material-ui/core/Typography', + '@mui/material/Accordion', + '@mui/material/AccordionActions', + '@mui/material/AccordionDetails', + '@mui/material/Alert', + '@mui/material/AlertTitle', + '@mui/material/Autocomplete', + '@mui/material/Avatar', + '@mui/material/AvatarGroup', + '@mui/material/Backdrop', + '@mui/material/Badge', + '@mui/material/Box', + '@mui/material/Breadcrumbs', + '@mui/material/Button', + '@mui/material/ButtonGroup', + '@mui/material/Card', + '@mui/material/CardActions', + '@mui/material/CardActionArea', + '@mui/material/CardContent', + '@mui/material/CardHeader', + '@mui/material/CardMedia', + '@mui/material/CircularProgress', + '@mui/material/Collapse', + '@mui/material/ClickAwayListener', + '@mui/material/Chip', + '@mui/material/Checkbox', + '@mui/material/Container', + '@mui/material/Dialog', + '@mui/material/DialogActions', + '@mui/material/DialogTitle', + '@mui/material/DialogContent', + '@mui/material/DialogContentText', + '@mui/material/Divider', + '@mui/material/Drawer', + '@mui/material/Fab', + '@mui/material/Fade', + '@mui/material/FilledInput', + '@mui/material/FormLabel', + '@mui/material/FormControl', + '@mui/material/FormControlLabel', + '@mui/material/FormHelperText', + '@mui/material/FormGroup', + '@mui/material/Grid', + '@mui/material/Grow', + '@mui/material/Icon', + '@mui/material/IconButton', + '@mui/material/Input', + '@mui/material/InputBase', + '@mui/material/InputLabel', + '@mui/material/InputAdornment', + '@mui/material/Link', + '@mui/material/LinearProgress', + '@mui/material/List', + '@mui/material/ListItem', + '@mui/material/ListItemAvatar', + '@mui/material/ListItemSecondaryAction', + '@mui/material/ListItemIcon', + '@mui/material/ListSubheader', + '@mui/material/ListItemText', + '@mui/material/Menu', + '@mui/material/MenuItem', + '@mui/material/MenuList', + '@mui/material/Modal', + '@mui/material/NativeSelect', + '@mui/material/OutlinedInput', + '@mui/material/Pagination', + '@mui/material/PaginationItem', + '@mui/material/Paper', + '@mui/material/Popover', + '@mui/material/Popper', + '@mui/material/Portal', + '@mui/material/Radio', + '@mui/material/RadioGroup', + '@mui/material/Rating', + '@mui/material/ScopedCssBaseline', + '@mui/material/Select', + '@mui/material/Skeleton', + '@mui/material/Slider', + '@mui/material/Snackbar', + '@mui/material/SnackbarContent', + '@mui/material/SpeedDial', + '@mui/material/SpeedDialAction', + '@mui/material/SpeedDialIcon', + '@mui/material/Stack', + '@mui/material/Step', + '@mui/material/StepButton', + '@mui/material/StepConnector', + '@mui/material/StepLabel', + '@mui/material/StepIcon', + '@mui/material/Stepper', + '@mui/material/SvgIcon', + '@mui/material/Switch', + '@mui/material/Tab', + '@mui/material/Table', + '@mui/material/TableBody', + '@mui/material/TableCell', + '@mui/material/TableContainer', + '@mui/material/TableFooter', + '@mui/material/TableHead', + '@mui/material/TablePagination', + '@mui/material/TableRow', + '@mui/material/TableSortLabel', + '@mui/material/Tabs', + '@mui/material/TextField', + '@mui/material/TextareaAutosize', + '@mui/material/ToggleButton', + '@mui/material/ToggleButtonGroup', + '@mui/material/Toolbar', + '@mui/material/Tooltip', + '@mui/material/Typography', + '@material-ui/lab/ToggleButton', + '@material-ui/lab/ToggleButtonGroup', + '@material-ui/lab/Autocomplete', + '@material-ui/lab/Alert', + '@material-ui/lab', '@jbrowse/core/Plugin', '@jbrowse/core/pluggableElementTypes', '@jbrowse/core/pluggableElementTypes/ViewType', @@ -31,5 +267,6 @@ export default [ '@jbrowse/core/util/io', '@jbrowse/core/util/mst-reflection', '@jbrowse/core/util/rxjs', + '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail', '@jbrowse/core/data_adapters/BaseAdapter', ] diff --git a/packages/core/ReExports/modules.tsx b/packages/core/ReExports/modules.tsx index 1add016df7..308834622d 100644 --- a/packages/core/ReExports/modules.tsx +++ b/packages/core/ReExports/modules.tsx @@ -1,5 +1,5 @@ // this is all the stuff that the pluginManager re-exports for plugins to use -import React, { lazy, Suspense } from 'react' +import React, { lazy, LazyExoticComponent, Suspense } from 'react' import * as ReactDom from 'react-dom' import * as mobx from 'mobx' import * as mst from 'mobx-state-tree' @@ -46,7 +46,7 @@ import * as coreMstReflection from '../util/mst-reflection' import * as rxjs from '../util/rxjs' import * as mstTypes from '../util/types/mst' -import ReExportsList from './list' +import reExportsList from './list' const Entries = { Accordion: lazy(() => import('@mui/material/Accordion')), @@ -192,11 +192,291 @@ const Attributes = lazy(() => import('./Attributes')) const FeatureDetails = lazy(() => import('./FeatureDetails')) const BaseCard = lazy(() => import('./BaseCard')) -// uses 'as any' because otherwise typescript gives warning Exported variable -// 'libs' has or is using name 'DataGridComponent' from external module -// "node_modules/@mui/x-data-grid/DataGrid/DataGrid" but cannot be named. // eslint-disable-next-line @typescript-eslint/no-explicit-any -const DataGrid = lazy(() => import('./DataGrid')) as any +const DataGridEntries: Record> = { + DataGrid: lazy(() => + import('@mui/x-data-grid').then(module => ({ default: module.DataGrid })), + ), + GridActionsCellItem: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridActionsCellItem, + })), + ), + GridAddIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridAddIcon, + })), + ), + GridArrowDownwardIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridArrowDownwardIcon, + })), + ), + GridArrowUpwardIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridArrowUpwardIcon, + })), + ), + GridAutoSizer: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridAutoSizer, + })), + ), + GridCellCheckboxForwardRef: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridCellCheckboxForwardRef, + })), + ), + GridCellCheckboxRenderer: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridCellCheckboxRenderer, + })), + ), + GridCheckCircleIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridCheckCircleIcon, + })), + ), + GridCheckIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridCheckIcon, + })), + ), + GridCloseIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridCloseIcon, + })), + ), + GridColumnHeaderSeparator: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridColumnHeaderSeparator, + })), + ), + GridColumnHeaderSortIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridColumnHeaderSortIcon, + })), + ), + GridColumnIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridColumnIcon, + })), + ), + GridColumnMenu: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridColumnMenu, + })), + ), + GridColumnMenuContainer: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridColumnMenuContainer, + })), + ), + GridDragIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridDragIcon, + })), + ), + GridExpandMoreIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridExpandMoreIcon, + })), + ), + GridFilterAltIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridFilterAltIcon, + })), + ), + GridFilterForm: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridFilterForm, + })), + ), + GridFilterListIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridFilterListIcon, + })), + ), + GridFilterPanel: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridFilterPanel, + })), + ), + GridFooter: lazy(() => + import('@mui/x-data-grid').then(module => ({ default: module.GridFooter })), + ), + GridFooterContainer: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridFooterContainer, + })), + ), + GridHeader: lazy(() => + import('@mui/x-data-grid').then(module => ({ default: module.GridHeader })), + ), + GridHeaderCheckbox: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridHeaderCheckbox, + })), + ), + GridKeyboardArrowRight: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridKeyboardArrowRight, + })), + ), + GridLoadIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridLoadIcon, + })), + ), + GridLoadingOverlay: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridLoadingOverlay, + })), + ), + GridMenuIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridMenuIcon, + })), + ), + GridMoreVertIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridMoreVertIcon, + })), + ), + GridNoRowsOverlay: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridNoRowsOverlay, + })), + ), + GridOverlay: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridOverlay, + })), + ), + GridPagination: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridPagination, + })), + ), + GridPanel: lazy(() => + import('@mui/x-data-grid').then(module => ({ default: module.GridPanel })), + ), + GridPanelWrapper: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridPanelWrapper, + })), + ), + GridPreferencesPanel: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridPreferencesPanel, + })), + ), + GridRemoveIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridRemoveIcon, + })), + ), + GridRoot: lazy(() => + import('@mui/x-data-grid').then(module => ({ default: module.GridRoot })), + ), + GridRowCount: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridRowCount, + })), + ), + GridSaveAltIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridSaveAltIcon, + })), + ), + GridScrollArea: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridScrollArea, + })), + ), + GridSearchIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridSearchIcon, + })), + ), + GridSelectedRowCount: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridSelectedRowCount, + })), + ), + GridSeparatorIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridSeparatorIcon, + })), + ), + GridTableRowsIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridTableRowsIcon, + })), + ), + GridToolbar: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridToolbar, + })), + ), + GridToolbarColumnsButton: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridToolbarColumnsButton, + })), + ), + GridToolbarContainer: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridToolbarContainer, + })), + ), + GridToolbarDensitySelector: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridToolbarDensitySelector, + })), + ), + GridToolbarExport: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridToolbarExport, + })), + ), + GridToolbarExportContainer: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridToolbarExportContainer, + })), + ), + GridToolbarFilterButton: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridToolbarFilterButton, + })), + ), + GridTripleDotsVerticalIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridTripleDotsVerticalIcon, + })), + ), + GridViewHeadlineIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridViewHeadlineIcon, + })), + ), + GridViewStreamIcon: lazy(() => + import('@mui/x-data-grid').then(module => ({ + default: module.GridViewStreamIcon, + })), + ), +} + +const LazyDataGridComponents = Object.fromEntries( + Object.entries(DataGridEntries).map(([key, ReactComponent]) => [ + key, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (props: any) => ( + }> + + + ), + ]), +) // eslint-disable-next-line @typescript-eslint/no-explicit-any const LazyAttributes = (props: any) => ( @@ -226,10 +506,10 @@ const libs = { 'react-dom': ReactDom, 'mobx-react': mxreact, '@mui/x-data-grid': { - DataGrid, useGridApiContext, useGridApiRef, useGridRootProps, + ...LazyDataGridComponents, }, // special case so plugins can easily use @mui/icons-material; don't remove @@ -306,12 +586,25 @@ const libs = { '@jbrowse/core/data_adapters/BaseAdapter': BaseAdapterExports, } -// make sure that all the items in the ReExports/list array (used by build systems and such) -// are included here. it's OK if there are some additional ones that are not in the list -ReExportsList.forEach(name => { - if (!(name in libs)) { - throw new Error(`ReExports/modules is missing ${name}`) - } -}) +const libsList = Array.from(Object.keys(libs)) + +// make sure that all the items in the ReExports/list array (used by build +// systems and such) are included here, and vice versa +const inLibsOnly = libsList.filter(mod => !reExportsList.includes(mod)) +if (inLibsOnly.length) { + throw new Error( + `The following modules are in the re-exports list, but not the modules libs: ${inLibsOnly.join( + ', ', + )}`, + ) +} +const inReExportsOnly = reExportsList.filter(mod => !libsList.includes(mod)) +if (inReExportsOnly.length) { + throw new Error( + `The following modules are in the modules libs, but not the re-exports list: ${inReExportsOnly.join( + ', ', + )}`, + ) +} export default libs