nmrium 0.38.2 → 0.40.1
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/lib/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +90 -67
- package/lib/component/NMRium.d.ts +1 -0
- package/lib/component/NMRium.js +4 -2
- package/lib/component/context/LoggerContext.js +12 -2
- package/lib/component/context/PreferencesContext.d.ts +4 -2
- package/lib/component/elements/formik/FormikError.d.ts +8 -0
- package/lib/component/elements/formik/FormikError.js +22 -0
- package/lib/component/elements/popup/Alert/AlertBlock.d.ts +7 -0
- package/lib/component/elements/popup/Alert/AlertBlock.js +24 -0
- package/lib/component/elements/popup/Alert/Provider.js +2 -20
- package/lib/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib/component/header/Header.js +2 -2
- package/lib/component/hooks/useSaveSettings.js +18 -16
- package/lib/component/modal/AboutUsModal.js +4 -2
- package/lib/component/modal/LoadJCAMPModal.js +41 -28
- package/lib/component/modal/LogsHistoryModal.d.ts +6 -0
- package/lib/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +6 -4
- package/lib/component/modal/PredictSpectraModal.js +12 -2
- package/lib/component/modal/editRange/EditRangeModal.d.ts +7 -6
- package/lib/component/modal/editRange/EditRangeModal.js +33 -13
- package/lib/component/modal/setting/GeneralSettings.js +29 -28
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +18 -16
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib/component/panels/Panels.js +2 -2
- package/lib/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +1 -1
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +9 -12
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +7 -10
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib/component/reducer/actions/DatabaseActions.js +6 -4
- package/lib/component/reducer/actions/DomainActions.js +3 -0
- package/lib/component/reducer/actions/IntegralsActions.js +3 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +6 -6
- package/lib/component/reducer/actions/ToolsActions.js +3 -32
- package/lib/component/reducer/actions/ZonesActions.js +2 -4
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +8 -0
- package/lib/component/reducer/helper/ZoomHistoryManager.js +35 -0
- package/lib/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
- package/lib/component/utility/export.d.ts +5 -4
- package/lib/component/utility/export.js +24 -52
- package/lib/data/PredictionManager.d.ts +3 -1
- package/lib/data/PredictionManager.js +27 -1
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +1 -2
- package/lib/data/data1d/Spectrum1D/integrals/initiateIntegrals.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +13 -6
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +23 -18
- package/lib/utils/clipboard/clipboard.d.ts +12 -0
- package/lib/utils/clipboard/clipboard.js +15 -0
- package/lib/utils/clipboard/clipboardComponents.d.ts +45 -0
- package/lib/utils/clipboard/clipboardComponents.js +150 -0
- package/lib/utils/clipboard/clipboardHooks.d.ts +94 -0
- package/lib/utils/clipboard/clipboardHooks.js +142 -0
- package/lib/utils/clipboard/types.d.ts +1 -0
- package/lib/utils/clipboard/types.js +1 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +90 -67
- package/lib-cjs/component/NMRium.js +4 -2
- package/lib-cjs/component/context/LoggerContext.js +11 -1
- package/lib-cjs/component/elements/formik/FormikError.js +27 -0
- package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +30 -0
- package/lib-cjs/component/elements/popup/Alert/Provider.js +2 -20
- package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib-cjs/component/header/Header.js +2 -2
- package/lib-cjs/component/hooks/useSaveSettings.js +17 -15
- package/lib-cjs/component/modal/AboutUsModal.js +4 -2
- package/lib-cjs/component/modal/LoadJCAMPModal.js +41 -28
- package/lib-cjs/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +8 -6
- package/lib-cjs/component/modal/PredictSpectraModal.js +12 -2
- package/lib-cjs/component/modal/editRange/EditRangeModal.js +32 -12
- package/lib-cjs/component/modal/setting/GeneralSettings.js +29 -28
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +17 -15
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib-cjs/component/panels/Panels.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib-cjs/component/panels/RangesPanel/hooks/useEditRangeModal.js +9 -12
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +7 -10
- package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib-cjs/component/reducer/actions/DatabaseActions.js +6 -4
- package/lib-cjs/component/reducer/actions/DomainActions.js +3 -0
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +3 -1
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +6 -6
- package/lib-cjs/component/reducer/actions/ToolsActions.js +26 -32
- package/lib-cjs/component/reducer/actions/ZonesActions.js +2 -4
- package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +37 -0
- package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib-cjs/component/utility/export.js +24 -54
- package/lib-cjs/data/PredictionManager.js +27 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +13 -6
- package/lib-cjs/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +23 -18
- package/lib-cjs/utils/clipboard/clipboard.js +23 -0
- package/lib-cjs/utils/clipboard/clipboardComponents.js +158 -0
- package/lib-cjs/utils/clipboard/clipboardHooks.js +147 -0
- package/lib-cjs/utils/clipboard/types.js +2 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +17 -17
- package/lib/component/header/LogsHistory.d.ts +0 -1
|
@@ -10,12 +10,13 @@ const react_1 = require("react");
|
|
|
10
10
|
const fa_1 = require("react-icons/fa");
|
|
11
11
|
const io5_1 = require("react-icons/io5");
|
|
12
12
|
const ui_1 = require("react-science/ui");
|
|
13
|
+
const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
|
|
14
|
+
const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
|
|
13
15
|
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
14
16
|
const ReactTable_1 = __importDefault(require("../../elements/ReactTable/ReactTable"));
|
|
15
17
|
const Alert_1 = require("../../elements/popup/Alert");
|
|
16
18
|
const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
|
|
17
19
|
const ExportAsJcampModal_1 = __importDefault(require("../../modal/ExportAsJcampModal"));
|
|
18
|
-
const export_1 = require("../../utility/export");
|
|
19
20
|
const ColorIndicator_1 = __importDefault(require("./base/ColorIndicator"));
|
|
20
21
|
const ShowHideSpectrumButton_1 = __importDefault(require("./base/ShowHideSpectrumButton"));
|
|
21
22
|
const SpectrumName_1 = require("./base/SpectrumName");
|
|
@@ -136,19 +137,15 @@ function SpectraTable(props) {
|
|
|
136
137
|
},
|
|
137
138
|
},
|
|
138
139
|
}), [onChangeVisibility, onOpenSettingModal]);
|
|
140
|
+
const { rawWriteWithType, cleanShouldFallback, shouldFallback, text } = (0, clipboardHooks_1.useClipboard)();
|
|
139
141
|
const selectContextMenuHandler = (0, react_1.useCallback)((option, spectrum) => {
|
|
140
142
|
const { id } = option.data;
|
|
141
143
|
switch (id) {
|
|
142
144
|
case SpectraContextMenuOptionsKeys.CopyToClipboard: {
|
|
143
145
|
void (async () => {
|
|
144
146
|
const { data, info } = spectrum;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
alert.success('Data copied to clipboard');
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
alert.error('Copy to clipboard failed');
|
|
151
|
-
}
|
|
147
|
+
await rawWriteWithType(JSON.stringify({ data, info }, (_, value) => ArrayBuffer.isView(value) ? Array.from(value) : value, 2));
|
|
148
|
+
alert.success('Data copied to clipboard');
|
|
152
149
|
})();
|
|
153
150
|
break;
|
|
154
151
|
}
|
|
@@ -166,7 +163,7 @@ function SpectraTable(props) {
|
|
|
166
163
|
break;
|
|
167
164
|
}
|
|
168
165
|
}
|
|
169
|
-
}, [alert, dispatch]);
|
|
166
|
+
}, [alert, dispatch, rawWriteWithType]);
|
|
170
167
|
function handleActiveRow(row) {
|
|
171
168
|
return activeSpectraObj?.[row?.original.id] || false;
|
|
172
169
|
}
|
|
@@ -220,7 +217,7 @@ function SpectraTable(props) {
|
|
|
220
217
|
? Spectra1DContextMenuOptions
|
|
221
218
|
: Spectra2DContextMenuOptions, onContextMenuSelect: selectContextMenuHandler, onSortEnd: handleSortEnd, style: { 'table td': { paddingTop: 0, paddingBottom: 0 } } }), exportedSpectrum && ((0, jsx_runtime_1.jsx)(ExportAsJcampModal_1.default, { spectrum: exportedSpectrum, closeDialog: () => {
|
|
222
219
|
setExportedSpectrum(null);
|
|
223
|
-
} }))] }));
|
|
220
|
+
} })), (0, jsx_runtime_1.jsx)(clipboardComponents_1.ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Spectra" })] }));
|
|
224
221
|
}
|
|
225
222
|
exports.SpectraTable = SpectraTable;
|
|
226
223
|
const ColumnHeader = ({ label, col, }) => {
|
|
@@ -11,6 +11,7 @@ const ui_1 = require("react-science/ui");
|
|
|
11
11
|
const PredictionManager_1 = require("../../../data/PredictionManager");
|
|
12
12
|
const ChartContext_1 = require("../../context/ChartContext");
|
|
13
13
|
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
14
|
+
const LoggerContext_1 = require("../../context/LoggerContext");
|
|
14
15
|
const Button_1 = __importDefault(require("../../elements/Button"));
|
|
15
16
|
const NextPrev_1 = __importDefault(require("../../elements/NextPrev"));
|
|
16
17
|
const Alert_1 = require("../../elements/popup/Alert");
|
|
@@ -36,6 +37,7 @@ function PredictionPanel() {
|
|
|
36
37
|
const { molecules, view: { molecules: moleculesView, predictions }, } = (0, ChartContext_1.useChartData)();
|
|
37
38
|
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
38
39
|
const alert = (0, Alert_1.useAlert)();
|
|
40
|
+
const { logger } = (0, LoggerContext_1.useLogger)();
|
|
39
41
|
const [currentIndex, setCurrentIndex] = (0, react_1.useState)(0);
|
|
40
42
|
const [molfile, setMolfile] = (0, react_1.useState)(null);
|
|
41
43
|
const [isFlipped, setFlipStatus] = (0, react_1.useState)(false);
|
|
@@ -75,7 +77,7 @@ function PredictionPanel() {
|
|
|
75
77
|
}
|
|
76
78
|
const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
|
|
77
79
|
try {
|
|
78
|
-
const data = await (0, PredictionManager_1.predictSpectra)(molfile);
|
|
80
|
+
const data = await (0, PredictionManager_1.predictSpectra)(molfile, logger);
|
|
79
81
|
dispatch({
|
|
80
82
|
type: 'PREDICT_SPECTRA',
|
|
81
83
|
payload: {
|
|
@@ -27,9 +27,11 @@ exports.handleResurrectSpectrumFromJcamp = handleResurrectSpectrumFromJcamp;
|
|
|
27
27
|
function handleResurrectSpectrumFromRanges(draft, action) {
|
|
28
28
|
const { ranges, info } = action.payload;
|
|
29
29
|
const datum = (0, generateSpectrumFromRanges_1.generateSpectrumFromRanges)(ranges, info, draft.usedColors);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
if (datum) {
|
|
31
|
+
draft.data.push(datum);
|
|
32
|
+
(0, DomainActions_1.setDomain)(draft, { isYDomainShared: false });
|
|
33
|
+
(0, DomainActions_1.setIntegralsYDomain)(draft, [datum]);
|
|
34
|
+
(0, Zoom1DManager_1.setZoom)(draft, { scale: 0.8, spectrumID: datum.id });
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
37
|
exports.handleResurrectSpectrumFromRanges = handleResurrectSpectrumFromRanges;
|
|
@@ -9,6 +9,7 @@ const get1DDataXY_1 = require("../../../data/data1d/Spectrum1D/get1DDataXY");
|
|
|
9
9
|
const Spectrum2D_1 = require("../../../data/data2d/Spectrum2D");
|
|
10
10
|
const nucleusToString_1 = __importDefault(require("../../utility/nucleusToString"));
|
|
11
11
|
const Constants_1 = require("../core/Constants");
|
|
12
|
+
const ZoomHistoryManager_1 = require("../helper/ZoomHistoryManager");
|
|
12
13
|
const getActiveSpectrum_1 = require("../helper/getActiveSpectrum");
|
|
13
14
|
function getActiveData(draft) {
|
|
14
15
|
let data = draft.data.filter((datum) => (0, nucleusToString_1.default)(datum.info.nucleus) === draft.view.spectra.activeTab &&
|
|
@@ -195,11 +196,13 @@ exports.setMode = setMode;
|
|
|
195
196
|
function handleSetXDomain(draft, action) {
|
|
196
197
|
const xDomain = action.payload.xDomain;
|
|
197
198
|
draft.xDomain = xDomain;
|
|
199
|
+
(0, ZoomHistoryManager_1.addToBrushHistory)(draft, { xDomain, yDomain: draft.yDomain });
|
|
198
200
|
}
|
|
199
201
|
exports.handleSetXDomain = handleSetXDomain;
|
|
200
202
|
//action
|
|
201
203
|
function handleSetYDomain(draft, action) {
|
|
202
204
|
const yDomain = action.payload.yDomain;
|
|
203
205
|
draft.yDomain = yDomain;
|
|
206
|
+
(0, ZoomHistoryManager_1.addToBrushHistory)(draft, { xDomain: draft.xDomain, yDomain });
|
|
204
207
|
}
|
|
205
208
|
exports.handleSetYDomain = handleSetYDomain;
|
|
@@ -33,13 +33,15 @@ function handleAddIntegral(draft, action) {
|
|
|
33
33
|
const datum = data[activeSpectrum.index];
|
|
34
34
|
const { x, re } = datum.data;
|
|
35
35
|
const shiftX = (0, Spectrum1D_1.getShiftX)(datum);
|
|
36
|
+
const integration = (0, ml_spectra_processing_1.xyIntegration)({ x, y: re }, { from, to, reverse: true });
|
|
36
37
|
const integral = {
|
|
37
38
|
id: (0, uuid_1.v4)(),
|
|
38
39
|
originFrom: from - shiftX,
|
|
39
40
|
originTo: to - shiftX,
|
|
40
41
|
from,
|
|
41
42
|
to,
|
|
42
|
-
|
|
43
|
+
integral: integration,
|
|
44
|
+
absolute: integration,
|
|
43
45
|
kind: 'signal',
|
|
44
46
|
};
|
|
45
47
|
datum.integrals.values.push(integral);
|
|
@@ -12,7 +12,6 @@ const nmr_processing_1 = require("nmr-processing");
|
|
|
12
12
|
const Spectrum1D_1 = require("../../../data/data1d/Spectrum1D");
|
|
13
13
|
const Spectrum2D_1 = require("../../../data/data2d/Spectrum2D");
|
|
14
14
|
const contours_1 = require("../../../data/data2d/Spectrum2D/contours");
|
|
15
|
-
const ToolTypes_1 = require("../../toolbar/ToolTypes");
|
|
16
15
|
const GroupByInfoKey_1 = __importDefault(require("../../utility/GroupByInfoKey"));
|
|
17
16
|
const getSpectraByNucleus_1 = require("../../utility/getSpectraByNucleus");
|
|
18
17
|
const Zoom1DManager_1 = require("../helper/Zoom1DManager");
|
|
@@ -213,8 +212,7 @@ function handleChangeActiveSpectrum(draft, action) {
|
|
|
213
212
|
(0, ToolsActions_1.setMargin)(draft);
|
|
214
213
|
(0, DomainActions_1.setMode)(draft);
|
|
215
214
|
}
|
|
216
|
-
if (
|
|
217
|
-
!toolOptions.data.activeFilterID) {
|
|
215
|
+
if (!toolOptions.data.activeFilterID) {
|
|
218
216
|
(0, ToolsActions_1.resetSelectedTool)(draft);
|
|
219
217
|
}
|
|
220
218
|
}
|
|
@@ -306,9 +304,11 @@ exports.handleAlignSpectraHandler = handleAlignSpectraHandler;
|
|
|
306
304
|
function handleGenerateSpectrumFromPublicationStringHandler(draft, action) {
|
|
307
305
|
const publicationString = action.payload.publicationText;
|
|
308
306
|
const spectrum = (0, Spectrum1D_1.generateSpectrumFromPublicationString)(publicationString, draft.usedColors);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
307
|
+
if (spectrum) {
|
|
308
|
+
draft.data.push(spectrum);
|
|
309
|
+
(0, ToolsActions_1.setActiveTab)(draft);
|
|
310
|
+
(0, Zoom1DManager_1.setZoom)(draft, { scale: 0.8, spectrumID: spectrum.id });
|
|
311
|
+
}
|
|
312
312
|
}
|
|
313
313
|
exports.handleGenerateSpectrumFromPublicationStringHandler = handleGenerateSpectrumFromPublicationStringHandler;
|
|
314
314
|
//action
|
|
@@ -1,4 +1,27 @@
|
|
|
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
|
};
|
|
@@ -17,7 +40,7 @@ const getSpectraByNucleus_1 = require("../../utility/getSpectraByNucleus");
|
|
|
17
40
|
const Reducer_1 = require("../Reducer");
|
|
18
41
|
const Constants_1 = require("../core/Constants");
|
|
19
42
|
const Zoom1DManager_1 = require("../helper/Zoom1DManager");
|
|
20
|
-
const ZoomHistoryManager_1 =
|
|
43
|
+
const ZoomHistoryManager_1 = __importStar(require("../helper/ZoomHistoryManager"));
|
|
21
44
|
const getActiveSpectra_1 = require("../helper/getActiveSpectra");
|
|
22
45
|
const getActiveSpectrum_1 = require("../helper/getActiveSpectrum");
|
|
23
46
|
const getVerticalAlign_1 = require("../helper/getVerticalAlign");
|
|
@@ -160,7 +183,7 @@ function handleToggleRealImaginaryVisibility(draft) {
|
|
|
160
183
|
exports.handleToggleRealImaginaryVisibility = handleToggleRealImaginaryVisibility;
|
|
161
184
|
function handleBrushEnd(draft, action) {
|
|
162
185
|
const is2D = draft.displayerMode === Constants_1.DISPLAYER_MODE.DM_2D;
|
|
163
|
-
const { height, margin, yDomain, yDomains, width, xDomains, xDomain, mode
|
|
186
|
+
const { height, margin, yDomain, yDomains, width, xDomains, xDomain, mode } = draft;
|
|
164
187
|
const xScale = (0, scale_1.getXScale)({ width, xDomains, xDomain, mode, margin });
|
|
165
188
|
const verticalAlign = (0, getVerticalAlign_1.getVerticalAlign)(draft);
|
|
166
189
|
const yScale = is2D
|
|
@@ -173,36 +196,7 @@ function handleBrushEnd(draft, action) {
|
|
|
173
196
|
const endY = yScale.invert(_endY);
|
|
174
197
|
const domainX = startX > endX ? [endX, startX] : [startX, endX];
|
|
175
198
|
const domainY = startY > endY ? [endY, startY] : [startY, endY];
|
|
176
|
-
|
|
177
|
-
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
178
|
-
draft.zoom.history,
|
|
179
|
-
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
180
|
-
draft.view.spectra.activeTab);
|
|
181
|
-
if (displayerMode === Constants_1.DISPLAYER_MODE.DM_2D) {
|
|
182
|
-
switch (trackID) {
|
|
183
|
-
case 'CENTER_2D':
|
|
184
|
-
draft.xDomain = domainX;
|
|
185
|
-
draft.yDomain = domainY;
|
|
186
|
-
break;
|
|
187
|
-
case 'TOP_1D':
|
|
188
|
-
draft.xDomain = domainX;
|
|
189
|
-
break;
|
|
190
|
-
case 'LEFT_1D':
|
|
191
|
-
draft.yDomain = domainY;
|
|
192
|
-
break;
|
|
193
|
-
default:
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
if (brushHistory) {
|
|
197
|
-
brushHistory.push({ xDomain, yDomain });
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
draft.xDomain = domainX;
|
|
202
|
-
if (brushHistory) {
|
|
203
|
-
brushHistory.push({ xDomain: domainX, yDomain: domainY });
|
|
204
|
-
}
|
|
205
|
-
}
|
|
199
|
+
(0, ZoomHistoryManager_1.addToBrushHistory)(draft, { trackID, xDomain: domainX, yDomain: domainY });
|
|
206
200
|
}
|
|
207
201
|
exports.handleBrushEnd = handleBrushEnd;
|
|
208
202
|
function setVerticalIndicatorXPosition(draft, action) {
|
|
@@ -62,10 +62,8 @@ exports.handleAutoZonesDetection = handleAutoZonesDetection;
|
|
|
62
62
|
function handleAutoSpectraZonesDetection(draft) {
|
|
63
63
|
for (const datum of draft.data) {
|
|
64
64
|
const { info, data } = datum;
|
|
65
|
-
if (info.dimension === 2) {
|
|
66
|
-
const { minX, maxX, minY, maxY } =
|
|
67
|
-
? data.re
|
|
68
|
-
: data.rr;
|
|
65
|
+
if (info.dimension === 2 && info.isFt) {
|
|
66
|
+
const { minX, maxX, minY, maxY } = data.rr;
|
|
69
67
|
const detectionOptions = {
|
|
70
68
|
selectedZone: { fromX: minX, toX: maxX, fromY: minY, toY: maxY },
|
|
71
69
|
thresholdFactor: 1,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addToBrushHistory = void 0;
|
|
4
|
+
const Constants_1 = require("../core/Constants");
|
|
3
5
|
function zoomHistoryManager(zoomHistory, nucleus, baseZoom) {
|
|
4
6
|
if (!zoomHistory[nucleus] && !Array.isArray(zoomHistory[nucleus])) {
|
|
5
7
|
zoomHistory[nucleus] = [];
|
|
@@ -32,3 +34,38 @@ function prepareGetLast(historyStack) {
|
|
|
32
34
|
return historyStack.at(-1);
|
|
33
35
|
};
|
|
34
36
|
}
|
|
37
|
+
function addToBrushHistory(draft, options) {
|
|
38
|
+
const { displayerMode } = draft;
|
|
39
|
+
const { trackID, xDomain, yDomain } = options;
|
|
40
|
+
const brushHistory = zoomHistoryManager(
|
|
41
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
42
|
+
draft.zoom.history,
|
|
43
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
44
|
+
draft.view.spectra.activeTab);
|
|
45
|
+
if (displayerMode === Constants_1.DISPLAYER_MODE.DM_2D) {
|
|
46
|
+
switch (trackID) {
|
|
47
|
+
case 'CENTER_2D':
|
|
48
|
+
draft.xDomain = xDomain;
|
|
49
|
+
draft.yDomain = yDomain;
|
|
50
|
+
break;
|
|
51
|
+
case 'TOP_1D':
|
|
52
|
+
draft.xDomain = xDomain;
|
|
53
|
+
break;
|
|
54
|
+
case 'LEFT_1D':
|
|
55
|
+
draft.yDomain = yDomain;
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (brushHistory) {
|
|
61
|
+
brushHistory.push({ xDomain, yDomain });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
draft.xDomain = xDomain;
|
|
66
|
+
if (brushHistory) {
|
|
67
|
+
brushHistory.push({ xDomain, yDomain });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.addToBrushHistory = addToBrushHistory;
|
|
@@ -9,12 +9,12 @@ const merge_1 = __importDefault(require("lodash/merge"));
|
|
|
9
9
|
const LocalStorage_1 = require("../../../utility/LocalStorage");
|
|
10
10
|
const workspaceDefaultProperties_1 = require("../../../workspaces/workspaceDefaultProperties");
|
|
11
11
|
function addWorkspace(draft, action) {
|
|
12
|
-
const {
|
|
12
|
+
const { workspaceKey, data } = action.payload;
|
|
13
13
|
const newWorkSpace = (0, merge_1.default)({}, workspaceDefaultProperties_1.workspaceDefaultProperties,
|
|
14
14
|
// eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary
|
|
15
15
|
data ? data : draft.workspaces[draft.workspace.current], {
|
|
16
16
|
version: 1,
|
|
17
|
-
label:
|
|
17
|
+
label: workspaceKey,
|
|
18
18
|
source: 'user',
|
|
19
19
|
});
|
|
20
20
|
const newWorkspaceKey = (0, uuid_1.v4)();
|
|
@@ -3,46 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getBlob = exports.exportAsMatrix = exports.exportAsMol = exports.
|
|
6
|
+
exports.getBlob = exports.exportAsMatrix = exports.exportAsMol = exports.copyPNGToClipboard = exports.exportAsPng = exports.exportAsNMRE = exports.exportAsJSON = exports.exportAsSVG = void 0;
|
|
7
7
|
const file_saver_1 = require("file-saver");
|
|
8
8
|
const jszip_1 = __importDefault(require("jszip"));
|
|
9
|
-
|
|
10
|
-
return copyToClipboard(data, 'text/html');
|
|
11
|
-
}
|
|
12
|
-
exports.copyHTMLToClipboard = copyHTMLToClipboard;
|
|
13
|
-
async function copyTextToClipboard(data) {
|
|
14
|
-
return copyToClipboard(data, 'text/plain');
|
|
15
|
-
}
|
|
16
|
-
exports.copyTextToClipboard = copyTextToClipboard;
|
|
17
|
-
async function copyToClipboard(data, type) {
|
|
18
|
-
try {
|
|
19
|
-
if (typeof ClipboardItem !== 'undefined') {
|
|
20
|
-
void navigator.clipboard.write([
|
|
21
|
-
new ClipboardItem({
|
|
22
|
-
[type]: new Promise((resolve) => {
|
|
23
|
-
resolve(new Blob([data], { type }));
|
|
24
|
-
}),
|
|
25
|
-
}),
|
|
26
|
-
]);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
const clipboard = await import('clipboard-polyfill');
|
|
30
|
-
//TODO when Firefox team implement ClipboardItem this code should be removed
|
|
31
|
-
// this library is used mainly to solve the problem of copy HTML to a clipboard in Firefox but we use it for both HTML and plain text
|
|
32
|
-
const item = new clipboard.ClipboardItem({
|
|
33
|
-
[type]: new Blob([data], { type }),
|
|
34
|
-
});
|
|
35
|
-
await clipboard.write([item]);
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
9
|
+
const clipboard_1 = require("../../utils/clipboard/clipboard");
|
|
43
10
|
/**
|
|
44
11
|
* export the experiments result in JSON format
|
|
45
|
-
* @param
|
|
12
|
+
* @param data
|
|
13
|
+
* @param fileName
|
|
14
|
+
* @param spaceIndent
|
|
15
|
+
* @param isCompressed
|
|
46
16
|
*/
|
|
47
17
|
async function exportAsJSON(data, fileName = 'experiment', spaceIndent = 0, isCompressed = false) {
|
|
48
18
|
const fileData = JSON.stringify(data, (key, value) => ArrayBuffer.isView(value) ? Array.from(value) : value, spaceIndent);
|
|
@@ -151,16 +121,24 @@ function copyDataURLClipboardFireFox(image) {
|
|
|
151
121
|
}
|
|
152
122
|
function copyBlobToClipboard(canvas) {
|
|
153
123
|
canvas.toBlob((b) => {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
124
|
+
if (!b)
|
|
125
|
+
return;
|
|
126
|
+
(async () => {
|
|
127
|
+
const clip = await (0, clipboard_1.newClipboardItem)({
|
|
128
|
+
[b.type]: b,
|
|
129
|
+
});
|
|
130
|
+
await (0, clipboard_1.write)([clip]);
|
|
131
|
+
})()
|
|
132
|
+
.catch(() => {
|
|
133
|
+
const png = canvas.toDataURL('image/png', 1);
|
|
134
|
+
copyDataURLClipboardFireFox(png);
|
|
135
|
+
URL.revokeObjectURL(png);
|
|
136
|
+
})
|
|
137
|
+
.then(() => {
|
|
158
138
|
// eslint-disable-next-line no-console
|
|
159
139
|
console.log('experiment copied.');
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
reportError(error);
|
|
163
|
-
});
|
|
140
|
+
})
|
|
141
|
+
.catch(reportError);
|
|
164
142
|
});
|
|
165
143
|
}
|
|
166
144
|
function copyPNGToClipboard(rootRef, elementID) {
|
|
@@ -176,17 +154,9 @@ function copyPNGToClipboard(rootRef, elementID) {
|
|
|
176
154
|
}
|
|
177
155
|
let img = new Image();
|
|
178
156
|
const url = URL.createObjectURL(blob);
|
|
179
|
-
img.addEventListener('load',
|
|
157
|
+
img.addEventListener('load', () => {
|
|
180
158
|
context?.drawImage(img, 0, 0);
|
|
181
|
-
|
|
182
|
-
// @ts-expect-error write exists in some browsers
|
|
183
|
-
if (navigator.clipboard.write) {
|
|
184
|
-
copyBlobToClipboard(canvas);
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
copyDataURLClipboardFireFox(png);
|
|
188
|
-
}
|
|
189
|
-
URL.revokeObjectURL(png);
|
|
159
|
+
copyBlobToClipboard(canvas);
|
|
190
160
|
});
|
|
191
161
|
img.src = url;
|
|
192
162
|
}
|
|
@@ -32,7 +32,10 @@ exports.defaultPredictionOptions = {
|
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
exports.FREQUENCIES = [
|
|
35
|
+
{ value: 40, label: '40 MHz' },
|
|
35
36
|
{ value: 60, label: '60 MHz' },
|
|
37
|
+
{ value: 80, label: '80 MHz' },
|
|
38
|
+
{ value: 90, label: '90 MHz' },
|
|
36
39
|
{ value: 100, label: '100 MHz' },
|
|
37
40
|
{ value: 200, label: '200 MHz' },
|
|
38
41
|
{ value: 300, label: '300 MHz' },
|
|
@@ -44,9 +47,10 @@ exports.FREQUENCIES = [
|
|
|
44
47
|
{ value: 1200, label: '1200 MHz' },
|
|
45
48
|
];
|
|
46
49
|
const baseURL = 'https://nmr-prediction.service.zakodium.com';
|
|
47
|
-
async function predictSpectra(molfile) {
|
|
50
|
+
async function predictSpectra(molfile, logger) {
|
|
48
51
|
const molecule = full_1.default.Molecule.fromMolfile(molfile);
|
|
49
52
|
return (0, nmr_processing_1.predictAll)(molecule, {
|
|
53
|
+
logger,
|
|
50
54
|
predictOptions: {
|
|
51
55
|
C: {
|
|
52
56
|
webserviceURL: `${baseURL}/v1/predict/carbon`,
|
|
@@ -173,6 +177,7 @@ function generated2DSpectrum(params) {
|
|
|
173
177
|
frequency,
|
|
174
178
|
experiment,
|
|
175
179
|
});
|
|
180
|
+
const spectralWidth = getSpectralWidth(experiment, inputOptions);
|
|
176
181
|
const datum = (0, Spectrum2D_1.initiateDatum2D)({
|
|
177
182
|
data: { rr: { ...minMaxContent, noise: 0.01 } },
|
|
178
183
|
display: {
|
|
@@ -186,6 +191,7 @@ function generated2DSpectrum(params) {
|
|
|
186
191
|
originFrequency: frequency,
|
|
187
192
|
baseFrequency: frequency,
|
|
188
193
|
pulseSequence: 'prediction',
|
|
194
|
+
spectralWidth,
|
|
189
195
|
experiment,
|
|
190
196
|
},
|
|
191
197
|
}, []);
|
|
@@ -195,6 +201,26 @@ function generated2DSpectrum(params) {
|
|
|
195
201
|
function get2DWidth(nucleus) {
|
|
196
202
|
return nucleus[0] === nucleus[1] ? 0.02 : { x: 0.02, y: 0.2133 };
|
|
197
203
|
}
|
|
204
|
+
function getSpectralWidth(experiment, options) {
|
|
205
|
+
const formTo = options['1d'];
|
|
206
|
+
switch (experiment) {
|
|
207
|
+
case 'cosy': {
|
|
208
|
+
const { from, to } = formTo['1H'];
|
|
209
|
+
const diff = to - from;
|
|
210
|
+
return [diff, diff];
|
|
211
|
+
}
|
|
212
|
+
case 'hsqc':
|
|
213
|
+
case 'hmbc': {
|
|
214
|
+
const proton = formTo['1H'];
|
|
215
|
+
const carbon = formTo['13C'];
|
|
216
|
+
const protonDiff = proton.to - proton.from;
|
|
217
|
+
const carbonDiff = carbon.to - carbon.from;
|
|
218
|
+
return [protonDiff, carbonDiff];
|
|
219
|
+
}
|
|
220
|
+
default:
|
|
221
|
+
return [];
|
|
222
|
+
}
|
|
223
|
+
}
|
|
198
224
|
function calculateFrequency(nucleus, frequency) {
|
|
199
225
|
if (typeof nucleus === 'string') {
|
|
200
226
|
return (0, nmr_processing_1.getFrequency)(nucleus, { nucleus: '1H', frequency });
|
|
@@ -61,13 +61,20 @@ function detectSignal(data, options) {
|
|
|
61
61
|
exports.default = detectSignal;
|
|
62
62
|
function joinCouplings(result) {
|
|
63
63
|
const { chemShift: delta, js } = result;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
let jCouplings = js;
|
|
65
|
+
if (js.length > 1) {
|
|
66
|
+
try {
|
|
67
|
+
jCouplings = (0, nmr_processing_1.signalJoinCouplings)({
|
|
68
68
|
delta,
|
|
69
69
|
js,
|
|
70
|
-
}, { tolerance: 0.6, ignoreDiaIDs: true }).js
|
|
71
|
-
|
|
70
|
+
}, { tolerance: 0.6, ignoreDiaIDs: true }).js;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
reportError(error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
delta,
|
|
78
|
+
js: jCouplings,
|
|
72
79
|
};
|
|
73
80
|
}
|
|
@@ -5,24 +5,29 @@ const nmr_processing_1 = require("nmr-processing");
|
|
|
5
5
|
const initiateDatum1D_1 = require("../initiateDatum1D");
|
|
6
6
|
function generateSpectrumFromRanges(ranges, info, usedColors) {
|
|
7
7
|
const { nucleus, solvent, name = null, frequency = 400 } = info;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
frequency,
|
|
11
|
-
nbPoints: 2 ** 17,
|
|
12
|
-
});
|
|
13
|
-
const datum = (0, initiateDatum1D_1.initiateDatum1D)({
|
|
14
|
-
data: { x, im: null, re: y },
|
|
15
|
-
info: {
|
|
8
|
+
try {
|
|
9
|
+
const { x, y } = (0, nmr_processing_1.rangesToXY)(ranges, {
|
|
16
10
|
nucleus,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
frequency,
|
|
12
|
+
nbPoints: 2 ** 17,
|
|
13
|
+
});
|
|
14
|
+
const datum = (0, initiateDatum1D_1.initiateDatum1D)({
|
|
15
|
+
data: { x, im: null, re: y },
|
|
16
|
+
info: {
|
|
17
|
+
nucleus,
|
|
18
|
+
originFrequency: frequency,
|
|
19
|
+
baseFrequency: frequency,
|
|
20
|
+
pulseSequence: '',
|
|
21
|
+
solvent,
|
|
22
|
+
isFt: true,
|
|
23
|
+
name,
|
|
24
|
+
},
|
|
25
|
+
ranges: { values: ranges, options: { sum: 100 } },
|
|
26
|
+
}, { usedColors });
|
|
27
|
+
return datum;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
reportError(error);
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
33
|
exports.generateSpectrumFromRanges = generateSpectrumFromRanges;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newClipboardItem = exports.write = exports.writeText = exports.read = exports.readText = void 0;
|
|
4
|
+
function readText() {
|
|
5
|
+
return import('clipboard-polyfill').then((c) => c.readText());
|
|
6
|
+
}
|
|
7
|
+
exports.readText = readText;
|
|
8
|
+
function read() {
|
|
9
|
+
return import('clipboard-polyfill').then((c) => c.read());
|
|
10
|
+
}
|
|
11
|
+
exports.read = read;
|
|
12
|
+
function writeText(data) {
|
|
13
|
+
return import('clipboard-polyfill').then((c) => c.writeText(data));
|
|
14
|
+
}
|
|
15
|
+
exports.writeText = writeText;
|
|
16
|
+
function write(data) {
|
|
17
|
+
return import('clipboard-polyfill').then((c) => c.write(data));
|
|
18
|
+
}
|
|
19
|
+
exports.write = write;
|
|
20
|
+
function newClipboardItem(items, options) {
|
|
21
|
+
return import('clipboard-polyfill').then((c) => new c.ClipboardItem(items, options));
|
|
22
|
+
}
|
|
23
|
+
exports.newClipboardItem = newClipboardItem;
|