react-cheminfo 0.23.0 → 0.25.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 (264) hide show
  1. package/README.md +39 -26
  2. package/lib/chrome/ui/HeaderToggle.d.ts +52 -0
  3. package/lib/chrome/ui/HeaderToggle.d.ts.map +1 -0
  4. package/lib/chrome/ui/HeaderToggle.js +31 -0
  5. package/lib/chrome/ui/HeaderToggle.js.map +1 -0
  6. package/lib/chrome/ui/index.d.ts +2 -0
  7. package/lib/chrome/ui/index.d.ts.map +1 -1
  8. package/lib/chrome/ui/index.js +1 -0
  9. package/lib/chrome/ui/index.js.map +1 -1
  10. package/lib/citation/core/gfn2Paper.d.ts +10 -0
  11. package/lib/citation/core/gfn2Paper.d.ts.map +1 -0
  12. package/lib/citation/core/gfn2Paper.js +28 -0
  13. package/lib/citation/core/gfn2Paper.js.map +1 -0
  14. package/lib/citation/core/index.d.ts +1 -0
  15. package/lib/citation/core/index.d.ts.map +1 -1
  16. package/lib/citation/core/index.js +1 -0
  17. package/lib/citation/core/index.js.map +1 -1
  18. package/lib/clipboard/ui/ClickToCopy.d.ts +8 -7
  19. package/lib/clipboard/ui/ClickToCopy.d.ts.map +1 -1
  20. package/lib/clipboard/ui/ClickToCopy.js +3 -3
  21. package/lib/clipboard/ui/ClickToCopy.js.map +1 -1
  22. package/lib/conformers.d.ts +27 -0
  23. package/lib/conformers.d.ts.map +1 -0
  24. package/lib/conformers.js +19 -0
  25. package/lib/conformers.js.map +1 -0
  26. package/lib/core.d.ts +1 -0
  27. package/lib/core.d.ts.map +1 -1
  28. package/lib/core.js +1 -0
  29. package/lib/core.js.map +1 -1
  30. package/lib/credits/core/credits.d.ts +12 -0
  31. package/lib/credits/core/credits.d.ts.map +1 -1
  32. package/lib/credits/core/credits.js +14 -0
  33. package/lib/credits/core/credits.js.map +1 -1
  34. package/lib/ecosystem/core/index.d.ts +1 -1
  35. package/lib/ecosystem/core/index.d.ts.map +1 -1
  36. package/lib/ecosystem/core/index.js.map +1 -1
  37. package/lib/ecosystem/core/sites.d.ts +11 -1
  38. package/lib/ecosystem/core/sites.d.ts.map +1 -1
  39. package/lib/ecosystem/core/sites.js +11 -4
  40. package/lib/ecosystem/core/sites.js.map +1 -1
  41. package/lib/ecosystem/ui/EcosystemLinks.d.ts.map +1 -1
  42. package/lib/ecosystem/ui/EcosystemLinks.js +3 -1
  43. package/lib/ecosystem/ui/EcosystemLinks.js.map +1 -1
  44. package/lib/ecosystem/ui/SiteTile.d.ts.map +1 -1
  45. package/lib/ecosystem/ui/SiteTile.js +3 -1
  46. package/lib/ecosystem/ui/SiteTile.js.map +1 -1
  47. package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
  48. package/lib/ecosystem/ui/glyphs.js +6 -5
  49. package/lib/ecosystem/ui/glyphs.js.map +1 -1
  50. package/lib/format/core/index.d.ts +1 -1
  51. package/lib/format/core/index.d.ts.map +1 -1
  52. package/lib/format/core/index.js +1 -1
  53. package/lib/format/core/index.js.map +1 -1
  54. package/lib/format/core/words.d.ts +9 -0
  55. package/lib/format/core/words.d.ts.map +1 -1
  56. package/lib/format/core/words.js +16 -0
  57. package/lib/format/core/words.js.map +1 -1
  58. package/lib/language/core/index.d.ts +3 -0
  59. package/lib/language/core/index.d.ts.map +1 -0
  60. package/lib/language/core/index.js +3 -0
  61. package/lib/language/core/index.js.map +1 -0
  62. package/lib/language/core/languageName.d.ts +8 -0
  63. package/lib/language/core/languageName.d.ts.map +1 -0
  64. package/lib/language/core/languageName.js +16 -0
  65. package/lib/language/core/languageName.js.map +1 -0
  66. package/lib/language/core/languageParam.d.ts +35 -0
  67. package/lib/language/core/languageParam.d.ts.map +1 -0
  68. package/lib/language/core/languageParam.js +67 -0
  69. package/lib/language/core/languageParam.js.map +1 -0
  70. package/lib/language/ui/SiteLanguage.d.ts +20 -0
  71. package/lib/language/ui/SiteLanguage.d.ts.map +1 -0
  72. package/lib/language/ui/SiteLanguage.js +14 -0
  73. package/lib/language/ui/SiteLanguage.js.map +1 -0
  74. package/lib/language/ui/index.d.ts +4 -0
  75. package/lib/language/ui/index.d.ts.map +1 -0
  76. package/lib/language/ui/index.js +3 -0
  77. package/lib/language/ui/index.js.map +1 -0
  78. package/lib/language/ui/siteLanguageContext.d.ts +12 -0
  79. package/lib/language/ui/siteLanguageContext.d.ts.map +1 -0
  80. package/lib/language/ui/siteLanguageContext.js +19 -0
  81. package/lib/language/ui/siteLanguageContext.js.map +1 -0
  82. package/lib/orbital/core/atomicOrbitals.d.ts +9 -1
  83. package/lib/orbital/core/atomicOrbitals.d.ts.map +1 -1
  84. package/lib/orbital/core/atomicOrbitals.js +7 -0
  85. package/lib/orbital/core/atomicOrbitals.js.map +1 -1
  86. package/lib/orbital/core/hydrogenic.d.ts +2 -1
  87. package/lib/orbital/core/hydrogenic.d.ts.map +1 -1
  88. package/lib/orbital/core/hydrogenic.js +2 -1
  89. package/lib/orbital/core/hydrogenic.js.map +1 -1
  90. package/lib/orbital/core/index.d.ts +1 -0
  91. package/lib/orbital/core/index.d.ts.map +1 -1
  92. package/lib/orbital/core/index.js +1 -0
  93. package/lib/orbital/core/index.js.map +1 -1
  94. package/lib/orbital/core/slaterEnergy.d.ts +35 -0
  95. package/lib/orbital/core/slaterEnergy.d.ts.map +1 -0
  96. package/lib/orbital/core/slaterEnergy.js +66 -0
  97. package/lib/orbital/core/slaterEnergy.js.map +1 -0
  98. package/lib/shared/ui/MenuButton.d.ts +3 -2
  99. package/lib/shared/ui/MenuButton.d.ts.map +1 -1
  100. package/lib/shared/ui/MenuButton.js +1 -1
  101. package/lib/shared/ui/MenuButton.js.map +1 -1
  102. package/lib/structure/core/conformerMinimise.d.ts +36 -0
  103. package/lib/structure/core/conformerMinimise.d.ts.map +1 -0
  104. package/lib/structure/core/conformerMinimise.js +81 -0
  105. package/lib/structure/core/conformerMinimise.js.map +1 -0
  106. package/lib/structure/core/conformerMinimum.d.ts +62 -0
  107. package/lib/structure/core/conformerMinimum.d.ts.map +1 -0
  108. package/lib/structure/core/conformerMinimum.js +90 -0
  109. package/lib/structure/core/conformerMinimum.js.map +1 -0
  110. package/lib/structure/core/conformerOptions.d.ts +62 -0
  111. package/lib/structure/core/conformerOptions.d.ts.map +1 -0
  112. package/lib/structure/core/conformerOptions.js +83 -0
  113. package/lib/structure/core/conformerOptions.js.map +1 -0
  114. package/lib/structure/core/conformerRefine.d.ts +104 -0
  115. package/lib/structure/core/conformerRefine.d.ts.map +1 -0
  116. package/lib/structure/core/conformerRefine.js +130 -0
  117. package/lib/structure/core/conformerRefine.js.map +1 -0
  118. package/lib/structure/core/conformerRefineRank.d.ts +36 -0
  119. package/lib/structure/core/conformerRefineRank.d.ts.map +1 -0
  120. package/lib/structure/core/conformerRefineRank.js +69 -0
  121. package/lib/structure/core/conformerRefineRank.js.map +1 -0
  122. package/lib/structure/core/conformerSession.d.ts +50 -0
  123. package/lib/structure/core/conformerSession.d.ts.map +1 -0
  124. package/lib/structure/core/conformerSession.js +88 -0
  125. package/lib/structure/core/conformerSession.js.map +1 -0
  126. package/lib/structure/core/conformerShape.d.ts +36 -0
  127. package/lib/structure/core/conformerShape.d.ts.map +1 -0
  128. package/lib/structure/core/conformerShape.js +150 -0
  129. package/lib/structure/core/conformerShape.js.map +1 -0
  130. package/lib/structure/core/conformers.d.ts +107 -0
  131. package/lib/structure/core/conformers.d.ts.map +1 -0
  132. package/lib/structure/core/conformers.js +149 -0
  133. package/lib/structure/core/conformers.js.map +1 -0
  134. package/lib/structure/core/geometryRelaxer.d.ts +66 -0
  135. package/lib/structure/core/geometryRelaxer.d.ts.map +1 -0
  136. package/lib/structure/core/geometryRelaxer.js +2 -0
  137. package/lib/structure/core/geometryRelaxer.js.map +1 -0
  138. package/lib/structure/core/index.d.ts +4 -0
  139. package/lib/structure/core/index.d.ts.map +1 -1
  140. package/lib/structure/core/index.js +2 -0
  141. package/lib/structure/core/index.js.map +1 -1
  142. package/lib/structure/core/moleculeCoordinates.d.ts +31 -0
  143. package/lib/structure/core/moleculeCoordinates.d.ts.map +1 -0
  144. package/lib/structure/core/moleculeCoordinates.js +80 -0
  145. package/lib/structure/core/moleculeCoordinates.js.map +1 -0
  146. package/lib/structure/core/molfileExport.d.ts +42 -0
  147. package/lib/structure/core/molfileExport.d.ts.map +1 -0
  148. package/lib/structure/core/molfileExport.js +47 -0
  149. package/lib/structure/core/molfileExport.js.map +1 -0
  150. package/lib/structure/core/oclResources.d.ts +12 -0
  151. package/lib/structure/core/oclResources.d.ts.map +1 -0
  152. package/lib/structure/core/oclResources.js +35 -0
  153. package/lib/structure/core/oclResources.js.map +1 -0
  154. package/lib/translate/core/catalog.d.ts +61 -0
  155. package/lib/translate/core/catalog.d.ts.map +1 -0
  156. package/lib/translate/core/catalog.js +49 -0
  157. package/lib/translate/core/catalog.js.map +1 -0
  158. package/lib/translate/core/checkTranslation.d.ts +32 -0
  159. package/lib/translate/core/checkTranslation.d.ts.map +1 -0
  160. package/lib/translate/core/checkTranslation.js +98 -0
  161. package/lib/translate/core/checkTranslation.js.map +1 -0
  162. package/lib/translate/core/contribution.d.ts +88 -0
  163. package/lib/translate/core/contribution.d.ts.map +1 -0
  164. package/lib/translate/core/contribution.js +14 -0
  165. package/lib/translate/core/contribution.js.map +1 -0
  166. package/lib/translate/core/index.d.ts +19 -0
  167. package/lib/translate/core/index.d.ts.map +1 -0
  168. package/lib/translate/core/index.js +15 -0
  169. package/lib/translate/core/index.js.map +1 -0
  170. package/lib/translate/core/marker.d.ts +45 -0
  171. package/lib/translate/core/marker.d.ts.map +1 -0
  172. package/lib/translate/core/marker.js +79 -0
  173. package/lib/translate/core/marker.js.map +1 -0
  174. package/lib/translate/core/mergeMessages.d.ts +35 -0
  175. package/lib/translate/core/mergeMessages.d.ts.map +1 -0
  176. package/lib/translate/core/mergeMessages.js +69 -0
  177. package/lib/translate/core/mergeMessages.js.map +1 -0
  178. package/lib/translate/core/session.d.ts +102 -0
  179. package/lib/translate/core/session.d.ts.map +1 -0
  180. package/lib/translate/core/session.js +162 -0
  181. package/lib/translate/core/session.js.map +1 -0
  182. package/lib/translate/core/start.d.ts +103 -0
  183. package/lib/translate/core/start.d.ts.map +1 -0
  184. package/lib/translate/core/start.js +92 -0
  185. package/lib/translate/core/start.js.map +1 -0
  186. package/lib/translate/core/suggestions.d.ts +77 -0
  187. package/lib/translate/core/suggestions.d.ts.map +1 -0
  188. package/lib/translate/core/suggestions.js +143 -0
  189. package/lib/translate/core/suggestions.js.map +1 -0
  190. package/lib/translate/core/tables.d.ts +100 -0
  191. package/lib/translate/core/tables.d.ts.map +1 -0
  192. package/lib/translate/core/tables.js +51 -0
  193. package/lib/translate/core/tables.js.map +1 -0
  194. package/lib/translate.d.ts +2 -0
  195. package/lib/translate.d.ts.map +1 -0
  196. package/lib/translate.js +6 -0
  197. package/lib/translate.js.map +1 -0
  198. package/lib/ui.d.ts +1 -0
  199. package/lib/ui.d.ts.map +1 -1
  200. package/lib/ui.js +1 -0
  201. package/lib/ui.js.map +1 -1
  202. package/lib/xtb/core/xtbRelaxer.d.ts +61 -0
  203. package/lib/xtb/core/xtbRelaxer.d.ts.map +1 -0
  204. package/lib/xtb/core/xtbRelaxer.js +108 -0
  205. package/lib/xtb/core/xtbRelaxer.js.map +1 -0
  206. package/lib/xtb.d.ts +11 -0
  207. package/lib/xtb.d.ts.map +1 -0
  208. package/lib/xtb.js +10 -0
  209. package/lib/xtb.js.map +1 -0
  210. package/package.json +18 -11
  211. package/src/chrome/ui/HeaderToggle.tsx +100 -0
  212. package/src/chrome/ui/index.ts +2 -0
  213. package/src/citation/core/gfn2Paper.ts +32 -0
  214. package/src/citation/core/index.ts +1 -0
  215. package/src/clipboard/ui/ClickToCopy.tsx +8 -7
  216. package/src/conformers.ts +87 -0
  217. package/src/core.ts +1 -0
  218. package/src/credits/core/credits.ts +16 -0
  219. package/src/ecosystem/core/index.ts +1 -0
  220. package/src/ecosystem/core/sites.ts +24 -4
  221. package/src/ecosystem/ui/EcosystemLinks.tsx +3 -1
  222. package/src/ecosystem/ui/SiteTile.tsx +3 -1
  223. package/src/ecosystem/ui/glyphs.tsx +16 -22
  224. package/src/format/core/index.ts +1 -1
  225. package/src/format/core/words.ts +19 -0
  226. package/src/language/core/index.ts +7 -0
  227. package/src/language/core/languageName.ts +16 -0
  228. package/src/language/core/languageParam.ts +70 -0
  229. package/src/language/ui/SiteLanguage.tsx +26 -0
  230. package/src/language/ui/index.ts +3 -0
  231. package/src/language/ui/siteLanguageContext.ts +20 -0
  232. package/src/orbital/core/atomicOrbitals.ts +17 -1
  233. package/src/orbital/core/hydrogenic.ts +2 -1
  234. package/src/orbital/core/index.ts +1 -0
  235. package/src/orbital/core/slaterEnergy.ts +83 -0
  236. package/src/shared/ui/MenuButton.tsx +4 -3
  237. package/src/structure/core/conformerMinimise.ts +99 -0
  238. package/src/structure/core/conformerMinimum.ts +125 -0
  239. package/src/structure/core/conformerOptions.ts +125 -0
  240. package/src/structure/core/conformerRefine.ts +234 -0
  241. package/src/structure/core/conformerRefineRank.ts +89 -0
  242. package/src/structure/core/conformerSession.ts +123 -0
  243. package/src/structure/core/conformerShape.ts +181 -0
  244. package/src/structure/core/conformers.ts +282 -0
  245. package/src/structure/core/geometryRelaxer.ts +71 -0
  246. package/src/structure/core/index.ts +13 -0
  247. package/src/structure/core/moleculeCoordinates.ts +93 -0
  248. package/src/structure/core/molfileExport.ts +62 -0
  249. package/src/structure/core/oclResources.ts +41 -0
  250. package/src/translate/core/catalog.ts +83 -0
  251. package/src/translate/core/checkTranslation.ts +128 -0
  252. package/src/translate/core/contribution.ts +99 -0
  253. package/src/translate/core/index.ts +72 -0
  254. package/src/translate/core/marker.ts +85 -0
  255. package/src/translate/core/mergeMessages.ts +74 -0
  256. package/src/translate/core/session.ts +250 -0
  257. package/src/translate/core/start.ts +183 -0
  258. package/src/translate/core/suggestions.ts +211 -0
  259. package/src/translate/core/tables.ts +120 -0
  260. package/src/translate.ts +5 -0
  261. package/src/ui.ts +1 -0
  262. package/src/xtb/core/xtbRelaxer.ts +160 -0
  263. package/src/xtb.ts +16 -0
  264. package/styles/chrome.css +61 -30
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The tables of a site whose rows are translated: the element sheet, a list of
3
+ * ions, the rules of a nomenclature.
4
+ *
5
+ * A site's prose is not only its interface. Most of what a chemistry tool
6
+ * shows is a table, and a table mixes two kinds of column: what was measured
7
+ * or computed — an atomic number, a mass, a formula, an identifier — and what
8
+ * was written — a name, where the name comes from, a note. The first kind is
9
+ * the same in every language and must never reach a translator; the second is
10
+ * exactly what a translator is for.
11
+ *
12
+ * The line between them is drawn once, here. A site declares its tables, and
13
+ * only a field it declares can be edited, in a catalog key built the same way
14
+ * everywhere:
15
+ *
16
+ * ```text
17
+ * <table>.<row>.<field> element.Fe.name, element.Fe.origin
18
+ * ```
19
+ *
20
+ * Everything else about the row — the mass, the density, the id itself — stays
21
+ * in the data the site generates from its source, out of reach.
22
+ */
23
+ /** How much room a field's text needs, which is how the editor draws it. */
24
+ export type TranslatableFieldSize = 'line' | 'paragraph';
25
+ /** One translated column of a table. */
26
+ export interface TranslatableField {
27
+ /** Last part of the key, e.g. `name`. */
28
+ id: string;
29
+ /** What the column is called in the editor, in English. */
30
+ label: string;
31
+ /**
32
+ * How much text it holds, which is whether the editor gives it one line or
33
+ * a box.
34
+ * @default 'line'
35
+ */
36
+ size?: TranslatableFieldSize;
37
+ /**
38
+ * Whether every row is expected to carry it, so the editor can say what is
39
+ * still missing rather than only what is there.
40
+ * @default false
41
+ */
42
+ required?: boolean;
43
+ /**
44
+ * One sentence telling the translator what the column is, shown above the
45
+ * column in the editor.
46
+ * @default undefined
47
+ */
48
+ hint?: string;
49
+ }
50
+ /** One row of a table. */
51
+ export interface TranslatableRow {
52
+ /** Middle part of the key, e.g. `Fe`. */
53
+ id: string;
54
+ /**
55
+ * What names the row in the editor — an atomic number and a symbol, a
56
+ * formula. It is data, never translated, and never a key.
57
+ */
58
+ label: string;
59
+ }
60
+ /** A table whose rows carry translated text. */
61
+ export interface TranslatableTable {
62
+ /** First part of the key, e.g. `element`. */
63
+ id: string;
64
+ /** What the table is called in the editor, in English. */
65
+ label: string;
66
+ /** The catalog its keys belong to, as the page registered it. */
67
+ catalogId: string;
68
+ /** The columns a translator may write, in the order the editor shows them. */
69
+ fields: readonly TranslatableField[];
70
+ /** The rows, in the order the editor lists them. */
71
+ rows: readonly TranslatableRow[];
72
+ }
73
+ /**
74
+ * The key one field of one row is kept under.
75
+ * @param table - The table the row belongs to.
76
+ * @param rowId - The row.
77
+ * @param fieldId - The column.
78
+ * @returns The catalog key, e.g. `element.Fe.name`.
79
+ */
80
+ export declare function tableKey(table: Pick<TranslatableTable, 'id'>, rowId: string, fieldId: string): string;
81
+ /**
82
+ * Every key a table can hold, row by row and field by field.
83
+ *
84
+ * It is what the editor walks to draw the grid, and what tells it which cells
85
+ * are still empty: a key absent from the catalog is a translation nobody has
86
+ * written yet, not a field that does not exist.
87
+ * @param table - The table to walk.
88
+ * @returns One entry per cell, in reading order.
89
+ */
90
+ export declare function tableCells(table: TranslatableTable): TableCell[];
91
+ /** One cell of a table: where it is, and what it is kept under. */
92
+ export interface TableCell {
93
+ /** The catalog key. */
94
+ key: string;
95
+ /** The row it belongs to. */
96
+ row: TranslatableRow;
97
+ /** The column it belongs to. */
98
+ field: TranslatableField;
99
+ }
100
+ //# sourceMappingURL=tables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../../src/translate/core/tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,WAAW,CAAC;AAEzD,wCAAwC;AACxC,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,0BAA0B;AAC1B,MAAM,WAAW,eAAe;IAC9B,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IAChC,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrC,oDAAoD;IACpD,IAAI,EAAE,SAAS,eAAe,EAAE,CAAC;CAClC;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,EACpC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,MAAM,CAER;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,EAAE,CAQhE;AAED,mEAAmE;AACnE,MAAM,WAAW,SAAS;IACxB,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,GAAG,EAAE,eAAe,CAAC;IACrB,gCAAgC;IAChC,KAAK,EAAE,iBAAiB,CAAC;CAC1B"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The tables of a site whose rows are translated: the element sheet, a list of
3
+ * ions, the rules of a nomenclature.
4
+ *
5
+ * A site's prose is not only its interface. Most of what a chemistry tool
6
+ * shows is a table, and a table mixes two kinds of column: what was measured
7
+ * or computed — an atomic number, a mass, a formula, an identifier — and what
8
+ * was written — a name, where the name comes from, a note. The first kind is
9
+ * the same in every language and must never reach a translator; the second is
10
+ * exactly what a translator is for.
11
+ *
12
+ * The line between them is drawn once, here. A site declares its tables, and
13
+ * only a field it declares can be edited, in a catalog key built the same way
14
+ * everywhere:
15
+ *
16
+ * ```text
17
+ * <table>.<row>.<field> element.Fe.name, element.Fe.origin
18
+ * ```
19
+ *
20
+ * Everything else about the row — the mass, the density, the id itself — stays
21
+ * in the data the site generates from its source, out of reach.
22
+ */
23
+ /**
24
+ * The key one field of one row is kept under.
25
+ * @param table - The table the row belongs to.
26
+ * @param rowId - The row.
27
+ * @param fieldId - The column.
28
+ * @returns The catalog key, e.g. `element.Fe.name`.
29
+ */
30
+ export function tableKey(table, rowId, fieldId) {
31
+ return `${table.id}.${rowId}.${fieldId}`;
32
+ }
33
+ /**
34
+ * Every key a table can hold, row by row and field by field.
35
+ *
36
+ * It is what the editor walks to draw the grid, and what tells it which cells
37
+ * are still empty: a key absent from the catalog is a translation nobody has
38
+ * written yet, not a field that does not exist.
39
+ * @param table - The table to walk.
40
+ * @returns One entry per cell, in reading order.
41
+ */
42
+ export function tableCells(table) {
43
+ const cells = [];
44
+ for (const row of table.rows) {
45
+ for (const field of table.fields) {
46
+ cells.push({ key: tableKey(table, row.id, field.id), row, field });
47
+ }
48
+ }
49
+ return cells;
50
+ }
51
+ //# sourceMappingURL=tables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../src/translate/core/tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAwDH;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAoC,EACpC,KAAa,EACb,OAAe;IAEf,OAAO,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,KAAwB;IACjD,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './translate/core/index.ts';
2
+ //# sourceMappingURL=translate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":"AAIA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Everything a page, an overlay or a server needs to translate a site of the
2
+ // family: the catalogs, the invisible marker, the checks, and the session a
3
+ // page in translate mode hands to the overlay. It is its own entry point
4
+ // because an ordinary visit loads none of it.
5
+ export * from "./translate/core/index.js";
6
+ //# sourceMappingURL=translate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.js","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,8CAA8C;AAC9C,cAAc,2BAA2B,CAAC"}
package/lib/ui.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from './ecosystem/ui/index.ts';
14
14
  export * from './error/ui/index.ts';
