react-cheminfo 0.134.1 → 0.136.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 (454) hide show
  1. package/README.md +13 -0
  2. package/lib/crystal/core/bondGrid.d.ts +26 -0
  3. package/lib/crystal/core/bondGrid.d.ts.map +1 -0
  4. package/lib/crystal/core/bondGrid.js +76 -0
  5. package/lib/crystal/core/bondGrid.js.map +1 -0
  6. package/lib/crystal/core/cellAtoms.d.ts +43 -0
  7. package/lib/crystal/core/cellAtoms.d.ts.map +1 -0
  8. package/lib/crystal/core/cellAtoms.js +70 -0
  9. package/lib/crystal/core/cellAtoms.js.map +1 -0
  10. package/lib/crystal/core/cellBonds.d.ts +21 -0
  11. package/lib/crystal/core/cellBonds.d.ts.map +1 -0
  12. package/lib/crystal/core/cellBonds.js +100 -0
  13. package/lib/crystal/core/cellBonds.js.map +1 -0
  14. package/lib/crystal/core/cif/element.d.ts +9 -0
  15. package/lib/crystal/core/cif/element.d.ts.map +1 -0
  16. package/lib/crystal/core/cif/element.js +41 -0
  17. package/lib/crystal/core/cif/element.js.map +1 -0
  18. package/lib/crystal/core/cif/index.d.ts +4 -0
  19. package/lib/crystal/core/cif/index.d.ts.map +1 -0
  20. package/lib/crystal/core/cif/index.js +3 -0
  21. package/lib/crystal/core/cif/index.js.map +1 -0
  22. package/lib/crystal/core/cif/number.d.ts +27 -0
  23. package/lib/crystal/core/cif/number.d.ts.map +1 -0
  24. package/lib/crystal/core/cif/number.js +57 -0
  25. package/lib/crystal/core/cif/number.js.map +1 -0
  26. package/lib/crystal/core/cif/read.d.ts +12 -0
  27. package/lib/crystal/core/cif/read.d.ts.map +1 -0
  28. package/lib/crystal/core/cif/read.js +183 -0
  29. package/lib/crystal/core/cif/read.js.map +1 -0
  30. package/lib/crystal/core/cif/readGeometry.d.ts +17 -0
  31. package/lib/crystal/core/cif/readGeometry.d.ts.map +1 -0
  32. package/lib/crystal/core/cif/readGeometry.js +93 -0
  33. package/lib/crystal/core/cif/readGeometry.js.map +1 -0
  34. package/lib/crystal/core/cif/tags.d.ts +62 -0
  35. package/lib/crystal/core/cif/tags.d.ts.map +1 -0
  36. package/lib/crystal/core/cif/tags.js +115 -0
  37. package/lib/crystal/core/cif/tags.js.map +1 -0
  38. package/lib/crystal/core/cif/types.d.ts +158 -0
  39. package/lib/crystal/core/cif/types.d.ts.map +1 -0
  40. package/lib/crystal/core/cif/types.js +2 -0
  41. package/lib/crystal/core/cif/types.js.map +1 -0
  42. package/lib/crystal/core/components.d.ts +56 -0
  43. package/lib/crystal/core/components.d.ts.map +1 -0
  44. package/lib/crystal/core/components.js +132 -0
  45. package/lib/crystal/core/components.js.map +1 -0
  46. package/lib/crystal/core/covalentRadii.d.ts +24 -0
  47. package/lib/crystal/core/covalentRadii.d.ts.map +1 -0
  48. package/lib/crystal/core/covalentRadii.js +55 -0
  49. package/lib/crystal/core/covalentRadii.js.map +1 -0
  50. package/lib/crystal/core/disorder.d.ts +59 -0
  51. package/lib/crystal/core/disorder.d.ts.map +1 -0
  52. package/lib/crystal/core/disorder.js +168 -0
  53. package/lib/crystal/core/disorder.js.map +1 -0
  54. package/lib/crystal/core/expand.d.ts +62 -0
  55. package/lib/crystal/core/expand.d.ts.map +1 -0
  56. package/lib/crystal/core/expand.js +61 -0
  57. package/lib/crystal/core/expand.js.map +1 -0
  58. package/lib/crystal/core/index.d.ts +20 -0
  59. package/lib/crystal/core/index.d.ts.map +1 -0
  60. package/lib/crystal/core/index.js +13 -0
  61. package/lib/crystal/core/index.js.map +1 -0
  62. package/lib/crystal/core/moleculeOf.d.ts +31 -0
  63. package/lib/crystal/core/moleculeOf.d.ts.map +1 -0
  64. package/lib/crystal/core/moleculeOf.js +128 -0
  65. package/lib/crystal/core/moleculeOf.js.map +1 -0
  66. package/lib/crystal/core/moleculeTypes.d.ts +80 -0
  67. package/lib/crystal/core/moleculeTypes.d.ts.map +1 -0
  68. package/lib/crystal/core/moleculeTypes.js +2 -0
  69. package/lib/crystal/core/moleculeTypes.js.map +1 -0
  70. package/lib/crystal/core/molecules.d.ts +39 -0
  71. package/lib/crystal/core/molecules.d.ts.map +1 -0
  72. package/lib/crystal/core/molecules.js +106 -0
  73. package/lib/crystal/core/molecules.js.map +1 -0
  74. package/lib/crystal/core/operations.d.ts +19 -0
  75. package/lib/crystal/core/operations.d.ts.map +1 -0
  76. package/lib/crystal/core/operations.js +68 -0
  77. package/lib/crystal/core/operations.js.map +1 -0
  78. package/lib/crystal/core/packing.d.ts +43 -0
  79. package/lib/crystal/core/packing.d.ts.map +1 -0
  80. package/lib/crystal/core/packing.js +89 -0
  81. package/lib/crystal/core/packing.js.map +1 -0
  82. package/lib/crystal/core/periodicBonds.d.ts +57 -0
  83. package/lib/crystal/core/periodicBonds.d.ts.map +1 -0
  84. package/lib/crystal/core/periodicBonds.js +167 -0
  85. package/lib/crystal/core/periodicBonds.js.map +1 -0
  86. package/lib/crystal/core/resolve.d.ts +61 -0
  87. package/lib/crystal/core/resolve.d.ts.map +1 -0
  88. package/lib/crystal/core/resolve.js +149 -0
  89. package/lib/crystal/core/resolve.js.map +1 -0
  90. package/lib/crystal/core/spaceGroups/index.d.ts +5 -0
  91. package/lib/crystal/core/spaceGroups/index.d.ts.map +1 -0
  92. package/lib/crystal/core/spaceGroups/index.js +4 -0
  93. package/lib/crystal/core/spaceGroups/index.js.map +1 -0
  94. package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts +14 -0
  95. package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts.map +1 -0
  96. package/lib/crystal/core/spaceGroups/spaceGroupOperations.js +24 -0
  97. package/lib/crystal/core/spaceGroups/spaceGroupOperations.js.map +1 -0
  98. package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts +3 -0
  99. package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts.map +1 -0
  100. package/lib/crystal/core/spaceGroups/spaceGroupRows.js +536 -0
  101. package/lib/crystal/core/spaceGroups/spaceGroupRows.js.map +1 -0
  102. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts +43 -0
  103. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts.map +1 -0
  104. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js +169 -0
  105. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js.map +1 -0
  106. package/lib/crystal/core/spaceGroups/spaceGroups.d.ts +78 -0
  107. package/lib/crystal/core/spaceGroups/spaceGroups.d.ts.map +1 -0
  108. package/lib/crystal/core/spaceGroups/spaceGroups.js +83 -0
  109. package/lib/crystal/core/spaceGroups/spaceGroups.js.map +1 -0
  110. package/lib/crystal/core/symmetry/group.d.ts +15 -0
  111. package/lib/crystal/core/symmetry/group.d.ts.map +1 -0
  112. package/lib/crystal/core/symmetry/group.js +37 -0
  113. package/lib/crystal/core/symmetry/group.js.map +1 -0
  114. package/lib/crystal/core/symmetry/index.d.ts +8 -0
  115. package/lib/crystal/core/symmetry/index.d.ts.map +1 -0
  116. package/lib/crystal/core/symmetry/index.js +6 -0
  117. package/lib/crystal/core/symmetry/index.js.map +1 -0
  118. package/lib/crystal/core/symmetry/integerMatrix.d.ts +45 -0
  119. package/lib/crystal/core/symmetry/integerMatrix.d.ts.map +1 -0
  120. package/lib/crystal/core/symmetry/integerMatrix.js +139 -0
  121. package/lib/crystal/core/symmetry/integerMatrix.js.map +1 -0
  122. package/lib/crystal/core/symmetry/lattice.d.ts +64 -0
  123. package/lib/crystal/core/symmetry/lattice.d.ts.map +1 -0
  124. package/lib/crystal/core/symmetry/lattice.js +113 -0
  125. package/lib/crystal/core/symmetry/lattice.js.map +1 -0
  126. package/lib/crystal/core/symmetry/operation.d.ts +91 -0
  127. package/lib/crystal/core/symmetry/operation.d.ts.map +1 -0
  128. package/lib/crystal/core/symmetry/operation.js +184 -0
  129. package/lib/crystal/core/symmetry/operation.js.map +1 -0
  130. package/lib/crystal/core/symmetry/parseOperation.d.ts +18 -0
  131. package/lib/crystal/core/symmetry/parseOperation.d.ts.map +1 -0
  132. package/lib/crystal/core/symmetry/parseOperation.js +145 -0
  133. package/lib/crystal/core/symmetry/parseOperation.js.map +1 -0
  134. package/lib/crystal/core/symmetry/types.d.ts +29 -0
  135. package/lib/crystal/core/symmetry/types.d.ts.map +1 -0
  136. package/lib/crystal/core/symmetry/types.js +5 -0
  137. package/lib/crystal/core/symmetry/types.js.map +1 -0
  138. package/lib/crystal/core/symmetryClasses.d.ts +28 -0
  139. package/lib/crystal/core/symmetryClasses.d.ts.map +1 -0
  140. package/lib/crystal/core/symmetryClasses.js +93 -0
  141. package/lib/crystal/core/symmetryClasses.js.map +1 -0
  142. package/lib/crystal.d.ts +12 -0
  143. package/lib/crystal.d.ts.map +1 -0
  144. package/lib/crystal.js +12 -0
  145. package/lib/crystal.js.map +1 -0
  146. package/lib/crystal3d/core/cellClip.d.ts +46 -0
  147. package/lib/crystal3d/core/cellClip.d.ts.map +1 -0
  148. package/lib/crystal3d/core/cellClip.js +198 -0
  149. package/lib/crystal3d/core/cellClip.js.map +1 -0
  150. package/lib/crystal3d/core/cellGeometry.d.ts +63 -0
  151. package/lib/crystal3d/core/cellGeometry.d.ts.map +1 -0
  152. package/lib/crystal3d/core/cellGeometry.js +153 -0
  153. package/lib/crystal3d/core/cellGeometry.js.map +1 -0
  154. package/lib/crystal3d/core/cellStack.d.ts +51 -0
  155. package/lib/crystal3d/core/cellStack.d.ts.map +1 -0
  156. package/lib/crystal3d/core/cellStack.js +79 -0
  157. package/lib/crystal3d/core/cellStack.js.map +1 -0
  158. package/lib/crystal3d/core/crystalView.d.ts +71 -0
  159. package/lib/crystal3d/core/crystalView.d.ts.map +1 -0
  160. package/lib/crystal3d/core/crystalView.js +48 -0
  161. package/lib/crystal3d/core/crystalView.js.map +1 -0
  162. package/lib/crystal3d/core/drawingSet.d.ts +31 -0
  163. package/lib/crystal3d/core/drawingSet.d.ts.map +1 -0
  164. package/lib/crystal3d/core/drawingSet.js +63 -0
  165. package/lib/crystal3d/core/drawingSet.js.map +1 -0
  166. package/lib/crystal3d/core/elementDrawing.d.ts +50 -0
  167. package/lib/crystal3d/core/elementDrawing.d.ts.map +1 -0
  168. package/lib/crystal3d/core/elementDrawing.js +100 -0
  169. package/lib/crystal3d/core/elementDrawing.js.map +1 -0
  170. package/lib/crystal3d/core/elementExtent.d.ts +42 -0
  171. package/lib/crystal3d/core/elementExtent.d.ts.map +1 -0
  172. package/lib/crystal3d/core/elementExtent.js +56 -0
  173. package/lib/crystal3d/core/elementExtent.js.map +1 -0
  174. package/lib/crystal3d/core/elementLabels.d.ts +31 -0
  175. package/lib/crystal3d/core/elementLabels.d.ts.map +1 -0
  176. package/lib/crystal3d/core/elementLabels.js +99 -0
  177. package/lib/crystal3d/core/elementLabels.js.map +1 -0
  178. package/lib/crystal3d/core/elementShapes.d.ts +43 -0
  179. package/lib/crystal3d/core/elementShapes.d.ts.map +1 -0
  180. package/lib/crystal3d/core/elementShapes.js +115 -0
  181. package/lib/crystal3d/core/elementShapes.js.map +1 -0
  182. package/lib/crystal3d/core/frame.d.ts +36 -0
  183. package/lib/crystal3d/core/frame.d.ts.map +1 -0
  184. package/lib/crystal3d/core/frame.js +35 -0
  185. package/lib/crystal3d/core/frame.js.map +1 -0
  186. package/lib/crystal3d/core/framing.d.ts +41 -0
  187. package/lib/crystal3d/core/framing.d.ts.map +1 -0
  188. package/lib/crystal3d/core/framing.js +79 -0
  189. package/lib/crystal3d/core/framing.js.map +1 -0
  190. package/lib/crystal3d/core/index.d.ts +42 -0
  191. package/lib/crystal3d/core/index.d.ts.map +1 -0
  192. package/lib/crystal3d/core/index.js +29 -0
  193. package/lib/crystal3d/core/index.js.map +1 -0
  194. package/lib/crystal3d/core/labelText.d.ts +19 -0
  195. package/lib/crystal3d/core/labelText.d.ts.map +1 -0
  196. package/lib/crystal3d/core/labelText.js +42 -0
  197. package/lib/crystal3d/core/labelText.js.map +1 -0
  198. package/lib/crystal3d/core/latticeBasis.d.ts +49 -0
  199. package/lib/crystal3d/core/latticeBasis.d.ts.map +1 -0
  200. package/lib/crystal3d/core/latticeBasis.js +89 -0
  201. package/lib/crystal3d/core/latticeBasis.js.map +1 -0
  202. package/lib/crystal3d/core/mat3.d.ts +68 -0
  203. package/lib/crystal3d/core/mat3.d.ts.map +1 -0
  204. package/lib/crystal3d/core/mat3.js +146 -0
  205. package/lib/crystal3d/core/mat3.js.map +1 -0
  206. package/lib/crystal3d/core/operationMatrix.d.ts +44 -0
  207. package/lib/crystal3d/core/operationMatrix.d.ts.map +1 -0
  208. package/lib/crystal3d/core/operationMatrix.js +172 -0
  209. package/lib/crystal3d/core/operationMatrix.js.map +1 -0
  210. package/lib/crystal3d/core/orientation.d.ts +62 -0
  211. package/lib/crystal3d/core/orientation.d.ts.map +1 -0
  212. package/lib/crystal3d/core/orientation.js +166 -0
  213. package/lib/crystal3d/core/orientation.js.map +1 -0
  214. package/lib/crystal3d/core/palette.d.ts +24 -0
  215. package/lib/crystal3d/core/palette.d.ts.map +1 -0
  216. package/lib/crystal3d/core/palette.js +34 -0
  217. package/lib/crystal3d/core/palette.js.map +1 -0
  218. package/lib/crystal3d/core/primitives.d.ts +133 -0
  219. package/lib/crystal3d/core/primitives.d.ts.map +1 -0
  220. package/lib/crystal3d/core/primitives.js +80 -0
  221. package/lib/crystal3d/core/primitives.js.map +1 -0
  222. package/lib/crystal3d/core/structureText.d.ts +20 -0
  223. package/lib/crystal3d/core/structureText.d.ts.map +1 -0
  224. package/lib/crystal3d/core/structureText.js +37 -0
  225. package/lib/crystal3d/core/structureText.js.map +1 -0
  226. package/lib/crystal3d/core/supercell.d.ts +20 -0
  227. package/lib/crystal3d/core/supercell.d.ts.map +1 -0
  228. package/lib/crystal3d/core/supercell.js +35 -0
  229. package/lib/crystal3d/core/supercell.js.map +1 -0
  230. package/lib/crystal3d/core/types.d.ts +166 -0
  231. package/lib/crystal3d/core/types.d.ts.map +1 -0
  232. package/lib/crystal3d/core/types.js +10 -0
  233. package/lib/crystal3d/core/types.js.map +1 -0
  234. package/lib/crystal3d/core/vec3.d.ts +75 -0
  235. package/lib/crystal3d/core/vec3.d.ts.map +1 -0
  236. package/lib/crystal3d/core/vec3.js +119 -0
  237. package/lib/crystal3d/core/vec3.js.map +1 -0
  238. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +52 -0
  239. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -0
  240. package/lib/crystal3d/ui/CrystalCanvas3D.js +242 -0
  241. package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -0
  242. package/lib/crystal3d/ui/CrystalStructureView.d.ts +17 -0
  243. package/lib/crystal3d/ui/CrystalStructureView.d.ts.map +1 -0
  244. package/lib/crystal3d/ui/CrystalStructureView.js +76 -0
  245. package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -0
  246. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts +22 -0
  247. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts.map +1 -0
  248. package/lib/crystal3d/ui/CrystalStructureViewer.js +29 -0
  249. package/lib/crystal3d/ui/CrystalStructureViewer.js.map +1 -0
  250. package/lib/crystal3d/ui/CrystalViewControls.d.ts +25 -0
  251. package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -0
  252. package/lib/crystal3d/ui/CrystalViewControls.js +22 -0
  253. package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -0
  254. package/lib/crystal3d/ui/CrystalViewer3D.d.ts +72 -0
  255. package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -0
  256. package/lib/crystal3d/ui/CrystalViewer3D.js +70 -0
  257. package/lib/crystal3d/ui/CrystalViewer3D.js.map +1 -0
  258. package/lib/crystal3d/ui/crystalScene.d.ts +91 -0
  259. package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -0
  260. package/lib/crystal3d/ui/crystalScene.js +10 -0
  261. package/lib/crystal3d/ui/crystalScene.js.map +1 -0
  262. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +52 -0
  263. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -0
  264. package/lib/crystal3d/ui/crystalStructureViewerProps.js +2 -0
  265. package/lib/crystal3d/ui/crystalStructureViewerProps.js.map +1 -0
  266. package/lib/crystal3d/ui/index.d.ts +16 -0
  267. package/lib/crystal3d/ui/index.d.ts.map +1 -0
  268. package/lib/crystal3d/ui/index.js +12 -0
  269. package/lib/crystal3d/ui/index.js.map +1 -0
  270. package/lib/crystal3d/ui/useCrystalCaption.d.ts +14 -0
  271. package/lib/crystal3d/ui/useCrystalCaption.d.ts.map +1 -0
  272. package/lib/crystal3d/ui/useCrystalCaption.js +32 -0
  273. package/lib/crystal3d/ui/useCrystalCaption.js.map +1 -0
  274. package/lib/crystal3d/viewer/animate.d.ts +49 -0
  275. package/lib/crystal3d/viewer/animate.d.ts.map +1 -0
  276. package/lib/crystal3d/viewer/animate.js +83 -0
  277. package/lib/crystal3d/viewer/animate.js.map +1 -0
  278. package/lib/crystal3d/viewer/camera.d.ts +44 -0
  279. package/lib/crystal3d/viewer/camera.d.ts.map +1 -0
  280. package/lib/crystal3d/viewer/camera.js +103 -0
  281. package/lib/crystal3d/viewer/camera.js.map +1 -0
  282. package/lib/crystal3d/viewer/index.d.ts +13 -0
  283. package/lib/crystal3d/viewer/index.d.ts.map +1 -0
  284. package/lib/crystal3d/viewer/index.js +8 -0
  285. package/lib/crystal3d/viewer/index.js.map +1 -0
  286. package/lib/crystal3d/viewer/layerRegistry.d.ts +24 -0
  287. package/lib/crystal3d/viewer/layerRegistry.d.ts.map +1 -0
  288. package/lib/crystal3d/viewer/layerRegistry.js +39 -0
  289. package/lib/crystal3d/viewer/layerRegistry.js.map +1 -0
  290. package/lib/crystal3d/viewer/meshPrimitives.d.ts +13 -0
  291. package/lib/crystal3d/viewer/meshPrimitives.d.ts.map +1 -0
  292. package/lib/crystal3d/viewer/meshPrimitives.js +76 -0
  293. package/lib/crystal3d/viewer/meshPrimitives.js.map +1 -0
  294. package/lib/crystal3d/viewer/plugin.d.ts +133 -0
  295. package/lib/crystal3d/viewer/plugin.d.ts.map +1 -0
  296. package/lib/crystal3d/viewer/plugin.js +181 -0
  297. package/lib/crystal3d/viewer/plugin.js.map +1 -0
  298. package/lib/crystal3d/viewer/renderCell.d.ts +43 -0
  299. package/lib/crystal3d/viewer/renderCell.d.ts.map +1 -0
  300. package/lib/crystal3d/viewer/renderCell.js +53 -0
  301. package/lib/crystal3d/viewer/renderCell.js.map +1 -0
  302. package/lib/crystal3d/viewer/renderElements.d.ts +54 -0
  303. package/lib/crystal3d/viewer/renderElements.d.ts.map +1 -0
  304. package/lib/crystal3d/viewer/renderElements.js +77 -0
  305. package/lib/crystal3d/viewer/renderElements.js.map +1 -0
  306. package/lib/crystal3d/viewer/renderStructure.d.ts +55 -0
  307. package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -0
  308. package/lib/crystal3d/viewer/renderStructure.js +103 -0
  309. package/lib/crystal3d/viewer/renderStructure.js.map +1 -0
  310. package/lib/crystal3d/viewer/sceneParts.d.ts +32 -0
  311. package/lib/crystal3d/viewer/sceneParts.d.ts.map +1 -0
  312. package/lib/crystal3d/viewer/sceneParts.js +77 -0
  313. package/lib/crystal3d/viewer/sceneParts.js.map +1 -0
  314. package/lib/crystal3d/viewer/shapeLayer.d.ts +41 -0
  315. package/lib/crystal3d/viewer/shapeLayer.d.ts.map +1 -0
  316. package/lib/crystal3d/viewer/shapeLayer.js +57 -0
  317. package/lib/crystal3d/viewer/shapeLayer.js.map +1 -0
  318. package/lib/crystal3d/viewer/textLayer.d.ts +21 -0
  319. package/lib/crystal3d/viewer/textLayer.d.ts.map +1 -0
  320. package/lib/crystal3d/viewer/textLayer.js +59 -0
  321. package/lib/crystal3d/viewer/textLayer.js.map +1 -0
  322. package/lib/crystal3d/viewer/viewer.d.ts +110 -0
  323. package/lib/crystal3d/viewer/viewer.d.ts.map +1 -0
  324. package/lib/crystal3d/viewer/viewer.js +157 -0
  325. package/lib/crystal3d/viewer/viewer.js.map +1 -0
  326. package/lib/crystal3d.d.ts +12 -0
  327. package/lib/crystal3d.d.ts.map +1 -0
  328. package/lib/crystal3d.js +12 -0
  329. package/lib/crystal3d.js.map +1 -0
  330. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  331. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  332. package/lib/locales/de.json +19 -1
  333. package/lib/locales/en.json +19 -1
  334. package/lib/locales/es.json +19 -1
  335. package/lib/locales/fr.json +19 -1
  336. package/lib/locales/it.json +19 -1
  337. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  338. package/lib/molecule3d/ui/MoleculeCanvas3D.js +16 -27
  339. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  340. package/lib/molstar/bonds/bondRule.d.ts +16 -0
  341. package/lib/molstar/bonds/bondRule.d.ts.map +1 -0
  342. package/lib/molstar/bonds/bondRule.js +23 -0
  343. package/lib/molstar/bonds/bondRule.js.map +1 -0
  344. package/lib/molstar/bonds/index.d.ts +9 -0
  345. package/lib/molstar/bonds/index.d.ts.map +1 -0
  346. package/lib/molstar/bonds/index.js +9 -0
  347. package/lib/molstar/bonds/index.js.map +1 -0
  348. package/lib/molstar/ui/MolstarToolbar.d.ts +47 -0
  349. package/lib/molstar/ui/MolstarToolbar.d.ts.map +1 -0
  350. package/lib/molstar/ui/MolstarToolbar.js +28 -0
  351. package/lib/molstar/ui/MolstarToolbar.js.map +1 -0
  352. package/lib/molstar/ui/index.d.ts +10 -0
  353. package/lib/molstar/ui/index.d.ts.map +1 -0
  354. package/lib/molstar/ui/index.js +8 -0
  355. package/lib/molstar/ui/index.js.map +1 -0
  356. package/lib/molstar/ui/useMolstarTools.d.ts +63 -0
  357. package/lib/molstar/ui/useMolstarTools.d.ts.map +1 -0
  358. package/lib/molstar/ui/useMolstarTools.js +36 -0
  359. package/lib/molstar/ui/useMolstarTools.js.map +1 -0
  360. package/package.json +4 -1
  361. package/src/crystal/core/bondGrid.ts +98 -0
  362. package/src/crystal/core/cellAtoms.ts +106 -0
  363. package/src/crystal/core/cellBonds.ts +121 -0
  364. package/src/crystal/core/cif/element.ts +40 -0
  365. package/src/crystal/core/cif/index.ts +12 -0
  366. package/src/crystal/core/cif/number.ts +62 -0
  367. package/src/crystal/core/cif/read.ts +218 -0
  368. package/src/crystal/core/cif/readGeometry.ts +104 -0
  369. package/src/crystal/core/cif/tags.ts +143 -0
  370. package/src/crystal/core/cif/types.ts +164 -0
  371. package/src/crystal/core/components.ts +183 -0
  372. package/src/crystal/core/covalentRadii.ts +56 -0
  373. package/src/crystal/core/disorder.ts +190 -0
  374. package/src/crystal/core/expand.ts +105 -0
  375. package/src/crystal/core/index.ts +46 -0
  376. package/src/crystal/core/moleculeOf.ts +169 -0
  377. package/src/crystal/core/moleculeTypes.ts +85 -0
  378. package/src/crystal/core/molecules.ts +128 -0
  379. package/src/crystal/core/operations.ts +79 -0
  380. package/src/crystal/core/packing.ts +116 -0
  381. package/src/crystal/core/periodicBonds.ts +234 -0
  382. package/src/crystal/core/resolve.ts +187 -0
  383. package/src/crystal/core/spaceGroups/index.ts +16 -0
  384. package/src/crystal/core/spaceGroups/spaceGroupOperations.ts +32 -0
  385. package/src/crystal/core/spaceGroups/spaceGroupRows.ts +536 -0
  386. package/src/crystal/core/spaceGroups/spaceGroupSymbols.ts +179 -0
  387. package/src/crystal/core/spaceGroups/spaceGroups.ts +154 -0
  388. package/src/crystal/core/symmetry/group.ts +42 -0
  389. package/src/crystal/core/symmetry/index.ts +23 -0
  390. package/src/crystal/core/symmetry/integerMatrix.ts +153 -0
  391. package/src/crystal/core/symmetry/lattice.ts +152 -0
  392. package/src/crystal/core/symmetry/operation.ts +223 -0
  393. package/src/crystal/core/symmetry/parseOperation.ts +180 -0
  394. package/src/crystal/core/symmetry/types.ts +32 -0
  395. package/src/crystal/core/symmetryClasses.ts +105 -0
  396. package/src/crystal.ts +12 -0
  397. package/src/crystal3d/core/cellClip.ts +229 -0
  398. package/src/crystal3d/core/cellGeometry.ts +193 -0
  399. package/src/crystal3d/core/cellStack.ts +87 -0
  400. package/src/crystal3d/core/crystalView.ts +114 -0
  401. package/src/crystal3d/core/drawingSet.ts +71 -0
  402. package/src/crystal3d/core/elementDrawing.ts +147 -0
  403. package/src/crystal3d/core/elementExtent.ts +81 -0
  404. package/src/crystal3d/core/elementLabels.ts +130 -0
  405. package/src/crystal3d/core/elementShapes.ts +141 -0
  406. package/src/crystal3d/core/frame.ts +56 -0
  407. package/src/crystal3d/core/framing.ts +101 -0
  408. package/src/crystal3d/core/index.ts +132 -0
  409. package/src/crystal3d/core/labelText.ts +44 -0
  410. package/src/crystal3d/core/latticeBasis.ts +110 -0
  411. package/src/crystal3d/core/mat3.ts +163 -0
  412. package/src/crystal3d/core/operationMatrix.ts +255 -0
  413. package/src/crystal3d/core/orientation.ts +229 -0
  414. package/src/crystal3d/core/palette.ts +43 -0
  415. package/src/crystal3d/core/primitives.ts +183 -0
  416. package/src/crystal3d/core/structureText.ts +43 -0
  417. package/src/crystal3d/core/supercell.ts +40 -0
  418. package/src/crystal3d/core/types.ts +186 -0
  419. package/src/crystal3d/core/vec3.ts +127 -0
  420. package/src/crystal3d/ui/CrystalCanvas3D.tsx +384 -0
  421. package/src/crystal3d/ui/CrystalStructureView.tsx +148 -0
  422. package/src/crystal3d/ui/CrystalStructureViewer.tsx +39 -0
  423. package/src/crystal3d/ui/CrystalViewControls.tsx +100 -0
  424. package/src/crystal3d/ui/CrystalViewer3D.tsx +183 -0
  425. package/src/crystal3d/ui/crystalScene.ts +100 -0
  426. package/src/crystal3d/ui/crystalStructureViewerProps.ts +54 -0
  427. package/src/crystal3d/ui/index.ts +20 -0
  428. package/src/crystal3d/ui/useCrystalCaption.ts +38 -0
  429. package/src/crystal3d/viewer/animate.ts +113 -0
  430. package/src/crystal3d/viewer/camera.ts +139 -0
  431. package/src/crystal3d/viewer/index.ts +13 -0
  432. package/src/crystal3d/viewer/layerRegistry.ts +47 -0
  433. package/src/crystal3d/viewer/meshPrimitives.ts +102 -0
  434. package/src/crystal3d/viewer/plugin.ts +258 -0
  435. package/src/crystal3d/viewer/renderCell.ts +98 -0
  436. package/src/crystal3d/viewer/renderElements.ts +121 -0
  437. package/src/crystal3d/viewer/renderStructure.ts +144 -0
  438. package/src/crystal3d/viewer/sceneParts.ts +119 -0
  439. package/src/crystal3d/viewer/shapeLayer.ts +108 -0
  440. package/src/crystal3d/viewer/textLayer.ts +85 -0
  441. package/src/crystal3d/viewer/viewer.ts +207 -0
  442. package/src/crystal3d.ts +12 -0
  443. package/src/locales/de.json +19 -1
  444. package/src/locales/en.json +19 -1
  445. package/src/locales/es.json +19 -1
  446. package/src/locales/fr.json +19 -1
  447. package/src/locales/it.json +19 -1
  448. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +45 -71
  449. package/src/molstar/bonds/bondRule.ts +34 -0
  450. package/src/molstar/bonds/index.ts +9 -0
  451. package/src/molstar/ui/MolstarToolbar.tsx +103 -0
  452. package/src/molstar/ui/index.ts +14 -0
  453. package/src/molstar/ui/useMolstarTools.ts +98 -0
  454. package/styles/chrome.css +90 -0
