react-cheminfo 0.76.0 → 0.78.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 (389) hide show
  1. package/README.md +141 -31
  2. package/lib/card/core/cardAddress.d.ts +19 -2
  3. package/lib/card/core/cardAddress.d.ts.map +1 -1
  4. package/lib/card/core/cardAddress.js +35 -2
  5. package/lib/card/core/cardAddress.js.map +1 -1
  6. package/lib/card/core/cardPageUrl.d.ts +7 -1
  7. package/lib/card/core/cardPageUrl.d.ts.map +1 -1
  8. package/lib/card/core/cardPageUrl.js +4 -2
  9. package/lib/card/core/cardPageUrl.js.map +1 -1
  10. package/lib/card/core/index.d.ts +1 -1
  11. package/lib/card/core/index.d.ts.map +1 -1
  12. package/lib/card/core/index.js +1 -1
  13. package/lib/card/core/index.js.map +1 -1
  14. package/lib/credits/core/credits.d.ts +30 -0
  15. package/lib/credits/core/credits.d.ts.map +1 -1
  16. package/lib/credits/core/credits.js +35 -0
  17. package/lib/credits/core/credits.js.map +1 -1
  18. package/lib/download/core/downloadFigure.d.ts +12 -1
  19. package/lib/download/core/downloadFigure.d.ts.map +1 -1
  20. package/lib/download/core/downloadFigure.js +21 -0
  21. package/lib/download/core/downloadFigure.js.map +1 -1
  22. package/lib/download/core/figureDpi.d.ts +59 -0
  23. package/lib/download/core/figureDpi.d.ts.map +1 -0
  24. package/lib/download/core/figureDpi.js +75 -0
  25. package/lib/download/core/figureDpi.js.map +1 -0
  26. package/lib/download/core/figurePng.d.ts +4 -1
  27. package/lib/download/core/figurePng.d.ts.map +1 -1
  28. package/lib/download/core/figurePng.js +11 -2
  29. package/lib/download/core/figurePng.js.map +1 -1
  30. package/lib/download/core/index.d.ts +4 -1
  31. package/lib/download/core/index.d.ts.map +1 -1
  32. package/lib/download/core/index.js +3 -1
  33. package/lib/download/core/index.js.map +1 -1
  34. package/lib/download/core/pngDpi.d.ts +22 -0
  35. package/lib/download/core/pngDpi.d.ts.map +1 -0
  36. package/lib/download/core/pngDpi.js +79 -0
  37. package/lib/download/core/pngDpi.js.map +1 -0
  38. package/lib/download/ui/FigureDownloadPanel.d.ts +13 -0
  39. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  40. package/lib/download/ui/FigureDownloadPanel.js +18 -34
  41. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  42. package/lib/download/ui/figureDownloadHint.d.ts +5 -0
  43. package/lib/download/ui/figureDownloadHint.d.ts.map +1 -1
  44. package/lib/download/ui/figureDownloadHint.js +8 -0
  45. package/lib/download/ui/figureDownloadHint.js.map +1 -1
  46. package/lib/download/ui/figureDownloadOptions.d.ts +84 -0
  47. package/lib/download/ui/figureDownloadOptions.d.ts.map +1 -0
  48. package/lib/download/ui/figureDownloadOptions.js +2 -0
  49. package/lib/download/ui/figureDownloadOptions.js.map +1 -0
  50. package/lib/download/ui/resolutionChoices.d.ts +27 -0
  51. package/lib/download/ui/resolutionChoices.d.ts.map +1 -0
  52. package/lib/download/ui/resolutionChoices.js +48 -0
  53. package/lib/download/ui/resolutionChoices.js.map +1 -0
  54. package/lib/download/ui/useFigureActions.d.ts +4 -1
  55. package/lib/download/ui/useFigureActions.d.ts.map +1 -1
  56. package/lib/download/ui/useFigureActions.js +17 -8
  57. package/lib/download/ui/useFigureActions.js.map +1 -1
  58. package/lib/download/ui/useFigureDownload.d.ts +2 -55
  59. package/lib/download/ui/useFigureDownload.d.ts.map +1 -1
  60. package/lib/download/ui/useFigureDownload.js +45 -13
  61. package/lib/download/ui/useFigureDownload.js.map +1 -1
  62. package/lib/ecosystem/core/sites.d.ts.map +1 -1
  63. package/lib/ecosystem/core/sites.js +14 -0
  64. package/lib/ecosystem/core/sites.js.map +1 -1
  65. package/lib/ecosystem/core/types.d.ts +1 -1
  66. package/lib/ecosystem/core/types.d.ts.map +1 -1
  67. package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
  68. package/lib/ecosystem/ui/glyphs.js +3 -0
  69. package/lib/ecosystem/ui/glyphs.js.map +1 -1
  70. package/lib/host/core/connectHost.js +1 -1
  71. package/lib/host/core/connectHost.js.map +1 -1
  72. package/lib/host/core/connectTool.d.ts +103 -0
  73. package/lib/host/core/connectTool.d.ts.map +1 -0
  74. package/lib/host/core/connectTool.js +169 -0
  75. package/lib/host/core/connectTool.js.map +1 -0
  76. package/lib/host/core/hostOutputs.d.ts +16 -3
  77. package/lib/host/core/hostOutputs.d.ts.map +1 -1
  78. package/lib/host/core/hostOutputs.js +38 -4
  79. package/lib/host/core/hostOutputs.js.map +1 -1
  80. package/lib/host/core/index.d.ts +8 -2
  81. package/lib/host/core/index.d.ts.map +1 -1
  82. package/lib/host/core/index.js +4 -1
  83. package/lib/host/core/index.js.map +1 -1
  84. package/lib/host/core/kinds.d.ts +31 -3
  85. package/lib/host/core/kinds.d.ts.map +1 -1
  86. package/lib/host/core/kinds.js +35 -4
  87. package/lib/host/core/kinds.js.map +1 -1
  88. package/lib/host/core/messageValues.d.ts +29 -0
  89. package/lib/host/core/messageValues.d.ts.map +1 -0
  90. package/lib/host/core/messageValues.js +57 -0
  91. package/lib/host/core/messageValues.js.map +1 -0
  92. package/lib/host/core/protocol.d.ts +2 -5
  93. package/lib/host/core/protocol.d.ts.map +1 -1
  94. package/lib/host/core/protocol.js +3 -37
  95. package/lib/host/core/protocol.js.map +1 -1
  96. package/lib/host/core/resultKinds.d.ts +74 -0
  97. package/lib/host/core/resultKinds.d.ts.map +1 -0
  98. package/lib/host/core/resultKinds.js +40 -0
  99. package/lib/host/core/resultKinds.js.map +1 -0
  100. package/lib/host/core/toolMessages.d.ts +24 -0
  101. package/lib/host/core/toolMessages.d.ts.map +1 -0
  102. package/lib/host/core/toolMessages.js +136 -0
  103. package/lib/host/core/toolMessages.js.map +1 -0
  104. package/lib/host/ui/index.d.ts +2 -0
  105. package/lib/host/ui/index.d.ts.map +1 -1
  106. package/lib/host/ui/index.js +1 -0
  107. package/lib/host/ui/index.js.map +1 -1
  108. package/lib/host/ui/useFramedTool.d.ts +74 -0
  109. package/lib/host/ui/useFramedTool.d.ts.map +1 -0
  110. package/lib/host/ui/useFramedTool.js +125 -0
  111. package/lib/host/ui/useFramedTool.js.map +1 -0
  112. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  113. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  114. package/lib/locales/de.json +30 -1
  115. package/lib/locales/en.json +30 -1
  116. package/lib/locales/es.json +30 -1
  117. package/lib/locales/fr.json +30 -1
  118. package/lib/locales/it.json +30 -1
  119. package/lib/molecule3d/ui/Molecule3DStage.d.ts +4 -33
  120. package/lib/molecule3d/ui/Molecule3DStage.d.ts.map +1 -1
  121. package/lib/molecule3d/ui/Molecule3DStage.js +3 -37
  122. package/lib/molecule3d/ui/Molecule3DStage.js.map +1 -1
  123. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  124. package/lib/molecule3d/ui/MoleculeCanvas3D.js +10 -2
  125. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  126. package/lib/molecule3d/ui/exportMoleculeImage.d.ts +10 -0
  127. package/lib/molecule3d/ui/exportMoleculeImage.d.ts.map +1 -1
  128. package/lib/molecule3d/ui/exportMoleculeImage.js +17 -0
  129. package/lib/molecule3d/ui/exportMoleculeImage.js.map +1 -1
  130. package/lib/molecule3d/ui/index.d.ts +1 -1
  131. package/lib/molecule3d/ui/index.d.ts.map +1 -1
  132. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts +23 -0
  133. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts.map +1 -1
  134. package/lib/molecule3d/ui/useImageExport.d.ts +3 -0
  135. package/lib/molecule3d/ui/useImageExport.d.ts.map +1 -1
  136. package/lib/molecule3d/ui/useImageExport.js +21 -3
  137. package/lib/molecule3d/ui/useImageExport.js.map +1 -1
  138. package/lib/osiris/core/barGeometry.d.ts +42 -0
  139. package/lib/osiris/core/barGeometry.d.ts.map +1 -0
  140. package/lib/osiris/core/barGeometry.js +46 -0
  141. package/lib/osiris/core/barGeometry.js.map +1 -0
  142. package/lib/osiris/core/computeProperties.d.ts +42 -0
  143. package/lib/osiris/core/computeProperties.d.ts.map +1 -0
  144. package/lib/osiris/core/computeProperties.js +115 -0
  145. package/lib/osiris/core/computeProperties.js.map +1 -0
  146. package/lib/osiris/core/constants.d.ts +70 -0
  147. package/lib/osiris/core/constants.d.ts.map +1 -0
  148. package/lib/osiris/core/constants.js +99 -0
  149. package/lib/osiris/core/constants.js.map +1 -0
  150. package/lib/osiris/core/fitness.d.ts +32 -0
  151. package/lib/osiris/core/fitness.d.ts.map +1 -0
  152. package/lib/osiris/core/fitness.js +48 -0
  153. package/lib/osiris/core/fitness.js.map +1 -0
  154. package/lib/osiris/core/index.d.ts +29 -0
  155. package/lib/osiris/core/index.d.ts.map +1 -0
  156. package/lib/osiris/core/index.js +19 -0
  157. package/lib/osiris/core/index.js.map +1 -0
  158. package/lib/osiris/core/poolSize.d.ts +17 -0
  159. package/lib/osiris/core/poolSize.d.ts.map +1 -0
  160. package/lib/osiris/core/poolSize.js +22 -0
  161. package/lib/osiris/core/poolSize.js.map +1 -0
  162. package/lib/osiris/core/poolTypes.d.ts +140 -0
  163. package/lib/osiris/core/poolTypes.d.ts.map +1 -0
  164. package/lib/osiris/core/poolTypes.js +12 -0
  165. package/lib/osiris/core/poolTypes.js.map +1 -0
  166. package/lib/osiris/core/predictIdCode.d.ts +39 -0
  167. package/lib/osiris/core/predictIdCode.d.ts.map +1 -0
  168. package/lib/osiris/core/predictIdCode.js +54 -0
  169. package/lib/osiris/core/predictIdCode.js.map +1 -0
  170. package/lib/osiris/core/predictProtocol.d.ts +67 -0
  171. package/lib/osiris/core/predictProtocol.d.ts.map +1 -0
  172. package/lib/osiris/core/predictProtocol.js +29 -0
  173. package/lib/osiris/core/predictProtocol.js.map +1 -0
  174. package/lib/osiris/core/predictionPool.d.ts +23 -0
  175. package/lib/osiris/core/predictionPool.d.ts.map +1 -0
  176. package/lib/osiris/core/predictionPool.js +186 -0
  177. package/lib/osiris/core/predictionPool.js.map +1 -0
  178. package/lib/osiris/core/predictionQueue.d.ts +46 -0
  179. package/lib/osiris/core/predictionQueue.d.ts.map +1 -0
  180. package/lib/osiris/core/predictionQueue.js +57 -0
  181. package/lib/osiris/core/predictionQueue.js.map +1 -0
  182. package/lib/osiris/core/predictors.d.ts +62 -0
  183. package/lib/osiris/core/predictors.d.ts.map +1 -0
  184. package/lib/osiris/core/predictors.js +100 -0
  185. package/lib/osiris/core/predictors.js.map +1 -0
  186. package/lib/osiris/core/propertyKeys.d.ts +32 -0
  187. package/lib/osiris/core/propertyKeys.d.ts.map +1 -0
  188. package/lib/osiris/core/propertyKeys.js +44 -0
  189. package/lib/osiris/core/propertyKeys.js.map +1 -0
  190. package/lib/osiris/core/riskAppearance.d.ts +60 -0
  191. package/lib/osiris/core/riskAppearance.d.ts.map +1 -0
  192. package/lib/osiris/core/riskAppearance.js +59 -0
  193. package/lib/osiris/core/riskAppearance.js.map +1 -0
  194. package/lib/osiris/core/riskDetail.d.ts +22 -0
  195. package/lib/osiris/core/riskDetail.d.ts.map +1 -0
  196. package/lib/osiris/core/riskDetail.js +86 -0
  197. package/lib/osiris/core/riskDetail.js.map +1 -0
  198. package/lib/osiris/core/riskDetailRequest.d.ts +31 -0
  199. package/lib/osiris/core/riskDetailRequest.d.ts.map +1 -0
  200. package/lib/osiris/core/riskDetailRequest.js +49 -0
  201. package/lib/osiris/core/riskDetailRequest.js.map +1 -0
  202. package/lib/osiris/core/riskFindings.d.ts +26 -0
  203. package/lib/osiris/core/riskFindings.d.ts.map +1 -0
  204. package/lib/osiris/core/riskFindings.js +79 -0
  205. package/lib/osiris/core/riskFindings.js.map +1 -0
  206. package/lib/osiris/core/runPredictionJob.d.ts +20 -0
  207. package/lib/osiris/core/runPredictionJob.d.ts.map +1 -0
  208. package/lib/osiris/core/runPredictionJob.js +43 -0
  209. package/lib/osiris/core/runPredictionJob.js.map +1 -0
  210. package/lib/osiris/core/scales.d.ts +70 -0
  211. package/lib/osiris/core/scales.d.ts.map +1 -0
  212. package/lib/osiris/core/scales.js +185 -0
  213. package/lib/osiris/core/scales.js.map +1 -0
  214. package/lib/osiris/core/types.d.ts +91 -0
  215. package/lib/osiris/core/types.d.ts.map +1 -0
  216. package/lib/osiris/core/types.js +19 -0
  217. package/lib/osiris/core/types.js.map +1 -0
  218. package/lib/osiris/core/valuation.d.ts +28 -0
  219. package/lib/osiris/core/valuation.d.ts.map +1 -0
  220. package/lib/osiris/core/valuation.js +39 -0
  221. package/lib/osiris/core/valuation.js.map +1 -0
  222. package/lib/osiris/ui/PropertyBar.d.ts +27 -0
  223. package/lib/osiris/ui/PropertyBar.d.ts.map +1 -0
  224. package/lib/osiris/ui/PropertyBar.js +27 -0
  225. package/lib/osiris/ui/PropertyBar.js.map +1 -0
  226. package/lib/osiris/ui/PropertyPanel.d.ts +91 -0
  227. package/lib/osiris/ui/PropertyPanel.d.ts.map +1 -0
  228. package/lib/osiris/ui/PropertyPanel.js +77 -0
  229. package/lib/osiris/ui/PropertyPanel.js.map +1 -0
  230. package/lib/osiris/ui/PropertyRows.d.ts +40 -0
  231. package/lib/osiris/ui/PropertyRows.d.ts.map +1 -0
  232. package/lib/osiris/ui/PropertyRows.js +23 -0
  233. package/lib/osiris/ui/PropertyRows.js.map +1 -0
  234. package/lib/osiris/ui/RiskFindings.d.ts +43 -0
  235. package/lib/osiris/ui/RiskFindings.d.ts.map +1 -0
  236. package/lib/osiris/ui/RiskFindings.js +51 -0
  237. package/lib/osiris/ui/RiskFindings.js.map +1 -0
  238. package/lib/osiris/ui/RiskPanel.d.ts +46 -0
  239. package/lib/osiris/ui/RiskPanel.d.ts.map +1 -0
  240. package/lib/osiris/ui/RiskPanel.js +32 -0
  241. package/lib/osiris/ui/RiskPanel.js.map +1 -0
  242. package/lib/osiris/ui/RiskSquare.d.ts +51 -0
  243. package/lib/osiris/ui/RiskSquare.d.ts.map +1 -0
  244. package/lib/osiris/ui/RiskSquare.js +23 -0
  245. package/lib/osiris/ui/RiskSquare.js.map +1 -0
  246. package/lib/osiris/ui/index.d.ts +15 -0
  247. package/lib/osiris/ui/index.d.ts.map +1 -0
  248. package/lib/osiris/ui/index.js +8 -0
  249. package/lib/osiris/ui/index.js.map +1 -0
  250. package/lib/osiris/ui/usePredictions.d.ts +81 -0
  251. package/lib/osiris/ui/usePredictions.d.ts.map +1 -0
  252. package/lib/osiris/ui/usePredictions.js +102 -0
  253. package/lib/osiris/ui/usePredictions.js.map +1 -0
  254. package/lib/osiris-ui.d.ts +11 -0
  255. package/lib/osiris-ui.d.ts.map +1 -0
  256. package/lib/osiris-ui.js +11 -0
  257. package/lib/osiris-ui.js.map +1 -0
  258. package/lib/osiris.d.ts +17 -0
  259. package/lib/osiris.d.ts.map +1 -0
  260. package/lib/osiris.js +17 -0
  261. package/lib/osiris.js.map +1 -0
  262. package/lib/panel/ui/FilterInput.d.ts.map +1 -1
  263. package/lib/panel/ui/FilterInput.js +3 -1
  264. package/lib/panel/ui/FilterInput.js.map +1 -1
  265. package/lib/panel/ui/SidePanelItem.d.ts +39 -0
  266. package/lib/panel/ui/SidePanelItem.d.ts.map +1 -0
  267. package/lib/panel/ui/SidePanelItem.js +63 -0
  268. package/lib/panel/ui/SidePanelItem.js.map +1 -0
  269. package/lib/panel/ui/SidePanelStack.d.ts +11 -10
  270. package/lib/panel/ui/SidePanelStack.d.ts.map +1 -1
  271. package/lib/panel/ui/SidePanelStack.js +22 -15
  272. package/lib/panel/ui/SidePanelStack.js.map +1 -1
  273. package/lib/panel/ui/SpectrumColorSwatch.d.ts.map +1 -1
  274. package/lib/panel/ui/SpectrumColorSwatch.js +4 -2
  275. package/lib/panel/ui/SpectrumColorSwatch.js.map +1 -1
  276. package/lib/panel/ui/usePanelFolds.d.ts +35 -0
  277. package/lib/panel/ui/usePanelFolds.d.ts.map +1 -0
  278. package/lib/panel/ui/usePanelFolds.js +73 -0
  279. package/lib/panel/ui/usePanelFolds.js.map +1 -0
  280. package/lib/shared/ui/FullscreenStage.d.ts +43 -0
  281. package/lib/shared/ui/FullscreenStage.d.ts.map +1 -0
  282. package/lib/shared/ui/FullscreenStage.js +38 -0
  283. package/lib/shared/ui/FullscreenStage.js.map +1 -0
  284. package/lib/shared/ui/canFillScreen.d.ts +7 -0
  285. package/lib/shared/ui/canFillScreen.d.ts.map +1 -0
  286. package/lib/shared/ui/canFillScreen.js +9 -0
  287. package/lib/shared/ui/canFillScreen.js.map +1 -0
  288. package/lib/shared/ui/index.d.ts +3 -0
  289. package/lib/shared/ui/index.d.ts.map +1 -1
  290. package/lib/shared/ui/index.js +2 -0
  291. package/lib/shared/ui/index.js.map +1 -1
  292. package/lib/split/ui/splitPanes.d.ts +3 -3
  293. package/lib/split/ui/splitPanes.js +1 -1
  294. package/lib/structure/core/structureNotations.d.ts +8 -1
  295. package/lib/structure/core/structureNotations.d.ts.map +1 -1
  296. package/lib/structure/core/structureNotations.js +14 -8
  297. package/lib/structure/core/structureNotations.js.map +1 -1
  298. package/lib/structure/ui/StructureExportPanel.d.ts +8 -0
  299. package/lib/structure/ui/StructureExportPanel.d.ts.map +1 -1
  300. package/lib/structure/ui/StructureExportPanel.js +9 -4
  301. package/lib/structure/ui/StructureExportPanel.js.map +1 -1
  302. package/lib/structure/ui/index.d.ts +1 -0
  303. package/lib/structure/ui/index.d.ts.map +1 -1
  304. package/lib/structure/ui/index.js.map +1 -1
  305. package/package.json +4 -1
  306. package/src/card/core/cardAddress.ts +39 -3
  307. package/src/card/core/cardPageUrl.ts +10 -3
  308. package/src/card/core/index.ts +7 -1
  309. package/src/credits/core/credits.ts +40 -0
  310. package/src/download/core/downloadFigure.ts +26 -1
  311. package/src/download/core/figureDpi.ts +94 -0
  312. package/src/download/core/figurePng.ts +11 -2
  313. package/src/download/core/index.ts +13 -1
  314. package/src/download/core/pngDpi.ts +84 -0
  315. package/src/download/ui/FigureDownloadPanel.tsx +41 -51
  316. package/src/download/ui/figureDownloadHint.ts +13 -0
  317. package/src/download/ui/figureDownloadOptions.ts +85 -0
  318. package/src/download/ui/resolutionChoices.ts +67 -0
  319. package/src/download/ui/useFigureActions.ts +24 -9
  320. package/src/download/ui/useFigureDownload.tsx +57 -71
  321. package/src/ecosystem/core/sites.ts +14 -0
  322. package/src/ecosystem/core/types.ts +2 -1
  323. package/src/ecosystem/ui/glyphs.tsx +20 -0
  324. package/src/host/core/connectHost.ts +1 -1
  325. package/src/host/core/connectTool.ts +285 -0
  326. package/src/host/core/hostOutputs.ts +47 -5
  327. package/src/host/core/index.ts +20 -1
  328. package/src/host/core/kinds.ts +53 -8
  329. package/src/host/core/messageValues.ts +58 -0
  330. package/src/host/core/protocol.ts +5 -37
  331. package/src/host/core/resultKinds.ts +65 -0
  332. package/src/host/core/toolMessages.ts +160 -0
  333. package/src/host/ui/index.ts +6 -0
  334. package/src/host/ui/useFramedTool.ts +213 -0
  335. package/src/locales/de.json +30 -1
  336. package/src/locales/en.json +30 -1
  337. package/src/locales/es.json +30 -1
  338. package/src/locales/fr.json +30 -1
  339. package/src/locales/it.json +30 -1
  340. package/src/molecule3d/ui/Molecule3DStage.tsx +4 -88
  341. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +10 -1
  342. package/src/molecule3d/ui/exportMoleculeImage.ts +22 -0
  343. package/src/molecule3d/ui/index.ts +4 -1
  344. package/src/molecule3d/ui/moleculeViewer3DProps.ts +24 -0
  345. package/src/molecule3d/ui/useImageExport.ts +28 -2
  346. package/src/osiris/core/barGeometry.ts +74 -0
  347. package/src/osiris/core/computeProperties.ts +175 -0
  348. package/src/osiris/core/constants.ts +110 -0
  349. package/src/osiris/core/fitness.ts +59 -0
  350. package/src/osiris/core/index.ts +78 -0
  351. package/src/osiris/core/poolSize.ts +24 -0
  352. package/src/osiris/core/poolTypes.ts +140 -0
  353. package/src/osiris/core/predictIdCode.ts +69 -0
  354. package/src/osiris/core/predictProtocol.ts +78 -0
  355. package/src/osiris/core/predictionPool.ts +237 -0
  356. package/src/osiris/core/predictionQueue.ts +89 -0
  357. package/src/osiris/core/predictors.ts +142 -0
  358. package/src/osiris/core/propertyKeys.ts +54 -0
  359. package/src/osiris/core/riskAppearance.ts +86 -0
  360. package/src/osiris/core/riskDetail.ts +120 -0
  361. package/src/osiris/core/riskDetailRequest.ts +64 -0
  362. package/src/osiris/core/riskFindings.ts +92 -0
  363. package/src/osiris/core/runPredictionJob.ts +49 -0
  364. package/src/osiris/core/scales.ts +236 -0
  365. package/src/osiris/core/types.ts +103 -0
  366. package/src/osiris/core/valuation.ts +44 -0
  367. package/src/osiris/ui/PropertyBar.tsx +77 -0
  368. package/src/osiris/ui/PropertyPanel.tsx +227 -0
  369. package/src/osiris/ui/PropertyRows.tsx +92 -0
  370. package/src/osiris/ui/RiskFindings.tsx +137 -0
  371. package/src/osiris/ui/RiskPanel.tsx +81 -0
  372. package/src/osiris/ui/RiskSquare.tsx +108 -0
  373. package/src/osiris/ui/index.ts +17 -0
  374. package/src/osiris/ui/usePredictions.ts +194 -0
  375. package/src/osiris-ui.ts +11 -0
  376. package/src/osiris.ts +17 -0
  377. package/src/panel/ui/FilterInput.tsx +4 -1
  378. package/src/panel/ui/SidePanelItem.tsx +162 -0
  379. package/src/panel/ui/SidePanelStack.tsx +29 -36
  380. package/src/panel/ui/SpectrumColorSwatch.tsx +5 -3
  381. package/src/panel/ui/usePanelFolds.ts +103 -0
  382. package/src/shared/ui/FullscreenStage.tsx +96 -0
  383. package/src/shared/ui/canFillScreen.ts +8 -0
  384. package/src/shared/ui/index.ts +6 -0
  385. package/src/split/ui/splitPanes.tsx +4 -4
  386. package/src/structure/core/structureNotations.ts +25 -8
  387. package/src/structure/ui/StructureExportPanel.tsx +23 -4
  388. package/src/structure/ui/index.ts +4 -0
  389. package/styles/osiris.css +339 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,YAAY,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,YAAY,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,YAAY,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,YAAY,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,YAAY,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,YAAY,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,YAAY,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,YAAY,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,YAAY,EACV,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structure/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAuB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA2B,CAAC;AAEhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA6B,CAAC;AAEpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA6B,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA6B,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structure/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAuB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA2B,CAAC;AAEhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA6B,CAAC;AAEpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA6B,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA6B,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AAOpD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cheminfo",