15
15
  export * from './help/ui/index.ts';
16
16
  export * from './hooks/ui/index.ts';
17
+ export * from './language/ui/index.ts';
17
18
  export * from './overlay/ui/index.ts';
18
19
  export * from './parallel/ui/index.ts';
19
20
  export * from './pedagogy/ui/index.ts';
package/lib/ui.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
package/lib/ui.js CHANGED
@@ -14,6 +14,7 @@ export * from "./ecosystem/ui/index.js";
14
14
  export * from "./error/ui/index.js";
15
15
  export * from "./help/ui/index.js";
16
16
  export * from "./hooks/ui/index.js";
17
+ export * from "./language/ui/index.js";
17
18
  export * from "./overlay/ui/index.js";
18
19
  export * from "./parallel/ui/index.js";
19
20
  export * from "./pedagogy/ui/index.js";
package/lib/ui.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { GeometryRelaxer } from '../../structure/core/geometryRelaxer.ts';
2
+ /**
3
+ * kcal/mol per hartree, CODATA 2018. Every energy a relaxer reports is in
4
+ * kcal/mol, so it can be read against a force-field energy without the reader
5
+ * converting anything.
6
+ */
7
+ export declare const KCAL_PER_MOL_PER_HARTREE = 627.5094740631;
8
+ /** How many occjs instances a relaxation may use. */
9
+ export interface XtbRelaxerOptions {
10
+ /**
11
+ * Hard cap on the number of GFN2 instances. Each one costs about 100 MB of
12
+ * WebAssembly memory, so a long batch on a small machine is worth capping.
13
+ * @default one per structure, one below the core count
14
+ */
15
+ maxWorkers?: number;
16
+ /**
17
+ * Total molecular charge in units of e, applied to every structure.
18
+ * @default 0
19
+ */
20
+ charge?: number;
21
+ /**
22
+ * Unpaired electrons, applied to every structure. `1` for a doublet radical.
23
+ * @default 0
24
+ */
25
+ unpairedElectrons?: number;
26
+ /**
27
+ * Cycle budget of one optimization.
28
+ * @default 250
29
+ */
30
+ maxCycles?: number;
31
+ }
32
+ /**
33
+ * GFN2-xTB as a {@link GeometryRelaxer}: the second stage that decides how good
34
+ * a force field's conformers really are.
35
+ *
36
+ * `xtb-wasm` is loaded on the **first call**, never on the import, so a page that
37
+ * offers refinement as an action downloads the 21.5 MB WebAssembly only once a
38
+ * visitor asks for it. The module is cached afterwards, and the worker pool it
39
+ * starts is kept alive between calls.
40
+ *
41
+ * Energies come back in kcal/mol, which is the unit `conformer.energy` is
42
+ * already in.
43
+ * @param options - Instance cap, charge, spin and the cycle budget.
44
+ * @returns A relaxer to hand to `refineConformers`, or to call directly.
45
+ */
46
+ export declare function xtbRelaxer(options?: XtbRelaxerOptions): GeometryRelaxer;
47
+ /**
48
+ * Whether this environment has the worker pool the relaxer prefers.
49
+ *
50
+ * Without `Worker` — Node, a prerender pass, a test run — the relaxer still
51
+ * works, one structure at a time on the calling thread, so a site keeps one code
52
+ * path. It is the caller's business only when the difference in speed matters.
53
+ * @returns `true` in a browser, `false` in a plain Node process.
54
+ */
55
+ export declare function isXtbRelaxerAvailable(): boolean;
56
+ /**
57
+ * Drop the GFN2 worker pool and the memory it holds, about 100 MB per instance.
58
+ * The next relaxation starts a fresh one.
59
+ */
60
+ export declare function disposeXtbRelaxer(): Promise<void>;
61
+ //# sourceMappingURL=xtbRelaxer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xtbRelaxer.d.ts","sourceRoot":"","sources":["../../../src/xtb/core/xtbRelaxer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,yCAAyC,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,iBAAoB,CAAC;AAE1D,qDAAqD;AACrD,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,eAAe,CAqC3E;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGvD"}
@@ -0,0 +1,108 @@
1
+ import { errorMessage } from "../../error/core/toError.js";
2
+ /**
3
+ * kcal/mol per hartree, CODATA 2018. Every energy a relaxer reports is in
4
+ * kcal/mol, so it can be read against a force-field energy without the reader
5
+ * converting anything.
6
+ */
7
+ export const KCAL_PER_MOL_PER_HARTREE = 627.509_474_063_1;
8
+ /**
9
+ * GFN2-xTB as a {@link GeometryRelaxer}: the second stage that decides how good
10
+ * a force field's conformers really are.
11
+ *
12
+ * `xtb-wasm` is loaded on the **first call**, never on the import, so a page that
13
+ * offers refinement as an action downloads the 21.5 MB WebAssembly only once a
14
+ * visitor asks for it. The module is cached afterwards, and the worker pool it
15
+ * starts is kept alive between calls.
16
+ *
17
+ * Energies come back in kcal/mol, which is the unit `conformer.energy` is
18
+ * already in.
19
+ * @param options - Instance cap, charge, spin and the cycle budget.
20
+ * @returns A relaxer to hand to `refineConformers`, or to call directly.
21
+ */
22
+ export function xtbRelaxer(options = {}) {
23
+ return async (geometries, runOptions = {}) => {
24
+ const xtb = await loadXtb();
25
+ const settings = {
26
+ charge: options.charge ?? 0,
27
+ unpairedElectrons: options.unpairedElectrons ?? 0,
28
+ ...(options.maxCycles === undefined
29
+ ? {}
30
+ : { maxCycles: options.maxCycles }),
31
+ };
32
+ const requests = geometries.map((geometry) => ({ geometry, settings }));
33
+ const results = isXtbRelaxerAvailable()
34
+ ? await xtb.relaxGeometries(requests, {
35
+ maxWorkers: options.maxWorkers,
36
+ onSettled: runOptions.onSettled,
37
+ signal: runOptions.signal,
38
+ })
39
+ : await relaxHere(xtb, requests, runOptions);
40
+ const relaxed = [];
41
+ for (const result of results) {
42
+ relaxed.push({
43
+ coordinates: result.coordinates,
44
+ energy: result.energy.total * KCAL_PER_MOL_PER_HARTREE,
45
+ dispersionEnergy: result.energy.dispersion === null
46
+ ? null
47
+ : result.energy.dispersion * KCAL_PER_MOL_PER_HARTREE,
48
+ cycles: result.cycles,
49
+ converged: result.converged,
50
+ warnings: result.warnings,
51
+ });
52
+ }
53
+ return relaxed;
54
+ };
55
+ }
56
+ /**
57
+ * Whether this environment has the worker pool the relaxer prefers.
58
+ *
59
+ * Without `Worker` — Node, a prerender pass, a test run — the relaxer still
60
+ * works, one structure at a time on the calling thread, so a site keeps one code
61
+ * path. It is the caller's business only when the difference in speed matters.
62
+ * @returns `true` in a browser, `false` in a plain Node process.
63
+ */
64
+ export function isXtbRelaxerAvailable() {
65
+ return typeof Worker !== 'undefined';
66
+ }
67
+ /**
68
+ * Drop the GFN2 worker pool and the memory it holds, about 100 MB per instance.
69
+ * The next relaxation starts a fresh one.
70
+ */
71
+ export async function disposeXtbRelaxer() {
72
+ const loaded = await pending;
73
+ loaded?.disposeOccPool();
74
+ }
75
+ /**
76
+ * Relax one structure after another on this thread, for want of a pool.
77
+ * @param xtb - The loaded `xtb-wasm` module.
78
+ * @param requests - The structures to relax, with their settings.
79
+ * @param runOptions - Progress and cancellation.
80
+ * @returns One `xtb-wasm` result per request, in request order.
81
+ * @throws {Error} When the run is cancelled, or when occ fails.
82
+ */
83
+ async function relaxHere(xtb, requests, runOptions) {
84
+ const results = [];
85
+ for (const [index, request] of requests.entries()) {
86
+ if (runOptions.signal?.aborted === true) {
87
+ throw new Error('calculation cancelled');
88
+ }
89
+ /* eslint-disable-next-line no-await-in-loop -- there is one thread: the
90
+ whole point of this path is that the structures run in turn. */
91
+ results.push(await xtb.relaxGeometryInProcess(request));
92
+ runOptions.onSettled?.(index + 1, requests.length);
93
+ }
94
+ return results;
95
+ }
96
+ let pending = null;
97
+ function loadXtb() {
98
+ pending ??= import('xtb-wasm').catch((error) => {
99
+ // A failed chunk load must not poison every later call of the session.
100
+ pending = null;
101
+ // The reason is in the message, not only in `cause`: what a reader sees is
102
+ // whatever the UI renders, and "could not be loaded" alone names neither a
103
+ // missing install nor a chunk that failed to come down the wire.
104
+ throw new Error(`xtb-wasm could not be loaded, so geometries cannot be refined: ${errorMessage(error)}`, { cause: error });
105
+ });
106
+ return pending;
107
+ }
108
+ //# sourceMappingURL=xtbRelaxer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xtbRelaxer.js","sourceRoot":"","sources":["../../../src/xtb/core/xtbRelaxer.ts"],"names":[],"mappings":"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"}
package/lib/xtb.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * GFN2-xTB, the opt-in second stage after a force field.
3
+ *
4
+ * Its own door because it drags `xtb-wasm` and a 21.5 MB WebAssembly binary
5
+ * behind it, and because most pages never refine anything. The contract it
6
+ * implements — `GeometryRelaxer` — lives in `react-cheminfo/core`, so the code
7
+ * that orchestrates a refinement (`refineConformers`) loads none of this.
8
+ */
9
+ export type { XtbRelaxerOptions } from './xtb/core/xtbRelaxer.ts';
10
+ export { KCAL_PER_MOL_PER_HARTREE, disposeXtbRelaxer, isXtbRelaxerAvailable, xtbRelaxer, } from './xtb/core/xtbRelaxer.ts';
11
+ //# sourceMappingURL=xtb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xtb.d.ts","sourceRoot":"","sources":["../src/xtb.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,GACX,MAAM,0BAA0B,CAAC"}
package/lib/xtb.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * GFN2-xTB, the opt-in second stage after a force field.
3
+ *
4
+ * Its own door because it drags `xtb-wasm` and a 21.5 MB WebAssembly binary
5
+ * behind it, and because most pages never refine anything. The contract it
6
+ * implements — `GeometryRelaxer` — lives in `react-cheminfo/core`, so the code
7
+ * that orchestrates a refinement (`refineConformers`) loads none of this.
8
+ */
9
+ export { KCAL_PER_MOL_PER_HARTREE, disposeXtbRelaxer, isXtbRelaxerAvailable, xtbRelaxer, } from "./xtb/core/xtbRelaxer.js";
10
+ //# sourceMappingURL=xtb.js.map
package/lib/xtb.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xtb.js","sourceRoot":"","sources":["../src/xtb.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,GACX,MAAM,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cheminfo",
3
- "version": "0.23.0",
3
+ "version": "0.25.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",
@@ -16,15 +16,18 @@
16
16
  ],
