react-cheminfo 0.131.0 → 0.133.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.
Files changed (293) hide show
  1. package/README.md +29 -0
  2. package/lib/core.d.ts +1 -0
  3. package/lib/core.d.ts.map +1 -1
  4. package/lib/core.js +1 -0
  5. package/lib/core.js.map +1 -1
  6. package/lib/drawing/captionEditor/CaptionEditor.d.ts +3 -3
  7. package/lib/drawing/captionEditor/CaptionEditor.d.ts.map +1 -1
  8. package/lib/drawing/captionEditor/CaptionEditor.js +8 -4
  9. package/lib/drawing/captionEditor/CaptionEditor.js.map +1 -1
  10. package/lib/drawing/captionEditor/CaptionToolbar.d.ts +4 -2
  11. package/lib/drawing/captionEditor/CaptionToolbar.d.ts.map +1 -1
  12. package/lib/drawing/captionEditor/CaptionToolbar.js +6 -4
  13. package/lib/drawing/captionEditor/CaptionToolbar.js.map +1 -1
  14. package/lib/drawing/captionEditor/index.d.ts +2 -0
  15. package/lib/drawing/captionEditor/index.d.ts.map +1 -1
  16. package/lib/drawing/captionEditor/index.js +1 -0
  17. package/lib/drawing/captionEditor/index.js.map +1 -1
  18. package/lib/drawing/captionEditor/toolbarInView.d.ts +40 -0
  19. package/lib/drawing/captionEditor/toolbarInView.d.ts.map +1 -0
  20. package/lib/drawing/captionEditor/toolbarInView.js +53 -0
  21. package/lib/drawing/captionEditor/toolbarInView.js.map +1 -0
  22. package/lib/drawing/core/camera.d.ts +2 -0
  23. package/lib/drawing/core/camera.d.ts.map +1 -1
  24. package/lib/drawing/core/camera.js +2 -0
  25. package/lib/drawing/core/camera.js.map +1 -1
  26. package/lib/drawing/core/index.d.ts +1 -1
  27. package/lib/drawing/core/index.d.ts.map +1 -1
  28. package/lib/drawing/core/index.js +1 -1
  29. package/lib/drawing/core/index.js.map +1 -1
  30. package/lib/drawing/render/index.d.ts +1 -1
  31. package/lib/drawing/render/index.d.ts.map +1 -1
  32. package/lib/drawing/render/index.js +1 -1
  33. package/lib/drawing/render/index.js.map +1 -1
  34. package/lib/drawing/render/pageGrid.d.ts +16 -0
  35. package/lib/drawing/render/pageGrid.d.ts.map +1 -1
  36. package/lib/drawing/render/pageGrid.js +28 -10
  37. package/lib/drawing/render/pageGrid.js.map +1 -1
  38. package/lib/drawing/ui/PageField.d.ts +29 -0
  39. package/lib/drawing/ui/PageField.d.ts.map +1 -0
  40. package/lib/drawing/ui/PageField.js +38 -0
  41. package/lib/drawing/ui/PageField.js.map +1 -0
  42. package/lib/drawing/ui/PageGrid.d.ts +20 -0
  43. package/lib/drawing/ui/PageGrid.d.ts.map +1 -0
  44. package/lib/drawing/ui/PageGrid.js +26 -0
  45. package/lib/drawing/ui/PageGrid.js.map +1 -0
  46. package/lib/drawing/ui/PageSideInput.d.ts +28 -0
  47. package/lib/drawing/ui/PageSideInput.d.ts.map +1 -0
  48. package/lib/drawing/ui/PageSideInput.js +47 -0
  49. package/lib/drawing/ui/PageSideInput.js.map +1 -0
  50. package/lib/drawing/ui/PageToolbar.d.ts +16 -0
  51. package/lib/drawing/ui/PageToolbar.d.ts.map +1 -0
  52. package/lib/drawing/ui/PageToolbar.js +16 -0
  53. package/lib/drawing/ui/PageToolbar.js.map +1 -0
  54. package/lib/drawing/ui/PrintSheets.d.ts +32 -0
  55. package/lib/drawing/ui/PrintSheets.d.ts.map +1 -0
  56. package/lib/drawing/ui/PrintSheets.js +17 -0
  57. package/lib/drawing/ui/PrintSheets.js.map +1 -0
  58. package/lib/drawing/ui/TextToolIcon.d.ts +19 -0
  59. package/lib/drawing/ui/TextToolIcon.d.ts.map +1 -0
  60. package/lib/drawing/ui/TextToolIcon.js +21 -0
  61. package/lib/drawing/ui/TextToolIcon.js.map +1 -0
  62. package/lib/drawing/ui/ZoomControl.d.ts +25 -0
  63. package/lib/drawing/ui/ZoomControl.d.ts.map +1 -0
  64. package/lib/drawing/ui/ZoomControl.js +27 -0
  65. package/lib/drawing/ui/ZoomControl.js.map +1 -0
  66. package/lib/drawing/ui/index.d.ts +10 -0
  67. package/lib/drawing/ui/index.d.ts.map +1 -1
  68. package/lib/drawing/ui/index.js +7 -0
  69. package/lib/drawing/ui/index.js.map +1 -1
  70. package/lib/guide/ui/EmptyGuide.d.ts +5 -2
  71. package/lib/guide/ui/EmptyGuide.d.ts.map +1 -1
  72. package/lib/guide/ui/EmptyGuide.js +8 -3
  73. package/lib/guide/ui/EmptyGuide.js.map +1 -1
  74. package/lib/guide/ui/GuideFigures.d.ts +6 -0
  75. package/lib/guide/ui/GuideFigures.d.ts.map +1 -1
  76. package/lib/guide/ui/GuideFigures.js +5 -5
  77. package/lib/guide/ui/GuideFigures.js.map +1 -1
  78. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  79. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  80. package/lib/locales/de.json +4 -0
  81. package/lib/locales/en.json +4 -0
  82. package/lib/locales/es.json +4 -0
  83. package/lib/locales/fr.json +4 -0
  84. package/lib/locales/it.json +4 -0
  85. package/lib/log/core/index.d.ts +4 -0
  86. package/lib/log/core/index.d.ts.map +1 -0
  87. package/lib/log/core/index.js +3 -0
  88. package/lib/log/core/index.js.map +1 -0
  89. package/lib/log/core/logGroups.d.ts +87 -0
  90. package/lib/log/core/logGroups.d.ts.map +1 -0
  91. package/lib/log/core/logGroups.js +85 -0
  92. package/lib/log/core/logGroups.js.map +1 -0
  93. package/lib/log/core/logLines.d.ts +19 -0
  94. package/lib/log/core/logLines.d.ts.map +1 -0
  95. package/lib/log/core/logLines.js +36 -0
  96. package/lib/log/core/logLines.js.map +1 -0
  97. package/lib/log/ui/LogBadge.d.ts +39 -0
  98. package/lib/log/ui/LogBadge.d.ts.map +1 -0
  99. package/lib/log/ui/LogBadge.js +28 -0
  100. package/lib/log/ui/LogBadge.js.map +1 -0
  101. package/lib/log/ui/LogCallouts.d.ts +55 -0
  102. package/lib/log/ui/LogCallouts.d.ts.map +1 -0
  103. package/lib/log/ui/LogCallouts.js +38 -0
  104. package/lib/log/ui/LogCallouts.js.map +1 -0
  105. package/lib/log/ui/index.d.ts +7 -0
  106. package/lib/log/ui/index.d.ts.map +1 -0
  107. package/lib/log/ui/index.js +5 -0
  108. package/lib/log/ui/index.js.map +1 -0
  109. package/lib/log/ui/logIcon.d.ts +9 -0
  110. package/lib/log/ui/logIcon.d.ts.map +1 -0
  111. package/lib/log/ui/logIcon.js +17 -0
  112. package/lib/log/ui/logIcon.js.map +1 -0
  113. package/lib/log/ui/useLogEntries.d.ts +15 -0
  114. package/lib/log/ui/useLogEntries.d.ts.map +1 -0
  115. package/lib/log/ui/useLogEntries.js +47 -0
  116. package/lib/log/ui/useLogEntries.js.map +1 -0
  117. package/lib/mass/core/index.d.ts +1 -0
  118. package/lib/mass/core/index.d.ts.map +1 -1
  119. package/lib/mass/core/index.js +1 -0
  120. package/lib/mass/core/index.js.map +1 -1
  121. package/lib/mass/core/massDomain.d.ts.map +1 -1
  122. package/lib/mass/core/massDomain.js +9 -5
  123. package/lib/mass/core/massDomain.js.map +1 -1
  124. package/lib/mass/core/massSpectrum.d.ts +9 -0
  125. package/lib/mass/core/massSpectrum.d.ts.map +1 -1
  126. package/lib/mass/core/massSpectrum.js.map +1 -1
  127. package/lib/mass/core/verticalScale.d.ts +30 -0
  128. package/lib/mass/core/verticalScale.d.ts.map +1 -0
  129. package/lib/mass/core/verticalScale.js +40 -0
  130. package/lib/mass/core/verticalScale.js.map +1 -0
  131. package/lib/mass/ui/MassChart.d.ts.map +1 -1
  132. package/lib/mass/ui/MassChart.js +4 -38
  133. package/lib/mass/ui/MassChart.js.map +1 -1
  134. package/lib/mass/ui/massChartLayers.d.ts +31 -0
  135. package/lib/mass/ui/massChartLayers.d.ts.map +1 -0
  136. package/lib/mass/ui/massChartLayers.js +57 -0
  137. package/lib/mass/ui/massChartLayers.js.map +1 -0
  138. package/lib/structure/core/conformerMinimise.d.ts +13 -4
  139. package/lib/structure/core/conformerMinimise.d.ts.map +1 -1
  140. package/lib/structure/core/conformerMinimise.js +23 -6
  141. package/lib/structure/core/conformerMinimise.js.map +1 -1
  142. package/lib/structure/core/conformerRefine.d.ts +2 -2
  143. package/lib/structure/core/conformerRefine.d.ts.map +1 -1
  144. package/lib/structure/core/conformerRefine.js +23 -7
  145. package/lib/structure/core/conformerRefine.js.map +1 -1
  146. package/lib/structure/core/conformers.d.ts +8 -3
  147. package/lib/structure/core/conformers.d.ts.map +1 -1
  148. package/lib/structure/core/conformers.js +10 -7
  149. package/lib/structure/core/conformers.js.map +1 -1
  150. package/lib/structure/core/geometryRelaxer.d.ts +10 -3
  151. package/lib/structure/core/geometryRelaxer.d.ts.map +1 -1
  152. package/lib/structure/core/index.d.ts +1 -1
  153. package/lib/structure/core/index.d.ts.map +1 -1
  154. package/lib/structure/core/index.js.map +1 -1
  155. package/lib/structure/core/relaxerLogLines.d.ts +16 -0
  156. package/lib/structure/core/relaxerLogLines.d.ts.map +1 -0
  157. package/lib/structure/core/relaxerLogLines.js +33 -0
  158. package/lib/structure/core/relaxerLogLines.js.map +1 -0
  159. package/lib/structure/core/structurePicture.d.ts +32 -1
  160. package/lib/structure/core/structurePicture.d.ts.map +1 -1
  161. package/lib/structure/core/structurePicture.js +29 -2
  162. package/lib/structure/core/structurePicture.js.map +1 -1
  163. package/lib/structure/ui/StructureEditor.d.ts +2 -1
  164. package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
  165. package/lib/structure/ui/StructureEditor.js +9 -3
  166. package/lib/structure/ui/StructureEditor.js.map +1 -1
  167. package/lib/structure/ui/StructureEditorGuide.d.ts +15 -0
  168. package/lib/structure/ui/StructureEditorGuide.d.ts.map +1 -0
  169. package/lib/structure/ui/StructureEditorGuide.js +26 -0
  170. package/lib/structure/ui/StructureEditorGuide.js.map +1 -0
  171. package/lib/structure/ui/structureEditorProps.d.ts +11 -1
  172. package/lib/structure/ui/structureEditorProps.d.ts.map +1 -1
  173. package/lib/structure/ui/useCanvasPress.d.ts +23 -0
  174. package/lib/structure/ui/useCanvasPress.d.ts.map +1 -0
  175. package/lib/structure/ui/useCanvasPress.js +53 -0
  176. package/lib/structure/ui/useCanvasPress.js.map +1 -0
  177. package/lib/ui.d.ts +1 -0
  178. package/lib/ui.d.ts.map +1 -1
  179. package/lib/ui.js +1 -0
  180. package/lib/ui.js.map +1 -1
  181. package/lib/xps/core/detectFormat.d.ts +6 -0
  182. package/lib/xps/core/detectFormat.d.ts.map +1 -1
  183. package/lib/xps/core/detectFormat.js +8 -0
  184. package/lib/xps/core/detectFormat.js.map +1 -1
  185. package/lib/xps/core/xpsEditorApi.d.ts +16 -0
  186. package/lib/xps/core/xpsEditorApi.d.ts.map +1 -1
  187. package/lib/xps/ui/XpsCanvas.d.ts +10 -1
  188. package/lib/xps/ui/XpsCanvas.d.ts.map +1 -1
  189. package/lib/xps/ui/XpsCanvas.js +14 -3
  190. package/lib/xps/ui/XpsCanvas.js.map +1 -1
  191. package/lib/xps/ui/XpsChart.d.ts.map +1 -1
  192. package/lib/xps/ui/XpsChart.js +12 -43
  193. package/lib/xps/ui/XpsChart.js.map +1 -1
  194. package/lib/xps/ui/XpsEditor.d.ts +8 -0
  195. package/lib/xps/ui/XpsEditor.d.ts.map +1 -1
  196. package/lib/xps/ui/XpsEditor.js +2 -2
  197. package/lib/xps/ui/XpsEditor.js.map +1 -1
  198. package/lib/xps/ui/XpsShell.d.ts +5 -0
  199. package/lib/xps/ui/XpsShell.d.ts.map +1 -1
  200. package/lib/xps/ui/XpsShell.js +18 -4
  201. package/lib/xps/ui/XpsShell.js.map +1 -1
  202. package/lib/xps/ui/dropEvents.d.ts +8 -1
  203. package/lib/xps/ui/dropEvents.d.ts.map +1 -1
  204. package/lib/xps/ui/dropEvents.js +15 -1
  205. package/lib/xps/ui/dropEvents.js.map +1 -1
  206. package/lib/xps/ui/useSpectrumDrop.d.ts +6 -0
  207. package/lib/xps/ui/useSpectrumDrop.d.ts.map +1 -1
  208. package/lib/xps/ui/useSpectrumDrop.js +1 -1
  209. package/lib/xps/ui/useSpectrumDrop.js.map +1 -1
  210. package/lib/xps/ui/useXpsEditorHandle.d.ts +4 -1
  211. package/lib/xps/ui/useXpsEditorHandle.d.ts.map +1 -1
  212. package/lib/xps/ui/useXpsEditorHandle.js +6 -2
  213. package/lib/xps/ui/useXpsEditorHandle.js.map +1 -1
  214. package/lib/xps/ui/useXpsReadout.d.ts +43 -0
  215. package/lib/xps/ui/useXpsReadout.d.ts.map +1 -0
  216. package/lib/xps/ui/useXpsReadout.js +59 -0
  217. package/lib/xps/ui/useXpsReadout.js.map +1 -0
  218. package/lib/xps/ui/xpsChartProps.d.ts +9 -0
  219. package/lib/xps/ui/xpsChartProps.d.ts.map +1 -1
  220. package/lib/xtb/core/taggedLogger.d.ts +11 -0
  221. package/lib/xtb/core/taggedLogger.d.ts.map +1 -0
  222. package/lib/xtb/core/taggedLogger.js +31 -0
  223. package/lib/xtb/core/taggedLogger.js.map +1 -0
  224. package/lib/xtb/core/xtbRelaxer.d.ts.map +1 -1
  225. package/lib/xtb/core/xtbRelaxer.js +13 -5
  226. package/lib/xtb/core/xtbRelaxer.js.map +1 -1
  227. package/package.json +4 -3
  228. package/src/core.ts +1 -0
  229. package/src/drawing/captionEditor/CaptionEditor.tsx +8 -3
  230. package/src/drawing/captionEditor/CaptionToolbar.tsx +18 -2
  231. package/src/drawing/captionEditor/index.ts +2 -0
  232. package/src/drawing/captionEditor/toolbarInView.ts +73 -0
  233. package/src/drawing/core/camera.ts +3 -0
  234. package/src/drawing/core/index.ts +1 -0
  235. package/src/drawing/render/index.ts +2 -0
  236. package/src/drawing/render/pageGrid.ts +29 -11
  237. package/src/drawing/ui/PageField.tsx +104 -0
  238. package/src/drawing/ui/PageGrid.tsx +48 -0
  239. package/src/drawing/ui/PageSideInput.tsx +81 -0
  240. package/src/drawing/ui/PageToolbar.tsx +45 -0
  241. package/src/drawing/ui/PrintSheets.tsx +57 -0
  242. package/src/drawing/ui/TextToolIcon.tsx +48 -0
  243. package/src/drawing/ui/ZoomControl.tsx +112 -0
  244. package/src/drawing/ui/index.ts +10 -0
  245. package/src/guide/ui/EmptyGuide.tsx +20 -13
  246. package/src/guide/ui/GuideFigures.tsx +15 -4
  247. package/src/locales/de.json +4 -0
  248. package/src/locales/en.json +4 -0
  249. package/src/locales/es.json +4 -0
  250. package/src/locales/fr.json +4 -0
  251. package/src/locales/it.json +4 -0
  252. package/src/log/core/index.ts +9 -0
  253. package/src/log/core/logGroups.ts +159 -0
  254. package/src/log/core/logLines.ts +44 -0
  255. package/src/log/ui/LogBadge.tsx +89 -0
  256. package/src/log/ui/LogCallouts.tsx +103 -0
  257. package/src/log/ui/index.ts +6 -0
  258. package/src/log/ui/logIcon.ts +21 -0
  259. package/src/log/ui/useLogEntries.ts +57 -0
  260. package/src/mass/core/index.ts +1 -0
  261. package/src/mass/core/massDomain.ts +9 -3
  262. package/src/mass/core/massSpectrum.ts +9 -0
  263. package/src/mass/core/verticalScale.ts +48 -0
  264. package/src/mass/ui/MassChart.tsx +12 -43
  265. package/src/mass/ui/massChartLayers.ts +66 -0
  266. package/src/structure/core/conformerMinimise.ts +34 -8
  267. package/src/structure/core/conformerRefine.ts +29 -13
  268. package/src/structure/core/conformers.ts +23 -12
  269. package/src/structure/core/geometryRelaxer.ts +11 -3
  270. package/src/structure/core/index.ts +1 -0
  271. package/src/structure/core/relaxerLogLines.ts +39 -0
  272. package/src/structure/core/structurePicture.ts +78 -4
  273. package/src/structure/ui/StructureEditor.tsx +13 -2
  274. package/src/structure/ui/StructureEditorGuide.tsx +35 -0
  275. package/src/structure/ui/structureEditorProps.ts +11 -1
  276. package/src/structure/ui/useCanvasPress.ts +69 -0
  277. package/src/ui.ts +1 -0
  278. package/src/xps/core/detectFormat.ts +9 -0
  279. package/src/xps/core/xpsEditorApi.ts +16 -0
  280. package/src/xps/ui/XpsCanvas.tsx +26 -3
  281. package/src/xps/ui/XpsChart.tsx +12 -56
  282. package/src/xps/ui/XpsEditor.tsx +10 -0
  283. package/src/xps/ui/XpsShell.tsx +37 -7
  284. package/src/xps/ui/dropEvents.ts +16 -1
  285. package/src/xps/ui/useSpectrumDrop.ts +7 -1
  286. package/src/xps/ui/useXpsEditorHandle.ts +12 -2
  287. package/src/xps/ui/useXpsReadout.ts +104 -0
  288. package/src/xps/ui/xpsChartProps.ts +9 -0
  289. package/src/xtb/core/taggedLogger.ts +35 -0
  290. package/src/xtb/core/xtbRelaxer.ts +15 -5
  291. package/styles/caption-editor.css +15 -1
  292. package/styles/chrome.css +164 -9
  293. package/styles/drawing.css +100 -0