3
- "version": "0.76.0",
3
+ "version": "0.78.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",
@@ -27,6 +27,8 @@
27
27
  "./molecule3d": "./lib/molecule3d.js",
28
28
  "./molstar/*": "./lib/molstar/*/index.js",
29
29
  "./orbital": "./lib/orbital.js",
30
+ "./osiris": "./lib/osiris.js",
31
+ "./osiris-ui": "./lib/osiris-ui.js",
30
32
  "./pages": "./lib/pages.js",
31
33
  "./raman": "./lib/raman.js",
32
34
  "./server": "./lib/server.js",
@@ -78,6 +80,7 @@
78
80
  "cheminfo-font": "^1.28.0",
79
81
  "cheminfo-types": "^1.16.0",
80
82
  "convert-to-jcamp": "^7.0.1",
83
+ "crc-32": "^1.2.2",
81
84
  "intl-messageformat": "^11.2.15",
82
85
  "ir-spectrum": "^4.2.0",
83
86
  "jcampconverter": "^12.5.11",
@@ -18,6 +18,13 @@ import { EMBED_PARAM, HIDE_PARAM } from '../../share/core/config.ts';
18
18
  /** The parameter asking for the answer's card instead of the page. */
19
19
  export const CARD_PARAM = 'card';
20
20
 
