Skip to content

Commit

Permalink
fix: update and dedupe dependencies (#1383)
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Feb 25, 2022
1 parent 44698cb commit 4995931
Show file tree
Hide file tree
Showing 14 changed files with 455 additions and 676 deletions.
4 changes: 1 addition & 3 deletions .ncurc.json
Expand Up @@ -3,8 +3,6 @@
"reject": [
"react-color",
"// TODO: Migrate to v6",
"react-router-dom",
"// TODO: Migrate out of reactstrap",
"reactstrap"
"react-router-dom"
]
}
985 changes: 377 additions & 608 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions package.json
Expand Up @@ -45,10 +45,10 @@
"react-dom": ">=16.0.0"
},
"dependencies": {
"@emotion/react": "^11.7.1",
"analysis-ui-components": "^0.10.1",
"@emotion/react": "^11.8.1",
"analysis-ui-components": "^0.10.2",
"cheminfo-font": "^1.8.1",
"cheminfo-types": "^0.9.1",
"cheminfo-types": "^1.0.0",
"d3": "^7.3.0",
"eventemitter3": "^4.0.7",
"file-saver": "^2.0.5",
Expand All @@ -64,22 +64,22 @@
"ml-array-xy-equally-spaced": "^1.2.1",
"ml-baseline-correction-regression": "^1.0.0",
"ml-conrec": "^3.2.1",
"ml-gsd": "^9.1.0",
"ml-spectra-processing": "^10.1.2",
"ml-gsd": "^10.1.2",
"ml-spectra-processing": "^11.0.0",
"ml-stat": "^1.3.3",
"multiplet-analysis": "^2.0.0",
"nmr-correlation": "^2.2.0",
"nmr-correlation": "^2.2.5",
"nmr-parser": "^1.7.2",
"nmr-processing": "^6.0.8",
"nmr-processing": "^7.0.1",
"nmredata": "^0.6.1",
"numeral": "^2.0.6",
"openchemlib": "^7.4.3",
"openchemlib-utils": "^1.9.0",
"re-resizable": "^6.9.1",
"re-resizable": "^6.9.2",
"react-color": "2.17.2",
"react-d3-utils": "^0.5.0",
"react-draggable": "^4.4.4",
"react-dropzone": "^11.5.3",
"react-dropzone": "^12.0.4",
"react-error-boundary": "^3.1.4",
"react-icons": "^4.3.1",
"react-inspector": "^5.1.1",
Expand All @@ -99,11 +99,11 @@
"@babel/plugin-transform-modules-commonjs": "^7.16.8",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@playwright/test": "^1.19.1",
"@playwright/test": "^1.19.2",
"@simbathesailor/use-what-changed": "^2.0.0",
"@types/d3": "^7.1.0",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.18",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.21",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"@types/react-router-dom": "^5.3.3",
Expand All @@ -118,7 +118,6 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.3.0",
"reactstrap": "^8.10.1",
"rimraf": "^3.0.2",
"rollup-plugin-analyzer": "^4.0.0",
"serve": "^13.0.2",
Expand Down
@@ -1,4 +1,4 @@
import { buildLink, Types } from 'nmr-correlation';
import { buildLink, Link, Correlation } from 'nmr-correlation';
import { useCallback, useMemo, useRef } from 'react';

import { buildID } from '../../../../data/utilities/Concatenation';
Expand Down Expand Up @@ -68,16 +68,16 @@ function AdditionalColumnField({
);

const handleEditPseudoHSQC = useCallback(
(action: 'add' | 'remove', link?: Types.Link) => {
(action: 'add' | 'remove', link?: Link) => {
const pseudoLinkCountHSQC = rowCorrelation.link.filter(
(_link) =>
(_link.experimentType === 'hsqc' ||
_link.experimentType === 'hmqc') &&
_link.pseudo === true,
).length;

let _correlationDim1: Types.Correlation;
let _correlationDim2: Types.Correlation;
let _correlationDim1: Correlation;
let _correlationDim2: Correlation;
if (action === 'add') {
const commonPseudoLink = buildLink({
experimentType: 'hsqc',
Expand Down
Expand Up @@ -3,7 +3,7 @@ import {
getCorrelationDelta,
getLabel,
getLinkDim,
Types,
Link,
} from 'nmr-correlation';
import { CSSProperties, useCallback, useMemo, useRef } from 'react';

Expand Down Expand Up @@ -83,7 +83,7 @@ function CorrelationTableRow({

const additionalColumnFields = useMemo(() => {
return additionalColumnData.map((_correlation) => {
const commonLinks: Types.Link[] = [];
const commonLinks: Link[] = [];
correlation.link.forEach((link) => {
_correlation.link.forEach((_link) => {
if (
Expand Down
@@ -1,6 +1,6 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { getCorrelationDelta, Types } from 'nmr-correlation';
import { getCorrelationDelta, Correlation, Link } from 'nmr-correlation';
import { useCallback, useState } from 'react';

import Select from '../../../../elements/Select';
Expand Down Expand Up @@ -38,10 +38,10 @@ const moveLinkStyles = css`
`;

interface MoveLinkProps {
correlationDim1: Types.Correlation;
correlationDim2: Types.Correlation;
link: Types.Link;
correlations: Types.Correlation[];
correlationDim1: Correlation;
correlationDim2: Correlation;
link: Link;
correlations: Correlation[];
onEdit: (
action: string,
valueDim1: string,
Expand All @@ -61,13 +61,13 @@ function MoveLink({
const [selectedCorrelationIdDim2, setSelectedCorrelationIdDim2] =
useState<string>(correlationDim2?.id || undefined);

function getCorrelationLabel(correlation: Types.Correlation) {
function getCorrelationLabel(correlation: Correlation) {
const delta = getCorrelationDelta(correlation);
return `${delta ? delta.toFixed(2) : '?'}`;
}

const getSelection = useCallback(
(correlation: Types.Correlation, dim: 0 | 1) => {
(correlation: Correlation, dim: 0 | 1) => {
const selectionData = correlations.reduce((arr, _correlation) => {
if (
_correlation.pseudo === false &&
Expand Down
23 changes: 15 additions & 8 deletions src/component/panels/SummaryPanel/SummaryPanel.tsx
@@ -1,6 +1,13 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { getLinkDelta, getLinkDim, Types } from 'nmr-correlation';
import {
getLinkDelta,
getLinkDim,
Correlation,
Values as CorrelationValues,
Options as CorrelationOptions,
Link,
} from 'nmr-correlation';
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
import { FaFlask, FaSlidersH } from 'react-icons/fa';

Expand Down Expand Up @@ -95,7 +102,7 @@ function SummaryPanel() {
const [filterIsActive, setFilterIsActive] = useState(false);

const filteredCorrelationsData = useMemo(() => {
const isInView = (correlation: Types.Correlation): boolean => {
const isInView = (correlation: Correlation): boolean => {
if (correlation.pseudo === true) {
return false;
}
Expand Down Expand Up @@ -381,7 +388,7 @@ function SummaryPanel() {
);

const setCorrelationsHandler = useCallback(
(correlations: Types.Values, options?: Types.Options) => {
(correlations: CorrelationValues, options?: CorrelationOptions) => {
dispatch({
type: SET_CORRELATIONS,
payload: {
Expand All @@ -394,7 +401,7 @@ function SummaryPanel() {
);

const deleteCorrelationHandler = useCallback(
(correlation: Types.Correlation) => {
(correlation: Correlation) => {
dispatch({
type: DELETE_CORRELATION,
payload: {
Expand All @@ -407,7 +414,7 @@ function SummaryPanel() {
);

const deleteSignalHandler = useCallback(
(link: Types.Link) => {
(link: Link) => {
// remove linking signal in spectrum
const linkDim = getLinkDim(link);
if (linkDim === 1) {
Expand Down Expand Up @@ -453,10 +460,10 @@ function SummaryPanel() {

const editCorrelationTableCellHandler = useCallback(
(
editedCorrelations: Types.Correlation[],
editedCorrelations: Correlation[],
action: string,
link?: Types.Link,
options?: Types.Options,
link?: Link,
options?: CorrelationOptions,
) => {
if (
action === 'add' ||
Expand Down
21 changes: 11 additions & 10 deletions src/component/panels/SummaryPanel/Utilities.ts
Expand Up @@ -6,7 +6,8 @@ import {
buildLink,
getLinkDim,
removeLink,
Types,
Link,
Correlation,
} from 'nmr-correlation';

import { Datum2D } from '../../../data/types/data2d';
Expand Down Expand Up @@ -44,7 +45,7 @@ function getLabelColor(correlationData, correlation) {

function findSignalMatch1D(
spectrum: Datum2D,
link: Types.Link,
link: Link,
factor: number,
xDomain0: number,
xDomain1: number,
Expand All @@ -64,7 +65,7 @@ function findSignalMatch1D(

function findSignalMatch2D(
spectrum: Datum2D,
link: Types.Link,
link: Link,
factor: number,
xDomain0: number,
xDomain1: number,
Expand All @@ -85,7 +86,7 @@ function findSignalMatch2D(
return false;
}

function getAbbreviation(link: Types.Link): string {
function getAbbreviation(link: Link): string {
if (link.experimentType === 'hsqc' || link.experimentType === 'hmqc') {
return !link.signal || link.signal.sign === 0
? 'S'
Expand Down Expand Up @@ -120,7 +121,7 @@ function buildNewLink1D(link) {
});
}

function buildNewLink2D(link: Types.Link, axis: 'x' | 'y') {
function buildNewLink2D(link: Link, axis: 'x' | 'y') {
const linkIDs = link.id.split('_');
return buildLink({
...link,
Expand All @@ -135,11 +136,11 @@ function buildNewLink2D(link: Types.Link, axis: 'x' | 'y') {
}

function cloneCorrelationAndEditLink(
correlation: Types.Correlation,
link: Types.Link,
correlation: Correlation,
link: Link,
axis: 'x' | 'y',
action: 'add' | 'remove' | 'unmove',
): Types.Correlation {
): Correlation {
const linkDim = getLinkDim(link);
const _correlation = lodashCloneDeep(correlation);
const split = link.id.split('_');
Expand Down Expand Up @@ -175,7 +176,7 @@ function getEditedCorrelations({
correlationDim2 && selectedCorrelationDim2?.id !== correlationDim2?.id;
const linkDim = getLinkDim(link);

const editedCorrelations: Types.Correlation[] = [];
const editedCorrelations: Correlation[] = [];
const buildCorrelationDataOptions: {
skipDataUpdate?: boolean;
} = {};
Expand All @@ -190,7 +191,7 @@ function getEditedCorrelations({
'remove',
);
// modify selected correlation
let newCorrelationDim1: Types.Correlation;
let newCorrelationDim1: Correlation;
if (selectedCorrelationDim1) {
newCorrelationDim1 = cloneCorrelationAndEditLink(
hasChangedDim1 ? selectedCorrelationDim1 : _correlationDim1,
Expand Down
4 changes: 2 additions & 2 deletions src/component/reducer/Reducer.ts
@@ -1,5 +1,5 @@
import { Draft, produce } from 'immer';
import { buildCorrelationData, Types } from 'nmr-correlation';
import { buildCorrelationData, CorrelationData } from 'nmr-correlation';

import { predictSpectra } from '../../data/PredictionManager';
import * as SpectraManager from '../../data/SpectraManager';
Expand Down Expand Up @@ -274,7 +274,7 @@ export interface State {
/**
* Correlation data
*/
correlations: Types.CorrelationData;
correlations: CorrelationData;

/**
* Zoom Manager for vertical scale for spectra, integral, And undo zoom in per tab (nucleus)
Expand Down
27 changes: 17 additions & 10 deletions src/component/reducer/actions/CorrelationsActions.ts
@@ -1,6 +1,13 @@
import { original, Draft } from 'immer';
import lodashCloneDeep from 'lodash/cloneDeep';
import { buildCorrelationData, setCorrelation, Types } from 'nmr-correlation';
import {
buildCorrelationData,
setCorrelation,
Tolerance,
Options as CorrelationOptions,
Correlation,
Values as CorrelationValues,
} from 'nmr-correlation';

import { Datum1D } from '../../../data/types/data1d';
import { Datum2D } from '../../../data/types/data2d';
Expand All @@ -18,7 +25,7 @@ import { handleDeleteSignal as handleDeleteSignal2D } from './ZonesActions';

function handleUpdateCorrelations(draft: Draft<State>) {
const { data: spectra, correlations } = draft;
draft.correlations = buildCorrelationData(spectra as Types.Spectra, {
draft.correlations = buildCorrelationData(spectra, {
...correlations.options,
values: lodashCloneDeep(correlations.values),
});
Expand All @@ -30,7 +37,7 @@ function handleSetMF(draft: Draft<State>, payload: { mf: string }) {
const { mf } = payload;
// update of correlation data is needed only if the following is true
if (correlations.options.mf === '' || correlations.options.mf !== mf) {
draft.correlations = buildCorrelationData(spectra as Types.Spectra, {
draft.correlations = buildCorrelationData(spectra, {
...correlations.options,
mf,
values: lodashCloneDeep(correlations.values),
Expand All @@ -40,12 +47,12 @@ function handleSetMF(draft: Draft<State>, payload: { mf: string }) {

function handleSetTolerance(
draft: Draft<State>,
payload: { tolerance: Types.Tolerance },
payload: { tolerance: Tolerance },
) {
const state = original(draft) as State;
const { data: spectra, correlations } = state;
const { tolerance } = payload;
draft.correlations = buildCorrelationData(spectra as Types.Spectra, {
draft.correlations = buildCorrelationData(spectra, {
...correlations.options,
tolerance,
values: lodashCloneDeep(correlations.values),
Expand All @@ -56,8 +63,8 @@ function handleSetCorrelation(
draft: Draft<State>,
payload: {
id: string;
correlation: Types.Correlation;
options: Types.Options;
correlation: Correlation;
options: CorrelationOptions;
},
) {
const state = original(draft) as State;
Expand All @@ -76,8 +83,8 @@ function handleSetCorrelation(
function handleSetCorrelations(
draft: Draft<State>,
payload: {
correlations: Types.Values;
options: Types.Options;
correlations: CorrelationValues;
options: CorrelationOptions;
},
) {
const { correlations, options } = payload;
Expand All @@ -102,7 +109,7 @@ function handleSetCorrelations(

function handleDeleteCorrelation(
draft: Draft<State>,
payload: { correlation: Types.Correlation; assignmentData },
payload: { correlation: Correlation; assignmentData },
) {
const { correlation, assignmentData } = payload;
// delete all signals linked to the correlation
Expand Down

0 comments on commit 4995931

Please sign in to comment.