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
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { minimiseConformer, rankByEnergy } from "./conformerMinimise.js";
|
|
1
|
+
import { minimiseConformer, producedSource, rankByEnergy, } from "./conformerMinimise.js";
|
|
3
2
|
import { isKeptMinimum, minimisedShapes } from "./conformerMinimum.js";
|
|
4
3
|
import { keepConformerSession, openConformerSession, readPotentialCount, } from "./conformerSession.js";
|
|
5
4
|
import { conformerShape, hasFiniteCoordinates } from "./conformerShape.js";
|
|
@@ -29,7 +28,7 @@ export { strategyConstant } from "./conformerSession.js";
|
|
|
29
28
|
* @param molecule - Structure to embed. Not mutated.
|
|
30
29
|
* @param options - Strategy, limits, seed and force field.
|
|
31
30
|
* @param now - Clock used for the time budget, injectable for tests.
|
|
32
|
-
* @returns Every conformer kept, most stable first, with relative energies and
|
|
31
|
+
* @returns Every conformer kept, most stable first, with relative energies and what the run logged.
|
|
33
32
|
* @throws {Error} When the structure is empty or OpenChemLib refuses to initialise it.
|
|
34
33
|
*/
|
|
35
34
|
export function generateConformers(molecule, options, now = defaultClock) {
|
|
@@ -84,7 +83,7 @@ function runConformers(molecule, options, previous, now) {
|
|
|
84
83
|
const into = {
|
|
85
84
|
conformers,
|
|
86
85
|
shapes: minimisedShapes(conformers),
|
|
87
|
-
|
|
86
|
+
logs: previous === null ? [] : [...previous.logs],
|
|
88
87
|
};
|
|
89
88
|
const budget = Math.max(options.timeoutSeconds * 1000, 0);
|
|
90
89
|
const stoppedBy = collect(session, options, into.conformers.length + options.maxConformers, () => now() - start >= budget, into);
|
|
@@ -94,7 +93,7 @@ function runConformers(molecule, options, previous, now) {
|
|
|
94
93
|
potentialConformerCount,
|
|
95
94
|
stoppedBy,
|
|
96
95
|
elapsedMilliseconds: (previous?.elapsedMilliseconds ?? 0) + now() - start,
|
|
97
|
-
|
|
96
|
+
logs: into.logs,
|
|
98
97
|
minimisation: options.minimisation,
|
|
99
98
|
produced: session.produced,
|
|
100
99
|
options,
|
|
@@ -120,10 +119,14 @@ function collect(session, options, target, spent, into) {
|
|
|
120
119
|
}
|
|
121
120
|
session.produced++;
|
|
122
121
|
if (!hasFiniteCoordinates(conformer)) {
|
|
123
|
-
into.
|
|
122
|
+
into.logs.push({
|
|
123
|
+
levelLabel: 'error',
|
|
124
|
+
message: 'It was dropped: the generator placed some of its atoms at non-finite coordinates.',
|
|
125
|
+
meta: { source: producedSource(session.produced) },
|
|
126
|
+
});
|
|
124
127
|
continue;
|
|
125
128
|
}
|
|
126
|
-
const energy = minimiseConformer(conformer, options, session.produced, into.
|
|
129
|
+
const energy = minimiseConformer(conformer, options, session.produced, into.logs);
|
|
127
130
|
const shape = energy === null ? null : conformerShape(conformer);
|
|
128
131
|
if (energy !== null &&
|
|
129
132
|
shape !== null &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conformers.js","sourceRoot":"","sources":["../../../src/structure/core/conformers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conformers.js","sourceRoot":"","sources":["../../../src/structure/core/conformers.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CA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AAG,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACjE,IACE,MAAM,KAAK,IAAI;YACf,KAAK,KAAK,IAAI;YACd,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,EAC1D,CAAC;YACD,SAAS;QACX,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACnB,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;YAC9B,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC;YACnC,MAAM;YACN,cAAc,EAAE,IAAI;YACpB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,UAAgC;IACtD,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,KAAK,MAAM,SAAS,IAAI,UAAU;QAAE,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;IAClE,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LightLogger } from 'cheminfo-types';
|
|
1
2
|
/**
|
|
2
3
|
* A geometry a relaxer is handed: element symbols plus flat Cartesian
|
|
3
4
|
* coordinates in ångström, `x,y,z` per atom.
|
|
@@ -32,11 +33,17 @@ export interface RelaxedGeometry {
|
|
|
32
33
|
cycles: number;
|
|
33
34
|
/** Whether the optimizer met its convergence criteria. */
|
|
34
35
|
converged: boolean;
|
|
35
|
-
/** Plain sentences about anything the caller should know. */
|
|
36
|
-
warnings: string[];
|
|
37
36
|
}
|
|
38
|
-
/** How a relaxation run is watched and
|
|
37
|
+
/** How a relaxation run is watched, cancelled and heard from. */
|
|
39
38
|
export interface RelaxerOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Receives what the relaxer has to say: `error` for something dropped while
|
|
41
|
+
* the rest went on, `warn` for what changes how a result must be read, `info`
|
|
42
|
+
* for context. An entry about one structure carries `structure`, its index
|
|
43
|
+
* in the batch; one without it is about the whole batch.
|
|
44
|
+
* @default nothing is reported
|
|
45
|
+
*/
|
|
46
|
+
logger?: LightLogger;
|
|
40
47
|
/**
|
|
41
48
|
* Called as each structure finishes, so a caller can show progress over a
|
|
42
49
|
* batch that runs for seconds.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometryRelaxer.d.ts","sourceRoot":"","sources":["../../../src/structure/core/geometryRelaxer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,uEAAuE;IACvE,WAAW,EAAE,YAAY,CAAC;CAC3B;AAED,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,WAAW,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,SAAS,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"geometryRelaxer.d.ts","sourceRoot":"","sources":["../../../src/structure/core/geometryRelaxer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,uEAAuE;IACvE,WAAW,EAAE,YAAY,CAAC;CAC3B;AAED,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,WAAW,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,UAAU,EAAE,SAAS,iBAAiB,EAAE,EACxC,OAAO,CAAC,EAAE,cAAc,KACrB,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LogEntry } from 'fifo-logger';
|
|
2
|
+
import type { LogLine } from '../../log/core/logGroups.ts';
|
|
3
|
+
/**
|
|
4
|
+
* What a relaxer logged about a batch, as lines a conformer set keeps: an
|
|
5
|
+
* entry about one structure is labelled with that structure's source, an entry
|
|
6
|
+
* about a structure that was dropped is dropped with it, and an entry naming no
|
|
7
|
+
* structure is about the whole batch — or, in a batch of one, about its only
|
|
8
|
+
* structure.
|
|
9
|
+
* @param entries - What the relaxer logged, each entry about one structure
|
|
10
|
+
* carrying `structure`, its index in the batch.
|
|
11
|
+
* @param sources - The label of each structure, `null` for one that was
|
|
12
|
+
* dropped.
|
|
13
|
+
* @returns Plain lines, in the order they were logged.
|
|
14
|
+
*/
|
|
15
|
+
export declare function relaxerLogLines(entries: readonly LogEntry[], sources: ReadonlyArray<string | null>): LogLine[];
|
|
16
|
+
//# sourceMappingURL=relaxerLogLines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relaxerLogLines.d.ts","sourceRoot":"","sources":["../../../src/structure/core/relaxerLogLines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,QAAQ,EAAE,EAC5B,OAAO,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,GACpC,OAAO,EAAE,CAmBX"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a relaxer logged about a batch, as lines a conformer set keeps: an
|
|
3
|
+
* entry about one structure is labelled with that structure's source, an entry
|
|
4
|
+
* about a structure that was dropped is dropped with it, and an entry naming no
|
|
5
|
+
* structure is about the whole batch — or, in a batch of one, about its only
|
|
6
|
+
* structure.
|
|
7
|
+
* @param entries - What the relaxer logged, each entry about one structure
|
|
8
|
+
* carrying `structure`, its index in the batch.
|
|
9
|
+
* @param sources - The label of each structure, `null` for one that was
|
|
10
|
+
* dropped.
|
|
11
|
+
* @returns Plain lines, in the order they were logged.
|
|
12
|
+
*/
|
|
13
|
+
export function relaxerLogLines(entries, sources) {
|
|
14
|
+
const lines = [];
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
const { structure, ...meta } = entry.meta ?? {};
|
|
17
|
+
const index = typeof structure === 'number'
|
|
18
|
+
? structure
|
|
19
|
+
: sources.length === 1
|
|
20
|
+
? 0
|
|
21
|
+
: null;
|
|
22
|
+
const source = index === null ? undefined : sources[index];
|
|
23
|
+
if (source === null)
|
|
24
|
+
continue;
|
|
25
|
+
lines.push({
|
|
26
|
+
levelLabel: entry.levelLabel,
|
|
27
|
+
message: entry.error?.message ?? entry.message,
|
|
28
|
+
meta: source === undefined ? meta : { ...meta, source },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return lines;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=relaxerLogLines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relaxerLogLines.js","sourceRoot":"","sources":["../../../src/structure/core/relaxerLogLines.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAC7B,OAA4B,EAC5B,OAAqC;IAErC,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;QAChD,MAAM,KAAK,GACT,OAAO,SAAS,KAAK,QAAQ;YAC3B,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;gBACpB,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,IAAI,CAAC;QACb,MAAM,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC3D,IAAI,MAAM,KAAK,IAAI;YAAE,SAAS;QAC9B,KAAK,CAAC,IAAI,CAAC;YACT,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO;YAC9C,IAAI,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE;SACxD,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/lib/ui.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export * from './highlight/ui/index.ts';
|
|
|
22
22
|
export * from './hooks/ui/index.ts';
|
|
23
23
|
export * from './i18n/ui/index.ts';
|
|
24
24
|
export * from './language/ui/index.ts';
|
|
25
|
+
export * from './log/ui/index.ts';
|
|
25
26
|
export * from './moleculesSources/ui/index.ts';
|
|
26
27
|
export * from './moleculesToken/ui/index.ts';
|
|
27
28
|
export * from './number/ui/index.ts';
|
package/lib/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;A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AC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AAKvC,YAAY,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,eAAe,GAChB,MAAM,oCAAoC,CAAC"}
|
package/lib/ui.js
CHANGED
|
@@ -22,6 +22,7 @@ export * from "./highlight/ui/index.js";
|
|
|
22
22
|
export * from "./hooks/ui/index.js";
|
|
23
23
|
export * from "./i18n/ui/index.js";
|
|
24
24
|
export * from "./language/ui/index.js";
|
|
25
|
+
export * from "./log/ui/index.js";
|
|
25
26
|
export * from "./moleculesSources/ui/index.js";
|
|
26
27
|
export * from "./moleculesToken/ui/index.js";
|
|
27
28
|
export * from "./number/ui/index.js";
|
package/lib/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,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AAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AAMvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAuC,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAmC,CAAC;AAEnE,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,eAAe,GAChB,MAAM,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LightLogger } from 'cheminfo-types';
|
|
2
|
+
/**
|
|
3
|
+
* A logger that adds some fields to every entry before passing it on — what
|
|
4
|
+
* xtb-wasm's pool does for the structures of a batch, done here for the ones
|
|
5
|
+
* relaxed in turn on this thread.
|
|
6
|
+
* @param logger - Where the entries go.
|
|
7
|
+
* @param context - The fields every entry gains, e.g. `{ structure: 2 }`.
|
|
8
|
+
* @returns The tagging logger.
|
|
9
|
+
*/
|
|
10
|
+
export declare function taggedLogger(logger: LightLogger, context: Record<string, unknown>): LightLogger;
|
|
11
|
+
//# sourceMappingURL=taggedLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taggedLogger.d.ts","sourceRoot":"","sources":["../../../src/xtb/core/taggedLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,WAAW,CAmBb"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A logger that adds some fields to every entry before passing it on — what
|
|
3
|
+
* xtb-wasm's pool does for the structures of a batch, done here for the ones
|
|
4
|
+
* relaxed in turn on this thread.
|
|
5
|
+
* @param logger - Where the entries go.
|
|
6
|
+
* @param context - The fields every entry gains, e.g. `{ structure: 2 }`.
|
|
7
|
+
* @returns The tagging logger.
|
|
8
|
+
*/
|
|
9
|
+
export function taggedLogger(logger, context) {
|
|
10
|
+
function forward(level) {
|
|
11
|
+
return (value, message) => {
|
|
12
|
+
if (value instanceof Error) {
|
|
13
|
+
logger[level](context, message ?? value.message);
|
|
14
|
+
}
|
|
15
|
+
else if (typeof value === 'object' && value !== null) {
|
|
16
|
+
logger[level]({ ...context, ...value }, message ?? '');
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
logger[level](context, message ?? String(value));
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
trace: forward('trace'),
|
|
25
|
+
debug: forward('debug'),
|
|
26
|
+
info: forward('info'),
|
|
27
|
+
warn: forward('warn'),
|
|
28
|
+
error: forward('error'),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=taggedLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taggedLogger.js","sourceRoot":"","sources":["../../../src/xtb/core/taggedLogger.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,OAAgC;IAEhC,SAAS,OAAO,CAAC,KAAY;QAC3B,OAAO,CAAC,KAAc,EAAE,OAAgB,EAAQ,EAAE;YAChD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;YACnD,CAAC;iBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACvD,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IACD,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;QACvB,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;QACvB,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;QACrB,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xtbRelaxer.d.ts","sourceRoot":"","sources":["../../../src/xtb/core/xtbRelaxer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"xtbRelaxer.d.ts","sourceRoot":"","sources":["../../../src/xtb/core/xtbRelaxer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,yCAAyC,CAAC;AAIjD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,iBAAoB,CAAC;AAE1D,qDAAqD;AACrD,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,eAAe,CAqC3E;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGvD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { errorMessage } from "../../error/core/toError.js";
|
|
2
|
+
import { taggedLogger } from "./taggedLogger.js";
|
|
2
3
|
/**
|
|
3
4
|
* kcal/mol per hartree, CODATA 2018. Every energy a relaxer reports is in
|
|
4
5
|
* kcal/mol, so it can be read against a force-field energy without the reader
|
|
@@ -35,6 +36,7 @@ export function xtbRelaxer(options = {}) {
|
|
|
35
36
|
maxWorkers: options.maxWorkers,
|
|
36
37
|
onSettled: runOptions.onSettled,
|
|
37
38
|
signal: runOptions.signal,
|
|
39
|
+
logger: runOptions.logger,
|
|
38
40
|
})
|
|
39
41
|
: await relaxHere(xtb, requests, runOptions);
|
|
40
42
|
const relaxed = [];
|
|
@@ -47,7 +49,6 @@ export function xtbRelaxer(options = {}) {
|
|
|
47
49
|
: result.energy.dispersion * KCAL_PER_MOL_PER_HARTREE,
|
|
48
50
|
cycles: result.cycles,
|
|
49
51
|
converged: result.converged,
|
|
50
|
-
warnings: result.warnings,
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
return relaxed;
|
|
@@ -76,20 +77,27 @@ export async function disposeXtbRelaxer() {
|
|
|
76
77
|
* Relax one structure after another on this thread, for want of a pool.
|
|
77
78
|
* @param xtb - The loaded `xtb-wasm` module.
|
|
78
79
|
* @param requests - The structures to relax, with their settings.
|
|
79
|
-
* @param runOptions - Progress and
|
|
80
|
+
* @param runOptions - Progress, cancellation, and the logger each structure's
|
|
81
|
+
* messages go to under its index, as the pool would have logged them.
|
|
80
82
|
* @returns One `xtb-wasm` result per request, in request order.
|
|
81
83
|
* @throws {Error} When the run is cancelled, or when occ fails.
|
|
82
84
|
*/
|
|
83
85
|
async function relaxHere(xtb, requests, runOptions) {
|
|
86
|
+
const { logger, signal, onSettled } = runOptions;
|
|
84
87
|
const results = [];
|
|
85
88
|
for (const [index, request] of requests.entries()) {
|
|
86
|
-
if (
|
|
89
|
+
if (signal?.aborted === true) {
|
|
87
90
|
throw new Error('calculation cancelled');
|
|
88
91
|
}
|
|
92
|
+
const options = {
|
|
93
|
+
logger: logger === undefined
|
|
94
|
+
? undefined
|
|
95
|
+
: taggedLogger(logger, { structure: index }),
|
|
96
|
+
};
|
|
89
97
|
/* eslint-disable-next-line no-await-in-loop -- there is one thread: the
|
|
90
98
|
whole point of this path is that the structures run in turn. */
|
|
91
|
-
results.push(await xtb.relaxGeometryInProcess(request));
|
|
92
|
-
|
|
99
|
+
results.push(await xtb.relaxGeometryInProcess(request, options));
|
|
100
|
+
onSettled?.(index + 1, requests.length);
|
|
93
101
|
}
|
|
94
102
|
return results;
|
|
95
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xtbRelaxer.js","sourceRoot":"","sources":["../../../src/xtb/core/xtbRelaxer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAQ3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AA2B1D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CAAC,UAA6B,EAAE;IACxD,OAAO,KAAK,EACV,UAAwC,EACxC,aAA6B,EAAE,EACH,EAAE;QAC9B,MAAM,GAAG,GAAG,MAAM,OAAO,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG;YACf,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC;YAC3B,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,CAAC;YACjD,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS;gBACjC,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,SAAS,EA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AO,OAAO,CAAC;AACjB,CAAC;AAID,IAAI,OAAO,GAA8B,IAAI,CAAC;AAE9C,SAAS,OAAO;IACd,OAAO,KAAK,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QACtD,uEAAuE;QACvE,OAAO,GAAG,IAAI,CAAC;QACf,2EAA2E;QAC3E,2EAA2E;QAC3E,iEAAiE;QACjE,MAAM,IAAI,KAAK,CACb,kEAAkE,YAAY,CAAC,KAAK,CAAC,EAAE,EACvF,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cheminfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.132.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
|
|
6
6
|
"author": "Luc Patiny",
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"countries-and-timezones": "^3.11.0",
|
|
92
92
|
"crc-32": "^1.2.2",
|
|
93
93
|
"fast-deep-equal": "^3.1.3",
|
|
94
|
+
"fifo-logger": "^2.0.1",
|
|
94
95
|
"idb": "^8.0.4",
|
|
95
96
|
"intl-messageformat": "^11.2.15",
|
|
96
97
|
"ir-spectrum": "^4.2.0",
|
|
@@ -164,7 +165,7 @@
|
|
|
164
165
|
"typescript": "^6.0.3",
|
|
165
166
|
"vite": "^8.2.1",
|
|
166
167
|
"vitest": "^4.1.12",
|
|
167
|
-
"xtb-wasm": "^
|
|
168
|
+
"xtb-wasm": "^2.0.0"
|
|
168
169
|
},
|
|
169
170
|
"peerDependencies": {
|
|
170
171
|
"@blueprintjs/core": "^6.18.0",
|
|
@@ -182,7 +183,7 @@
|
|
|
182
183
|
"react-science": "^20.6.2 || ^21.0.0 || ^22.0.0 || ^23.0.0 || ^24.0.0",
|
|
183
184
|
"spectra-processor": "^5.0.0",
|
|
184
185
|
"vite": "^7.0.0 || ^8.0.0",
|
|
185
|
-
"xtb-wasm": "^
|
|
186
|
+
"xtb-wasm": "^2.0.0"
|
|
186
187
|
},
|
|
187
188
|
"repository": {
|
|
188
189
|
"type": "git",
|
package/src/core.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './format/core/index.ts';
|
|
|
18
18
|
export * from './highlight/core/index.ts';
|
|
19
19
|
export * from './i18n/core/index.ts';
|
|
20
20
|
export * from './language/core/index.ts';
|
|
21
|
+
export * from './log/core/index.ts';
|
|
21
22
|
export * from './moleculesClient/core/index.ts';
|
|
22
23
|
export * from './moleculesSources/core/index.ts';
|
|
23
24
|
export * from './moleculesToken/core/index.ts';
|
package/src/locales/de.json
CHANGED
|
@@ -246,6 +246,10 @@
|
|
|
246
246
|
"help.label": "Hilfe",
|
|
247
247
|
"help.learnMore": "Mehr erfahren",
|
|
248
248
|
"help.on": "auf",
|
|
249
|
+
"log.badge.one": "Ein Hinweis",
|
|
250
|
+
"log.badge.other": "{count} Hinweise",
|
|
251
|
+
"log.more.one": "Eine weitere Meldung wird nicht angezeigt.",
|
|
252
|
+
"log.more.other": "{count} weitere Meldungen werden nicht angezeigt.",
|
|
249
253
|
"confirm.delete": "Löschen",
|
|
250
254
|
"confirm.cancel": "Abbrechen",
|
|
251
255
|
"error.title": "Etwas ist schiefgelaufen",
|
package/src/locales/en.json
CHANGED
|
@@ -281,6 +281,10 @@
|
|
|
281
281
|
"help.label": "Help",
|
|
282
282
|
"help.learnMore": "Learn more",
|
|
283
283
|
"help.on": "on",
|
|
284
|
+
"log.badge.one": "One note",
|
|
285
|
+
"log.badge.other": "{count} notes",
|
|
286
|
+
"log.more.one": "One more message is not shown.",
|
|
287
|
+
"log.more.other": "{count} more messages are not shown.",
|
|
284
288
|
"confirm.delete": "Delete",
|
|
285
289
|
"confirm.cancel": "Cancel",
|
|
286
290
|
"error.title": "Something went wrong",
|
package/src/locales/es.json
CHANGED
|
@@ -246,6 +246,10 @@
|
|
|
246
246
|
"help.label": "Ayuda",
|
|
247
247
|
"help.learnMore": "Saber más",
|
|
248
248
|
"help.on": "sobre",
|
|
249
|
+
"log.badge.one": "Una nota",
|
|
250
|
+
"log.badge.other": "{count} notas",
|
|
251
|
+
"log.more.one": "Un mensaje más no se muestra.",
|
|
252
|
+
"log.more.other": "{count} mensajes más no se muestran.",
|
|
249
253
|
"confirm.delete": "Eliminar",
|
|
250
254
|
"confirm.cancel": "Cancelar",
|
|
251
255
|
"error.title": "Algo ha salido mal",
|
package/src/locales/fr.json
CHANGED
|
@@ -246,6 +246,10 @@
|
|
|
246
246
|
"help.label": "Aide",
|
|
247
247
|
"help.learnMore": "En savoir plus",
|
|
248
248
|
"help.on": "sur",
|
|
249
|
+
"log.badge.one": "Une remarque",
|
|
250
|
+
"log.badge.other": "{count} remarques",
|
|
251
|
+
"log.more.one": "Un autre message n’est pas affiché.",
|
|
252
|
+
"log.more.other": "{count} autres messages ne sont pas affichés.",
|
|
249
253
|
"confirm.delete": "Supprimer",
|
|
250
254
|
"confirm.cancel": "Annuler",
|
|
251
255
|
"error.title": "Quelque chose s'est mal passé",
|
package/src/locales/it.json
CHANGED
|
@@ -281,6 +281,10 @@
|
|
|
281
281
|
"help.label": "Aiuto",
|
|
282
282
|
"help.learnMore": "Scopri di più",
|
|
283
283
|
"help.on": "su",
|
|
284
|
+
"log.badge.one": "Una nota",
|
|
285
|
+
"log.badge.other": "{count} note",
|
|
286
|
+
"log.more.one": "Un altro messaggio non è mostrato.",
|
|
287
|
+
"log.more.other": "Altri {count} messaggi non sono mostrati.",
|
|
284
288
|
"confirm.delete": "Elimina",
|
|
285
289
|
"confirm.cancel": "Annulla",
|
|
286
290
|
"error.title": "Qualcosa è andato storto",
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/** A level a log entry carries, as fifo-logger and pino label it. */
|
|
2
|
+
export type LogLevelLabel =
|
|
3
|
+
'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
4
|
+
|
|
5
|
+
/** How a message reads on the page, in Blueprint's intents. */
|
|
6
|
+
export type LogIntent = 'danger' | 'warning' | 'primary' | 'none';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* One logged message, as the page reads it. A fifo-logger `LogEntry` is one;
|
|
10
|
+
* so is a plain object a site writes for a caveat that is always true, or one
|
|
11
|
+
* read back from a saved file.
|
|
12
|
+
*
|
|
13
|
+
* Two keys of `meta` are shown: a string `title` heads the message, and a
|
|
14
|
+
* string `source` — a file, a line, the third conformer — labels where it
|
|
15
|
+
* comes from, so the message itself never has to name it.
|
|
16
|
+
*/
|
|
17
|
+
export interface LogLine {
|
|
18
|
+
/** The level it was logged at; `silent` entries are never shown. */
|
|
19
|
+
levelLabel: LogLevelLabel | 'silent';
|
|
20
|
+
/** The message. */
|
|
21
|
+
message: string;
|
|
22
|
+
/**
|
|
23
|
+
* What was logged with it.
|
|
24
|
+
* @default undefined
|
|
25
|
+
*/
|
|
26
|
+
meta?: Record<string, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* The error that was logged, whose own message is shown.
|
|
29
|
+
* @default undefined
|
|
30
|
+
*/
|
|
31
|
+
error?: Error;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** One message as the page shows it: every entry that said it, once. */
|
|
35
|
+
export interface LogGroup {
|
|
36
|
+
/** The same for the same level, source, title and text. */
|
|
37
|
+
key: string;
|
|
38
|
+
/** The level it was logged at. */
|
|
39
|
+
level: LogLevelLabel;
|
|
40
|
+
/**
|
|
41
|
+
* Where it comes from, from a string `source` in the meta.
|
|
42
|
+
* @default undefined
|
|
43
|
+
*/
|
|
44
|
+
source?: string;
|
|
45
|
+
/**
|
|
46
|
+
* A heading for the message, from a string `title` in the meta.
|
|
47
|
+
* @default undefined
|
|
48
|
+
*/
|
|
49
|
+
title?: string;
|
|
50
|
+
/** The message, or the logged error's own message. */
|
|
51
|
+
text: string;
|
|
52
|
+
/** How many entries said it. */
|
|
53
|
+
count: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Which entries {@link groupLogEntries} keeps. */
|
|
57
|
+
export interface LogGroupOptions {
|
|
58
|
+
/**
|
|
59
|
+
* The least serious level shown. Debug and trace are for a developer, so
|
|
60
|
+
* they stay out of the page unless asked for.
|
|
61
|
+
* @default 'info'
|
|
62
|
+
*/
|
|
63
|
+
minLevel?: LogLevelLabel;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The messages a page shows for some log entries: the same message said twice
|
|
68
|
+
* once, with its count, and the most serious first. Within one level the
|
|
69
|
+
* messages keep the order they were first said in, which is the order the
|
|
70
|
+
* work happened in.
|
|
71
|
+
*
|
|
72
|
+
* Entries from several loggers can be passed together, so what a run reported
|
|
73
|
+
* and what a model always says about its results read as one list.
|
|
74
|
+
* @param lines - What one or more loggers collected.
|
|
75
|
+
* @param options - See {@link LogGroupOptions}.
|
|
76
|
+
* @returns The messages to show, worst first.
|
|
77
|
+
*/
|
|
78
|
+
export function groupLogEntries(
|
|
79
|
+
lines: readonly LogLine[],
|
|
80
|
+
options: LogGroupOptions = {},
|
|
81
|
+
): LogGroup[] {
|
|
82
|
+
const minimum = SEVERITY[options.minLevel ?? 'info'];
|
|
83
|
+
const groups = new Map<string, LogGroup>();
|
|
84
|
+
for (const line of lines) {
|
|
85
|
+
const level = line.levelLabel;
|
|
86
|
+
if (level === 'silent' || SEVERITY[level] < minimum) continue;
|
|
87
|
+
const source = metaString(line, 'source');
|
|
88
|
+
const title = metaString(line, 'title');
|
|
89
|
+
const text = line.error?.message ?? line.message;
|
|
90
|
+
const key = [level, source ?? '', title ?? '', text].join('\u0000');
|
|
91
|
+
const group = groups.get(key);
|
|
92
|
+
if (group === undefined) {
|
|
93
|
+
groups.set(key, {
|
|
94
|
+
key,
|
|
95
|
+
level,
|
|
96
|
+
...(source === undefined ? {} : { source }),
|
|
97
|
+
...(title === undefined ? {} : { title }),
|
|
98
|
+
text,
|
|
99
|
+
count: 1,
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
group.count++;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return [...groups.values()].toSorted(
|
|
106
|
+
(first, second) => SEVERITY[second.level] - SEVERITY[first.level],
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The most serious level among some messages: the one a single indicator
|
|
112
|
+
* standing for all of them is drawn in.
|
|
113
|
+
* @param groups - Messages from {@link groupLogEntries}.
|
|
114
|
+
* @returns The worst level, or `null` when there is no message.
|
|
115
|
+
*/
|
|
116
|
+
export function worstLogLevel(
|
|
117
|
+
groups: readonly LogGroup[],
|
|
118
|
+
): LogLevelLabel | null {
|
|
119
|
+
let worst: LogLevelLabel | null = null;
|
|
120
|
+
for (const group of groups) {
|
|
121
|
+
if (worst === null || SEVERITY[group.level] > SEVERITY[worst]) {
|
|
122
|
+
worst = group.level;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return worst;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The intent a message of this level is drawn in: an error in red, a warning
|
|
130
|
+
* in amber, context in the primary blue.
|
|
131
|
+
* @param level - The level it was logged at.
|
|
132
|
+
* @returns A Blueprint intent.
|
|
133
|
+
*/
|
|
134
|
+
export function logIntent(level: LogLevelLabel): LogIntent {
|
|
135
|
+
return INTENTS[level];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const SEVERITY: Record<LogLevelLabel, number> = {
|
|
139
|
+
trace: 10,
|
|
140
|
+
debug: 20,
|
|
141
|
+
info: 30,
|
|
142
|
+
warn: 40,
|
|
143
|
+
error: 50,
|
|
144
|
+
fatal: 60,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const INTENTS: Record<LogLevelLabel, LogIntent> = {
|
|
148
|
+
trace: 'none',
|
|
149
|
+
debug: 'none',
|
|
150
|
+
info: 'primary',
|
|
151
|
+
warn: 'warning',
|
|
152
|
+
error: 'danger',
|
|
153
|
+
fatal: 'danger',
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
function metaString(line: LogLine, key: string): string | undefined {
|
|
157
|
+
const value = line.meta?.[key];
|
|
158
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
159
|
+
}
|