17
17
  "exports": {
18
18
  "./build-info": "./lib/build-info.js",
19
+ "./conformers": "./lib/conformers.js",
19
20
  "./core": "./lib/core.js",
20
21
  "./molecule3d": "./lib/molecule3d.js",
21
22
  "./orbital": "./lib/orbital.js",
22
23
  "./slides": "./lib/slides.js",
23
24
  "./spectra": "./lib/spectra.js",
24
25
  "./structure": "./lib/structure.js",
26
+ "./styles/*.css": "./styles/*.css",
27
+ "./translate": "./lib/translate.js",
25
28
  "./ui": "./lib/ui.js",
26
29
  "./vite": "./lib/vite.js",
27
- "./styles/*.css": "./styles/*.css"
30
+ "./xtb": "./lib/xtb.js"
28
31
  },
29
32
  "bin": {
30
33
  "cheminfo-check-deploy": "bin/check-deploy.mjs",
@@ -55,7 +58,11 @@
55
58
  "tsc-build": "tsc --project tsconfig.build.json"
56
59
  },
57
60
  "dependencies": {
61
+ "@formatjs/icu-messageformat-parser": "^3.5.20",
58
62
  "cheminfo-font": "^1.28.0",
63
+ "intl-messageformat": "^11.2.15",
64
+ "leven": "^4.1.0",
65
+ "openchemlib": "^9.25.0",
59
66
  "react-markdown": "^10.1.0",
60
67
  "rehype-raw": "^7.0.0",
61
68
  "rehype-sanitize": "^6.0.0",
@@ -80,7 +87,6 @@
80
87
  "ml-pca": "^4.1.1",
81
88
  "ml-signal-processing": "^2.2.2",
82
89
  "molstar": "^5.11.0",
83
- "openchemlib": "^9.25.0",
84
90
  "prettier": "^3.9.6",
85
91
  "react": "^19.2.8",
86
92
  "react-dom": "^19.2.8",
@@ -91,20 +97,21 @@
91
97
  "storybook": "^10.5.8",
92
98
  "typescript": "^6.0.3",
93
99
  "vite": "^8.2.1",
94
- "vitest": "^4.1.10"
100
+ "vitest": "^4.1.10",
101
+ "xtb-wasm": "^1.1.0"
95
102
  },
