react-cheminfo 0.69.0 → 0.71.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 (616) hide show
  1. package/README.md +70 -2
  2. package/lib/about/core/providers.d.ts +6 -0
  3. package/lib/about/core/providers.d.ts.map +1 -1
  4. package/lib/about/core/providers.js +7 -0
  5. package/lib/about/core/providers.js.map +1 -1
  6. package/lib/about/ui/AboutProvidedBy.js +34 -0
  7. package/lib/about/ui/AboutProvidedBy.js.map +1 -1
  8. package/lib/chart/ui/useChartPointer.d.ts +9 -1
  9. package/lib/chart/ui/useChartPointer.d.ts.map +1 -1
  10. package/lib/chart/ui/useChartPointer.js +11 -3
  11. package/lib/chart/ui/useChartPointer.js.map +1 -1
  12. package/lib/credits/core/credits.d.ts +41 -0
  13. package/lib/credits/core/credits.d.ts.map +1 -1
  14. package/lib/credits/core/credits.js +50 -0
  15. package/lib/credits/core/credits.js.map +1 -1
  16. package/lib/download/core/drawingMarkup.d.ts +8 -1
  17. package/lib/download/core/drawingMarkup.d.ts.map +1 -1
  18. package/lib/download/core/drawingMarkup.js +13 -1
  19. package/lib/download/core/drawingMarkup.js.map +1 -1
  20. package/lib/download/core/figurePng.d.ts +14 -0
  21. package/lib/download/core/figurePng.d.ts.map +1 -1
  22. package/lib/download/core/figurePng.js +21 -6
  23. package/lib/download/core/figurePng.js.map +1 -1
  24. package/lib/download/core/figureSvg.d.ts.map +1 -1
  25. package/lib/download/core/figureSvg.js +5 -3
  26. package/lib/download/core/figureSvg.js.map +1 -1
  27. package/lib/download/core/figureTarget.d.ts +13 -0
  28. package/lib/download/core/figureTarget.d.ts.map +1 -1
  29. package/lib/download/core/figureTarget.js +25 -5
  30. package/lib/download/core/figureTarget.js.map +1 -1
  31. package/lib/download/core/svgBounds.d.ts +15 -0
  32. package/lib/download/core/svgBounds.d.ts.map +1 -1
  33. package/lib/download/core/svgBounds.js +20 -0
  34. package/lib/download/core/svgBounds.js.map +1 -1
  35. package/lib/download/core/svgToPng.d.ts.map +1 -1
  36. package/lib/download/core/svgToPng.js +4 -2
  37. package/lib/download/core/svgToPng.js.map +1 -1
  38. package/lib/format/core/relativeTime.d.ts +8 -3
  39. package/lib/format/core/relativeTime.d.ts.map +1 -1
  40. package/lib/format/core/relativeTime.js +19 -7
  41. package/lib/format/core/relativeTime.js.map +1 -1
  42. package/lib/host/core/connectHost.d.ts +25 -34
  43. package/lib/host/core/connectHost.d.ts.map +1 -1
  44. package/lib/host/core/connectHost.js +43 -89
  45. package/lib/host/core/connectHost.js.map +1 -1
  46. package/lib/host/core/hostOutputs.d.ts +58 -0
  47. package/lib/host/core/hostOutputs.d.ts.map +1 -0
  48. package/lib/host/core/hostOutputs.js +151 -0
  49. package/lib/host/core/hostOutputs.js.map +1 -0
  50. package/lib/host/core/index.d.ts +9 -3
  51. package/lib/host/core/index.d.ts.map +1 -1
  52. package/lib/host/core/index.js +4 -1
  53. package/lib/host/core/index.js.map +1 -1
  54. package/lib/host/core/irKinds.d.ts +124 -0
  55. package/lib/host/core/irKinds.d.ts.map +1 -0
  56. package/lib/host/core/irKinds.js +46 -0
  57. package/lib/host/core/irKinds.js.map +1 -0
  58. package/lib/host/core/kinds.d.ts +13 -5
  59. package/lib/host/core/kinds.d.ts.map +1 -1
  60. package/lib/host/core/kinds.js +11 -5
  61. package/lib/host/core/kinds.js.map +1 -1
  62. package/lib/host/core/protocol.d.ts +50 -7
  63. package/lib/host/core/protocol.d.ts.map +1 -1
  64. package/lib/host/core/protocol.js +10 -6
  65. package/lib/host/core/protocol.js.map +1 -1
  66. package/lib/host/core/selectInputs.d.ts +37 -0
  67. package/lib/host/core/selectInputs.d.ts.map +1 -0
  68. package/lib/host/core/selectInputs.js +110 -0
  69. package/lib/host/core/selectInputs.js.map +1 -0
  70. package/lib/host/testing/sciPeaks.d.ts +31 -0
  71. package/lib/host/testing/sciPeaks.d.ts.map +1 -1
  72. package/lib/host/testing/sciPeaks.js +73 -0
  73. package/lib/host/testing/sciPeaks.js.map +1 -1
  74. package/lib/host/testing/standInHost.d.ts +9 -1
  75. package/lib/host/testing/standInHost.d.ts.map +1 -1
  76. package/lib/host/testing/standInHost.js +19 -1
  77. package/lib/host/testing/standInHost.js.map +1 -1
  78. package/lib/host/ui/useHostConnection.d.ts +13 -5
  79. package/lib/host/ui/useHostConnection.d.ts.map +1 -1
  80. package/lib/host/ui/useHostConnection.js +4 -3
  81. package/lib/host/ui/useHostConnection.js.map +1 -1
  82. package/lib/host-testing.d.ts +2 -2
  83. package/lib/host-testing.d.ts.map +1 -1
  84. package/lib/host-testing.js +2 -2
  85. package/lib/host-testing.js.map +1 -1
  86. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  87. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  88. package/lib/ir/core/handPicking.d.ts +58 -0
  89. package/lib/ir/core/handPicking.d.ts.map +1 -0
  90. package/lib/ir/core/handPicking.js +130 -0
  91. package/lib/ir/core/handPicking.js.map +1 -0
  92. package/lib/ir/core/index.d.ts +3 -0
  93. package/lib/ir/core/index.d.ts.map +1 -1
  94. package/lib/ir/core/index.js +3 -0
  95. package/lib/ir/core/index.js.map +1 -1
  96. package/lib/ir/core/irBandState.d.ts +57 -0
  97. package/lib/ir/core/irBandState.d.ts.map +1 -0
  98. package/lib/ir/core/irBandState.js +119 -0
  99. package/lib/ir/core/irBandState.js.map +1 -0
  100. package/lib/ir/core/irCommands.d.ts +11 -0
  101. package/lib/ir/core/irCommands.d.ts.map +1 -1
  102. package/lib/ir/core/irCommands.js +6 -0
  103. package/lib/ir/core/irCommands.js.map +1 -1
  104. package/lib/ir/core/irPeaks.d.ts +28 -0
  105. package/lib/ir/core/irPeaks.d.ts.map +1 -0
  106. package/lib/ir/core/irPeaks.js +66 -0
  107. package/lib/ir/core/irPeaks.js.map +1 -0
  108. package/lib/ir/core/irReducer.d.ts +8 -0
  109. package/lib/ir/core/irReducer.d.ts.map +1 -1
  110. package/lib/ir/core/irReducer.js +15 -32
  111. package/lib/ir/core/irReducer.js.map +1 -1
  112. package/lib/ir/core/irSpectrum.d.ts +15 -0
  113. package/lib/ir/core/irSpectrum.d.ts.map +1 -1
  114. package/lib/ir/core/irSpectrum.js.map +1 -1
  115. package/lib/ir/core/irState.d.ts +9 -6
  116. package/lib/ir/core/irState.d.ts.map +1 -1
  117. package/lib/ir/core/irState.js +10 -6
  118. package/lib/ir/core/irState.js.map +1 -1
  119. package/lib/ir/core/pickBands.d.ts +14 -0
  120. package/lib/ir/core/pickBands.d.ts.map +1 -1
  121. package/lib/ir/core/pickBands.js +39 -33
  122. package/lib/ir/core/pickBands.js.map +1 -1
  123. package/lib/ir/core/ramanBands.d.ts +9 -1
  124. package/lib/ir/core/ramanBands.d.ts.map +1 -1
  125. package/lib/ir/core/ramanBands.js +2 -2
  126. package/lib/ir/core/ramanBands.js.map +1 -1
  127. package/lib/ir/core/spectrumBands.d.ts +46 -0
  128. package/lib/ir/core/spectrumBands.d.ts.map +1 -0
  129. package/lib/ir/core/spectrumBands.js +98 -0
  130. package/lib/ir/core/spectrumBands.js.map +1 -0
  131. package/lib/ir/ui/BandRow.d.ts +5 -0
  132. package/lib/ir/ui/BandRow.d.ts.map +1 -1
  133. package/lib/ir/ui/BandRow.js +4 -3
  134. package/lib/ir/ui/BandRow.js.map +1 -1
  135. package/lib/ir/ui/BandsPanel.d.ts +5 -0
  136. package/lib/ir/ui/BandsPanel.d.ts.map +1 -1
  137. package/lib/ir/ui/BandsPanel.js +36 -16
  138. package/lib/ir/ui/BandsPanel.js.map +1 -1
  139. package/lib/ir/ui/BandsToolbar.d.ts +9 -0
  140. package/lib/ir/ui/BandsToolbar.d.ts.map +1 -0
  141. package/lib/ir/ui/BandsToolbar.js +61 -0
  142. package/lib/ir/ui/BandsToolbar.js.map +1 -0
  143. package/lib/ir/ui/IrCanvas.d.ts +2 -1
  144. package/lib/ir/ui/IrCanvas.d.ts.map +1 -1
  145. package/lib/ir/ui/IrCanvas.js +19 -5
  146. package/lib/ir/ui/IrCanvas.js.map +1 -1
  147. package/lib/ir/ui/IrChart.d.ts.map +1 -1
  148. package/lib/ir/ui/IrChart.js +8 -1
  149. package/lib/ir/ui/IrChart.js.map +1 -1
  150. package/lib/ir/ui/IrDocumentationDialog.js +1 -1
  151. package/lib/ir/ui/IrDocumentationDialog.js.map +1 -1
  152. package/lib/ir/ui/IrEditor.d.ts +4 -2
  153. package/lib/ir/ui/IrEditor.d.ts.map +1 -1
  154. package/lib/ir/ui/IrEditor.js.map +1 -1
  155. package/lib/ir/ui/IrShell.d.ts.map +1 -1
  156. package/lib/ir/ui/IrShell.js +6 -0
  157. package/lib/ir/ui/IrShell.js.map +1 -1
  158. package/lib/ir/ui/IrStatusBar.d.ts.map +1 -1
  159. package/lib/ir/ui/IrStatusBar.js +1 -1
  160. package/lib/ir/ui/IrStatusBar.js.map +1 -1
  161. package/lib/ir/ui/IrToolbar.d.ts +4 -3
  162. package/lib/ir/ui/IrToolbar.d.ts.map +1 -1
  163. package/lib/ir/ui/IrToolbar.js +5 -4
  164. package/lib/ir/ui/IrToolbar.js.map +1 -1
  165. package/lib/ir/ui/VibrationalEditor.d.ts +2 -1
  166. package/lib/ir/ui/VibrationalEditor.d.ts.map +1 -1
  167. package/lib/ir/ui/VibrationalEditor.js.map +1 -1
  168. package/lib/ir/ui/irActions.d.ts +5 -0
  169. package/lib/ir/ui/irActions.d.ts.map +1 -1
  170. package/lib/ir/ui/irActions.js +6 -0
  171. package/lib/ir/ui/irActions.js.map +1 -1
  172. package/lib/ir/ui/irChartProps.d.ts +4 -1
  173. package/lib/ir/ui/irChartProps.d.ts.map +1 -1
  174. package/lib/ir/ui/useIrEditor.d.ts +5 -11
  175. package/lib/ir/ui/useIrEditor.d.ts.map +1 -1
  176. package/lib/ir/ui/useIrEditor.js +17 -18
  177. package/lib/ir/ui/useIrEditor.js.map +1 -1
  178. package/lib/locales/de.json +63 -0
  179. package/lib/locales/en.json +63 -0
  180. package/lib/locales/es.json +63 -0
  181. package/lib/locales/fr.json +63 -0
  182. package/lib/locales/it.json +63 -0
  183. package/lib/mass/core/analyseSpectrum.d.ts +85 -0
  184. package/lib/mass/core/analyseSpectrum.d.ts.map +1 -0
  185. package/lib/mass/core/analyseSpectrum.js +101 -0
  186. package/lib/mass/core/analyseSpectrum.js.map +1 -0
  187. package/lib/mass/core/ascendingTrace.d.ts +24 -0
  188. package/lib/mass/core/ascendingTrace.d.ts.map +1 -0
  189. package/lib/mass/core/ascendingTrace.js +57 -0
  190. package/lib/mass/core/ascendingTrace.js.map +1 -0
  191. package/lib/mass/core/centroidPeaks.d.ts +77 -0
  192. package/lib/mass/core/centroidPeaks.d.ts.map +1 -0
  193. package/lib/mass/core/centroidPeaks.js +62 -0
  194. package/lib/mass/core/centroidPeaks.js.map +1 -0
  195. package/lib/mass/core/detectMassFormat.d.ts +24 -0
  196. package/lib/mass/core/detectMassFormat.d.ts.map +1 -0
  197. package/lib/mass/core/detectMassFormat.js +105 -0
  198. package/lib/mass/core/detectMassFormat.js.map +1 -0
  199. package/lib/mass/core/downloadSpectra.d.ts +24 -0
  200. package/lib/mass/core/downloadSpectra.d.ts.map +1 -0
  201. package/lib/mass/core/downloadSpectra.js +35 -0
  202. package/lib/mass/core/downloadSpectra.js.map +1 -0
  203. package/lib/mass/core/fromJcamp.d.ts +46 -0
  204. package/lib/mass/core/fromJcamp.d.ts.map +1 -0
  205. package/lib/mass/core/fromJcamp.js +123 -0
  206. package/lib/mass/core/fromJcamp.js.map +1 -0
  207. package/lib/mass/core/fromText.d.ts +30 -0
  208. package/lib/mass/core/fromText.d.ts.map +1 -0
  209. package/lib/mass/core/fromText.js +39 -0
  210. package/lib/mass/core/fromText.js.map +1 -0
  211. package/lib/mass/core/index.d.ts +70 -0
  212. package/lib/mass/core/index.d.ts.map +1 -0
  213. package/lib/mass/core/index.js +42 -0
  214. package/lib/mass/core/index.js.map +1 -0
  215. package/lib/mass/core/jcampTechnique.d.ts +38 -0
  216. package/lib/mass/core/jcampTechnique.d.ts.map +1 -0
  217. package/lib/mass/core/jcampTechnique.js +70 -0
  218. package/lib/mass/core/jcampTechnique.js.map +1 -0
  219. package/lib/mass/core/labelStackBox.d.ts +49 -0
  220. package/lib/mass/core/labelStackBox.d.ts.map +1 -0
  221. package/lib/mass/core/labelStackBox.js +44 -0
  222. package/lib/mass/core/labelStackBox.js.map +1 -0
  223. package/lib/mass/core/labelledPeaks.d.ts +79 -0
  224. package/lib/mass/core/labelledPeaks.d.ts.map +1 -0
  225. package/lib/mass/core/labelledPeaks.js +74 -0
  226. package/lib/mass/core/labelledPeaks.js.map +1 -0
  227. package/lib/mass/core/loadMassSpectra.d.ts +57 -0
  228. package/lib/mass/core/loadMassSpectra.d.ts.map +1 -0
  229. package/lib/mass/core/loadMassSpectra.js +45 -0
  230. package/lib/mass/core/loadMassSpectra.js.map +1 -0
  231. package/lib/mass/core/loadedMassSpectrum.d.ts +42 -0
  232. package/lib/mass/core/loadedMassSpectrum.d.ts.map +1 -0
  233. package/lib/mass/core/loadedMassSpectrum.js +15 -0
  234. package/lib/mass/core/loadedMassSpectrum.js.map +1 -0
  235. package/lib/mass/core/massCommands.d.ts +170 -0
  236. package/lib/mass/core/massCommands.d.ts.map +1 -0
  237. package/lib/mass/core/massCommands.js +95 -0
  238. package/lib/mass/core/massCommands.js.map +1 -0
  239. package/lib/mass/core/massDomain.d.ts +121 -0
  240. package/lib/mass/core/massDomain.d.ts.map +1 -0
  241. package/lib/mass/core/massDomain.js +179 -0
  242. package/lib/mass/core/massDomain.js.map +1 -0
  243. package/lib/mass/core/massEditorApi.d.ts +65 -0
  244. package/lib/mass/core/massEditorApi.d.ts.map +1 -0
  245. package/lib/mass/core/massEditorApi.js +10 -0
  246. package/lib/mass/core/massEditorApi.js.map +1 -0
  247. package/lib/mass/core/massFormat.d.ts +78 -0
  248. package/lib/mass/core/massFormat.d.ts.map +1 -0
  249. package/lib/mass/core/massFormat.js +168 -0
  250. package/lib/mass/core/massFormat.js.map +1 -0
  251. package/lib/mass/core/massMeta.d.ts +85 -0
  252. package/lib/mass/core/massMeta.d.ts.map +1 -0
  253. package/lib/mass/core/massMeta.js +182 -0
  254. package/lib/mass/core/massMeta.js.map +1 -0
  255. package/lib/mass/core/massReducer.d.ts +82 -0
  256. package/lib/mass/core/massReducer.d.ts.map +1 -0
  257. package/lib/mass/core/massReducer.js +163 -0
  258. package/lib/mass/core/massReducer.js.map +1 -0
  259. package/lib/mass/core/massResolution.d.ts +92 -0
  260. package/lib/mass/core/massResolution.d.ts.map +1 -0
  261. package/lib/mass/core/massResolution.js +126 -0
  262. package/lib/mass/core/massResolution.js.map +1 -0
  263. package/lib/mass/core/massSidePanels.d.ts +28 -0
  264. package/lib/mass/core/massSidePanels.d.ts.map +1 -0
  265. package/lib/mass/core/massSidePanels.js +12 -0
  266. package/lib/mass/core/massSidePanels.js.map +1 -0
  267. package/lib/mass/core/massSpectrum.d.ts +206 -0
  268. package/lib/mass/core/massSpectrum.d.ts.map +1 -0
  269. package/lib/mass/core/massSpectrum.js +41 -0
  270. package/lib/mass/core/massSpectrum.js.map +1 -0
  271. package/lib/mass/core/massState.d.ts +145 -0
  272. package/lib/mass/core/massState.d.ts.map +1 -0
  273. package/lib/mass/core/massState.js +102 -0
  274. package/lib/mass/core/massState.js.map +1 -0
  275. package/lib/mass/core/massStateEdits.d.ts +51 -0
  276. package/lib/mass/core/massStateEdits.d.ts.map +1 -0
  277. package/lib/mass/core/massStateEdits.js +90 -0
  278. package/lib/mass/core/massStateEdits.js.map +1 -0
  279. package/lib/mass/core/massSummary.d.ts +77 -0
  280. package/lib/mass/core/massSummary.d.ts.map +1 -0
  281. package/lib/mass/core/massSummary.js +174 -0
  282. package/lib/mass/core/massSummary.js.map +1 -0
  283. package/lib/mass/core/mzDecimalsSetting.d.ts +36 -0
  284. package/lib/mass/core/mzDecimalsSetting.d.ts.map +1 -0
  285. package/lib/mass/core/mzDecimalsSetting.js +42 -0
  286. package/lib/mass/core/mzDecimalsSetting.js.map +1 -0
  287. package/lib/mass/core/nearestPeak.d.ts +75 -0
  288. package/lib/mass/core/nearestPeak.d.ts.map +1 -0
  289. package/lib/mass/core/nearestPeak.js +99 -0
  290. package/lib/mass/core/nearestPeak.js.map +1 -0
  291. package/lib/mass/core/peakLabelLines.d.ts +77 -0
  292. package/lib/mass/core/peakLabelLines.d.ts.map +1 -0
  293. package/lib/mass/core/peakLabelLines.js +54 -0
  294. package/lib/mass/core/peakLabelLines.js.map +1 -0
  295. package/lib/mass/core/peakLabelPlan.d.ts +109 -0
  296. package/lib/mass/core/peakLabelPlan.d.ts.map +1 -0
  297. package/lib/mass/core/peakLabelPlan.js +143 -0
  298. package/lib/mass/core/peakLabelPlan.js.map +1 -0
  299. package/lib/mass/core/peakTable.d.ts +54 -0
  300. package/lib/mass/core/peakTable.d.ts.map +1 -0
  301. package/lib/mass/core/peakTable.js +53 -0
  302. package/lib/mass/core/peakTable.js.map +1 -0
  303. package/lib/mass/core/resolutionOf.d.ts +60 -0
  304. package/lib/mass/core/resolutionOf.d.ts.map +1 -0
  305. package/lib/mass/core/resolutionOf.js +84 -0
  306. package/lib/mass/core/resolutionOf.js.map +1 -0
  307. package/lib/mass/core/scanFilter.d.ts +25 -0
  308. package/lib/mass/core/scanFilter.d.ts.map +1 -0
  309. package/lib/mass/core/scanFilter.js +107 -0
  310. package/lib/mass/core/scanFilter.js.map +1 -0
  311. package/lib/mass/core/spectrumJcamp.d.ts +47 -0
  312. package/lib/mass/core/spectrumJcamp.d.ts.map +1 -0
  313. package/lib/mass/core/spectrumJcamp.js +167 -0
  314. package/lib/mass/core/spectrumJcamp.js.map +1 -0
  315. package/lib/mass/core/toMassSpectrum.d.ts +67 -0
  316. package/lib/mass/core/toMassSpectrum.d.ts.map +1 -0
  317. package/lib/mass/core/toMassSpectrum.js +78 -0
  318. package/lib/mass/core/toMassSpectrum.js.map +1 -0
  319. package/lib/mass/core/traceIcon.d.ts +82 -0
  320. package/lib/mass/core/traceIcon.d.ts.map +1 -0
  321. package/lib/mass/core/traceIcon.js +66 -0
  322. package/lib/mass/core/traceIcon.js.map +1 -0
  323. package/lib/mass/core/writtenResolution.d.ts +40 -0
  324. package/lib/mass/core/writtenResolution.d.ts.map +1 -0
  325. package/lib/mass/core/writtenResolution.js +77 -0
  326. package/lib/mass/core/writtenResolution.js.map +1 -0
  327. package/lib/mass/ui/MassAboutDialog.d.ts +16 -0
  328. package/lib/mass/ui/MassAboutDialog.d.ts.map +1 -0
  329. package/lib/mass/ui/MassAboutDialog.js +44 -0
  330. package/lib/mass/ui/MassAboutDialog.js.map +1 -0
  331. package/lib/mass/ui/MassCanvas.d.ts +46 -0
  332. package/lib/mass/ui/MassCanvas.d.ts.map +1 -0
  333. package/lib/mass/ui/MassCanvas.js +84 -0
  334. package/lib/mass/ui/MassCanvas.js.map +1 -0
  335. package/lib/mass/ui/MassChart.d.ts +21 -0
  336. package/lib/mass/ui/MassChart.d.ts.map +1 -0
  337. package/lib/mass/ui/MassChart.js +139 -0
  338. package/lib/mass/ui/MassChart.js.map +1 -0
  339. package/lib/mass/ui/MassCommandProvider.d.ts +15 -0
  340. package/lib/mass/ui/MassCommandProvider.d.ts.map +1 -0
  341. package/lib/mass/ui/MassCommandProvider.js +14 -0
  342. package/lib/mass/ui/MassCommandProvider.js.map +1 -0
  343. package/lib/mass/ui/MassCommandTooltip.d.ts +16 -0
  344. package/lib/mass/ui/MassCommandTooltip.d.ts.map +1 -0
  345. package/lib/mass/ui/MassCommandTooltip.js +22 -0
  346. package/lib/mass/ui/MassCommandTooltip.js.map +1 -0
  347. package/lib/mass/ui/MassDocumentationDialog.d.ts +18 -0
  348. package/lib/mass/ui/MassDocumentationDialog.d.ts.map +1 -0
  349. package/lib/mass/ui/MassDocumentationDialog.js +70 -0
  350. package/lib/mass/ui/MassDocumentationDialog.js.map +1 -0
  351. package/lib/mass/ui/MassEditor.d.ts +78 -0
  352. package/lib/mass/ui/MassEditor.d.ts.map +1 -0
  353. package/lib/mass/ui/MassEditor.js +42 -0
  354. package/lib/mass/ui/MassEditor.js.map +1 -0
  355. package/lib/mass/ui/MassHeader.d.ts +12 -0
  356. package/lib/mass/ui/MassHeader.d.ts.map +1 -0
  357. package/lib/mass/ui/MassHeader.js +20 -0
  358. package/lib/mass/ui/MassHeader.js.map +1 -0
  359. package/lib/mass/ui/MassLogo.d.ts +21 -0
  360. package/lib/mass/ui/MassLogo.d.ts.map +1 -0
  361. package/lib/mass/ui/MassLogo.js +36 -0
  362. package/lib/mass/ui/MassLogo.js.map +1 -0
  363. package/lib/mass/ui/MassPointerTracker.d.ts +44 -0
  364. package/lib/mass/ui/MassPointerTracker.d.ts.map +1 -0
  365. package/lib/mass/ui/MassPointerTracker.js +29 -0
  366. package/lib/mass/ui/MassPointerTracker.js.map +1 -0
  367. package/lib/mass/ui/MassShell.d.ts +29 -0
  368. package/lib/mass/ui/MassShell.d.ts.map +1 -0
  369. package/lib/mass/ui/MassShell.js +133 -0
  370. package/lib/mass/ui/MassShell.js.map +1 -0
  371. package/lib/mass/ui/MassSidePanel.d.ts +32 -0
  372. package/lib/mass/ui/MassSidePanel.d.ts.map +1 -0
  373. package/lib/mass/ui/MassSidePanel.js +44 -0
  374. package/lib/mass/ui/MassSidePanel.js.map +1 -0
  375. package/lib/mass/ui/MassStateProvider.d.ts +19 -0
  376. package/lib/mass/ui/MassStateProvider.d.ts.map +1 -0
  377. package/lib/mass/ui/MassStateProvider.js +16 -0
  378. package/lib/mass/ui/MassStateProvider.js.map +1 -0
  379. package/lib/mass/ui/MassStatusBar.d.ts +15 -0
  380. package/lib/mass/ui/MassStatusBar.d.ts.map +1 -0
  381. package/lib/mass/ui/MassStatusBar.js +50 -0
  382. package/lib/mass/ui/MassStatusBar.js.map +1 -0
  383. package/lib/mass/ui/MassToolbar.d.ts +24 -0
  384. package/lib/mass/ui/MassToolbar.d.ts.map +1 -0
  385. package/lib/mass/ui/MassToolbar.js +36 -0
  386. package/lib/mass/ui/MassToolbar.js.map +1 -0
  387. package/lib/mass/ui/MetadataPanel.d.ts +35 -0
  388. package/lib/mass/ui/MetadataPanel.d.ts.map +1 -0
  389. package/lib/mass/ui/MetadataPanel.js +100 -0
  390. package/lib/mass/ui/MetadataPanel.js.map +1 -0
  391. package/lib/mass/ui/MzDecimalsMenu.d.ts +28 -0
  392. package/lib/mass/ui/MzDecimalsMenu.d.ts.map +1 -0
  393. package/lib/mass/ui/MzDecimalsMenu.js +40 -0
  394. package/lib/mass/ui/MzDecimalsMenu.js.map +1 -0
  395. package/lib/mass/ui/PeakLabels.d.ts +93 -0
  396. package/lib/mass/ui/PeakLabels.d.ts.map +1 -0
  397. package/lib/mass/ui/PeakLabels.js +91 -0
  398. package/lib/mass/ui/PeakLabels.js.map +1 -0
  399. package/lib/mass/ui/PeakTable.d.ts +34 -0
  400. package/lib/mass/ui/PeakTable.d.ts.map +1 -0
  401. package/lib/mass/ui/PeakTable.js +49 -0
  402. package/lib/mass/ui/PeakTable.js.map +1 -0
  403. package/lib/mass/ui/PeaksPanel.d.ts +31 -0
  404. package/lib/mass/ui/PeaksPanel.d.ts.map +1 -0
  405. package/lib/mass/ui/PeaksPanel.js +53 -0
  406. package/lib/mass/ui/PeaksPanel.js.map +1 -0
  407. package/lib/mass/ui/SpectraPanel.d.ts +17 -0
  408. package/lib/mass/ui/SpectraPanel.d.ts.map +1 -0
  409. package/lib/mass/ui/SpectraPanel.js +76 -0
  410. package/lib/mass/ui/SpectraPanel.js.map +1 -0
  411. package/lib/mass/ui/SpectrumRow.d.ts +26 -0
  412. package/lib/mass/ui/SpectrumRow.d.ts.map +1 -0
  413. package/lib/mass/ui/SpectrumRow.js +141 -0
  414. package/lib/mass/ui/SpectrumRow.js.map +1 -0
  415. package/lib/mass/ui/SpectrumTrace.d.ts +46 -0
  416. package/lib/mass/ui/SpectrumTrace.d.ts.map +1 -0
  417. package/lib/mass/ui/SpectrumTrace.js +68 -0
  418. package/lib/mass/ui/SpectrumTrace.js.map +1 -0
  419. package/lib/mass/ui/index.d.ts +69 -0
  420. package/lib/mass/ui/index.d.ts.map +1 -0
  421. package/lib/mass/ui/index.js +42 -0
  422. package/lib/mass/ui/index.js.map +1 -0
  423. package/lib/mass/ui/massActions.d.ts +52 -0
  424. package/lib/mass/ui/massActions.d.ts.map +1 -0
  425. package/lib/mass/ui/massActions.js +62 -0
  426. package/lib/mass/ui/massActions.js.map +1 -0
  427. package/lib/mass/ui/massChartProps.d.ts +128 -0
  428. package/lib/mass/ui/massChartProps.d.ts.map +1 -0
  429. package/lib/mass/ui/massChartProps.js +14 -0
  430. package/lib/mass/ui/massChartProps.js.map +1 -0
  431. package/lib/mass/ui/massCommandContext.d.ts +36 -0
  432. package/lib/mass/ui/massCommandContext.d.ts.map +1 -0
  433. package/lib/mass/ui/massCommandContext.js +45 -0
  434. package/lib/mass/ui/massCommandContext.js.map +1 -0
  435. package/lib/mass/ui/massHostPanels.d.ts +48 -0
  436. package/lib/mass/ui/massHostPanels.d.ts.map +1 -0
  437. package/lib/mass/ui/massHostPanels.js +41 -0
  438. package/lib/mass/ui/massHostPanels.js.map +1 -0
  439. package/lib/mass/ui/massStateContext.d.ts +26 -0
  440. package/lib/mass/ui/massStateContext.d.ts.map +1 -0
  441. package/lib/mass/ui/massStateContext.js +37 -0
  442. package/lib/mass/ui/massStateContext.js.map +1 -0
  443. package/lib/mass/ui/useIntensityZoom.d.ts +20 -0
  444. package/lib/mass/ui/useIntensityZoom.d.ts.map +1 -0
  445. package/lib/mass/ui/useIntensityZoom.js +42 -0
  446. package/lib/mass/ui/useIntensityZoom.js.map +1 -0
  447. package/lib/mass/ui/useMassEditor.d.ts +52 -0
  448. package/lib/mass/ui/useMassEditor.d.ts.map +1 -0
  449. package/lib/mass/ui/useMassEditor.js +93 -0
  450. package/lib/mass/ui/useMassEditor.js.map +1 -0
  451. package/lib/mass/ui/useMassFiles.d.ts +22 -0
  452. package/lib/mass/ui/useMassFiles.d.ts.map +1 -0
  453. package/lib/mass/ui/useMassFiles.js +71 -0
  454. package/lib/mass/ui/useMassFiles.js.map +1 -0
  455. package/lib/mass/ui/useMassHandle.d.ts +15 -0
  456. package/lib/mass/ui/useMassHandle.d.ts.map +1 -0
  457. package/lib/mass/ui/useMassHandle.js +35 -0
  458. package/lib/mass/ui/useMassHandle.js.map +1 -0
  459. package/lib/mass/ui/useMassPointer.d.ts +70 -0
  460. package/lib/mass/ui/useMassPointer.d.ts.map +1 -0
  461. package/lib/mass/ui/useMassPointer.js +57 -0
  462. package/lib/mass/ui/useMassPointer.js.map +1 -0
  463. package/lib/mass/ui/useMassShortcuts.d.ts +21 -0
  464. package/lib/mass/ui/useMassShortcuts.d.ts.map +1 -0
  465. package/lib/mass/ui/useMassShortcuts.js +66 -0
  466. package/lib/mass/ui/useMassShortcuts.js.map +1 -0
  467. package/lib/mass/ui/useMassSide.d.ts +27 -0
  468. package/lib/mass/ui/useMassSide.d.ts.map +1 -0
  469. package/lib/mass/ui/useMassSide.js +45 -0
  470. package/lib/mass/ui/useMassSide.js.map +1 -0
  471. package/lib/mass/ui/useMassZoom.d.ts +92 -0
  472. package/lib/mass/ui/useMassZoom.d.ts.map +1 -0
  473. package/lib/mass/ui/useMassZoom.js +65 -0
  474. package/lib/mass/ui/useMassZoom.js.map +1 -0
  475. package/lib/mass.d.ts +16 -0
  476. package/lib/mass.d.ts.map +1 -0
  477. package/lib/mass.js +16 -0
  478. package/lib/mass.js.map +1 -0
  479. package/lib/panel/ui/PanelRail.d.ts.map +1 -1
  480. package/lib/panel/ui/PanelRail.js +6 -1
  481. package/lib/panel/ui/PanelRail.js.map +1 -1
  482. package/lib/slides/ui/slideSanitizeSchema.d.ts +3 -2
  483. package/lib/slides/ui/slideSanitizeSchema.d.ts.map +1 -1
  484. package/lib/slides/ui/slideSanitizeSchema.js +82 -2
  485. package/lib/slides/ui/slideSanitizeSchema.js.map +1 -1
  486. package/package.json +6 -1
  487. package/src/about/core/providers.ts +7 -0
  488. package/src/about/ui/AboutProvidedBy.tsx +49 -0
  489. package/src/chart/ui/useChartPointer.ts +18 -4
  490. package/src/credits/core/credits.ts +53 -0
  491. package/src/download/core/drawingMarkup.ts +18 -1
  492. package/src/download/core/figurePng.ts +21 -8
  493. package/src/download/core/figureSvg.ts +5 -2
  494. package/src/download/core/figureTarget.ts +28 -3
  495. package/src/download/core/svgBounds.ts +21 -0
  496. package/src/download/core/svgToPng.ts +3 -4
  497. package/src/format/core/relativeTime.ts +29 -7
  498. package/src/host/core/connectHost.ts +77 -120
  499. package/src/host/core/hostOutputs.ts +197 -0
  500. package/src/host/core/index.ts +13 -7
  501. package/src/host/core/irKinds.ts +92 -0
  502. package/src/host/core/kinds.ts +16 -6
  503. package/src/host/core/protocol.ts +50 -8
  504. package/src/host/core/selectInputs.ts +145 -0
  505. package/src/host/testing/sciPeaks.ts +140 -0
  506. package/src/host/testing/standInHost.ts +30 -5
  507. package/src/host/ui/useHostConnection.ts +17 -8
  508. package/src/host-testing.ts +4 -0
  509. package/src/ir/core/handPicking.ts +154 -0
  510. package/src/ir/core/index.ts +14 -0
  511. package/src/ir/core/irBandState.ts +155 -0
  512. package/src/ir/core/irCommands.ts +7 -0
  513. package/src/ir/core/irPeaks.ts +79 -0
  514. package/src/ir/core/irReducer.ts +27 -34
  515. package/src/ir/core/irSpectrum.ts +16 -0
  516. package/src/ir/core/irState.ts +15 -8
  517. package/src/ir/core/pickBands.ts +46 -39
  518. package/src/ir/core/ramanBands.ts +2 -2
  519. package/src/ir/core/spectrumBands.ts +113 -0
  520. package/src/ir/ui/BandRow.tsx +20 -2
  521. package/src/ir/ui/BandsPanel.tsx +46 -88
  522. package/src/ir/ui/BandsToolbar.tsx +152 -0
  523. package/src/ir/ui/IrCanvas.tsx +22 -11
  524. package/src/ir/ui/IrChart.tsx +10 -1
  525. package/src/ir/ui/IrDocumentationDialog.tsx +7 -0
  526. package/src/ir/ui/IrEditor.tsx +4 -2
  527. package/src/ir/ui/IrShell.tsx +5 -0
  528. package/src/ir/ui/IrStatusBar.tsx +4 -1
  529. package/src/ir/ui/IrToolbar.tsx +14 -5
  530. package/src/ir/ui/VibrationalEditor.tsx +2 -1
  531. package/src/ir/ui/irActions.ts +11 -0
  532. package/src/ir/ui/irChartProps.ts +4 -1
  533. package/src/ir/ui/useIrEditor.ts +21 -21
  534. package/src/locales/de.json +63 -0
  535. package/src/locales/en.json +63 -0
  536. package/src/locales/es.json +63 -0
  537. package/src/locales/fr.json +63 -0
  538. package/src/locales/it.json +63 -0
  539. package/src/mass/core/analyseSpectrum.ts +191 -0
  540. package/src/mass/core/ascendingTrace.ts +62 -0
  541. package/src/mass/core/centroidPeaks.ts +114 -0
  542. package/src/mass/core/detectMassFormat.ts +113 -0
  543. package/src/mass/core/downloadSpectra.ts +52 -0
  544. package/src/mass/core/fromJcamp.ts +151 -0
  545. package/src/mass/core/fromText.ts +58 -0
  546. package/src/mass/core/index.ts +194 -0
  547. package/src/mass/core/jcampTechnique.ts +87 -0
  548. package/src/mass/core/labelStackBox.ts +75 -0
  549. package/src/mass/core/labelledPeaks.ts +135 -0
  550. package/src/mass/core/loadMassSpectra.ts +86 -0
  551. package/src/mass/core/loadedMassSpectrum.ts +43 -0
  552. package/src/mass/core/massCommands.ts +156 -0
  553. package/src/mass/core/massDomain.ts +229 -0
  554. package/src/mass/core/massEditorApi.ts +68 -0
  555. package/src/mass/core/massFormat.ts +187 -0
  556. package/src/mass/core/massMeta.ts +239 -0
  557. package/src/mass/core/massReducer.ts +232 -0
  558. package/src/mass/core/massResolution.ts +169 -0
  559. package/src/mass/core/massSidePanels.ts +27 -0
  560. package/src/mass/core/massSpectrum.ts +220 -0
  561. package/src/mass/core/massState.ts +206 -0
  562. package/src/mass/core/massStateEdits.ts +104 -0
  563. package/src/mass/core/massSummary.ts +213 -0
  564. package/src/mass/core/mzDecimalsSetting.ts +52 -0
  565. package/src/mass/core/nearestPeak.ts +130 -0
  566. package/src/mass/core/peakLabelLines.ts +112 -0
  567. package/src/mass/core/peakLabelPlan.ts +246 -0
  568. package/src/mass/core/peakTable.ts +82 -0
  569. package/src/mass/core/resolutionOf.ts +100 -0
  570. package/src/mass/core/scanFilter.ts +119 -0
  571. package/src/mass/core/spectrumJcamp.ts +186 -0
  572. package/src/mass/core/toMassSpectrum.ts +126 -0
  573. package/src/mass/core/traceIcon.ts +105 -0
  574. package/src/mass/core/writtenResolution.ts +81 -0
  575. package/src/mass/ui/MassAboutDialog.tsx +89 -0
  576. package/src/mass/ui/MassCanvas.tsx +170 -0
  577. package/src/mass/ui/MassChart.tsx +266 -0
  578. package/src/mass/ui/MassCommandProvider.tsx +34 -0
  579. package/src/mass/ui/MassCommandTooltip.tsx +36 -0
  580. package/src/mass/ui/MassDocumentationDialog.tsx +136 -0
  581. package/src/mass/ui/MassEditor.tsx +130 -0
  582. package/src/mass/ui/MassHeader.tsx +38 -0
  583. package/src/mass/ui/MassLogo.tsx +84 -0
  584. package/src/mass/ui/MassPointerTracker.tsx +72 -0
  585. package/src/mass/ui/MassShell.tsx +237 -0
  586. package/src/mass/ui/MassSidePanel.tsx +107 -0
  587. package/src/mass/ui/MassStateProvider.tsx +32 -0
  588. package/src/mass/ui/MassStatusBar.tsx +108 -0
  589. package/src/mass/ui/MassToolbar.tsx +120 -0
  590. package/src/mass/ui/MetadataPanel.tsx +201 -0
  591. package/src/mass/ui/MzDecimalsMenu.tsx +86 -0
  592. package/src/mass/ui/PeakLabels.tsx +242 -0
  593. package/src/mass/ui/PeakTable.tsx +199 -0
  594. package/src/mass/ui/PeaksPanel.tsx +182 -0
  595. package/src/mass/ui/SpectraPanel.tsx +153 -0
  596. package/src/mass/ui/SpectrumRow.tsx +246 -0
  597. package/src/mass/ui/SpectrumTrace.tsx +119 -0
  598. package/src/mass/ui/index.ts +69 -0
  599. package/src/mass/ui/massActions.ts +109 -0
  600. package/src/mass/ui/massChartProps.ts +130 -0
  601. package/src/mass/ui/massCommandContext.tsx +65 -0
  602. package/src/mass/ui/massHostPanels.ts +71 -0
  603. package/src/mass/ui/massStateContext.ts +48 -0
  604. package/src/mass/ui/useIntensityZoom.ts +55 -0
  605. package/src/mass/ui/useMassEditor.ts +156 -0
  606. package/src/mass/ui/useMassFiles.ts +91 -0
  607. package/src/mass/ui/useMassHandle.ts +58 -0
  608. package/src/mass/ui/useMassPointer.ts +120 -0
  609. package/src/mass/ui/useMassShortcuts.ts +85 -0
  610. package/src/mass/ui/useMassSide.ts +63 -0
  611. package/src/mass/ui/useMassZoom.ts +157 -0
  612. package/src/mass.ts +16 -0
  613. package/src/panel/ui/PanelRail.tsx +5 -1
  614. package/src/slides/ui/slideSanitizeSchema.ts +86 -2
  615. package/styles/chrome.css +7 -0
  616. package/styles/slides.css +47 -0
