nmrium 0.38.0 → 0.38.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.
@@ -31,8 +31,9 @@ function DatabaseSpectrum() {
31
31
  const loadSpectrum = useRef(throttle(async (baseURL, jcampRelativeURL) => {
32
32
  try {
33
33
  setLoading(true);
34
+ const url = new URL(jcampRelativeURL, baseURL);
34
35
  const { data } = await readFromWebSource({
35
- entries: [{ relativePath: jcampRelativeURL, baseURL }],
36
+ entries: [{ relativePath: url.pathname, baseURL: url.origin }],
36
37
  });
37
38
  setLoading(false);
38
39
  const spectrum = data?.spectra?.[0] || null;
@@ -1,6 +1,6 @@
1
1
  interface PredictSpectraModalProps {
2
2
  onClose?: (element?: string) => void;
3
- molfile: any;
3
+ molfile: string;
4
4
  }
5
5
  declare function PredictSpectraModal({ onClose, molfile, }: PredictSpectraModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
6
6
  export default PredictSpectraModal;
@@ -149,7 +149,7 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
149
149
  assignmentData,
150
150
  ]);
151
151
  const openPredictSpectraModal = useCallback(() => {
152
- modal.show(_jsx(PredictSpectraModal, { molfile: molecules[currentIndex] }), {
152
+ modal.show(_jsx(PredictSpectraModal, { molfile: molecules[currentIndex].molfile }), {
153
153
  position: positions.TOP_CENTER,
154
154
  enableResizing: true,
155
155
  width: 600,
@@ -188,14 +188,15 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
188
188
  return prepareData(result.data);
189
189
  }, [result.data]);
190
190
  const resurrectHandler = useCallback((rowData) => {
191
- const { index, baseURL, jcampURL: jcampRelativeURL } = rowData;
191
+ let { index, baseURL, jcampURL: jcampRelativeURL } = rowData;
192
192
  const { ranges, solvent, names = [] } = result.data[index];
193
193
  if (jcampRelativeURL) {
194
+ const url = new URL(jcampRelativeURL, baseURL);
194
195
  setTimeout(async () => {
195
196
  const hideLoading = await alert.showLoading(`load jcamp in progress...`);
196
197
  try {
197
198
  const { data } = await readFromWebSource({
198
- entries: [{ baseURL, relativePath: jcampRelativeURL }],
199
+ entries: [{ baseURL: url.origin, relativePath: url.pathname }],
199
200
  });
200
201
  const spectrum = data?.spectra?.[0] || null;
201
202
  if (spectrum && isSpectrum1D(spectrum)) {
@@ -309,10 +310,11 @@ function mapSolventsToSelect(solvents) {
309
310
  return result;
310
311
  }
311
312
  async function saveJcampAsJson(rowData, filteredData) {
312
- const { index, baseURL, jcampURL: jcampRelativeURL, names, ocl = {}, smiles, } = rowData;
313
+ const { index, baseURL, jcampURL, names, ocl = {}, smiles } = rowData;
313
314
  const { ranges } = filteredData.data[index];
315
+ const url = new URL(jcampURL, baseURL);
314
316
  const { data: { spectra, source } = { source: {}, spectra: [] }, version } = await readFromWebSource({
315
- entries: [{ baseURL, relativePath: jcampRelativeURL }],
317
+ entries: [{ baseURL: url.origin, relativePath: url.pathname }],
316
318
  });
317
319
  let molfile = '';
318
320
  let molecule = null;
@@ -132,8 +132,12 @@ export function dispatchMiddleware(dispatch) {
132
132
  }
133
133
  case 'PREDICT_SPECTRA': {
134
134
  const { molfile, options } = action.payload;
135
- void predictSpectra(molfile).then((predictedSpectra) => {
136
- action.payload = { predictedSpectra, options, molfile };
135
+ void predictSpectra(molfile).then((data) => {
136
+ action.payload = {
137
+ predictedSpectra: data.spectra,
138
+ options,
139
+ molfile,
140
+ };
137
141
  dispatch(action);
138
142
  }, () => {
139
143
  dispatch(action);
@@ -1,4 +1,5 @@
1
1
  import { Spectrum } from 'nmr-load-save';
2
+ import { PredictedAll } from 'nmr-processing';
2
3
  export type Experiment = 'proton' | 'carbon' | 'cosy' | 'hsqc' | 'hmbc';
3
4
  export type SpectraPredictionOptions = Record<Experiment, boolean>;
4
5
  export type PredictedSpectraResult = Partial<Record<Experiment, Spectrum>>;
@@ -30,5 +31,5 @@ export declare const FREQUENCIES: Array<{
30
31
  value: number;
31
32
  label: string;
32
33
  }>;
33
- export declare function predictSpectra(molfile: string): Promise<any>;
34
+ export declare function predictSpectra(molfile: string): Promise<PredictedAll>;
34
35
  export declare function generateSpectra(predictedSpectra: PredictedSpectraResult, inputOptions: PredictionOptions, color: string): Spectrum[];
@@ -1 +1 @@
1
- export default { version: 'v0.38.0' };
1
+ export default { version: 'v0.38.1' };
@@ -36,8 +36,9 @@ function DatabaseSpectrum() {
36
36
  const loadSpectrum = (0, react_1.useRef)((0, throttle_1.default)(async (baseURL, jcampRelativeURL) => {
37
37
  try {
38
38
  setLoading(true);
39
+ const url = new URL(jcampRelativeURL, baseURL);
39
40
  const { data } = await (0, nmr_load_save_1.readFromWebSource)({
40
- entries: [{ relativePath: jcampRelativeURL, baseURL }],
41
+ entries: [{ relativePath: url.pathname, baseURL: url.origin }],
41
42
  });
42
43
  setLoading(false);
43
44
  const spectrum = data?.spectra?.[0] || null;
@@ -154,7 +154,7 @@ function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMolecul
154
154
  assignmentData,
155
155
  ]);
156
156
  const openPredictSpectraModal = (0, react_2.useCallback)(() => {
157
- modal.show((0, jsx_runtime_1.jsx)(PredictSpectraModal_1.default, { molfile: molecules[currentIndex] }), {
157
+ modal.show((0, jsx_runtime_1.jsx)(PredictSpectraModal_1.default, { molfile: molecules[currentIndex].molfile }), {
158
158
  position: Modal_1.positions.TOP_CENTER,
159
159
  enableResizing: true,
160
160
  width: 600,
@@ -193,14 +193,15 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
193
193
  return (0, database_1.prepareData)(result.data);
194
194
  }, [result.data]);
195
195
  const resurrectHandler = (0, react_2.useCallback)((rowData) => {
196
- const { index, baseURL, jcampURL: jcampRelativeURL } = rowData;
196
+ let { index, baseURL, jcampURL: jcampRelativeURL } = rowData;
197
197
  const { ranges, solvent, names = [] } = result.data[index];
198
198
  if (jcampRelativeURL) {
199
+ const url = new URL(jcampRelativeURL, baseURL);
199
200
  setTimeout(async () => {
200
201
  const hideLoading = await alert.showLoading(`load jcamp in progress...`);
201
202
  try {
202
203
  const { data } = await (0, nmr_load_save_1.readFromWebSource)({
203
- entries: [{ baseURL, relativePath: jcampRelativeURL }],
204
+ entries: [{ baseURL: url.origin, relativePath: url.pathname }],
204
205
  });
205
206
  const spectrum = data?.spectra?.[0] || null;
206
207
  if (spectrum && (0, Spectrum1D_1.isSpectrum1D)(spectrum)) {
@@ -315,10 +316,11 @@ function mapSolventsToSelect(solvents) {
315
316
  return result;
316
317
  }
317
318
  async function saveJcampAsJson(rowData, filteredData) {
318
- const { index, baseURL, jcampURL: jcampRelativeURL, names, ocl = {}, smiles, } = rowData;
319
+ const { index, baseURL, jcampURL, names, ocl = {}, smiles } = rowData;
319
320
  const { ranges } = filteredData.data[index];
321
+ const url = new URL(jcampURL, baseURL);
320
322
  const { data: { spectra, source } = { source: {}, spectra: [] }, version } = await (0, nmr_load_save_1.readFromWebSource)({
321
- entries: [{ baseURL, relativePath: jcampRelativeURL }],
323
+ entries: [{ baseURL: url.origin, relativePath: url.pathname }],
322
324
  });
323
325
  let molfile = '';
324
326
  let molecule = null;
@@ -161,8 +161,12 @@ function dispatchMiddleware(dispatch) {
161
161
  }
162
162
  case 'PREDICT_SPECTRA': {
163
163
  const { molfile, options } = action.payload;
164
- void (0, PredictionManager_1.predictSpectra)(molfile).then((predictedSpectra) => {
165
- action.payload = { predictedSpectra, options, molfile };
164
+ void (0, PredictionManager_1.predictSpectra)(molfile).then((data) => {
165
+ action.payload = {
166
+ predictedSpectra: data.spectra,
167
+ options,
168
+ molfile,
169
+ };
166
170
  dispatch(action);
167
171
  }, () => {
168
172
  dispatch(action);
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = { version: 'v0.38.0' };
3
+ exports.default = { version: 'v0.38.1' };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nmrium",
3
3
  "description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
4
- "version": "0.38.0",
4
+ "version": "0.38.1",
5
5
  "license": "MIT",
6
6
  "main": "lib-cjs/component/NMRium.js",
7
7
  "module": "lib/component/NMRium.js",