@@ -0,0 +1,104 @@
1
+ /**
2
+ * What the pointer reads off the XPS chart, and what of it the rest of the
3
+ * viewer hears: the crosshair follows every pixel, the viewer only the peak.
4
+ */
5
+
6
+ import type { RefObject } from 'react';
7
+ import { useCallback, useRef } from 'react';
8
+
9
+ import type { PlotRect } from '../../chart/core/chartGeometry.ts';
10
+ import type { ChartScale } from '../../chart/core/chartScale.ts';
11
+ import { chartValue } from '../../chart/core/chartScale.ts';
12
+ import type { ChartPoint } from '../../chart/core/svgPoint.ts';
13
+ import type { ChartPointer } from '../../chart/ui/useChartPointer.ts';
14
+ import { useChartPointer } from '../../chart/ui/useChartPointer.ts';
15
+ import type { NearestPeak } from '../core/nearestPeak.ts';
16
+ import { nearestPeakEnergy, sameNearestPeak } from '../core/nearestPeak.ts';
17
+ import type { XpsHighlight } from '../core/xpsHighlight.ts';
18
+ import { NO_HIGHLIGHT } from '../core/xpsHighlight.ts';
19
+ import type { EnergyAxis } from '../core/xpsSettings.ts';
20
+ import type { XpsSpectrum } from '../core/xpsSpectrum.ts';
21
+
22
+ import type { XpsReadout } from './XpsPointerTracker.tsx';
23
+
24
+ /** What {@link useXpsReadout} reads the pointer against. */
25
+ export interface XpsReadoutOptions {
26
+ /** The chart's SVG, which the pointer is heard on. */
27
+ svgRef: RefObject<SVGSVGElement | null>;
28
+ /** The plot, outside which the pointer reads nothing. */
29
+ plot: PlotRect;
30
+ /** The spectra drawn, whose peaks the pointer is nearest to. */
31
+ spectra: readonly XpsSpectrum[];
32
+ /** The energy axis the chart is drawn against. */
33
+ axis: EnergyAxis;
34
+ /** The energy scale on screen. */
35
+ xScale: ChartScale;
36
+ /** The counts scale on screen. */
37
+ yScale: ChartScale;
38
+ /**
39
+ * Told whenever the peak under the pointer changes.
40
+ * @default undefined
41
+ */
42
+ onHighlightChange?: (highlight: XpsHighlight) => void;
43
+ }
44
+
45
+ /**
46
+ * Follow the pointer over the chart, and tell the viewer which peak it is on.
47
+ *
48
+ * Only a change of peak is reported, starting from none: the pointer coming
49
+ * onto the plot over no peak says nothing, so a guide a panel put on the chart
50
+ * stays until the pointer actually reaches a peak.
51
+ * @param options - See {@link XpsReadoutOptions}.
52
+ * @returns Where the pointer is and what it reads.
53
+ */
54
+ export function useXpsReadout(
55
+ options: XpsReadoutOptions,
56
+ ): ChartPointer<XpsReadout> {
57
+ const { svgRef, plot, spectra, axis, xScale, yScale, onHighlightChange } =
58
+ options;
59
+ const read = useCallback(
60
+ (point: ChartPoint): XpsReadout => ({
61
+ energy: chartValue(xScale, point.x),
62
+ counts: chartValue(yScale, point.y),
63
+ peak: nearestPeakEnergy(spectra, axis, xScale, point.x),
64
+ }),
65
+ [xScale, yScale, spectra, axis],
66
+ );
67
+ const reportedPeak = useRef<NearestPeak | null>(null);
68
+ const onReadout = useCallback(
69
+ (readout: XpsReadout | null) => {
70
+ const found = readout?.peak ?? null;
71
+ if (sameNearestPeak(reportedPeak.current, found)) return;
72
+ reportedPeak.current = found;
73
+ onHighlightChange?.(
74
+ found === null
75
+ ? NO_HIGHLIGHT
76
+ : {
77
+ spectrumId: found.spectrumId,
78
+ peakId: found.peak.id,
79
+ componentId: null,
80
+ bindingEnergy: found.peak.bindingEnergy,
81
+ },
82
+ );
83
+ },
84
+ [onHighlightChange],
85
+ );
86
+ return useChartPointer<XpsReadout>({
87
+ svgRef,
88
+ plot,
89
+ read,
90
+ sameReadout: samePeakReadout,
91
+ onReadout,
92
+ });
93
+ }
94
+
95
+ /**
96
+ * Whether two readings are about the same peak, which is all the rest of the
97
+ * viewer hears about: the energy under the crosshair changes on every pixel.
98
+ * @param current - The reading last reported.
99
+ * @param next - The reading now.
100
+ * @returns Whether nothing needs reporting.
101
+ */
102
+ function samePeakReadout(current: XpsReadout, next: XpsReadout): boolean {
103
+ return sameNearestPeak(current.peak, next.peak);
104
+ }
@@ -12,6 +12,7 @@
12
12
  * test.