96
103
  "peerDependencies": {
97
104
  "@blueprintjs/core": "^6.18.0",
98
105
  "ml-pca": "^4.1.1",
99
106
  "ml-signal-processing": "^2.2.2",
100
107
  "molstar": "^5.11.0",
101
- "openchemlib": "^9.24.0",
102
- "react": "^18.3.1 || ^19.0.0",
103
- "react-dom": "^18.3.1 || ^19.0.0",
108
+ "react": "^19.0.0",
109
+ "react-dom": "^19.0.0",
104
110
  "react-ocl": "^8.7.1",
105
111
  "react-science": "^20.6.2 || ^21.0.0 || ^22.0.0 || ^23.0.0",
106
112
  "spectra-processor": "^5.0.0",
107
- "vite": "^7.0.0 || ^8.0.0"
113
+ "vite": "^7.0.0 || ^8.0.0",
114
+ "xtb-wasm": "^1.1.0"
108
115
  },
109
116
  "repository": {
110
117
  "type": "git",
@@ -124,9 +131,6 @@
124
131
  "molstar": {
125
132
  "optional": true
126
133
  },
127
- "openchemlib": {
128
- "optional": true
129
- },
130
134
  "react-ocl": {
131
135
  "optional": true
132
136
  },
@@ -135,6 +139,9 @@
135
139
  },