21
+ /**
22
+ * The parameter naming what a precise question asked, e.g. `only=formula`:
23
+ * the card then draws what the answer is about and only those facts. Without
24
+ * it the card draws everything it would.
25
+ */
26
+ export const ONLY_PARAM = 'only';
27
+
21
28
  /**
22
29
  * Whether an address asks for a card.
23
30
  * @param search - The query string, with or without its leading `?`.
@@ -30,6 +37,29 @@ export function isCardAddress(search: string): boolean {
30
37
  return false;
31
38
  }
32
39
 
40
+ /**
41
+ * The facts a card's `only` names, among those the site's card can single
42
+ * out. A name the card does not know is ignored, so a link written before a
43
+ * fact was renamed still opens, on the facts it still names.
44
+ * @param value - The value of `only` as the query holds it, comma-separated;
45
+ * null or undefined when the address has none.
46
+ * @param known - Every fact the card can single out.
47
+ * @returns The facts named, each once, in the order written; empty when none
48
+ * is known, and the card then draws everything.
49
+ */
50
+ export function parseOnlyParam<Fact extends string>(
51
+ value: string | null | undefined,
52
+ known: readonly Fact[],
53
+ ): Fact[] {
54
+ const facts: Fact[] = [];
55
+ if (value == null) return facts;
56
+ for (const part of value.split(',')) {
57
+ const fact = known.find((candidate) => candidate === part.trim());
58
+ if (fact !== undefined && !facts.includes(fact)) facts.push(fact);
59
+ }
60
+ return facts;
61
+ }
62
+
33
63
  /**
34
64
  * The address a card is at: `globalThis.location`, a `URL`, or any record of
35
65
  * the three parts.
@@ -62,7 +92,7 @@ export interface SitePageOptions {
62
92
  /**
63
93
  * A parameter the page at a given path does not read, though another page
64
94
  * of the site does: a tutorial step reads no InChI, the converter does.
65
- * @default undefined - nothing beyond `card`, `embed`, `hide` and
95
+ * @default undefined - nothing beyond `card`, `only`, `embed`, `hide` and
66
96
  * `cardParams` is left out
67
97
  */