@@ -0,0 +1,143 @@
1
+ import type { CifJson } from 'cif-to-json';
2
+
3
+ /** One `loop_` row, keyed on the lowercased tag of each column. */
4
+ export type CifRowIndex = ReadonlyMap<string, string>;
5
+
6
+ /** A parsed CIF, with every tag folded to lower case so lookups are case-blind. */
7
+ export interface CifIndex {
8
+ /** Every scalar tag of the block. */
9
+ readonly scalars: ReadonlyMap<string, string>;
10
+ /** Every `loop_` of the block, in file order. */
11
+ readonly loops: ReadonlyArray<readonly CifRowIndex[]>;
12
+ }
13
+
14
+ /**
15
+ * Fold a parsed CIF so every tag can be looked up whatever case it was written in.
16
+ *
17
+ * CIF tags are case-insensitive and real files disagree: COD writes
18
+ * `_symmetry_Int_Tables_number`, other producers write it all in lower case.
19
+ * `cif-to-json` stores the tag verbatim, so the folding has to happen here.
20
+ * @param parsed - the output of `cifParser`.
21
+ * @returns the folded index.
22
+ */
23
+ export function indexCif(parsed: CifJson): CifIndex {
24
+ const scalars = new Map<string, string>();
25
+ const loops: Array<readonly CifRowIndex[]> = [];
26
+ for (const [tag, value] of Object.entries(parsed)) {
27
+ if (typeof value === 'string') {
28
+ scalars.set(tag.toLowerCase(), value);
29
+ continue;
30
+ }
31
+ const rows: CifRowIndex[] = [];
32
+ for (const source of value) {
33
+ const row = new Map<string, string>();
34
+ for (const [column, cell] of Object.entries(source)) {
35
+ row.set(column.toLowerCase(), cell);
36
+ }
37
+ rows.push(row);
38
+ }
39
+ loops.push(rows);
40
+ }
41
+ return { scalars, loops };
42
+ }
43
+
44
+ /**
45
+ * Read a scalar tag, trying each alias in turn.
46
+ * @param index - the folded CIF.
47
+ * @param aliases - the tags to try, lowercased, most current first.
48
+ * @returns the trimmed value, or `null` when no alias carries one.
49
+ */
50
+ export function scalarTag(
51
+ index: CifIndex,
52
+ aliases: readonly string[],
53
+ ): string | null {
54
+ for (const alias of aliases) {
55
+ const value = index.scalars.get(alias);
56
+ if (value !== undefined && value.trim() !== '') return value.trim();
57
+ }
58
+ return null;
59
+ }
60
+
61
+ /**
62
+ * Find the loop that carries one of these columns.
63
+ *
64
+ * `cif-to-json` keys a loop on the longest common prefix of its column tags, so
65
+ * the key changes with the optional columns a file happened to write: the same
66
+ * operation list arrives as `_space_group_symop`, `_symmetry_equiv_pos` or the
67
+ * full tag. Searching the columns instead of the key is immune to that.
68
+ * @param index - the folded CIF.
69
+ * @param aliases - the column tags to look for, lowercased.
70
+ * @returns the loop's rows, or `null` when no loop carries any of them.
71
+ */
72
+ export function loopWith(
73
+ index: CifIndex,
74
+ aliases: readonly string[],
75
+ ): readonly CifRowIndex[] | null {
76
+ for (const rows of index.loops) {
77
+ const first = rows[0];
78
+ if (first === undefined) continue;
79
+ for (const alias of aliases) {
80
+ if (first.has(alias)) return rows;
81
+ }
82
+ }
83
+ return null;
84
+ }
85
+
86
+ /**
87
+ * Read one cell of a loop row, trying each alias in turn.
88
+ * @param row - the row.
89
+ * @param aliases - the column tags to try, lowercased.
90
+ * @returns the trimmed value, or `null` when no alias carries one.
91
+ */
92
+ export function rowTag(
93
+ row: CifRowIndex,
94
+ aliases: readonly string[],
95
+ ): string | null {
96
+ for (const alias of aliases) {
97
+ const value = row.get(alias);
98
+ if (value !== undefined && value.trim() !== '') return value.trim();
99
+ }
100
+ return null;
101
+ }
102
+
103
+ /**
104
+ * Read one cell of a loop row that may be left unknown or inapplicable.
105
+ * @param row - the row.
106
+ * @param aliases - the column tags to try, lowercased.
107
+ * @returns the trimmed value, or `null` when it is absent, `.` or `?`.
108
+ */
109
+ export function optionalRowTag(
110
+ row: CifRowIndex,
111
+ aliases: readonly string[],
112
+ ): string | null {
113
+ const value = rowTag(row, aliases);
114
+ return value === null || ['.', '?'].includes(value) ? null : value;
115
+ }
116
+
117
+ /** The four tags a file may carry its symmetry operations under. */
118
+ export const SYMOP_TAGS = [
119
+ '_space_group_symop_operation_xyz',
120
+ '_space_group_symop.operation_xyz',
121
+ '_symmetry_equiv_pos_as_xyz',
122
+ '_symmetry_equiv_pos.as_xyz',
123
+ ] as const;
124
+
125
+ /** The two tags a file may carry its International Tables number under. */
126
+ export const IT_NUMBER_TAGS = [
127
+ '_space_group_it_number',
128
+ '_symmetry_int_tables_number',
129
+ ] as const;
130
+
131
+ /** The tags a file may carry its Hermann-Mauguin symbol under. */
132
+ export const HM_TAGS = [
133
+ '_space_group_name_h-m_alt',
134
+ '_space_group_name_h-m_full',
135
+ '_symmetry_space_group_name_h-m',
136
+ '_cod_original_sg_symbol_h-m',
137
+ ] as const;
138
+
139
+ /** The tags a file may carry its Hall symbol under. */
140
+ export const HALL_TAGS = [
141
+ '_space_group_name_hall',
142
+ '_symmetry_space_group_name_hall',
143
+ ] as const;
@@ -0,0 +1,164 @@
1
+ /** A number read from a CIF, with the standard uncertainty the file wrote it with. */
2
+ export interface CifNumber {
3
+ /** The value, with the parenthesised standard uncertainty removed. */
4
+ readonly value: number;
5
+ /**
6
+ * The standard uncertainty, in the unit of `value`: `0.30475(3)` gives `0.00003`.
7
+ * `null` when the token carried none.
8
+ */
9
+ readonly su: number | null;
10
+ /** The token exactly as the file wrote it, e.g. `0.30475(3)`. */
11
+ readonly raw: string;
12
+ }
13
+
14
+ /** The unit cell: three edges in ångström, three angles in degrees. */
15
+ export interface CrystalCell {
16
+ readonly a: number;
17
+ readonly b: number;
18
+ readonly c: number;
19
+ readonly alpha: number;
20
+ readonly beta: number;
21
+ readonly gamma: number;
22
+ }
23
+
24
+ /** The space group as the file names it, plus the number when the file gives one. */
25
+ export interface CrystalSpaceGroup {
26
+ /** `_space_group_IT_number`, else `_symmetry_Int_Tables_number`. 1 to 230. */
27
+ readonly number: number | null;
28
+ /** The Hermann-Mauguin symbol, spaced as the file wrote it, e.g. `F m -3 m`. */
29
+ readonly hm: string | null;
30
+ /** The Hall symbol, e.g. `-F 4 2 3`. */
31
+ readonly hall: string | null;
32
+ }
33
+
34
+ /** One entry of the `_atom_site` loop: an atom of the asymmetric unit. */
35
+ export interface CrystalSite {
36
+ /** `_atom_site_label`, e.g. `Na1`. Unique within the file, and not an element. */
37
+ readonly label: string;
38
+ /**
39
+ * The chemical symbol, from `_atom_site_type_symbol` with any charge removed,
40
+ * else from the letters that open `label`.
41
+ */
42
+ readonly element: string;
43
+ /** Fractional coordinate along **a**. */
44
+ readonly x: number;
45
+ /** Fractional coordinate along **b**. */
46
+ readonly y: number;
47
+ /** Fractional coordinate along **c**. */
48
+ readonly z: number;
49
+ /** `_atom_site_occupancy`, 1 when the file gives none. */
50
+ readonly occupancy: number;
51
+ /** `_atom_site_U_iso_or_equiv` in Ų, or `null` when the file gives none. */
52
+ readonly uiso: number | null;
53
+ /**
54
+ * `_atom_site_disorder_group`, as written: `1`, `2`, `-1`. Absent on an atom
55
+ * the file leaves in no group (`.`).
56
+ * @default undefined
57
+ */
58
+ readonly disorderGroup?: string;
59
+ /**
60
+ * `_atom_site_disorder_assembly`: which disorder the group is a part of,
61
+ * e.g. `A`. Absent when the file names none.
62
+ * @default undefined
63
+ */
64
+ readonly disorderAssembly?: string;
65
+ /**
66
+ * `_atom_site_calc_flag`: `d` refined from the diffraction data, `calc` or
67
+ * `c` placed geometrically, `dum` a dummy atom.
68
+ * @default undefined
69
+ */
70
+ readonly calcFlag?: string;
71
+ }
72
+
73
+ /** Where the structure came from, as far as the file says. */
74
+ export interface CrystalSource {
75
+ /** `_journal_paper_doi`. */
76
+ readonly doi?: string;
77
+ /** `_cod_database_code`, the Crystallography Open Database entry. */
78
+ readonly cod?: string;
79
+ /** `_chemical_name_mineral`, else `_chemical_name_common`, e.g. `Halite`. */
80
+ readonly note?: string;
81
+ }
82
+
83
+ /** One row of the `_geom_bond` loop: a distance the authors reported. */
84
+ export interface CifGeometryBond {
85
+ /** `_geom_bond_atom_site_label_1`. */
86
+ readonly label1: string;
87
+ /** `_geom_bond_atom_site_label_2`. */
88
+ readonly label2: string;
89
+ /** `_geom_bond_distance`, in ångström, with its standard uncertainty. */
90
+ readonly distance: CifNumber;
91
+ /**
92
+ * `_geom_bond_site_symmetry_1`, e.g. `2_655`. Absent when the atom is the
93
+ * one the file lists (`.`).
94
+ * @default undefined
95
+ */
96
+ readonly siteSymmetry1?: string;
97
+ /**
98
+ * `_geom_bond_site_symmetry_2`, e.g. `2_655`: the operation and the cell
99
+ * translation that carry the second atom to the bonded copy.
100
+ * @default undefined
101
+ */
102
+ readonly siteSymmetry2?: string;
103
+ }
104
+
105
+ /** One row of the `_geom_torsion` loop: a torsion angle the authors reported. */
106
+ export interface CifGeometryTorsion {
107
+ /** `_geom_torsion_atom_site_label_1`. */
108
+ readonly label1: string;
109
+ /** `_geom_torsion_atom_site_label_2`. */
110
+ readonly label2: string;
111
+ /** `_geom_torsion_atom_site_label_3`. */
112
+ readonly label3: string;
113
+ /** `_geom_torsion_atom_site_label_4`. */
114
+ readonly label4: string;
115
+ /** `_geom_torsion`, in degrees, with its standard uncertainty. */
116
+ readonly angle: CifNumber;
117
+ /**
118
+ * `_geom_torsion_site_symmetry_1`.
119
+ * @default undefined
120
+ */
121
+ readonly siteSymmetry1?: string;
122
+ /**
123
+ * `_geom_torsion_site_symmetry_2`.
124
+ * @default undefined
125
+ */
126
+ readonly siteSymmetry2?: string;
127
+ /**
128
+ * `_geom_torsion_site_symmetry_3`.
129
+ * @default undefined
130
+ */
131
+ readonly siteSymmetry3?: string;
132
+ /**
133
+ * `_geom_torsion_site_symmetry_4`.
134
+ * @default undefined
135
+ */
136
+ readonly siteSymmetry4?: string;
137
+ }
138
+
139
+ /** One crystal structure: the cell, the space group and the asymmetric unit. */
140
+ export interface CrystalStructure {
141
+ /** The text after `data_`, e.g. `9008671`. */
142
+ readonly name: string;
143
+ /** `_chemical_formula_sum`, else `_chemical_formula_moiety`; `''` when absent. */
144
+ readonly formula: string;
145
+ readonly cell: CrystalCell;
146
+ readonly spaceGroup: CrystalSpaceGroup;
147
+ /** The operations the file carries, verbatim and in file order, when it carries any. */
148
+ readonly symopsXyz: readonly string[];
149
+ /** The asymmetric unit, in file order. */
150
+ readonly sites: readonly CrystalSite[];
151
+ readonly source: CrystalSource;
152
+ /**
153
+ * The bond distances the authors reported, in file order. Absent when the
154
+ * file carries no `_geom_bond` loop.
155
+ * @default undefined
156
+ */
157
+ readonly geometryBonds?: readonly CifGeometryBond[];
158
+ /**
159
+ * The torsion angles the authors reported, in file order. Absent when the
160
+ * file carries no `_geom_torsion` loop.
161
+ * @default undefined
162
+ */
163
+ readonly geometryTorsions?: readonly CifGeometryTorsion[];
164
+ }
@@ -0,0 +1,183 @@
1
+ /**
2
+ * The cell read as the periodic graph it is: which atoms are bonded, across
3
+ * which face, and which sets of them reach their own translate.
4
+ */
5
+
6
+ import type { PeriodicPairs } from './periodicBonds.ts';
7
+
8
+ /** Every bond of a cell from each atom's side, listed contiguously per atom. */
9
+ export interface BondGraph {
10
+ /** `offsets[i]` to `offsets[i + 1]` index the bonds of atom `i`. */
11
+ readonly offsets: Int32Array;
12
+ /** The atom each bond reaches. */
13
+ readonly targets: Int32Array;
14
+ /** The cell it is reached in, three integers per bond. */
15
+ readonly shifts: Int32Array;
16
+ /** The bond length, Å. */
17
+ readonly lengths: Float64Array;
18
+ }
19
+
20
+ /** One connected set of atoms. */
21
+ export interface PeriodicComponent {
22
+ /** Its atoms, in the order the walk reached them. */
23
+ readonly atoms: readonly number[];
24
+ /**
25
+ * How many independent directions it repeats along: 0 for a molecule, 1 for
26
+ * a chain, 2 for a layer, 3 for a framework.
27
+ */
28
+ readonly periodicity: 0 | 1 | 2 | 3;
29
+ }
30
+
31
+ /** The connected sets of a cell, and the cell each atom was reached in. */
32
+ export interface ComponentWalk {
33
+ readonly components: readonly PeriodicComponent[];
34
+ /**
35
+ * The cell each atom was reached in, three integers per atom: an atom's
36
+ * position plus its shift puts a molecule back together.
37
+ */
38
+ readonly shifts: Int32Array;
39
+ }
40
+
41
+ /**
42
+ * Turn a list of pairs into each atom's bonds.
43
+ * @param atomCount - How many atoms the cell holds.
44
+ * @param pairs - What `findPeriodicBonds` returned.
45
+ * @param keep - One flag per pair, 0 to leave it out.
46
+ * @default every pair kept
47
+ * @returns The bonds of each atom, both directions of every pair listed.
48
+ */
49
+ export function bondGraph(
50
+ atomCount: number,
51
+ pairs: PeriodicPairs,
52
+ keep?: Uint8Array,
53
+ ): BondGraph {
54
+ const offsets = new Int32Array(atomCount + 1);
55
+ for (let pair = 0; pair < pairs.count; pair++) {
56
+ if (keep?.[pair] === 0) continue;
57
+ const from = pairs.from[pair] ?? 0;
58
+ const to = pairs.to[pair] ?? 0;
59
+ offsets[from + 1] = (offsets[from + 1] ?? 0) + 1;
60
+ offsets[to + 1] = (offsets[to + 1] ?? 0) + 1;
61
+ }
62
+ for (let atom = 0; atom < atomCount; atom++) {
63
+ offsets[atom + 1] = (offsets[atom + 1] ?? 0) + (offsets[atom] ?? 0);
64
+ }
65
+ const total = offsets[atomCount] ?? 0;
66
+ const targets = new Int32Array(total);
67
+ const shifts = new Int32Array(total * 3);
68
+ const lengths = new Float64Array(total);
69
+ const cursor = offsets.slice(0, atomCount);
70
+ for (let pair = 0; pair < pairs.count; pair++) {
71
+ if (keep?.[pair] === 0) continue;
72
+ const from = pairs.from[pair] ?? 0;
73
+ const to = pairs.to[pair] ?? 0;
74
+ const length = pairs.lengths[pair] ?? 0;
75
+ for (let side = 0; side < 2; side++) {
76
+ const atom = side === 0 ? from : to;
77
+ const slot = cursor[atom] ?? 0;
78
+ cursor[atom] = slot + 1;
79
+ targets[slot] = side === 0 ? to : from;
80
+ lengths[slot] = length;
81
+ const sign = side === 0 ? 1 : -1;
82
+ for (let axis = 0; axis < 3; axis++) {
83
+ shifts[slot * 3 + axis] = sign * (pairs.shifts[pair * 3 + axis] ?? 0);
84
+ }
85
+ }
86
+ }
87
+ return { offsets, targets, shifts, lengths };
88
+ }
89
+
90
+ /**
91
+ * Walk every connected set of atoms, noting which cell each atom is reached
92
+ * in. Reaching an atom a second time in another cell means the set is bonded
93
+ * to its own translate, and the independent translations met that way say
94
+ * along how many directions it extends.
95
+ * @param graph - The bonds of each atom.
96
+ * @param skip - One flag per atom, 1 for an atom that belongs to no set.
97
+ * @default no atom skipped
98
+ * @returns The sets, in the order of their lowest atom, and each atom's cell.
99
+ */
100
+ export function walkComponents(
101
+ graph: BondGraph,
102
+ skip?: Uint8Array,
103
+ ): ComponentWalk {
104
+ const count = graph.offsets.length - 1;
105
+ const seen = new Uint8Array(count);
106
+ const shifts = new Int32Array(count * 3);
107
+ const components: PeriodicComponent[] = [];
108
+ for (let start = 0; start < count; start++) {
109
+ if (seen[start] === 1 || skip?.[start] === 1) continue;
110
+ components.push(walkOne(start, graph, seen, shifts));
111
+ }
112
+ return { components, shifts };
113
+ }
114
+
115
+ function walkOne(
116
+ start: number,
117
+ graph: BondGraph,
118
+ seen: Uint8Array,
119
+ shifts: Int32Array,
120
+ ): PeriodicComponent {
121
+ const atoms = [start];
122
+ const basis: number[][] = [];
123
+ seen[start] = 1;
124
+ for (let head = 0; head < atoms.length; head++) {
125
+ const from = atoms[head] ?? 0;
126
+ const last = graph.offsets[from + 1] ?? 0;
127
+ for (let bond = graph.offsets[from] ?? 0; bond < last; bond++) {
128
+ const to = graph.targets[bond] ?? 0;
129
+ const a = (shifts[from * 3] ?? 0) + (graph.shifts[bond * 3] ?? 0);
130
+ const b = (shifts[from * 3 + 1] ?? 0) + (graph.shifts[bond * 3 + 1] ?? 0);
131
+ const c = (shifts[from * 3 + 2] ?? 0) + (graph.shifts[bond * 3 + 2] ?? 0);
132
+ if (seen[to] === 1) {
133
+ if (basis.length < 3) {
134
+ addTranslation(
135
+ basis,
136
+ a - (shifts[to * 3] ?? 0),
137
+ b - (shifts[to * 3 + 1] ?? 0),
138
+ c - (shifts[to * 3 + 2] ?? 0),
139
+ );
140
+ }
141
+ continue;
142
+ }
143
+ seen[to] = 1;
144
+ shifts[to * 3] = a;
145
+ shifts[to * 3 + 1] = b;
146
+ shifts[to * 3 + 2] = c;
147
+ atoms.push(to);
148
+ }
149
+ }
150
+ return { atoms, periodicity: basis.length as 0 | 1 | 2 | 3 };
151
+ }
152
+
153
+ /**
154
+ * Keep a lattice translation when it is independent of those already kept.
155
+ * @param basis - The independent translations kept so far.
156
+ * @param a - The translation along a, in cells.
157
+ * @param b - The translation along b, in cells.
158
+ * @param c - The translation along c, in cells.
159
+ */
160
+ function addTranslation(basis: number[][], a: number, b: number, c: number) {
161
+ if (a === 0 && b === 0 && c === 0) return;
162
+ const [first, second] = basis;
163
+ if (first === undefined) {
164
+ basis.push([a, b, c]);
165
+ return;
166
+ }
167
+ const cross = [
168
+ (first[1] ?? 0) * c - (first[2] ?? 0) * b,
169
+ (first[2] ?? 0) * a - (first[0] ?? 0) * c,
170
+ (first[0] ?? 0) * b - (first[1] ?? 0) * a,
171
+ ];
172
+ if (second === undefined) {
173
+ if (cross[0] !== 0 || cross[1] !== 0 || cross[2] !== 0) {
174
+ basis.push([a, b, c]);
175
+ }
176
+ return;
177
+ }
178
+ const volume =
179
+ (second[0] ?? 0) * (cross[0] ?? 0) +
180
+ (second[1] ?? 0) * (cross[1] ?? 0) +
181
+ (second[2] ?? 0) * (cross[2] ?? 0);
182
+ if (volume !== 0) basis.push([a, b, c]);
183
+ }
@@ -0,0 +1,56 @@
1
+ import { elementBySymbol } from '../../periodic/core/elements.ts';
2
+
3
+ /** What is added to the sum of two covalent radii before two atoms are bonded, Å. */
4
+ export const BOND_TOLERANCE = 0.45;
5
+
6
+ /**
7
+ * The longest bond between two elements: the sum of their covalent radii plus
8
+ * {@link BOND_TOLERANCE}, and never one between two hydrogens.
9
+ *
10
+ * It is the rule openchemlib's `BondsCalculator` builds bonds from 3D
11
+ * coordinates with, on the same radii — except that openchemlib bonds only
12
+ * organic atoms, and this rule bonds every element, metals included, so a
13
+ * metal complex comes out whole and a salt or a metal as a network.
14
+ * @param a - One element symbol, e.g. `C`.
15
+ * @param b - The other.
16
+ * @returns The distance in ångström, or 0 for a pair never bonded: H–H, or an
17
+ * element the periodic table does not hold.
18
+ */
19
+ export function covalentBondLimit(a: string, b: string): number {
20
+ if (a === 'H' && b === 'H') return 0;
21
+ const first = covalentRadius(a);
22
+ const second = covalentRadius(b);
23
+ if (first === undefined || second === undefined) return 0;
24
+ return first + second + BOND_TOLERANCE;
25
+ }
26
+
27
+ /**
28
+ * The single-bond covalent radius of an element.
29
+ * @param symbol - The element symbol, e.g. `Fe`.
30
+ * @returns The radius in ångström, or `undefined` for a symbol that names no
31
+ * element.
32
+ */
33
+ export function covalentRadius(symbol: string): number | undefined {
34
+ const element = elementBySymbol(symbol);
35
+ return element === undefined
36
+ ? undefined
37
+ : COVALENT_RADII[element.atomicNumber];
38
+ }
39
+
40
+ /**
41
+ * Single-bond covalent radii in ångström, by atomic number, as openchemlib
42
+ * carries them (`VDWRadii.COVALENT_RADIUS`); they follow Pyykkö and Atsumi's
43
+ * single-bond radii (Chem. Eur. J. 2009, 15, 186). Index 0 is unused.
44
+ */
45
+ const COVALENT_RADII: readonly number[] = [
46
+ 0.25, 0.32, 0.46, 1.33, 1.02, 0.85, 0.75, 0.71, 0.63, 0.64, 0.96, 1.6, 1.39,
47
+ 1.26, 1.16, 1.11, 1.03, 0.99, 1.07, 1.96, 1.71, 1.48, 1.36, 1.34, 1.22, 1.19,
48
+ 1.16, 1.11, 1.1, 1.2, 1.2, 1.24, 1.21, 1.21, 1.16, 1.14, 1.21, 2.1, 1.85,
49
+ 1.63, 1.54, 1.47, 1.38, 1.28, 1.25, 1.25, 1.2, 1.39, 1.44, 1.46, 1.4, 1.4,
50
+ 1.36, 1.33, 1.35, 2.32, 1.96, 1.8, 1.63, 1.76, 1.74, 1.73, 1.72, 1.68, 1.69,
51
+ 1.68, 1.67, 1.66, 1.65, 1.64, 1.7, 1.62, 1.52, 1.46, 1.37, 1.31, 1.29, 1.22,
52
+ 1.23, 1.24, 1.42, 1.5, 1.44, 1.51, 1.45, 1.47, 1.45, 2.23, 2.01, 1.86, 1.75,
53
+ 1.69, 1.7, 1.71, 1.72, 1.66, 1.66, 1.68, 1.68, 1.65, 1.67, 1.73, 1.76, 1.61,
54
+ 1.57, 1.49, 1.43, 1.41, 1.34, 1.29, 1.28, 1.21, 1.37, 1.36, 1.43, 1.62, 1.75,
55
+ 1.65, 1.57,
56
+ ];