136
140
  "vite": {
137
141
  "optional": true
142
+ },
143
+ "xtb-wasm": {
144
+ "optional": true
138
145
  }
139
146
  }
140
147
  }
@@ -0,0 +1,100 @@
1
+ import { Button, ButtonGroup } from '@blueprintjs/core';
2
+ import type { ReactElement } from 'react';
3
+
4
+ /** One value a {@link HeaderToggle} offers. */
5
+ export interface HeaderToggleOption<TValue extends string = string> {
6
+ /** What picking it sets. */
7
+ value: TValue;
8
+ /**
9
+ * What the button reads. It sits in the bar beside every other value, so it
10
+ * is a mark rather than a sentence: `FR`, `°C`.
11
+ */
12
+ label: string;
13
+ /**
14
+ * What the pointer and a screen reader are told, e.g. `Français` behind
15
+ * `FR`.
16
+ * @default the label
17
+ */
18
+ title?: string;
19
+ }
20
+
21
+ /** Props of {@link HeaderToggle}. */
22
+ export interface HeaderToggleProps<TValue extends string = string> {
23
+ /** What the row sets, e.g. `Language`: the name it is read by. */
24
+ label: string;
25
+ /** The values on offer, in the order they are shown. */
26
+ options: ReadonlyArray<HeaderToggleOption<TValue>>;
27
+ /** The value in force. */
28
+ value: TValue;
29
+ /** Called with the value picked. */
30
+ onChange: (value: TValue) => void;
31
+ /**
32
+ * Whether the bar has run out of room: the row is then the one button of the
33
+ * value in force, and a click advances to the next.
34
+ * @default false
35
+ */
36
+ compact?: boolean;
37
+ /**
38
+ * `data-testid` of the row; each button carries it suffixed by its value.
39
+ * @default undefined
40
+ */
41
+ testId?: string;
42
+ }
43
+
44
+ /**
45
+ * A setting of the site header shown as the values themselves, the one in
46
+ * force pressed — the language the page is written in, the scale a temperature
47
+ * is read on.
48
+ *
49
+ * It is a row of buttons rather than a menu: there are two or four values, all
50
+ * of them a mark wide, so a click sets one instead of opening a list to look
51
+ * through, and the bar says what is set without being asked.
52
+ * @param props - The values, the one in force, and what a click changes.
53
+ * @returns The row, or the single advancing button of a narrow bar.
54
+ */
55
+ export function HeaderToggle<TValue extends string>(
56
+ props: HeaderToggleProps<TValue>,
57
+ ): ReactElement | null {
58
+ const { label, options, value, onChange, compact = false, testId } = props;
59
+ const index = options.findIndex((option) => option.value === value);
60
+ const current = options[index === -1 ? 0 : index];
61
+ if (current === undefined) return null;
62
+
63
+ if (compact) {
64
+ const next = options[(options.indexOf(current) + 1) % options.length];
65
+ return (
66
+ <Button
67
+ variant="minimal"
68
+ className="site-toggle site-toggle--compact"
69
+ text={current.label}
70
+ aria-label={`${label}: ${current.title ?? current.label}`}
71
+ title={`${label}: ${current.title ?? current.label}`}
72
+ data-testid={testId}
73
+ onClick={() => {
74
+ if (next !== undefined) onChange(next.value);
75
+ }}
76
+ />
77
+ );
78
+ }
79
+
80
+ return (
81
+ <ButtonGroup className="site-toggle" role="group" aria-label={label}>
82
+ {options.map((option) => (
83
+ <Button
84
+ key={option.value}
85
+ variant="minimal"
86
+ active={option.value === current.value}
87
+ aria-pressed={option.value === current.value}
88
+ text={option.label}
89
+ title={option.title ?? option.label}
90
+ data-testid={
91
+ testId === undefined ? undefined : `${testId}-${option.value}`
92
+ }
93
+ onClick={() => {
94
+ onChange(option.value);
95
+ }}
96
+ />
97
+ ))}
98
+ </ButtonGroup>
99
+ );
100
+ }
@@ -1,3 +1,5 @@
1
+ export type { HeaderToggleOption, HeaderToggleProps } from './HeaderToggle.tsx';
2
+ export { HeaderToggle } from './HeaderToggle.tsx';
1
3
  export type { NavItem } from './navItem.ts';