13
13
  */
14
14
 
15
+ import type { ChartSize } from '../../chart/core/chartGeometry.ts';
15
16
  import type { XpsHighlight } from '../core/xpsHighlight.ts';
16
17
  import type { XpsDomain, XpsRegion, XpsSpectrum } from '../core/xpsSpectrum.ts';
17
18
  import type { XpsSettings } from '../core/xpsState.ts';
@@ -66,6 +67,14 @@ export interface XpsChartProps {
66
67
  * @default false
67
68
  */
68
69
  isReading?: boolean;
70
+ /**
71
+ * The size to draw at, in CSS pixels, instead of the box the chart is put in
72
+ * — for a chart drawn where nothing is laid out, as a figure written to a
73
+ * file by `renderToStaticMarkup`, which would otherwise come out at the
74
+ * smallest plot there is.
75
+ * @default undefined — the box the chart is put in, measured
76
+ */
77
+ size?: ChartSize;
69
78
  }
70
79
 
71
80
  /** Windows shaded on the chart for one spectrum, beside the ones its file defines. */
@@ -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 cancellation.
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 (runOptions.signal?.aborted === true) {
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
- runOptions.onSettled?.(index + 1, requests.length);
147
+ results.push(await xtb.relaxGeometryInProcess(request, options));
148
+ onSettled?.(index + 1, requests.length);
139
149
  }