68
98
  isCardOnly?: (key: string, pathname: string) => boolean;
@@ -70,7 +100,7 @@ export interface SitePageOptions {
70
100
 
71
101
  /**
72
102
  * The site's own page a card stands for, with its chrome: the card's address
73
- * without `card`, `embed`, `hide` and what only the card reads. Every other
103
+ * without `card`, `only`, `embed`, `hide` and what only the card reads. Every other
74
104
  * parameter is kept exactly as it was written, so the `+` of a charged atom
75
105
  * stays a plus and the commas of a list stay commas. This is the address an
76
106
  * answer's `link` names, and the one the card's Details button opens.
@@ -84,7 +114,13 @@ export function sitePageUrl(
84
114
  options: SitePageOptions = {},
85
115
  ): string {
86
116
  const { cardParams = [], literalPlus = true, isCardOnly } = options;
87
- const dropped = new Set([CARD_PARAM, EMBED_PARAM, HIDE_PARAM, ...cardParams]);
117
+ const dropped = new Set([
118
+ CARD_PARAM,
119
+ ONLY_PARAM,
120
+ EMBED_PARAM,
121
+ HIDE_PARAM,
122
+ ...cardParams,
123
+ ]);
88
124
  const kept: string[] = [];
89
125
  const search = location.search.startsWith('?')
90
126
  ? location.search.slice(1)
@@ -9,7 +9,7 @@ import type { QueryEntry } from '../../router/core/query.ts';
9
9
  import { formatQueryEntries } from '../../router/core/query.ts';
10
10
  import { EMBED_PARAM, HIDE_PARAM } from '../../share/core/config.ts';
11
11
 
12
- import { CARD_PARAM } from './cardAddress.ts';
12
+ import { CARD_PARAM, ONLY_PARAM } from './cardAddress.ts';
13
13
 
14
14
  /** How {@link framedPageUrl} frames a page. */
15
15
  export interface FramedPageOptions {
@@ -30,7 +30,13 @@ export interface CardPageOptions extends FramedPageOptions {
30
30
  */
31
31
  card?: string;
32
32
  /**
33
- * What only the card reads, written after `card` in the order given, e.g.
33
+ * The facts a precise question asked, written `only=formula,mass` after
34
+ * `card`: the card draws what the answer is about and only those.
35
+ * @default [] - the card draws everything
36
+ */
37
+ only?: readonly string[];
38
+ /**
39
+ * What only the card reads, written after `card` and `only` in the order given, e.g.
34
40
  * `{ rows: '10' }`. A value left `undefined` or empty is not written.
35
41
  * @default {}
36
42
  */
@@ -67,8 +73,9 @@ export function cardPageUrl(
67
73
  page: string,
68
74
  options: CardPageOptions = {},
69
75
  ): string {
70
- const { card = '1', extra = {} } = options;
76
+ const { card = '1', only = [], extra = {} } = options;
71
77
  const entries: QueryEntry[] = [[CARD_PARAM, card]];
78
+ if (only.length > 0) entries.push([ONLY_PARAM, only.join(',')]);
72
79
  for (const [key, value] of Object.entries(extra)) {
73
80
  if (value !== undefined && value !== '') entries.push([key, value]);
74
81
  }
@@ -1,5 +1,11 @@
1
1
  export type { CardLocation, SitePageOptions } from './cardAddress.ts';
2
- export { CARD_PARAM, isCardAddress, sitePageUrl } from './cardAddress.ts';
2
+ export {
3
+ CARD_PARAM,
4
+ ONLY_PARAM,
5
+ isCardAddress,
6
+ parseOnlyParam,
7
+ sitePageUrl,
8
+ } from './cardAddress.ts';
3
9
  export type { CardPageOptions, FramedPageOptions } from './cardPageUrl.ts';
4
10
  export { cardPageUrl, framedPageUrl } from './cardPageUrl.ts';
5
11
  export type { OpenPanel } from './panelRoom.ts';
@@ -84,6 +84,46 @@ export const CREDITS = [
84
84
  description: 'the substructure and similarity search, inside SQLite.',
85
85
  license: 'MIT',
86
86
  },
87
+ {
88
+ id: 'openchemlib-search-wasm',
89
+ name: 'openchemlib-search-wasm',
90
+ href: 'https://github.com/cheminfo/openchemlib-search-wasm',
91
+ description:
92
+ 'the functional-group keys of every structure, and the dictionary that names them.',
93
+ license: 'BSD-3-Clause',
94
+ },
95
+ {
96
+ id: 'chemcaption',
97
+ name: 'ChemCaption',
98
+ href: 'https://github.com/lamalab-org/chem-caption',
99
+ description:
100
+ 'definitions of functional groups, adapted in the function-key dictionary.',
101
+ license: 'MIT',
102
+ },
103
+ {
104
+ id: 'accfg',
105
+ name: 'AccFG',
106
+ href: 'https://github.com/xuanliugit/AccFG',
107
+ description:
108
+ 'definitions of functional groups, adapted in the function-key dictionary.',
109
+ license: 'MIT',
110
+ },
111
+ {
112
+ id: 'medchem',
113
+ name: 'medchem',
114
+ href: 'https://github.com/datamol-io/medchem',
115
+ description:
116
+ 'definitions of functional groups, adapted in the function-key dictionary.',
117
+ license: 'Apache-2.0',
118
+ },
119
+ {
120
+ id: 'rdkit',
121
+ name: 'RDKit',
122
+ href: 'https://github.com/rdkit/rdkit',
123
+ description:
124
+ 'definitions of functional groups, and the reference every key was checked against.',
125
+ license: 'BSD-3-Clause',
126
+ },
87
127
  {
88
128
  id: 'osiris-property-explorer',
89
129
  name: 'OSIRIS Property Explorer',
@@ -11,7 +11,7 @@
11
11
  import { downloadBlob } from './downloadBlob.ts';
12
12
  import { figurePng } from './figurePng.ts';
13
13
  import { defaultFigureScale } from './figureScale.ts';
14
- import type { FigureSvgOptions } from './figureSvg.ts';
14
+ import type { FigureSvg, FigureSvgOptions } from './figureSvg.ts';
15
15
  import { FIGURE_SVG_TYPE, figureSvg } from './figureSvg.ts';
16
16
  import { sanitizeFileName } from './sanitizeFileName.ts';
17
17
 
@@ -67,3 +67,28 @@ export async function downloadFigure(
67
67
  const figure = figureSvg(target, { background });
68
68
  downloadBlob(await figurePng(figure, scale), `${name}.png`);
69
69
  }
70
+
71
+ /**
72
+ * Save a figure its page wrote as an SVG document itself, rather than one
73
+ * copied off the page: a drawing whose file carries more than its picture.
74
+ * The SVG is saved as written, at the size it states; the PNG is painted from
75
+ * it at the multiple asked for.
76
+ * @param figure - The document, and its size in pixels of the page.
77
+ * @param options - Which file, at what multiple, and its name; a background
78
+ * is the document's own business.
79
+ * @throws {Error} When the browser cannot paint it.
80
+ */
81
+ export async function downloadFigureSvg(
82
+ figure: FigureSvg,
83
+ options: Omit<DownloadFigureOptions, 'background'> = {},
84
+ ): Promise<void> {
85
+ const { format = 'png', fileName = DEFAULT_FILE_NAME } = options;
86
+ const name = sanitizeFileName(fileName, DEFAULT_FILE_NAME);
87
+ if (format === 'svg') {
88
+ const blob = new Blob([figure.markup], { type: FIGURE_SVG_TYPE });
89
+ downloadBlob(blob, `${name}.svg`);
90
+ return;
91
+ }
92
+ const scale = options.scale ?? defaultFigureScale(format);
93
+ downloadBlob(await figurePng(figure, scale), `${name}.png`);
94
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * A figure's resolution stated in dots per inch.
3
+ *
4
+ * A pixel of the page is a ninety-sixth of an inch, by the definition of CSS,
5
+ * so every figure on screen already has a printed size, and the multiple it is
6
+ * painted at is a resolution in another unit: 1× is 96 dpi. A figure whose size
7
+ * on the page is the size it prints at — a structure drawn to a journal's bond
8
+ * length — is offered its resolution in dots per inch, which is what a journal
9
+ * asks for; any other figure is offered multiples of what the reader sees.
10
+ */
11
+
12
+ import type { FigurePixels } from './figureScale.ts';
13
+ import { figureScaleLabel } from './figureScale.ts';
14
+
15
+ /** How the resolution of a figure is offered. */
16
+ export type FigureResolutionUnit = 'multiple' | 'dpi';
17
+
18
+ /** How many pixels of the page make an inch. */
19
+ export const CSS_PIXELS_PER_INCH = 96;
20
+
21
+ /**
22
+ * The dots per inch offered: a slide, a journal's halftone, its combination
23
+ * art, and its line art.
24
+ */
25
+ export const FIGURE_DPIS: readonly number[] = [150, 300, 600, 1200];
26
+
27
+ /** The dots per inch a figure with a printed size is saved at by default. */
28
+ export const DEFAULT_FIGURE_DPI = 300;
29
+
30
+ /** Centimetres in an inch. */
31
+ const CENTIMETRES_PER_INCH = 2.54;
32
+
33
+ /**
34
+ * The multiple a figure is painted at to reach this many dots per inch.
35
+ * @param dpi - Dots per inch.
36
+ * @returns The multiple of its size on the page.
37
+ */
38
+ export function dpiScale(dpi: number): number {
39
+ return dpi / CSS_PIXELS_PER_INCH;
40
+ }
41
+
42
+ /**
43
+ * The dots per inch a figure painted at this multiple has, when it is printed
44
+ * at its size on the page.
45
+ * @param scale - The multiple of its size on the page.
46
+ * @returns Whole dots per inch.
47
+ */
48
+ export function figureDpi(scale: number): number {
49
+ return Math.round(scale * CSS_PIXELS_PER_INCH);
50
+ }
51
+
52
+ /**
53
+ * The size a figure prints at.
54
+ * @param size - Its size on the page, in pixels.
55
+ * @returns Its width and height in centimetres.
56
+ */
57
+ export function figureCentimetres(size: FigurePixels): FigurePixels {
58
+ const factor = CENTIMETRES_PER_INCH / CSS_PIXELS_PER_INCH;
59
+ return { width: size.width * factor, height: size.height * factor };
60
+ }
61
+
62
+ /**
63
+ * The size a figure prints at, written out to a tenth of a centimetre.
64
+ * @param size - Its size on the page, in pixels.
65
+ * @param language - The language the numbers are written in.
66
+ * @returns Its width and height in centimetres, as text: `8.5` or `8,5`.
67
+ */
68
+ export function formatFigureCentimetres(
69
+ size: FigurePixels,
70
+ language: string,
71
+ ): { width: string; height: string } {
72
+ const printed = figureCentimetres(size);
73
+ const format = new Intl.NumberFormat(language, {
74
+ minimumFractionDigits: 1,
75
+ maximumFractionDigits: 1,
76
+ });
77
+ return {
78
+ width: format.format(printed.width),
79
+ height: format.format(printed.height),
80
+ };
81
+ }
82
+
83
+ /**
84
+ * What a resolution reads on a button: `2×`, or `300 dpi`.
85
+ * @param scale - The multiple of the figure's size on the page.
86
+ * @param unit - How the resolution is offered.
87
+ * @returns Its label.
88
+ */
89
+ export function figureResolutionLabel(
90
+ scale: number,
91
+ unit: FigureResolutionUnit,
92
+ ): string {
93
+ return unit === 'dpi' ? `${figureDpi(scale)} dpi` : figureScaleLabel(scale);
94
+ }
@@ -6,11 +6,16 @@
6
6
  * the figure that was read, and two drawing paths are two things to keep in
7
7
  * step. Scaling is the browser's own, so a figure saved at three times is
8
8
  * genuinely three times the detail rather than a stretched screenshot.
9
+ *
10
+ * The file states its resolution, so a document places it at the size the
11
+ * figure has on the page rather than at one pixel per point.
9
12
  */
10
13
 
14
+ import { figureDpi } from './figureDpi.ts';
11
15
  import { DEFAULT_FIGURE_SCALE, figurePixels } from './figureScale.ts';
12
16
  import type { FigureSvg } from './figureSvg.ts';
13
17
  import { FIGURE_SVG_TYPE } from './figureSvg.ts';
18
+ import { withPngDpi } from './pngDpi.ts';
14
19
 
15
20
  /** What a saved raster figure is. */
16
21
  export const FIGURE_PNG_TYPE = 'image/png';
@@ -19,7 +24,7 @@ export const FIGURE_PNG_TYPE = 'image/png';
19
24
  * The figure as a PNG.
20
25
  * @param figure - The figure, already copied off the page.
21
26
  * @param scale - How many pixels are painted per pixel on screen.
22
- * @returns The image.
27
+ * @returns The image, stating `96 × scale` dots per inch.
23
28
  * @throws {Error} When the browser cannot paint or encode it.
24
29
  */
25
30
  export async function figurePng(
@@ -38,7 +43,11 @@ export async function figurePng(
38
43
  }
39
44
  context.drawImage(drawing, 0, 0, pixels.width, pixels.height);
40
45
 
41
- return encode(canvas);
46
+ const encoded = await encode(canvas);
47
+ const png = new Uint8Array(await encoded.arrayBuffer());
48
+ return new Blob([withPngDpi(png, figureDpi(scale))], {
49
+ type: FIGURE_PNG_TYPE,
50
+ });
42
51
  }
43
52
 
44
53
  /**
@@ -4,8 +4,19 @@ export { copySvg } from './copySvg.ts';
4
4
  export { cssTokenNames, resolveCssTokens } from './cssTokens.ts';
5
5
  export { downloadBlob } from './downloadBlob.ts';
6
6
  export type { DownloadFigureOptions, FigureFormat } from './downloadFigure.ts';
7
- export { downloadFigure } from './downloadFigure.ts';
7
+ export { downloadFigure, downloadFigureSvg } from './downloadFigure.ts';
8
8
  export { downloadText } from './downloadText.ts';
9
+ export type { FigureResolutionUnit } from './figureDpi.ts';
10
+ export {
11
+ CSS_PIXELS_PER_INCH,
12
+ DEFAULT_FIGURE_DPI,
13
+ FIGURE_DPIS,
14
+ dpiScale,
15
+ figureCentimetres,
16
+ figureDpi,
17
+ figureResolutionLabel,
18
+ formatFigureCentimetres,
19
+ } from './figureDpi.ts';
9
20
  export type { FigureLayout } from './figureLayout.ts';
10
21
  export {
11
22
  FIGURE_COLUMN_WIDTH,
@@ -53,6 +64,7 @@ export {
53
64
  figurePaintings,
54
65
  figureSize,
55
66
  } from './figureTarget.ts';
67
+ export { pngDpi, withPngDpi } from './pngDpi.ts';
56
68
  export { sanitizeFileName } from './sanitizeFileName.ts';
57
69
 
58
70
  export { drawingIn, stackDrawings } from './stackedDrawing.ts';
@@ -0,0 +1,84 @@
1
+ /**
2
+ * The resolution a PNG states, in its `pHYs` chunk.
3
+ *
4
+ * A browser writes none, and a word processor or a slide then places the
5
+ * picture as if it were 72 or 96 dpi — a figure painted for print arrives
6
+ * several times too large. Stated, it arrives at the size it was drawn.
7
+ */
8
+
9
+ import CRC32 from 'crc-32';
10
+
11
+ const SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
12
+
13
+ /** Metres in an inch: `pHYs` counts pixels per metre. */
14
+ const METRES_PER_INCH = 0.0254;
15
+
16
+ /**
17
+ * A PNG stating a resolution, any resolution it stated before dropped.
18
+ * @param png - The PNG file's bytes.
19
+ * @param dpi - Dots per inch.
20
+ * @returns A new PNG file.
21
+ * @throws {Error} When the bytes are not a PNG.
22
+ */
23
+ export function withPngDpi(
24
+ png: Uint8Array,
25
+ dpi: number,
26
+ ): Uint8Array<ArrayBuffer> {
27
+ for (let index = 0; index < SIGNATURE.length; index++) {
28
+ if (png[index] !== SIGNATURE[index]) throw new Error('Not a PNG file.');
29
+ }
30
+ const view = new DataView(png.buffer, png.byteOffset, png.byteLength);
31
+ const chunks: Uint8Array[] = [png.subarray(0, SIGNATURE.length)];
32
+ let offset = SIGNATURE.length;
33
+ while (offset + 8 <= png.length) {
34
+ const end = offset + 12 + view.getUint32(offset);
35
+ const type = chunkType(png, offset);
36
+ if (type !== 'pHYs') chunks.push(png.subarray(offset, end));
37
+ if (type === 'IHDR') chunks.push(physChunk(dpi));
38
+ offset = end;
39
+ }
40
+ let total = 0;
41
+ for (const chunk of chunks) total += chunk.length;
42
+ const result = new Uint8Array(total);
43
+ let position = 0;
44
+ for (const chunk of chunks) {
45
+ result.set(chunk, position);
46
+ position += chunk.length;
47
+ }
48
+ return result;
49
+ }
50
+
51
+ /**
52
+ * The resolution a PNG states.
53
+ * @param png - The PNG file's bytes.
54
+ * @returns Whole dots per inch, or `undefined` when it states none.
55
+ */
56
+ export function pngDpi(png: Uint8Array): number | undefined {
57
+ const view = new DataView(png.buffer, png.byteOffset, png.byteLength);
58
+ let offset = SIGNATURE.length;
59
+ while (offset + 8 <= png.length) {
60
+ if (chunkType(png, offset) === 'pHYs' && png[offset + 16] === 1) {
61
+ return Math.round(view.getUint32(offset + 8) * METRES_PER_INCH);
62
+ }
63
+ offset += 12 + view.getUint32(offset);
64
+ }
65
+ return undefined;
66
+ }
67
+
68
+ function chunkType(png: Uint8Array, offset: number): string {
69
+ return String.fromCodePoint(...png.subarray(offset + 4, offset + 8));
70
+ }
71
+
72
+ function physChunk(dpi: number): Uint8Array {
73
+ const chunk = new Uint8Array(21);
74
+ const view = new DataView(chunk.buffer);
75
+ view.setUint32(0, 9);
76
+ chunk.set([0x70, 0x48, 0x59, 0x73], 4);
77
+ const perMetre = Math.round(dpi / METRES_PER_INCH);
78
+ view.setUint32(8, perMetre);
79
+ view.setUint32(12, perMetre);
80
+ // The unit: 1 is the metre, 0 an aspect ratio with no size.
81
+ chunk[16] = 1;
82
+ view.setInt32(17, CRC32.buf(chunk.subarray(4, 17)));
83
+ return chunk;
84
+ }
@@ -1,5 +1,6 @@
1
1
  import type { ReactElement, ReactNode } from 'react';
2
2
 
3
+ import { useLanguage } from '../../i18n/ui/useLanguage.ts';
3
4
  import { useChromeT } from '../../i18n/ui/useT.ts';
4
5
  import { OverlayAction } from '../../overlay/ui/OverlayAction.tsx';
5
6
  import { OverlayPanel } from '../../overlay/ui/OverlayPanel.tsx';
@@ -7,18 +8,14 @@ import type { OverlayOption } from '../../overlay/ui/OverlayRow.tsx';
7
8
  import { OverlaySegmented } from '../../overlay/ui/OverlaySegmented.tsx';
8
9
  import type { FigureNotice } from '../core/copyFigure.ts';
9
10
  import type { FigureFormat } from '../core/downloadFigure.ts';
11
+ import type { FigureResolutionUnit } from '../core/figureDpi.ts';
10
12
  import { figureLayoutSize } from '../core/figureLayout.ts';
11
13
  import type { FigurePixels } from '../core/figureScale.ts';
12
- import {
13
- figurePixels,
14
- figureScaleFits,
15
- figureScaleLabel,
16
- formatFigurePixels,
17
- } from '../core/figureScale.ts';
18
14
 
19
15
  import type { FigureSizing } from './FigureSizeRows.tsx';
20
16
  import { FigureSizeRows } from './FigureSizeRows.tsx';
21
17
  import { hintOf } from './figureDownloadHint.ts';
18
+ import { resolutionHelp, scaleChoices } from './resolutionChoices.ts';
22
19
 
23
20
  /** What {@link FigureDownloadPanel} is drawn from. */
24
21
  export interface FigureDownloadPanelProps {
@@ -30,6 +27,18 @@ export interface FigureDownloadPanelProps {
30
27
  scale: number;
31
28
  /** The multiples offered. */
32
29
  scales: readonly number[];
30
+ /**
31
+ * How the resolution reads: multiples of the figure on screen, or the dots
32
+ * per inch it has printed at its size on the page — 1× is 96 dpi.
33
+ * @default 'multiple'
34
+ */
35
+ unit?: FigureResolutionUnit;
36
+ /**
37
+ * Whether an SVG is saved at the size it states, whatever the resolution:
38
+ * the resolution then paints the PNG alone, and is not offered for the SVG.
39
+ * @default false
40
+ */
41
+ svgAtOwnSize?: boolean;
33
42
  /** How big the figure is on the page, or `null` where there is none. */
34
43
  size: FigurePixels | null;
35
44
  /** What went wrong the last time save was pressed, if anything. */
@@ -100,7 +109,9 @@ export function FigureDownloadPanel(
100
109
  const { title, format, scale, scales, size, failure, saving } = props;
101
110
  const { onFormatChange, onScaleChange, onSave, rasterSvg = false } = props;
102
111
  const { sizing, onCopy, notice = null, children } = props;
112
+ const { unit = 'multiple', svgAtOwnSize = false } = props;
103
113
  const t = useChromeT();
114
+ const language = useLanguage();
104
115
 
105
116
  // What the file is drawn at: the figure on screen, or the shape picked.
106
117
  const drawn =
@@ -109,13 +120,23 @@ export function FigureDownloadPanel(
109
120
  : figureLayoutSize(sizing.layout, size, sizing.custom ?? size);
110
121
 
111
122
  const painted = format === 'png' || rasterSvg;
123
+ const offerResolution = format === 'png' || !svgAtOwnSize;
112
124
 
113
125
  return (
114
126
  <OverlayPanel
115
127
  title={title}
116
- width={PANEL_WIDTH}
128
+ width={unit === 'dpi' ? DPI_PANEL_WIDTH : PANEL_WIDTH}
117
129
  hint={hintOf(
118
- { format, size: drawn, scale, failure, notice, rasterSvg },
130
+ {
131
+ format,
132
+ size: drawn,
133
+ scale,
134
+ failure,
135
+ notice,
136
+ rasterSvg,
137
+ unit,
138
+ language,
139
+ },
119
140
  t,
120
141
  )}
121
142
  actions={
@@ -152,20 +173,15 @@ export function FigureDownloadPanel(
152
173
  {sizing === undefined ? null : (
153
174
  <FigureSizeRows sizing={sizing} size={size} />
154
175
  )}
155
- <OverlaySegmented
156
- label={t('download.resolution')}
157
- help={{
158
- title: t('download.resolution'),
159
- body: t('download.resolutionHelp'),
160
- example: {
161
- code: '2×',
162
- note: t('download.resolutionExample'),
163
- },
164
- }}
165
- value={String(scale)}
166
- options={scaleChoices(scales, drawn, painted)}
167
- onChange={(picked) => onScaleChange(Number(picked))}
168
- />
176
+ {offerResolution ? (
177
+ <OverlaySegmented
178
+ label={t('download.resolution')}
179
+ help={resolutionHelp(unit, t)}
180
+ value={String(scale)}
181
+ options={scaleChoices(scales, drawn, painted, unit)}
182
+ onChange={(picked) => onScaleChange(Number(picked))}
183
+ />
184
+ ) : null}
169
185
  </OverlayPanel>
170
186
  );
171
187
  }
@@ -176,37 +192,11 @@ export function FigureDownloadPanel(
176
192
  */
177
193
  const PANEL_WIDTH = '27em';
178
194
 
195
+ /** Wide enough for the four dots per inch on one row, `1200 dpi` last. */
196
+ const DPI_PANEL_WIDTH = '33em';
197
+
179
198
  /** The two files a figure can leave the page as. */
180
199
  const FORMAT_CHOICES: ReadonlyArray<OverlayOption<FigureFormat>> = [
181
200
  { value: 'png', label: 'PNG' },
182
201
  { value: 'svg', label: 'SVG' },
183
202
  ];
184
-
185
- /**
186
- * The multiples offered, each saying what it would actually produce.
187
- *
188
- * One too large for the browser to paint is greyed rather than dropped, so the
189
- * reader learns the ceiling exists before they meet it as a blank file. An SVG
190
- * is not painted, so it has no such ceiling.
191
- * @param scales - The multiples the caller offers.
192
- * @param size - How big the figure is drawn for the file.
193
- * @param painted - Whether the file is painted into pixels.
194
- * @returns The choices, in the order offered.
195
- */
196
- function scaleChoices(
197
- scales: readonly number[],
198
- size: FigurePixels | null,
199
- painted: boolean,
200
- ): readonly OverlayOption[] {
201
- const choices: OverlayOption[] = [];
202
- for (const scale of scales) {
203
- const pixels = size === null ? null : figurePixels(size, scale);
204
- choices.push({
205
- value: String(scale),
206
- label: figureScaleLabel(scale),
207
- title: pixels === null ? undefined : formatFigurePixels(pixels),
208
- disabled: painted && size !== null && !figureScaleFits(size, scale),
209
- });
210
- }
211
- return choices;
212
- }