2
4
  // A site drawing its own link needs the same reading of a click the shared nav
3
5
  // items use: a middle click or a modified one belongs to the browser.
@@ -0,0 +1,32 @@
1
+ import type { Reference } from './reference.ts';
2
+ import type { CitedWork } from './works.ts';
3
+
4
+ /**
5
+ * The paper that defines GFN2-xTB: the semi-empirical tight-binding method, its
6
+ * multipole electrostatics and its D4 dispersion.
7
+ */
8
+ export const GFN2_XTB_PAPER: Reference = {
9
+ authors: [
10
+ { given: 'C.', family: 'Bannwarth' },
11
+ { given: 'S.', family: 'Ehlert' },
12
+ { given: 'S.', family: 'Grimme' },
13
+ ],
14
+ title:
15
+ 'GFN2-xTB — an accurate and broadly parametrized self-consistent tight-binding quantum chemical method with multipole electrostatics and density-dependent dispersion contributions',
16
+ journal: 'Journal of Chemical Theory and Computation',
17
+ journalAbbreviation: 'J. Chem. Theory Comput.',
18
+ year: 2019,
19
+ volume: '15',
20
+ issue: '3',
21
+ firstPage: '1652',
22
+ lastPage: '1671',
23
+ doi: '10.1021/acs.jctc.8b01176',
24
+ publisher: 'American Chemical Society',
25
+ };
26
+
27
+ /** GFN2-xTB, for a site that computes an energy or a geometry with it. */
28
+ export const GFN2_XTB_WORK: CitedWork = {
29
+ reference: GFN2_XTB_PAPER,
30
+ what: 'GFN2-xTB',
31
+ note: 'Cite it for the method behind every refined geometry and energy.',
32
+ };