140
150
  return results;
141
151
  }
@@ -92,10 +92,18 @@
92
92
  font-family: inherit;
93
93
  font-size: 13px;
94
94
  gap: 4px;
95
- transform: translateX(-50%);
95
+ /* Centred over its caption, then moved back inside the figure when the
96
+ caption sits near an edge (`useToolbarInView`). */
97
+ transform: translateX(calc(-50% + var(--caption-toolbar-shift, 0px)));
96
98
  white-space: nowrap;
97
99
  }
98
100
 
101
+ /* With no room above the caption, the bar goes under it. */
102
+ .caption-toolbar[data-below] {
103
+ top: calc(100% + 4px);
104
+ bottom: auto;
105
+ }
106
+
99
107
  .caption-toolbar__size {
100
108
  display: flex;
101
109
  align-items: center;
@@ -109,3 +117,9 @@
109
117
  .caption-toolbar__unit {
110
118
  color: var(--text-muted);
111
119
  }
120
+
121
+ /* The tick keeps the caption: it stands apart from the styles. */
122
+ .caption-toolbar__done {
123
+ padding-left: 4px;
124
+ border-left: 1px solid var(--border);
125
+ }
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
  /*
@@ -2519,18 +2553,14 @@ span.taxon-lineage__name {
2519
2553
  /*
2520
2554
  What a tool shows while it holds nothing: `<EmptyGuide>`. Grey on purpose, so
2521
2555
  it reads as the empty space saying how to start and never as content. The
2522
- pointer goes through it to the tool, except on a link or a figure that can be
2523
- clicked, so a first stroke can start on the words.
2556
+ pointer goes through it to the tool, except on what can be clicked or typed
2557
+ in, so a first stroke can start on the words.
2524
2558
  */
2525
2559
  .empty-guide {
2526
2560
  position: absolute;
2527
- display: flex;
2528
- flex-direction: column;
2529
- padding: 12px 20px;
2530
2561
  color: var(--text-muted);
2531
2562
  container-type: size;
2532
2563
  font-size: 12.5px;
2533
- gap: 10px;
2534
2564
  inset: 0;
2535
2565
  line-height: 1.4;
2536
2566
  overflow: hidden;
@@ -2540,15 +2570,40 @@ span.taxon-lineage__name {
2540
2570
  animation: empty-guide-in 240ms ease-out 120ms both;
2541
2571
  }
2542
2572
 
2573
+ /* Laid out inside the box that is measured, so a small box can tighten it. */
2574
+ .empty-guide__body {
2575
+ display: flex;
2576
+ height: 100%;
2577
+ box-sizing: border-box;
2578
+ flex-direction: column;
2579
+ padding: 12px 20px;
2580
+ gap: 10px;
2581
+ }
2582
+
2543
2583
  .empty-guide a,
2544
2584
  .empty-guide button {
2545
2585
  color: inherit;
2546
- pointer-events: auto;
2547
2586
  text-decoration: underline;
2548
2587
  text-decoration-color: var(--border-strong);
2549
2588
  text-underline-offset: 2px;
2550
2589
  }
2551
2590
 
2591
+ /* Whatever can be clicked or typed in takes the pointer: a link, a button, a
2592
+ capsule or a tab drawn as one, a field and the label that ticks a box. */
2593
+ .empty-guide a,
2594
+ .empty-guide button,
2595
+ .empty-guide label,
2596
+ .empty-guide input,
2597
+ .empty-guide select,
2598
+ .empty-guide textarea,
2599
+ .empty-guide [role='button'],
2600
+ .empty-guide [role='checkbox'],
2601
+ .empty-guide [role='radio'],
2602
+ .empty-guide [role='switch'],
2603
+ .empty-guide [role='tab'] {
2604
+ pointer-events: auto;
2605
+ }
2606
+
2552
2607
  .empty-guide a:hover,
2553
2608
  .empty-guide button:hover {
2554
2609
  color: var(--accent);
@@ -2687,6 +2742,34 @@ button.empty-guide__figure:focus-visible img {
2687
2742
  opacity: 1;
2688
2743
  }
2689
2744
 
2745
+ /* A figure's name, one line under it, read before the faint picture is. */
2746
+ .empty-guide__label {
2747
+ overflow: hidden;
2748
+ flex: none;
2749
+ margin-top: 4px;
2750
+ color: var(--text-muted);
2751
+ font-size: 12.5px;
2752
+ font-weight: 600;
2753
+ text-align: center;
2754
+ text-overflow: ellipsis;
2755
+ white-space: nowrap;
2756
+ }
2757
+
2758
+ /* A named figure sits on its name, whatever room is left above it. */
2759
+ .empty-guide__figure:has(> .empty-guide__label) img {
2760
+ object-position: 50% 100%;
2761
+ }
2762
+
2763
+ /* A name is not a link: the figure it names is what is clicked. */
2764
+ .empty-guide button.empty-guide__figure {
2765
+ text-decoration: none;
2766
+ }
2767
+
2768
+ button.empty-guide__figure:hover .empty-guide__label,
2769
+ button.empty-guide__figure:focus-visible .empty-guide__label {
2770
+ color: var(--accent);
2771
+ }
2772
+
2690
2773
  .empty-guide__hint {
2691
2774
  display: flex;
2692
2775
  flex: none;
@@ -2706,14 +2789,86 @@ button.empty-guide__figure:focus-visible img {
2706
2789
  animation: empty-guide-in 400ms ease-out both;
2707
2790
  }
2708
2791
 
2709
- /* On a narrow or a short view the words take the whole of it: a picture the
2710
- size of a stamp shows nothing, and leaves its caption floating. */
2792
+ /* A small view — half an editor, a short window — keeps its figures: the help
2793
+ says each section's title and its first line, the buttons shrink, and the
2794
+ figures take what is left, never less than a third of the height. */
2711
2795
  @container (max-width: 640px) or (max-height: 520px) {
2796
+ .empty-guide__body {
2797
+ padding: 8px 12px;
2798
+ font-size: 12px;
2799
+ gap: 6px;
2800
+ line-height: 1.35;
2801
+ }
2802
+
2803
+ /* One row of sections, as many as the width holds: a section that would
2804
+ wrap is left out whole rather than cut through a line. */
2805
+ .empty-guide__help {
2806
+ min-height: 0;
2807
+ flex: 0 1 auto;
2808
+ gap: 0 16px;
2809
+ grid-auto-rows: 0;
2810
+ grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
2811
+ grid-template-rows: auto;
2812
+ overflow: hidden;
2813
+ }
2814
+
2815
+ .empty-guide__title {
2816
+ margin-bottom: 1px;
2817
+ font-size: 12px;
2818
+ }
2819
+
2820
+ .empty-guide__section > :nth-child(n + 3),
2821
+ .empty-guide__help .shortcut-list__row:nth-child(n + 4) {
2822
+ display: none;
2823
+ }
2824
+
2825
+ .empty-guide__section p {
2826
+ margin: 0;
2827
+ }
2828
+
2829
+ .empty-guide__start {
2830
+ gap: 6px 10px;
2831
+ }
2832
+
2833
+ .empty-guide button.empty-guide__action {
2834
+ min-height: 34px;
2835
+ padding: 0 14px;
2836
+ font-size: 13.5px;
2837
+ gap: 6px;
2838
+ }
2839
+
2840
+ .empty-guide__figures-title {
2841
+ font-size: 13px;
2842
+ }
2843
+
2844
+ .empty-guide__figures:not(:empty) {
2845
+ min-height: 33cqh;
2846
+ }
2847
+
2848
+ .empty-guide__stack {
2849
+ gap: 6px;
2850
+ }
2851
+
2852
+ .empty-guide__label {
2853
+ margin-top: 2px;
2854
+ font-size: 12px;
2855
+ }
2856
+ }
2857
+
2858
+ /* A phone-sized view takes the words alone: a picture the size of a stamp
2859
+ shows nothing, and leaves its caption floating. */
2860
+ @container (max-width: 440px) or (max-height: 300px) {
2712
2861
  .empty-guide__figures,
2713
2862
  .empty-guide__figures-title {
2714
2863
  display: none;
2715
2864
  }
2716
2865
 
2866
+ /* With no figures to make room for, every section is said. */
2867
+ .empty-guide__help {
2868
+ gap: 4px 16px;
2869
+ grid-auto-rows: auto;
2870
+ }
2871
+
2717
2872
  /* First, or a help taller than the view would push the buttons out of it. */
2718
2873
  .empty-guide__start {
2719
2874
  order: -1;
@@ -30,6 +30,21 @@
30
30
  stroke: var(--border-strong);
31
31
  }
32
32
 
33
+ /* The lines `PageGrid` draws between the sheets of a drawing, and the number
34
+ each sheet prints under. */
35
+ .draw-sheet {
36
+ fill: none;
37
+ pointer-events: none;
38
+ stroke: var(--border-strong);
39
+ stroke-dasharray: 6 4;
40
+ vector-effect: non-scaling-stroke;
41
+ }
42
+
43
+ .draw-sheet__number {
44
+ fill: var(--text-faint);
45
+ pointer-events: none;
46
+ }
47
+
33
48
  /* What `PageMask` hides around a page shown alone, and its edge. */
34
49
  .draw-page-mask {
35
50
  fill: var(--surface-sunken);
@@ -179,3 +194,88 @@
179
194
  color: var(--text-faint);
180
195
  font-style: italic;
181
196
  }
197
+
198
+ /* `ZoomControl`, at the right of an editor's status bar. */
199
+ .zoom-control {
200
+ display: inline-flex;
201
+ flex: none;
202
+ align-items: center;
203
+ gap: 4px;
204
+ }
205
+
206
+ /* Blueprint's slider is 40px tall for its labels; without them the 16px handle
207
+ is the whole of it, and the status bar keeps its height. */
208
+ .zoom-control .bp6-slider {
209
+ width: 120px;
210
+ min-width: 120px;
211
+ height: 16px;
212
+ }
213
+
214
+ /* As wide at 25 % as at 1600 %, so what stands beside it does not move. */
215
+ .zoom-control .zoom-control__level {
216
+ min-width: 92px;
217
+ }
218
+
219
+ @media (width < 640px) {
220
+ .zoom-control .bp6-slider {
221
+ display: none;
222
+ }
223
+ }
224
+
225
+ /* `PageField`: the orientation, then a page's width × height in centimetres. */
226
+ .page-field__orientation {
227
+ margin-top: 4px;
228
+ }
229
+
230
+ .page-field__size {
231
+ display: flex;
232
+ align-items: center;
233
+ margin-top: 4px;
234
+ gap: 6px;
235
+ }
236
+
237
+ .page-field__size .bp6-input-group {
238
+ width: 5rem;
239
+ }
240
+
241
+ .page-field__unit {
242
+ color: var(--text-muted);
243
+ font-size: 0.8125rem;
244
+ }
245
+
246
+ /* `PrintSheets`: on paper the editor gives way to the figure it holds, at the
247
+ size it was laid out at and shrunk only when it would not fit the page. */
248
+ .draw-print {
249
+ display: none;
250
+ }
251
+
252
+ @media print {
253
+ .draw-print {
254
+ display: flex;
255
+ justify-content: center;
256
+ }
257
+
258
+ .draw-print__figure {
259
+ width: auto;
260
+ height: auto;
261
+ max-width: 100%;
262
+ max-height: 100vh;
263
+ }
264
+
265
+ /* A grid of sheets: the paper is the sheet, so each one fills a sheet of
266
+ paper and nothing is shrunk. */
267
+ .draw-print--sheets {
268
+ display: block;
269
+ }
270
+
271
+ .draw-print--sheets .draw-print__figure {
272
+ display: block;
273
+ max-width: none;
274
+ max-height: none;
275
+ break-after: page;
276
+ }
277
+
278
+ .draw-print--sheets .draw-print__figure:last-child {
279
+ break-after: auto;
280
+ }
281
+ }