@@ -0,0 +1,197 @@
1
+ /**
2
+ * What a tool hands back: the values a `get` asks for, and the `output` it
3
+ * sends when a value the host accepted changes.
4
+ *
5
+ * An `output` carries only what changed, item by item, against what the host
6
+ * already has: the values as they stood once its document was applied, then
7
+ * every value sent since. Opening a document therefore never writes it back,
8
+ * and a band picked on one spectrum of a sample leaves the others alone.
9
+ */
10
+
11
+ import { kindAccepts } from './kinds.ts';
12
+ import type {
13
+ GetRequest,
14
+ HostItem,
15
+ OutputMessage,
16
+ ResultMessage,
17
+ ToolInterface,
18
+ } from './protocol.ts';
19
+
20
+ /** Where a tool's outputs are read, and how their changes are heard. */
21
+ export interface HostOutputs {
22
+ /**
23
+ * The value of every output now, one item each, carrying its `key` and the
24
+ * `id` of the item it was made from. It must already show a document once
25
+ * `load` has returned, or the host is sent back what it just loaded.
26
+ */
27
+ read: () => readonly HostItem[];
28
+ /** Be told whenever they may have changed; the returned function stops it. */
29
+ subscribe: (listener: () => void) => () => void;
30
+ }
31
+
32
+ /**
33
+ * How long the outputs must stay still before a change is sent, in
34
+ * milliseconds: a burst of edits is one message.
35
+ */
36
+ export const OUTPUT_DELAY = 300;
37
+
38
+ /**
39
+ * Answer a `get` with the values it asks for — every output when it names
40
+ * none.
41
+ * @param request - The request.
42
+ * @param tool - What the tool hands back.
43
+ * @param outputs - Where the values are read, if anywhere.
44
+ * @returns The values, or `no-output` when the tool has none of those asked.
45
+ */
46
+ export function answerGet(
47
+ request: GetRequest,
48
+ tool: ToolInterface,
49
+ outputs: HostOutputs | undefined,
50
+ ): ResultMessage {
51
+ const { id, keys } = request;
52
+ const declared = new Set<string>();
53
+ for (const output of tool.outputs) declared.add(output.key);
54
+ if (outputs === undefined || declared.size === 0) {
55
+ return noOutput(id, `${tool.name} has nothing to give back yet.`);
56
+ }
57
+ const wanted = keys.length === 0 ? declared : new Set<string>();
58
+ for (const key of keys) {
59
+ if (declared.has(key)) wanted.add(key);
60
+ }
61
+ if (wanted.size === 0) {
62
+ return noOutput(
63
+ id,
64
+ `${tool.name} has no output called ${LIST.format(keys)}.`,
65
+ );
66
+ }
67
+ const items: HostItem[] = [];
68
+ for (const item of outputs.read()) {
69
+ if (item.key !== undefined && wanted.has(item.key)) items.push(item);
70
+ }
71
+ return { type: 'result', id, ok: true, items };
72
+ }
73
+
74
+ /** What the connection tells the publisher, and the means to stop it. */
75
+ export interface OutputPublisher {
76
+ /** A document was applied: what the host has is what the tool now shows. */
77
+ baseline: (document: string, accept: readonly string[]) => void;
78
+ /** The outputs may have changed. */
79
+ changed: () => void;
80
+ /**
81
+ * Send what changed now rather than once it settles: another document is
82
+ * about to replace what the outputs are read from.
83
+ */
84
+ flush: () => void;
85
+ /** Send nothing more. */
86
+ stop: () => void;
87
+ }
88
+
89
+ /**
90
+ * Send the host what changed of the outputs it accepted, once they settle.
91
+ * @param outputs - Where the values are read.
92
+ * @param send - Posts a message to the host, when there is one.
93
+ * @param delay - How long the values must stay still, in milliseconds.
94
+ * @returns The publisher.
95
+ */
96
+ export function createOutputPublisher(
97
+ outputs: HostOutputs,
98
+ send: (message: OutputMessage) => void,
99
+ delay: number,
100
+ ): OutputPublisher {
101
+ let document: string | null = null;
102
+ let accepted = new Set<string>();
103
+ let known = new Map<string, string>();
104
+ let timer: ReturnType<typeof setTimeout> | undefined;
105
+
106
+ function flush(): void {
107
+ timer = undefined;
108
+ if (document === null) return;
109
+ const items: HostItem[] = [];
110
+ for (const [identity, entry] of readAccepted(outputs, accepted)) {
111
+ if (known.get(identity) === entry.text) continue;
112
+ known.set(identity, entry.text);
113
+ items.push(entry.item);
114
+ }
115
+ if (items.length > 0) send({ type: 'output', document, items });
116
+ }
117
+
118
+ function stop(): void {
119
+ clearTimeout(timer);
120
+ timer = undefined;
121
+ }
122
+
123
+ return {
124
+ baseline(next, accept) {
125
+ stop();
126
+ document = next;
127
+ accepted = new Set(accept);
128
+ known = new Map();
129
+ for (const [identity, entry] of readAccepted(outputs, accepted)) {
130
+ known.set(identity, entry.text);
131
+ }
132
+ },
133
+ changed() {
134
+ if (document === null || accepted.size === 0) return;
135
+ stop();
136
+ timer = setTimeout(flush, delay);
137
+ },
138
+ flush() {
139
+ stop();
140
+ flush();
141
+ },
142
+ stop,
143
+ };
144
+ }
145
+
146
+ /**
147
+ * The accepted items, each under an identity that survives a re-read: its
148
+ * key, the id of the item it was made from, and its rank among items sharing
149
+ * both.
150
+ * @param outputs - Where the values are read.
151
+ * @param accepted - The keys and kinds the host takes back.
152
+ * @returns Each item with its value as text, by identity.
153
+ */
154
+ function readAccepted(
155
+ outputs: HostOutputs,
156
+ accepted: ReadonlySet<string>,
157
+ ): Map<string, { item: HostItem; text: string }> {
158
+ const entries = new Map<string, { item: HostItem; text: string }>();
159
+ if (accepted.size === 0) return entries;
160
+ for (const item of outputs.read()) {
161
+ if (!isAccepted(item, accepted)) continue;
162
+ const base = `${item.key ?? item.kind}\n${item.id ?? ''}`;
163
+ let rank = 0;
164
+ while (entries.has(`${base}\n${rank}`)) rank++;
165
+ entries.set(`${base}\n${rank}`, {
166
+ item,
167
+ text: JSON.stringify(item.value),
168
+ });
169
+ }
170
+ return entries;
171
+ }
172
+
173
+ /**
174
+ * Whether the host takes an item back: `accept` names its output's key, or
175
+ * its kind — a kind taking every kind under it, as an input's does.
176
+ * @param item - The item.
177
+ * @param accepted - What the host takes back.
178
+ * @returns Whether it goes back.
179
+ */
180
+ function isAccepted(item: HostItem, accepted: ReadonlySet<string>): boolean {
181
+ if (item.key !== undefined && accepted.has(item.key)) return true;
182
+ for (const name of accepted) {
183
+ if (kindAccepts(name, item.kind)) return true;
184
+ }
185
+ return false;
186
+ }
187
+
188
+ function noOutput(id: string, message: string): ResultMessage {
189
+ return {
190
+ type: 'result',
191
+ id,
192
+ ok: false,
193
+ error: { code: 'no-output', message },
194
+ };
195
+ }
196
+
197
+ const LIST = new Intl.ListFormat('en', { type: 'disjunction' });
@@ -1,10 +1,11 @@
1
- export type {
2
- HostConnectionOptions,
3
- HostMessageEvent,
4
- InputSelection,
5
- LoadedInput,
6
- } from './connectHost.ts';
7
- export { connectHost, selectInputs } from './connectHost.ts';
1
+ export type { HostConnectionOptions, HostMessageEvent } from './connectHost.ts';
2
+ export { connectHost } from './connectHost.ts';
3
+ export type { HostOutputs, OutputPublisher } from './hostOutputs.ts';
4
+ export {
5
+ OUTPUT_DELAY,
6
+ answerGet,
7
+ createOutputPublisher,
8
+ } from './hostOutputs.ts';
8
9
  export type { StructureValue } from './hostStructure.ts';
