react-cheminfo 0.131.0 → 0.132.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.
- package/README.md +29 -0
- package/lib/core.d.ts +1 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +1 -0
- package/lib/core.js.map +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +4 -0
- package/lib/locales/en.json +4 -0
- package/lib/locales/es.json +4 -0
- package/lib/locales/fr.json +4 -0
- package/lib/locales/it.json +4 -0
- package/lib/log/core/index.d.ts +4 -0
- package/lib/log/core/index.d.ts.map +1 -0
- package/lib/log/core/index.js +3 -0
- package/lib/log/core/index.js.map +1 -0
- package/lib/log/core/logGroups.d.ts +87 -0
- package/lib/log/core/logGroups.d.ts.map +1 -0
- package/lib/log/core/logGroups.js +85 -0
- package/lib/log/core/logGroups.js.map +1 -0
- package/lib/log/core/logLines.d.ts +19 -0
- package/lib/log/core/logLines.d.ts.map +1 -0
- package/lib/log/core/logLines.js +36 -0
- package/lib/log/core/logLines.js.map +1 -0
- package/lib/log/ui/LogBadge.d.ts +39 -0
- package/lib/log/ui/LogBadge.d.ts.map +1 -0
- package/lib/log/ui/LogBadge.js +28 -0
- package/lib/log/ui/LogBadge.js.map +1 -0
- package/lib/log/ui/LogCallouts.d.ts +55 -0
- package/lib/log/ui/LogCallouts.d.ts.map +1 -0
- package/lib/log/ui/LogCallouts.js +38 -0
- package/lib/log/ui/LogCallouts.js.map +1 -0
- package/lib/log/ui/index.d.ts +7 -0
- package/lib/log/ui/index.d.ts.map +1 -0
- package/lib/log/ui/index.js +5 -0
- package/lib/log/ui/index.js.map +1 -0
- package/lib/log/ui/logIcon.d.ts +9 -0
- package/lib/log/ui/logIcon.d.ts.map +1 -0
- package/lib/log/ui/logIcon.js +17 -0
- package/lib/log/ui/logIcon.js.map +1 -0
- package/lib/log/ui/useLogEntries.d.ts +15 -0
- package/lib/log/ui/useLogEntries.d.ts.map +1 -0
- package/lib/log/ui/useLogEntries.js +47 -0
- package/lib/log/ui/useLogEntries.js.map +1 -0
- package/lib/structure/core/conformerMinimise.d.ts +13 -4
- package/lib/structure/core/conformerMinimise.d.ts.map +1 -1
- package/lib/structure/core/conformerMinimise.js +23 -6
- package/lib/structure/core/conformerMinimise.js.map +1 -1
- package/lib/structure/core/conformerRefine.d.ts +2 -2
- package/lib/structure/core/conformerRefine.d.ts.map +1 -1
- package/lib/structure/core/conformerRefine.js +23 -7
- package/lib/structure/core/conformerRefine.js.map +1 -1
- package/lib/structure/core/conformers.d.ts +8 -3
- package/lib/structure/core/conformers.d.ts.map +1 -1
- package/lib/structure/core/conformers.js +10 -7
- package/lib/structure/core/conformers.js.map +1 -1
- package/lib/structure/core/geometryRelaxer.d.ts +10 -3
- package/lib/structure/core/geometryRelaxer.d.ts.map +1 -1
- package/lib/structure/core/relaxerLogLines.d.ts +16 -0
- package/lib/structure/core/relaxerLogLines.d.ts.map +1 -0
- package/lib/structure/core/relaxerLogLines.js +33 -0
- package/lib/structure/core/relaxerLogLines.js.map +1 -0
- package/lib/ui.d.ts +1 -0
- package/lib/ui.d.ts.map +1 -1
- package/lib/ui.js +1 -0
- package/lib/ui.js.map +1 -1
- package/lib/xtb/core/taggedLogger.d.ts +11 -0
- package/lib/xtb/core/taggedLogger.d.ts.map +1 -0
- package/lib/xtb/core/taggedLogger.js +31 -0
- package/lib/xtb/core/taggedLogger.js.map +1 -0
- package/lib/xtb/core/xtbRelaxer.d.ts.map +1 -1
- package/lib/xtb/core/xtbRelaxer.js +13 -5
- package/lib/xtb/core/xtbRelaxer.js.map +1 -1
- package/package.json +4 -3
- package/src/core.ts +1 -0
- package/src/locales/de.json +4 -0
- package/src/locales/en.json +4 -0
- package/src/locales/es.json +4 -0
- package/src/locales/fr.json +4 -0
- package/src/locales/it.json +4 -0
- package/src/log/core/index.ts +9 -0
- package/src/log/core/logGroups.ts +159 -0
- package/src/log/core/logLines.ts +44 -0
- package/src/log/ui/LogBadge.tsx +89 -0
- package/src/log/ui/LogCallouts.tsx +103 -0
- package/src/log/ui/index.ts +6 -0
- package/src/log/ui/logIcon.ts +21 -0
- package/src/log/ui/useLogEntries.ts +57 -0
- package/src/structure/core/conformerMinimise.ts +34 -8
- package/src/structure/core/conformerRefine.ts +29 -13
- package/src/structure/core/conformers.ts +23 -12
- package/src/structure/core/geometryRelaxer.ts +11 -3
- package/src/structure/core/relaxerLogLines.ts +39 -0
- package/src/ui.ts +1 -0
- package/src/xtb/core/taggedLogger.ts +35 -0
- package/src/xtb/core/xtbRelaxer.ts +15 -5
- package/styles/chrome.css +34 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { LightLogger } from 'cheminfo-types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A logger that adds some fields to every entry before passing it on — what
|
|
5
|
+
* xtb-wasm's pool does for the structures of a batch, done here for the ones
|
|
6
|
+
* relaxed in turn on this thread.
|
|
7
|
+
* @param logger - Where the entries go.
|
|
8
|
+
* @param context - The fields every entry gains, e.g. `{ structure: 2 }`.
|
|
9
|
+
* @returns The tagging logger.
|
|
10
|
+
*/
|
|
11
|
+
export function taggedLogger(
|
|
12
|
+
logger: LightLogger,
|
|
13
|
+
context: Record<string, unknown>,
|
|
14
|
+
): LightLogger {
|
|
15
|
+
function forward(level: Level) {
|
|
16
|
+
return (value: unknown, message?: string): void => {
|
|
17
|
+
if (value instanceof Error) {
|
|
18
|
+
logger[level](context, message ?? value.message);
|
|
19
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
20
|
+
logger[level]({ ...context, ...value }, message ?? '');
|
|
21
|
+
} else {
|
|
22
|
+
logger[level](context, message ?? String(value));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
trace: forward('trace'),
|
|
28
|
+
debug: forward('debug'),
|
|
29
|
+
info: forward('info'),
|
|
30
|
+
warn: forward('warn'),
|
|
31
|
+
error: forward('error'),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type Level = 'trace' | 'debug' | 'info' | 'warn' | 'error';
|
|
@@ -8,6 +8,8 @@ import type {
|
|
|
8
8
|
RelaxerOptions,
|
|
9
9
|
} from '../../structure/core/geometryRelaxer.ts';
|
|
10
10
|
|
|
11
|
+
import { taggedLogger } from './taggedLogger.ts';
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
14
|
* kcal/mol per hartree, CODATA 2018. Every energy a relaxer reports is in
|
|
13
15
|
* kcal/mol, so it can be read against a force-field energy without the reader
|
|
@@ -73,6 +75,7 @@ export function xtbRelaxer(options: XtbRelaxerOptions = {}): GeometryRelaxer {
|
|
|
73
75
|
maxWorkers: options.maxWorkers,
|
|
74
76
|
onSettled: runOptions.onSettled,
|
|
75
77
|
signal: runOptions.signal,
|
|
78
|
+
logger: runOptions.logger,
|
|
76
79
|
})
|
|
77
80
|
: await relaxHere(xtb, requests, runOptions);
|
|
78
81
|
const relaxed: RelaxedGeometry[] = [];
|
|
@@ -86,7 +89,6 @@ export function xtbRelaxer(options: XtbRelaxerOptions = {}): GeometryRelaxer {
|
|
|
86
89
|
: result.energy.dispersion * KCAL_PER_MOL_PER_HARTREE,
|
|
87
90
|
cycles: result.cycles,
|
|
88
91
|
converged: result.converged,
|
|
89
|
-
warnings: result.warnings,
|
|
90
92
|
});
|
|
91
93
|
}
|
|
92
94
|
return relaxed;
|
|
@@ -118,7 +120,8 @@ export async function disposeXtbRelaxer(): Promise<void> {
|
|
|
118
120
|
* Relax one structure after another on this thread, for want of a pool.
|
|
119
121
|
* @param xtb - The loaded `xtb-wasm` module.
|
|
120
122
|
* @param requests - The structures to relax, with their settings.
|
|
121
|
-
* @param runOptions - Progress and
|
|
123
|
+
* @param runOptions - Progress, cancellation, and the logger each structure's
|
|
124
|
+
* messages go to under its index, as the pool would have logged them.
|
|
122
125
|
* @returns One `xtb-wasm` result per request, in request order.
|
|
123
126
|
* @throws {Error} When the run is cancelled, or when occ fails.
|
|
124
127
|
*/
|
|
@@ -127,15 +130,22 @@ async function relaxHere(
|
|
|
127
130
|
requests: ReadonlyArray<Parameters<XtbModule['relaxGeometryInProcess']>[0]>,
|
|
128
131
|
runOptions: RelaxerOptions,
|
|
129
132
|
): Promise<Array<Awaited<ReturnType<XtbModule['relaxGeometryInProcess']>>>> {
|
|
133
|
+
const { logger, signal, onSettled } = runOptions;
|
|
130
134
|
const results = [];
|
|
131
135
|
for (const [index, request] of requests.entries()) {
|
|
132
|
-
if (
|
|
136
|
+
if (signal?.aborted === true) {
|
|
133
137
|
throw new Error('calculation cancelled');
|
|
134
138
|
}
|
|
139
|
+
const options = {
|
|
140
|
+
logger:
|
|
141
|
+
logger === undefined
|
|
142
|
+
? undefined
|
|
143
|
+
: taggedLogger(logger, { structure: index }),
|
|
144
|
+
};
|
|
135
145
|
/* eslint-disable-next-line no-await-in-loop -- there is one thread: the
|
|
136
146
|
whole point of this path is that the structures run in turn. */
|
|
137
|
-
results.push(await xtb.relaxGeometryInProcess(request));
|
|
138
|
-
|
|
147
|
+
results.push(await xtb.relaxGeometryInProcess(request, options));
|
|
148
|
+
onSettled?.(index + 1, requests.length);
|
|
139
149
|
}
|
|
140
150
|
return results;
|
|
141
151
|
}
|
package/styles/chrome.css
CHANGED
|
@@ -1778,6 +1778,40 @@ span.taxon-lineage__name {
|
|
|
1778
1778
|
color: var(--accent);
|
|
1779
1779
|
}
|
|
1780
1780
|
|
|
1781
|
+
/* ── What a logger collected ────────────────────────────────────────────── */
|
|
1782
|
+
|
|
1783
|
+
/*
|
|
1784
|
+
`<LogCallouts>` and the popover of `<LogBadge>`: one callout per message,
|
|
1785
|
+
worst first, close enough to read as one list.
|
|
1786
|
+
*/
|
|
1787
|
+
.log-callouts {
|
|
1788
|
+
display: flex;
|
|
1789
|
+
flex-direction: column;
|
|
1790
|
+
gap: 6px;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
.log-badge__popover .log-callouts {
|
|
1794
|
+
max-width: 460px;
|
|
1795
|
+
padding: 8px;
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
.log-callouts__count {
|
|
1799
|
+
margin-left: 0.4em;
|
|
1800
|
+
color: var(--text-muted);
|
|
1801
|
+
font-variant-numeric: tabular-nums;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/* Where a message comes from — a file, a line — read before the message. */
|
|
1805
|
+
.log-callouts__source {
|
|
1806
|
+
margin-right: 0.4em;
|
|
1807
|
+
font-weight: 600;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
.log-callouts__more {
|
|
1811
|
+
color: var(--text-muted);
|
|
1812
|
+
font-size: 12px;
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1781
1815
|
/* ── The splitter ───────────────────────────────────────────────────────── */
|
|
1782
1816
|
|
|
1783
1817
|
/*
|