9
10
  export {
10
11
  STRUCTURE_KINDS,
@@ -12,6 +13,8 @@ export {
12
13
  hostStructureSource,
13
14
  readHostMolecule,
14
15
  } from './hostStructure.ts';
16
+ export type { IrJdxValue, IrPeakValue, IrPeaksValue } from './irKinds.ts';
17
+ export { IR_JDX_SCHEMA, IR_PEAKS_SCHEMA } from './irKinds.ts';
15
18
  export type {
16
19
  CheckOutcome,
17
20
  CheckedValue,
@@ -29,6 +32,7 @@ export type {
29
32
  HostItem,
30
33
  HostRequest,
31
34
  LoadRequest,
35
+ OutputMessage,
32
36
  ResultMessage,
33
37
  ToolInput,
34
38
  ToolInterface,
@@ -44,3 +48,5 @@ export {
44
48
  isConnect,
45
49
  parseRequest,
46
50
  } from './protocol.ts';
51
+ export type { InputSelection, LoadedInput } from './selectInputs.ts';
52
+ export { selectInputs } from './selectInputs.ts';
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The kinds a measured infrared spectrum travels as: the JCAMP-DX a notebook
3
+ * keeps with the bands picked on it, and those bands alone, which is what a
4
+ * tool hands back.
5
+ *
6
+ * Shaped on what SciPeaks keeps for a sample's infrared spectrum — a JCAMP-DX
7
+ * attachment and a `peak` list beside it — with the text of the attachment in
8
+ * place of its address, since a tool framed from another origin cannot fetch
9
+ * what the notebook serves its own pages. A band is written the way SciPeaks
10
+ * and `ir-spectrum` write one, so what a tool hands back can be stored as it
11
+ * arrives.
12
+ *
13
+ * Named after pipeline's `spectra.nmr.1d.jdx`. Pipeline's own `spectra.ir` is
14
+ * a computed spectrum — normal modes, not a measurement — and is not one of the
15
+ * kinds read here.
16
+ */
17
+
18
+ /** One band of an infrared spectrum, as SciPeaks and `ir-spectrum` write it. */
19
+ export interface IrPeakValue {
20
+ /** Where it sits, in cm⁻¹. */
21
+ wavenumber: number;
22
+ /**
23
+ * Its absorbance.
24
+ * @default read off the spectrum
25
+ */
26
+ absorbance?: number;
27
+ /**
28
+ * Its transmittance, as a fraction between 0 and 1 — not a percentage.
29
+ * @default read off the spectrum
30
+ */
31
+ transmittance?: number;
32
+ /**
33
+ * How strong it is: `w` weak, `m` medium, `S` strong. Any other letter is
34
+ * worked out again from the spectrum.
35
+ * @default worked out from the spectrum
36
+ */
37
+ kind?: string;
38
+ }
39
+
40
+ /** `spectra.ir.jdx`: a measured infrared spectrum and the bands picked on it. */
41
+ export interface IrJdxValue {
42
+ /** The JCAMP-DX, as text. */
43
+ jdx: string;
44
+ /**
45
+ * The name the notebook keeps it under, e.g. `spectra/ir/sample.jdx`.
46
+ * @default undefined
47
+ */
48
+ filename?: string;
49
+ /**
50
+ * The bands picked on it. Absent or empty, the tool picks them itself.
51
+ * @default undefined
52
+ */
53
+ peaks?: IrPeakValue[];
54
+ }
55
+
56
+ /** `spectra.ir.peaks`: the bands picked on an infrared spectrum, alone. */
57
+ export interface IrPeaksValue {
58
+ /** The bands, ascending by wavenumber. */
59
+ peaks: IrPeakValue[];
60
+ }
61
+
62
+ const IR_PEAK_SCHEMA = {
63
+ type: 'object',
64
+ properties: {
65
+ wavenumber: { type: 'number' },
66
+ absorbance: { type: 'number' },
67
+ transmittance: { type: 'number' },
68
+ kind: { type: 'string' },
69
+ },
70
+ required: ['wavenumber'],
71
+ additionalProperties: false,
72
+ } as const;
73
+
74
+ /** The schema of `spectra.ir.jdx`. */
75
+ export const IR_JDX_SCHEMA = {
76
+ type: 'object',
77
+ properties: {
78
+ jdx: { type: 'string' },
79
+ filename: { type: 'string' },
80
+ peaks: { type: 'array', items: IR_PEAK_SCHEMA },
81
+ },
82
+ required: ['jdx'],
83
+ additionalProperties: false,
84
+ } as const;
85
+
86
+ /** The schema of `spectra.ir.peaks`. */
87
+ export const IR_PEAKS_SCHEMA = {
88
+ type: 'object',
89
+ properties: { peaks: { type: 'array', items: IR_PEAK_SCHEMA } },
90
+ required: ['peaks'],
91
+ additionalProperties: false,
92
+ } as const;
@@ -4,16 +4,20 @@
4
4
  * name, a JSON Schema, and ajv.
5
5
  *
6
6
  * The names are pipeline's (`chem.molfile.2d`, `chem.ocl.id`…), plus
7
- * `chem.smiles`, which pipeline lists among its future schemas. A name with
8
- * children is a category whose schema every child satisfies, so `chem.molfile`
9
- * reads `chem.molfile.2d` and `chem.molfile.3d.h.energy` alike; the fields a
10
- * tool does not read are stripped rather than refused, so a host sending more
11
- * than it needs to is never turned away.
7
+ * `chem.smiles`, which pipeline lists among its future schemas, and the two
8
+ * infrared kinds of `./irKinds.ts`. A name with children is a category whose
9
+ * schema every child satisfies, so `chem.molfile` reads `chem.molfile.2d` and
10
+ * `chem.molfile.3d.h.energy` alike; the fields a tool does not read are
11
+ * stripped rather than refused, so a host sending more than it needs to is
12
+ * never turned away.
12
13
  */
13
14
 
14
15
  import type { JSONSchemaType, ValidateFunction } from 'ajv';
15
16
  import { Ajv } from 'ajv';
16
17
 
18
+ import type { IrJdxValue, IrPeaksValue } from './irKinds.ts';
19
+ import { IR_JDX_SCHEMA, IR_PEAKS_SCHEMA } from './irKinds.ts';
20
+
17
21
  /** A molfile, V2000 or V3000. */
18
22
  export interface MolfileValue {
19
23
  molfile: string;
@@ -34,7 +38,9 @@ export interface SmilesValue {
34
38
  export type CheckedValue =
35
39
  | { kind: 'chem.molfile'; value: MolfileValue }
36
40
  | { kind: 'chem.ocl.id'; value: OclIdValue }
37
- | { kind: 'chem.smiles'; value: SmilesValue };
41
+ | { kind: 'chem.smiles'; value: SmilesValue }
42
+ | { kind: 'spectra.ir.jdx'; value: IrJdxValue }
43
+ | { kind: 'spectra.ir.peaks'; value: IrPeaksValue };
38
44
 
39
45
  /** The name of a kind a tool can read. */
40
46
  export type KnownKind = CheckedValue['kind'];
@@ -125,4 +131,8 @@ const VALIDATORS: { [K in KnownKind]: ValidateFunction<ValueOf<K>> } = {
125
131
  'chem.molfile': ajv.compile(MOLFILE_SCHEMA),
126
132
  'chem.ocl.id': ajv.compile(OCL_ID_SCHEMA),
127
133
  'chem.smiles': ajv.compile(SMILES_SCHEMA),
134
+ // Written as plain schemas rather than `JSONSchemaType`, which would demand
135
+ // `nullable` on every optional field and so let a `null` band through.
136
+ 'spectra.ir.jdx': ajv.compile<IrJdxValue>(IR_JDX_SCHEMA),
137
+ 'spectra.ir.peaks': ajv.compile<IrPeaksValue>(IR_PEAKS_SCHEMA),
128
138
  };
@@ -4,9 +4,10 @@
4
4
  *
5
5
  * Two messages travel between the windows — `hello`, from the tool, and
6
6
  * `connect`, the host's answer carrying a private `MessagePort` — and everything
7
- * else goes through that port: the host's requests (`load`, `get`) and the
8
- * tool's `result` for each. This module only spells the messages, and reads
9
- * what arrives as the untrusted input it is.
7
+ * else goes through that port: the host's requests (`load`, `get`), the tool's
8
+ * `result` for each, and the `output` the tool sends when a value the host
9
+ * takes back changes. This module only spells the messages, and reads what
10
+ * arrives as the untrusted input it is.
10
11
  */
11
12
 
12
13
  /** The version a tool speaks; a `connect` naming another is ignored. */
@@ -52,9 +53,24 @@ export interface ToolInput {
52
53
  key: string;
53
54
  /** Kinds in order of preference; a category accepts every kind under it. */
54
55
  kinds: readonly string[];
56
+ /**
57
+ * Whether it takes every item of its kinds, in the host's order, rather than
58
+ * the one it prefers — every spectrum of a sample.
59
+ * @default false
60
+ */
61
+ many?: boolean;
62
+ /**
63
+ * Whether a request may leave it without an item. A request is still
64
+ * refused when no input at all gets one.
65
+ * @default false
66
+ */
67
+ optional?: boolean;
55
68
  }
56
69
 
57
- /** One value the tool can hand back. */
70
+ /**
71
+ * One value the tool can hand back: answered to `get`, and sent as `output`
72
+ * whenever it changes, when the host accepted it.
73
+ */
58
74
  export interface ToolOutput {
59
75
  key: string;
60
76
  kind: string;
@@ -86,6 +102,13 @@ export interface LoadRequest {
86
102
  /** What the data belongs to; the same document twice is applied once. */
87
103
  document: string;
88
104
  items: HostItem[];
105
+ /**
106
+ * The outputs the host takes back for this document, by key or by kind — a
107
+ * kind taking every kind under it: the tool sends an `output` whenever one
108
+ * of their values changes.
109
+ * @default undefined — nothing is sent unasked
110
+ */
111
+ accept?: string[];
89
112
  }
90
113
 
91
114
  /** `get`: the current value of some outputs. */
@@ -119,18 +142,35 @@ export interface UsedItem {
119
142
  kind: string;
120
143
  }
121
144
 
122
- /** The answer to one request, carrying its `id`. */
145
+ /**
146
+ * The answer to one request, carrying its `id`: which items a `load` used, or
147
+ * the values a `get` asked for.
148
+ */
123
149
  export type ResultMessage =
124
150
  | { type: 'result'; id: string; ok: true; used: UsedItem[] }
151
+ | { type: 'result'; id: string; ok: true; items: HostItem[] }
125
152
  | { type: 'result'; id: string; ok: false; error: HostError };
126
153
 
154
+ /**
155
+ * Sent by the tool, unasked, when values the host accepted have changed — the
156
+ * user picked a band. It carries only the items that changed: one missing is
157
+ * unchanged, never deleted.
158
+ */
159
+ export interface OutputMessage {
160
+ type: 'output';
161
+ /** The document the values belong to, as the host's `load` named it. */
162
+ document: string;
163
+ /** Each with its `key`, and the `id` of the item it was made from. */
164
+ items: HostItem[];
165
+ }
166
+
127
167
  /**
128
168
  * Read a message that arrived through the port.
129
169
  *
130
170
  * Anything that is not a well-formed `load` or `get` is `null`, and goes
131
171
  * unanswered: an unknown request is a newer host talking, not an error. An item
132
- * without a string `kind` is dropped, and a label is cut to
133
- * {@link MAX_LABEL_LENGTH}.
172
+ * without a string `kind` is dropped, a label is cut to
173
+ * {@link MAX_LABEL_LENGTH}, and a `load` without `accept` takes nothing back.
134
174
  * @param data - What the port delivered.
135
175
  * @returns The request, or `null`.
136
176
  */
@@ -140,12 +180,14 @@ export function parseRequest(data: unknown): HostRequest | null {
140
180
  if (typeof data.document !== 'string' || !Array.isArray(data.items)) {
141
181
  return null;
142
182
  }
143
- return {
183
+ const load: LoadRequest = {
144
184
  type: 'load',
145
185
  id: data.id,
146
186
  document: data.document,
147
187
  items: readItems(data.items),
148
188
  };
189
+ if (Array.isArray(data.accept)) load.accept = readStrings(data.accept);
190
+ return load;
149
191
  }
150
192
  if (data.type === 'get') {
151
193
  return { type: 'get', id: data.id, keys: readStrings(data.keys) };
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Which items of a request each input of a tool takes, and the sentence a
3
+ * host is answered with when the request loads nothing.
4
+ */
5
+
6
+ import type { CheckedValue, KnownKind } from './kinds.ts';
7
+ import { checkValue, isKnownKind, kindAccepts } from './kinds.ts';
8
+ import type {
9
+ HostError,
10
+ HostItem,
11
+ ToolInput,
12
+ ToolInterface,
13
+ } from './protocol.ts';
14
+
15
+ /** The item an input took, and its value as the input's kind reads it. */
16
+ export interface LoadedInput {
17
+ key: string;
18
+ item: HostItem;
19
+ checked: CheckedValue;
20
+ }
21
+
22
+ /** What choosing the items of a request gave. */
23
+ export type InputSelection =
24
+ { ok: true; inputs: LoadedInput[] } | { ok: false; error: HostError };
25
+
26
+ /**
27
+ * Give each input of the tool the items of a request it takes.
28
+ *
29
+ * Each input tries its kinds in its own order of preference, and takes the
30
+ * first item that falls under one and passes that kind's schema: the tool
31
+ * knows which notation serves it best, whatever order the host listed them in.
32
+ * An input taking `many` takes every such item instead, in the host's order.
33
+ * An item naming another input's `key` is left to that input.
34
+ *
35
+ * A required input left without an item refuses the request. An optional one
36
+ * is passed over, unless no input got an item at all.
37
+ * @param tool - What the tool takes.
38
+ * @param items - What the host sent.
39
+ * @returns The items the inputs took, or why the request loads nothing.
40
+ */
41
+ export function selectInputs(
42
+ tool: ToolInterface,
43
+ items: readonly HostItem[],
44
+ ): InputSelection {
45
+ const inputs: LoadedInput[] = [];
46
+ const passedOver: string[] = [];
47
+ for (const input of tool.inputs) {
48
+ const errors: string[] = [];
49
+ const taken = input.many
50
+ ? selectEvery(input, items, errors)
51
+ : selectFirst(input, items, errors);
52
+ if (taken.length > 0) {
53
+ inputs.push(...taken);
54
+ } else if (input.optional) {
55
+ passedOver.push(...errors);
56
+ } else {
57
+ return { ok: false, error: refusal(tool, [input], errors) };
58
+ }
59
+ }
60
+ if (inputs.length > 0 || tool.inputs.length === 0) {
61
+ return { ok: true, inputs };
62
+ }
63
+ return { ok: false, error: refusal(tool, tool.inputs, passedOver) };
64
+ }
65
+
66
+ function selectFirst(
67
+ input: ToolInput,
68
+ items: readonly HostItem[],
69
+ errors: string[],
70
+ ): LoadedInput[] {
71
+ for (const accepted of input.kinds) {
72
+ if (!isKnownKind(accepted)) continue;
73
+ for (const item of items) {
74
+ if (!isFor(input, accepted, item)) continue;
75
+ const loaded = checkItem(input.key, accepted, item, errors);
76
+ if (loaded !== null) return [loaded];
77
+ }
78
+ }
79
+ return [];
80
+ }
81
+
82
+ function selectEvery(
83
+ input: ToolInput,
84
+ items: readonly HostItem[],
85
+ errors: string[],
86
+ ): LoadedInput[] {
87
+ const taken: LoadedInput[] = [];
88
+ for (const item of items) {
89
+ for (const accepted of input.kinds) {
90
+ if (!isKnownKind(accepted) || !isFor(input, accepted, item)) continue;
91
+ const loaded = checkItem(input.key, accepted, item, errors);
92
+ if (loaded === null) continue;
93
+ taken.push(loaded);
94
+ break;
95
+ }
96
+ }
97
+ return taken;
98
+ }
99
+
100
+ function isFor(input: ToolInput, accepted: KnownKind, item: HostItem): boolean {
101
+ if (item.key !== undefined && item.key !== input.key) return false;
102
+ return kindAccepts(accepted, item.kind);
103
+ }
104
+
105
+ function checkItem(
106
+ key: string,
107
+ accepted: KnownKind,
108
+ item: HostItem,
109
+ errors: string[],
110
+ ): LoadedInput | null {
111
+ const outcome = checkValue(accepted, item.value);
112
+ if (outcome.valid) return { key, item, checked: outcome.checked };
113
+ for (const error of outcome.errors) errors.push(`${item.kind} ${error}`);
114
+ return null;
115
+ }
116
+
117
+ /**
118
+ * Why a request loads nothing: some item had the wrong shape, or no item was
119
+ * of a kind the inputs take.
120
+ * @param tool - What the tool takes.
121
+ * @param inputs - The inputs left without an item.
122
+ * @param errors - What the schemas found.
123
+ * @returns The error the host is answered with.
124
+ */
125
+ function refusal(
126
+ tool: ToolInterface,
127
+ inputs: readonly ToolInput[],
128
+ errors: string[],
129
+ ): HostError {
130
+ if (errors.length > 0) {
131
+ const keys = inputs.map((input) => input.key);
132
+ return {
133
+ code: 'invalid',
134
+ message: `No item for ${LIST.format(keys)} has the shape its kind requires, so ${tool.name} loaded nothing.`,
135
+ errors,
136
+ };
137
+ }
138
+ const kinds = inputs.flatMap((input) => input.kinds);
139
+ return {
140
+ code: 'no-input',
141
+ message: `No item is a ${LIST.format(kinds)}, so ${tool.name} loaded nothing.`,
142
+ };
143
+ }
144
+
145
+ const LIST = new Intl.ListFormat('en', { type: 'disjunction' });