matterviz 0.3.4 → 0.3.6

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 (852) hide show
  1. package/.vscode/launch.json +13 -0
  2. package/.vscodeignore +7 -0
  3. package/dist/assets/STLExporter-BpTH3YHE.js +8 -0
  4. package/dist/assets/browser-DdDecX_W.js +1 -0
  5. package/dist/assets/export-qgn-H9y6.js +2 -0
  6. package/dist/assets/main-DiKYzti2.css +1 -0
  7. package/dist/assets/moyo_wasm_bg-0ocwg7xY.wasm +0 -0
  8. package/dist/extension.js +31293 -0
  9. package/dist/src/lib/FilePicker.svelte +360 -0
  10. package/dist/src/lib/MillerIndexInput.svelte +66 -0
  11. package/dist/src/lib/api/mp.ts +26 -0
  12. package/dist/src/lib/api/optimade.ts +204 -0
  13. package/dist/src/lib/app.css +247 -0
  14. package/dist/src/lib/brillouin/BrillouinZone.svelte +549 -0
  15. package/dist/src/lib/brillouin/BrillouinZoneControls.svelte +144 -0
  16. package/dist/src/lib/brillouin/BrillouinZoneExportPane.svelte +146 -0
  17. package/dist/src/lib/brillouin/BrillouinZoneInfoPane.svelte +146 -0
  18. package/dist/src/lib/brillouin/BrillouinZoneScene.svelte +476 -0
  19. package/dist/src/lib/brillouin/BrillouinZoneTooltip.svelte +92 -0
  20. package/dist/src/lib/brillouin/compute.ts +529 -0
  21. package/dist/src/lib/brillouin/index.ts +8 -0
  22. package/dist/src/lib/brillouin/types.ts +51 -0
  23. package/dist/src/lib/chempot-diagram/ChemPotDiagram.svelte +327 -0
  24. package/dist/src/lib/chempot-diagram/ChemPotDiagram2D.svelte +846 -0
  25. package/dist/src/lib/chempot-diagram/ChemPotDiagram3D.svelte +3193 -0
  26. package/dist/src/lib/chempot-diagram/async-compute.svelte.ts +94 -0
  27. package/dist/src/lib/chempot-diagram/chempot-worker.ts +11 -0
  28. package/dist/src/lib/chempot-diagram/color.ts +42 -0
  29. package/dist/src/lib/chempot-diagram/compute.ts +1014 -0
  30. package/dist/src/lib/chempot-diagram/index.ts +6 -0
  31. package/dist/src/lib/chempot-diagram/pointer.ts +56 -0
  32. package/dist/src/lib/chempot-diagram/temperature.ts +77 -0
  33. package/dist/src/lib/chempot-diagram/types.ts +130 -0
  34. package/dist/src/lib/colors/index.ts +249 -0
  35. package/dist/src/lib/composition/BarChart.svelte +297 -0
  36. package/dist/src/lib/composition/BubbleChart.svelte +218 -0
  37. package/dist/src/lib/composition/Composition.svelte +165 -0
  38. package/dist/src/lib/composition/Formula.svelte +268 -0
  39. package/dist/src/lib/composition/FormulaFilter.svelte +1257 -0
  40. package/dist/src/lib/composition/PieChart.svelte +323 -0
  41. package/dist/src/lib/composition/format.ts +155 -0
  42. package/dist/src/lib/composition/index.ts +37 -0
  43. package/dist/src/lib/composition/parse.ts +605 -0
  44. package/dist/src/lib/constants.ts +134 -0
  45. package/dist/src/lib/controls.ts +42 -0
  46. package/dist/src/lib/convex-hull/ConvexHull.svelte +157 -0
  47. package/dist/src/lib/convex-hull/ConvexHull2D.svelte +825 -0
  48. package/dist/src/lib/convex-hull/ConvexHull3D.svelte +1801 -0
  49. package/dist/src/lib/convex-hull/ConvexHull4D.svelte +1398 -0
  50. package/dist/src/lib/convex-hull/ConvexHullControls.svelte +535 -0
  51. package/dist/src/lib/convex-hull/ConvexHullInfoPane.svelte +125 -0
  52. package/dist/src/lib/convex-hull/ConvexHullStats.svelte +929 -0
  53. package/dist/src/lib/convex-hull/ConvexHullTooltip.svelte +131 -0
  54. package/dist/src/lib/convex-hull/GasPressureControls.svelte +247 -0
  55. package/dist/src/lib/convex-hull/StructurePopup.svelte +151 -0
  56. package/dist/src/lib/convex-hull/TemperatureSlider.svelte +140 -0
  57. package/dist/src/lib/convex-hull/barycentric-coords.ts +246 -0
  58. package/dist/src/lib/convex-hull/demo-temperature.ts +63 -0
  59. package/dist/src/lib/convex-hull/gas-thermodynamics.ts +405 -0
  60. package/dist/src/lib/convex-hull/helpers.ts +932 -0
  61. package/dist/src/lib/convex-hull/index.ts +202 -0
  62. package/dist/src/lib/convex-hull/thermodynamics.ts +2192 -0
  63. package/dist/src/lib/convex-hull/types.ts +267 -0
  64. package/dist/src/lib/coordination/CoordinationBarPlot.svelte +311 -0
  65. package/dist/src/lib/coordination/calc-coordination.ts +93 -0
  66. package/dist/src/lib/coordination/index.ts +9 -0
  67. package/dist/src/lib/effects.svelte.ts +48 -0
  68. package/dist/src/lib/element/BohrAtom.svelte +147 -0
  69. package/dist/src/lib/element/ElementHeading.svelte +26 -0
  70. package/dist/src/lib/element/ElementPhoto.svelte +57 -0
  71. package/dist/src/lib/element/ElementStats.svelte +80 -0
  72. package/dist/src/lib/element/ElementTile.svelte +484 -0
  73. package/dist/src/lib/element/data.json.gz.d.ts +4 -0
  74. package/dist/src/lib/element/data.ts +14 -0
  75. package/dist/src/lib/element/index.ts +8 -0
  76. package/dist/src/lib/element/types.ts +62 -0
  77. package/dist/src/lib/feedback/ClickFeedback.svelte +58 -0
  78. package/dist/src/lib/feedback/DragOverlay.svelte +42 -0
  79. package/dist/src/lib/feedback/index.ts +4 -0
  80. package/dist/src/lib/fermi-surface/FermiSlice.svelte +189 -0
  81. package/dist/src/lib/fermi-surface/FermiSurface.svelte +600 -0
  82. package/dist/src/lib/fermi-surface/FermiSurfaceControls.svelte +448 -0
  83. package/dist/src/lib/fermi-surface/FermiSurfaceScene.svelte +794 -0
  84. package/dist/src/lib/fermi-surface/FermiSurfaceTooltip.svelte +111 -0
  85. package/dist/src/lib/fermi-surface/compute.ts +728 -0
  86. package/dist/src/lib/fermi-surface/constants.ts +32 -0
  87. package/dist/src/lib/fermi-surface/export.ts +64 -0
  88. package/dist/src/lib/fermi-surface/index.ts +14 -0
  89. package/dist/src/lib/fermi-surface/marching-cubes.ts +3 -0
  90. package/dist/src/lib/fermi-surface/parse.ts +574 -0
  91. package/dist/src/lib/fermi-surface/symmetry.ts +56 -0
  92. package/dist/src/lib/fermi-surface/types.ts +159 -0
  93. package/dist/src/lib/heatmap-matrix/HeatmapMatrix.svelte +1545 -0
  94. package/dist/src/lib/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
  95. package/dist/src/lib/heatmap-matrix/index.ts +167 -0
  96. package/dist/src/lib/heatmap-matrix/shared.ts +7 -0
  97. package/dist/src/lib/icons.ts +650 -0
  98. package/dist/src/lib/index.ts +61 -0
  99. package/dist/src/lib/io/decompress.ts +92 -0
  100. package/dist/src/lib/io/export.ts +385 -0
  101. package/dist/src/lib/io/fetch.ts +46 -0
  102. package/dist/src/lib/io/file-drop.ts +51 -0
  103. package/dist/src/lib/io/index.ts +7 -0
  104. package/dist/src/lib/io/is-binary.ts +24 -0
  105. package/dist/src/lib/io/types.ts +8 -0
  106. package/dist/src/lib/io/url-drop.ts +141 -0
  107. package/dist/src/lib/isosurface/Isosurface.svelte +285 -0
  108. package/dist/src/lib/isosurface/IsosurfaceControls.svelte +277 -0
  109. package/dist/src/lib/isosurface/index.ts +7 -0
  110. package/dist/src/lib/isosurface/parse.ts +656 -0
  111. package/dist/src/lib/isosurface/slice.ts +175 -0
  112. package/dist/src/lib/isosurface/types.ts +309 -0
  113. package/dist/src/lib/labels.ts +320 -0
  114. package/dist/src/lib/layout/FullscreenToggle.svelte +50 -0
  115. package/dist/src/lib/layout/InfoCard.svelte +120 -0
  116. package/dist/src/lib/layout/InfoTag.svelte +185 -0
  117. package/dist/src/lib/layout/PropertyFilter.svelte +246 -0
  118. package/dist/src/lib/layout/SettingsSection.svelte +148 -0
  119. package/dist/src/lib/layout/SubpageGrid.svelte +82 -0
  120. package/dist/src/lib/layout/fullscreen.ts +65 -0
  121. package/dist/src/lib/layout/index.ts +11 -0
  122. package/dist/src/lib/layout/json-tree/JsonNode.svelte +548 -0
  123. package/dist/src/lib/layout/json-tree/JsonTree.svelte +1230 -0
  124. package/dist/src/lib/layout/json-tree/JsonValue.svelte +334 -0
  125. package/dist/src/lib/layout/json-tree/index.ts +3 -0
  126. package/dist/src/lib/layout/json-tree/types.ts +126 -0
  127. package/dist/src/lib/layout/json-tree/utils.ts +682 -0
  128. package/dist/src/lib/marching-cubes.ts +614 -0
  129. package/dist/src/lib/math.ts +1081 -0
  130. package/dist/src/lib/overlays/ContextMenu.svelte +162 -0
  131. package/dist/src/lib/overlays/CopyButton.svelte +45 -0
  132. package/dist/src/lib/overlays/DragControlTab.svelte +98 -0
  133. package/dist/src/lib/overlays/DraggablePane.svelte +487 -0
  134. package/dist/src/lib/overlays/InfoPaneCards.svelte +149 -0
  135. package/dist/src/lib/overlays/index.ts +3 -0
  136. package/dist/src/lib/periodic-table/PeriodicTable.svelte +469 -0
  137. package/dist/src/lib/periodic-table/PeriodicTableControls.svelte +557 -0
  138. package/dist/src/lib/periodic-table/PropertySelect.svelte +37 -0
  139. package/dist/src/lib/periodic-table/index.ts +12 -0
  140. package/dist/src/lib/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +1086 -0
  141. package/dist/src/lib/phase-diagram/PhaseDiagramControls.svelte +444 -0
  142. package/dist/src/lib/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
  143. package/dist/src/lib/phase-diagram/PhaseDiagramExportPane.svelte +184 -0
  144. package/dist/src/lib/phase-diagram/PhaseDiagramTooltip.svelte +391 -0
  145. package/dist/src/lib/phase-diagram/TdbInfoPanel.svelte +203 -0
  146. package/dist/src/lib/phase-diagram/build-diagram.ts +186 -0
  147. package/dist/src/lib/phase-diagram/colors.ts +58 -0
  148. package/dist/src/lib/phase-diagram/diagram-input.ts +40 -0
  149. package/dist/src/lib/phase-diagram/index.ts +13 -0
  150. package/dist/src/lib/phase-diagram/parse.ts +348 -0
  151. package/dist/src/lib/phase-diagram/svg-to-diagram.ts +1023 -0
  152. package/dist/src/lib/phase-diagram/types.ts +144 -0
  153. package/dist/src/lib/phase-diagram/utils.ts +775 -0
  154. package/dist/src/lib/plot/AxisLabel.svelte +51 -0
  155. package/dist/src/lib/plot/BarPlot.svelte +2113 -0
  156. package/dist/src/lib/plot/BarPlotControls.svelte +66 -0
  157. package/dist/src/lib/plot/BinnedScatterPlot.svelte +1114 -0
  158. package/dist/src/lib/plot/ColorBar.svelte +721 -0
  159. package/dist/src/lib/plot/ColorScaleSelect.svelte +54 -0
  160. package/dist/src/lib/plot/ElementScatter.svelte +63 -0
  161. package/dist/src/lib/plot/FillArea.svelte +223 -0
  162. package/dist/src/lib/plot/Histogram.svelte +1558 -0
  163. package/dist/src/lib/plot/HistogramControls.svelte +212 -0
  164. package/dist/src/lib/plot/InteractiveAxisLabel.svelte +96 -0
  165. package/dist/src/lib/plot/Line.svelte +84 -0
  166. package/dist/src/lib/plot/PlotAxis.svelte +169 -0
  167. package/dist/src/lib/plot/PlotControls.svelte +537 -0
  168. package/dist/src/lib/plot/PlotLegend.svelte +569 -0
  169. package/dist/src/lib/plot/PlotTooltip.svelte +67 -0
  170. package/dist/src/lib/plot/PortalSelect.svelte +253 -0
  171. package/dist/src/lib/plot/ReferenceLine3D.svelte +156 -0
  172. package/dist/src/lib/plot/ReferencePlane.svelte +175 -0
  173. package/dist/src/lib/plot/ScatterPlot.svelte +2778 -0
  174. package/dist/src/lib/plot/ScatterPlot3D.svelte +529 -0
  175. package/dist/src/lib/plot/ScatterPlot3DControls.svelte +437 -0
  176. package/dist/src/lib/plot/ScatterPlot3DScene.svelte +912 -0
  177. package/dist/src/lib/plot/ScatterPlotControls.svelte +306 -0
  178. package/dist/src/lib/plot/ScatterPoint.svelte +182 -0
  179. package/dist/src/lib/plot/SpacegroupBarPlot.svelte +293 -0
  180. package/dist/src/lib/plot/Surface3D.svelte +197 -0
  181. package/dist/src/lib/plot/ZeroLines.svelte +97 -0
  182. package/dist/src/lib/plot/ZoomRect.svelte +23 -0
  183. package/dist/src/lib/plot/adaptive-density.ts +316 -0
  184. package/dist/src/lib/plot/auto-place.ts +184 -0
  185. package/dist/src/lib/plot/axis-utils.ts +122 -0
  186. package/dist/src/lib/plot/binned-scatter-types.ts +83 -0
  187. package/dist/src/lib/plot/data-cleaning.ts +1069 -0
  188. package/dist/src/lib/plot/data-transform.ts +69 -0
  189. package/dist/src/lib/plot/defaults.ts +9 -0
  190. package/dist/src/lib/plot/fill-utils.ts +494 -0
  191. package/dist/src/lib/plot/hover-lock.svelte.ts +60 -0
  192. package/dist/src/lib/plot/index.ts +53 -0
  193. package/dist/src/lib/plot/interactions.ts +119 -0
  194. package/dist/src/lib/plot/layout.ts +425 -0
  195. package/dist/src/lib/plot/reference-line.ts +426 -0
  196. package/dist/src/lib/plot/scales.ts +654 -0
  197. package/dist/src/lib/plot/svg.ts +23 -0
  198. package/dist/src/lib/plot/types.ts +1144 -0
  199. package/dist/src/lib/plot/utils/label-placement.ts +541 -0
  200. package/dist/src/lib/plot/utils/series-visibility.ts +140 -0
  201. package/dist/src/lib/plot/utils.ts +11 -0
  202. package/dist/src/lib/rdf/RdfPlot.svelte +247 -0
  203. package/dist/src/lib/rdf/calc-rdf.ts +167 -0
  204. package/dist/src/lib/rdf/index.ts +27 -0
  205. package/dist/src/lib/sanitize.ts +126 -0
  206. package/dist/src/lib/settings.ts +1479 -0
  207. package/dist/src/lib/spectral/Bands.svelte +1040 -0
  208. package/dist/src/lib/spectral/BandsAndDos.svelte +134 -0
  209. package/dist/src/lib/spectral/BrillouinBandsDos.svelte +252 -0
  210. package/dist/src/lib/spectral/Dos.svelte +697 -0
  211. package/dist/src/lib/spectral/helpers.ts +1381 -0
  212. package/dist/src/lib/spectral/index.ts +8 -0
  213. package/dist/src/lib/spectral/types.ts +112 -0
  214. package/dist/src/lib/state.svelte.ts +64 -0
  215. package/dist/src/lib/structure/Arrow.svelte +72 -0
  216. package/dist/src/lib/structure/AtomLegend.svelte +815 -0
  217. package/dist/src/lib/structure/Bond.svelte +140 -0
  218. package/dist/src/lib/structure/CanvasTooltip.svelte +33 -0
  219. package/dist/src/lib/structure/CellSelect.svelte +349 -0
  220. package/dist/src/lib/structure/Cylinder.svelte +45 -0
  221. package/dist/src/lib/structure/Lattice.svelte +196 -0
  222. package/dist/src/lib/structure/Structure.svelte +2248 -0
  223. package/dist/src/lib/structure/StructureControls.svelte +1273 -0
  224. package/dist/src/lib/structure/StructureExportPane.svelte +252 -0
  225. package/dist/src/lib/structure/StructureInfoPane.svelte +737 -0
  226. package/dist/src/lib/structure/StructureScene.svelte +2255 -0
  227. package/dist/src/lib/structure/atom-properties.ts +316 -0
  228. package/dist/src/lib/structure/bond-order-perception.ts +447 -0
  229. package/dist/src/lib/structure/bonding.ts +944 -0
  230. package/dist/src/lib/structure/export.ts +861 -0
  231. package/dist/src/lib/structure/index.ts +291 -0
  232. package/dist/src/lib/structure/label-placement.ts +130 -0
  233. package/dist/src/lib/structure/measure.ts +45 -0
  234. package/dist/src/lib/structure/parse.ts +1705 -0
  235. package/dist/src/lib/structure/partial-occupancy.ts +183 -0
  236. package/dist/src/lib/structure/pbc.ts +164 -0
  237. package/dist/src/lib/structure/supercell.ts +226 -0
  238. package/dist/src/lib/structure/validation.ts +11 -0
  239. package/dist/src/lib/symmetry/SymmetryStats.svelte +226 -0
  240. package/dist/src/lib/symmetry/WyckoffTable.svelte +120 -0
  241. package/dist/src/lib/symmetry/cell-transform.ts +118 -0
  242. package/dist/src/lib/symmetry/index.ts +348 -0
  243. package/dist/src/lib/symmetry/spacegroups.ts +404 -0
  244. package/dist/src/lib/table/HeatmapTable.svelte +1833 -0
  245. package/dist/src/lib/table/ToggleMenu.svelte +385 -0
  246. package/dist/src/lib/table/index.ts +139 -0
  247. package/dist/src/lib/theme/ThemeControl.svelte +53 -0
  248. package/dist/src/lib/theme/index.ts +107 -0
  249. package/dist/src/lib/theme/themes.mjs +297 -0
  250. package/dist/src/lib/time.ts +71 -0
  251. package/dist/src/lib/tooltip/TooltipContent.svelte +58 -0
  252. package/dist/src/lib/tooltip/index.ts +2 -0
  253. package/dist/src/lib/tooltip/types.ts +13 -0
  254. package/dist/src/lib/trajectory/Trajectory.svelte +1545 -0
  255. package/dist/src/lib/trajectory/TrajectoryError.svelte +128 -0
  256. package/dist/src/lib/trajectory/TrajectoryExportPane.svelte +357 -0
  257. package/dist/src/lib/trajectory/TrajectoryInfoPane.svelte +313 -0
  258. package/dist/src/lib/trajectory/constants.ts +7 -0
  259. package/dist/src/lib/trajectory/extract.ts +196 -0
  260. package/dist/src/lib/trajectory/format-detect.ts +96 -0
  261. package/dist/src/lib/trajectory/frame-reader.ts +456 -0
  262. package/dist/src/lib/trajectory/helpers.ts +217 -0
  263. package/dist/src/lib/trajectory/index.ts +218 -0
  264. package/dist/src/lib/trajectory/parse/ase.ts +109 -0
  265. package/dist/src/lib/trajectory/parse/hdf5.ts +173 -0
  266. package/dist/src/lib/trajectory/parse/index.ts +411 -0
  267. package/dist/src/lib/trajectory/parse/lammps.ts +215 -0
  268. package/dist/src/lib/trajectory/parse/vasp.ts +102 -0
  269. package/dist/src/lib/trajectory/parse/xyz.ts +143 -0
  270. package/dist/src/lib/trajectory/plotting.ts +599 -0
  271. package/dist/src/lib/trajectory/types.ts +13 -0
  272. package/dist/src/lib/utils.ts +56 -0
  273. package/dist/src/lib/xrd/XrdPlot.svelte +615 -0
  274. package/dist/src/lib/xrd/broadening.ts +130 -0
  275. package/dist/src/lib/xrd/calc-xrd.ts +397 -0
  276. package/dist/src/lib/xrd/index.ts +38 -0
  277. package/dist/src/lib/xrd/parse.ts +858 -0
  278. package/dist/webview.js +29421 -0
  279. package/icon.png +0 -0
  280. package/license +1 -1
  281. package/matterviz-0.3.2.vsix +0 -0
  282. package/matterviz-0.3.4.vsix +0 -0
  283. package/matterviz-0.3.5.vsix +0 -0
  284. package/package.json +1461 -231
  285. package/readme.md +171 -98
  286. package/scripts/sync-config.ts +101 -0
  287. package/src/declarations.d.ts +2 -0
  288. package/src/extension.ts +972 -0
  289. package/src/node-io.ts +65 -0
  290. package/src/types.ts +17 -0
  291. package/src/webview/JsonBrowser.svelte +1079 -0
  292. package/src/webview/PlotPanel.svelte +346 -0
  293. package/src/webview/detect.ts +444 -0
  294. package/src/webview/main.ts +764 -0
  295. package/src/webview/plot-utils.ts +250 -0
  296. package/test-fixtures/all-viz-types.json.gz +0 -0
  297. package/test-fixtures/plot-demo-data.json.gz +0 -0
  298. package/tests/detect.test.ts +604 -0
  299. package/tests/extension.test.ts +2041 -0
  300. package/tests/node-io.test.ts +39 -0
  301. package/tests/plot-utils.test.ts +302 -0
  302. package/tests/vite-plugin-json-gz.test.ts +114 -0
  303. package/tests/vscode-mock.ts +18 -0
  304. package/tests/webview.test.ts +231 -0
  305. package/tsconfig.json +20 -0
  306. package/vite-plugin-json-gz.ts +29 -0
  307. package/vite.config.ts +34 -0
  308. package/vite.extension.config.ts +34 -0
  309. package/dist/EmptyState.svelte.d.ts +0 -9
  310. package/dist/FilePicker.svelte +0 -360
  311. package/dist/FilePicker.svelte.d.ts +0 -17
  312. package/dist/Icon.svelte.d.ts +0 -13
  313. package/dist/MillerIndexInput.svelte +0 -66
  314. package/dist/MillerIndexInput.svelte.d.ts +0 -7
  315. package/dist/api/mp.d.ts +0 -6
  316. package/dist/api/mp.js +0 -22
  317. package/dist/api/optimade.d.ts +0 -45
  318. package/dist/api/optimade.js +0 -135
  319. package/dist/app.css +0 -240
  320. package/dist/brillouin/BrillouinZone.svelte +0 -543
  321. package/dist/brillouin/BrillouinZone.svelte.d.ts +0 -83
  322. package/dist/brillouin/BrillouinZoneControls.svelte +0 -144
  323. package/dist/brillouin/BrillouinZoneControls.svelte.d.ts +0 -17
  324. package/dist/brillouin/BrillouinZoneExportPane.svelte +0 -148
  325. package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +0 -15
  326. package/dist/brillouin/BrillouinZoneInfoPane.svelte +0 -146
  327. package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +0 -13
  328. package/dist/brillouin/BrillouinZoneScene.svelte +0 -476
  329. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +0 -48
  330. package/dist/brillouin/BrillouinZoneTooltip.svelte +0 -92
  331. package/dist/brillouin/BrillouinZoneTooltip.svelte.d.ts +0 -8
  332. package/dist/brillouin/compute.d.ts +0 -17
  333. package/dist/brillouin/compute.js +0 -422
  334. package/dist/brillouin/index.d.ts +0 -8
  335. package/dist/brillouin/index.js +0 -8
  336. package/dist/brillouin/types.d.ts +0 -48
  337. package/dist/brillouin/types.js +0 -1
  338. package/dist/chempot-diagram/ChemPotDiagram.svelte +0 -327
  339. package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +0 -13
  340. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +0 -847
  341. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +0 -16
  342. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +0 -3194
  343. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +0 -16
  344. package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +0 -7
  345. package/dist/chempot-diagram/async-compute.svelte.d.ts +0 -3
  346. package/dist/chempot-diagram/async-compute.svelte.js +0 -77
  347. package/dist/chempot-diagram/chempot-worker.d.ts +0 -1
  348. package/dist/chempot-diagram/chempot-worker.js +0 -11
  349. package/dist/chempot-diagram/color.d.ts +0 -10
  350. package/dist/chempot-diagram/color.js +0 -32
  351. package/dist/chempot-diagram/compute.d.ts +0 -48
  352. package/dist/chempot-diagram/compute.js +0 -812
  353. package/dist/chempot-diagram/index.d.ts +0 -6
  354. package/dist/chempot-diagram/index.js +0 -6
  355. package/dist/chempot-diagram/pointer.d.ts +0 -16
  356. package/dist/chempot-diagram/pointer.js +0 -40
  357. package/dist/chempot-diagram/temperature.d.ts +0 -15
  358. package/dist/chempot-diagram/temperature.js +0 -36
  359. package/dist/chempot-diagram/types.d.ts +0 -86
  360. package/dist/chempot-diagram/types.js +0 -28
  361. package/dist/colors/index.d.ts +0 -47
  362. package/dist/colors/index.js +0 -203
  363. package/dist/composition/BarChart.svelte +0 -297
  364. package/dist/composition/BarChart.svelte.d.ts +0 -39
  365. package/dist/composition/BubbleChart.svelte +0 -218
  366. package/dist/composition/BubbleChart.svelte.d.ts +0 -28
  367. package/dist/composition/Composition.svelte +0 -164
  368. package/dist/composition/Composition.svelte.d.ts +0 -15
  369. package/dist/composition/Formula.svelte +0 -265
  370. package/dist/composition/Formula.svelte.d.ts +0 -19
  371. package/dist/composition/FormulaFilter.svelte +0 -1259
  372. package/dist/composition/FormulaFilter.svelte.d.ts +0 -51
  373. package/dist/composition/PieChart.svelte +0 -323
  374. package/dist/composition/PieChart.svelte.d.ts +0 -37
  375. package/dist/composition/format.d.ts +0 -15
  376. package/dist/composition/format.js +0 -109
  377. package/dist/composition/index.d.ts +0 -20
  378. package/dist/composition/index.js +0 -14
  379. package/dist/composition/parse.d.ts +0 -55
  380. package/dist/composition/parse.js +0 -459
  381. package/dist/constants.d.ts +0 -29
  382. package/dist/constants.js +0 -105
  383. package/dist/controls.d.ts +0 -14
  384. package/dist/controls.js +0 -30
  385. package/dist/convex-hull/ConvexHull.svelte +0 -157
  386. package/dist/convex-hull/ConvexHull.svelte.d.ts +0 -13
  387. package/dist/convex-hull/ConvexHull2D.svelte +0 -813
  388. package/dist/convex-hull/ConvexHull2D.svelte.d.ts +0 -11
  389. package/dist/convex-hull/ConvexHull3D.svelte +0 -1788
  390. package/dist/convex-hull/ConvexHull3D.svelte.d.ts +0 -8
  391. package/dist/convex-hull/ConvexHull4D.svelte +0 -1374
  392. package/dist/convex-hull/ConvexHull4D.svelte.d.ts +0 -8
  393. package/dist/convex-hull/ConvexHullControls.svelte +0 -546
  394. package/dist/convex-hull/ConvexHullControls.svelte.d.ts +0 -48
  395. package/dist/convex-hull/ConvexHullInfoPane.svelte +0 -115
  396. package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +0 -18
  397. package/dist/convex-hull/ConvexHullStats.svelte +0 -905
  398. package/dist/convex-hull/ConvexHullStats.svelte.d.ts +0 -15
  399. package/dist/convex-hull/ConvexHullTooltip.svelte +0 -131
  400. package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +0 -33
  401. package/dist/convex-hull/GasPressureControls.svelte +0 -247
  402. package/dist/convex-hull/GasPressureControls.svelte.d.ts +0 -11
  403. package/dist/convex-hull/StructurePopup.svelte +0 -116
  404. package/dist/convex-hull/StructurePopup.svelte.d.ts +0 -18
  405. package/dist/convex-hull/TemperatureSlider.svelte +0 -137
  406. package/dist/convex-hull/TemperatureSlider.svelte.d.ts +0 -8
  407. package/dist/convex-hull/barycentric-coords.d.ts +0 -18
  408. package/dist/convex-hull/barycentric-coords.js +0 -182
  409. package/dist/convex-hull/demo-temperature.d.ts +0 -6
  410. package/dist/convex-hull/demo-temperature.js +0 -40
  411. package/dist/convex-hull/gas-thermodynamics.d.ts +0 -16
  412. package/dist/convex-hull/gas-thermodynamics.js +0 -316
  413. package/dist/convex-hull/helpers.d.ts +0 -103
  414. package/dist/convex-hull/helpers.js +0 -671
  415. package/dist/convex-hull/index.d.ts +0 -118
  416. package/dist/convex-hull/index.js +0 -57
  417. package/dist/convex-hull/thermodynamics.d.ts +0 -66
  418. package/dist/convex-hull/thermodynamics.js +0 -1752
  419. package/dist/convex-hull/types.d.ts +0 -162
  420. package/dist/convex-hull/types.js +0 -36
  421. package/dist/coordination/CoordinationBarPlot.svelte +0 -311
  422. package/dist/coordination/CoordinationBarPlot.svelte.d.ts +0 -30
  423. package/dist/coordination/calc-coordination.d.ts +0 -15
  424. package/dist/coordination/calc-coordination.js +0 -63
  425. package/dist/coordination/index.d.ts +0 -8
  426. package/dist/coordination/index.js +0 -7
  427. package/dist/element/BohrAtom.svelte +0 -149
  428. package/dist/element/BohrAtom.svelte.d.ts +0 -20
  429. package/dist/element/ElementHeading.svelte +0 -26
  430. package/dist/element/ElementHeading.svelte.d.ts +0 -8
  431. package/dist/element/ElementPhoto.svelte +0 -57
  432. package/dist/element/ElementPhoto.svelte.d.ts +0 -9
  433. package/dist/element/ElementStats.svelte +0 -80
  434. package/dist/element/ElementStats.svelte.d.ts +0 -8
  435. package/dist/element/ElementTile.svelte +0 -484
  436. package/dist/element/ElementTile.svelte.d.ts +0 -29
  437. package/dist/element/Nucleus.svelte.d.ts +0 -17
  438. package/dist/element/data.d.ts +0 -3
  439. package/dist/element/data.js +0 -2
  440. package/dist/element/data.json.gz.d.ts +0 -2
  441. package/dist/element/index.d.ts +0 -8
  442. package/dist/element/index.js +0 -8
  443. package/dist/element/types.d.ts +0 -57
  444. package/dist/element/types.js +0 -1
  445. package/dist/feedback/ClickFeedback.svelte +0 -58
  446. package/dist/feedback/ClickFeedback.svelte.d.ts +0 -12
  447. package/dist/feedback/DragOverlay.svelte +0 -42
  448. package/dist/feedback/DragOverlay.svelte.d.ts +0 -7
  449. package/dist/feedback/Spinner.svelte.d.ts +0 -7
  450. package/dist/feedback/StatusMessage.svelte.d.ts +0 -9
  451. package/dist/feedback/index.d.ts +0 -4
  452. package/dist/feedback/index.js +0 -4
  453. package/dist/fermi-surface/FermiSlice.svelte +0 -189
  454. package/dist/fermi-surface/FermiSlice.svelte.d.ts +0 -24
  455. package/dist/fermi-surface/FermiSurface.svelte +0 -597
  456. package/dist/fermi-surface/FermiSurface.svelte.d.ts +0 -83
  457. package/dist/fermi-surface/FermiSurfaceControls.svelte +0 -452
  458. package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +0 -35
  459. package/dist/fermi-surface/FermiSurfaceScene.svelte +0 -792
  460. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +0 -50
  461. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +0 -111
  462. package/dist/fermi-surface/FermiSurfaceTooltip.svelte.d.ts +0 -8
  463. package/dist/fermi-surface/compute.d.ts +0 -5
  464. package/dist/fermi-surface/compute.js +0 -538
  465. package/dist/fermi-surface/constants.d.ts +0 -9
  466. package/dist/fermi-surface/constants.js +0 -27
  467. package/dist/fermi-surface/export.d.ts +0 -5
  468. package/dist/fermi-surface/export.js +0 -63
  469. package/dist/fermi-surface/index.d.ts +0 -12
  470. package/dist/fermi-surface/index.js +0 -13
  471. package/dist/fermi-surface/marching-cubes.d.ts +0 -2
  472. package/dist/fermi-surface/marching-cubes.js +0 -2
  473. package/dist/fermi-surface/parse.d.ts +0 -2
  474. package/dist/fermi-surface/parse.js +0 -495
  475. package/dist/fermi-surface/symmetry.d.ts +0 -3
  476. package/dist/fermi-surface/symmetry.js +0 -46
  477. package/dist/fermi-surface/types.d.ts +0 -113
  478. package/dist/fermi-surface/types.js +0 -4
  479. package/dist/heatmap-matrix/HeatmapMatrix.svelte +0 -1527
  480. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +0 -110
  481. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +0 -225
  482. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +0 -30
  483. package/dist/heatmap-matrix/index.d.ts +0 -53
  484. package/dist/heatmap-matrix/index.js +0 -100
  485. package/dist/heatmap-matrix/shared.d.ts +0 -2
  486. package/dist/heatmap-matrix/shared.js +0 -4
  487. package/dist/icons.d.ts +0 -569
  488. package/dist/icons.js +0 -648
  489. package/dist/index.d.ts +0 -39
  490. package/dist/index.js +0 -39
  491. package/dist/io/decompress.d.ts +0 -10
  492. package/dist/io/decompress.js +0 -69
  493. package/dist/io/export.d.ts +0 -16
  494. package/dist/io/export.js +0 -312
  495. package/dist/io/fetch.d.ts +0 -5
  496. package/dist/io/fetch.js +0 -39
  497. package/dist/io/file-drop.d.ts +0 -7
  498. package/dist/io/file-drop.js +0 -43
  499. package/dist/io/index.d.ts +0 -7
  500. package/dist/io/index.js +0 -7
  501. package/dist/io/is-binary.d.ts +0 -1
  502. package/dist/io/is-binary.js +0 -5
  503. package/dist/io/types.d.ts +0 -8
  504. package/dist/io/types.js +0 -1
  505. package/dist/io/url-drop.d.ts +0 -2
  506. package/dist/io/url-drop.js +0 -117
  507. package/dist/isosurface/Isosurface.svelte +0 -285
  508. package/dist/isosurface/Isosurface.svelte.d.ts +0 -8
  509. package/dist/isosurface/IsosurfaceControls.svelte +0 -291
  510. package/dist/isosurface/IsosurfaceControls.svelte.d.ts +0 -9
  511. package/dist/isosurface/index.d.ts +0 -5
  512. package/dist/isosurface/index.js +0 -6
  513. package/dist/isosurface/parse.d.ts +0 -6
  514. package/dist/isosurface/parse.js +0 -553
  515. package/dist/isosurface/slice.d.ts +0 -11
  516. package/dist/isosurface/slice.js +0 -140
  517. package/dist/isosurface/types.d.ts +0 -56
  518. package/dist/isosurface/types.js +0 -227
  519. package/dist/labels.d.ts +0 -53
  520. package/dist/labels.js +0 -274
  521. package/dist/layout/FullscreenToggle.svelte +0 -50
  522. package/dist/layout/FullscreenToggle.svelte.d.ts +0 -7
  523. package/dist/layout/InfoCard.svelte +0 -120
  524. package/dist/layout/InfoCard.svelte.d.ts +0 -21
  525. package/dist/layout/InfoTag.svelte +0 -183
  526. package/dist/layout/InfoTag.svelte.d.ts +0 -19
  527. package/dist/layout/PropertyFilter.svelte +0 -244
  528. package/dist/layout/PropertyFilter.svelte.d.ts +0 -24
  529. package/dist/layout/SettingsSection.svelte +0 -148
  530. package/dist/layout/SettingsSection.svelte.d.ts +0 -17
  531. package/dist/layout/SubpageGrid.svelte +0 -82
  532. package/dist/layout/SubpageGrid.svelte.d.ts +0 -14
  533. package/dist/layout/fullscreen.d.ts +0 -9
  534. package/dist/layout/fullscreen.js +0 -53
  535. package/dist/layout/index.d.ts +0 -10
  536. package/dist/layout/index.js +0 -8
  537. package/dist/layout/json-tree/JsonNode.svelte +0 -547
  538. package/dist/layout/json-tree/JsonNode.svelte.d.ts +0 -11
  539. package/dist/layout/json-tree/JsonTree.svelte +0 -1222
  540. package/dist/layout/json-tree/JsonTree.svelte.d.ts +0 -6
  541. package/dist/layout/json-tree/JsonValue.svelte +0 -334
  542. package/dist/layout/json-tree/JsonValue.svelte.d.ts +0 -9
  543. package/dist/layout/json-tree/index.d.ts +0 -3
  544. package/dist/layout/json-tree/index.js +0 -3
  545. package/dist/layout/json-tree/types.d.ts +0 -73
  546. package/dist/layout/json-tree/types.js +0 -3
  547. package/dist/layout/json-tree/utils.d.ts +0 -29
  548. package/dist/layout/json-tree/utils.js +0 -648
  549. package/dist/marching-cubes.d.ts +0 -14
  550. package/dist/marching-cubes.js +0 -542
  551. package/dist/math.d.ts +0 -91
  552. package/dist/math.js +0 -896
  553. package/dist/overlays/ContextMenu.svelte +0 -162
  554. package/dist/overlays/ContextMenu.svelte.d.ts +0 -25
  555. package/dist/overlays/DraggablePane.svelte +0 -564
  556. package/dist/overlays/DraggablePane.svelte.d.ts +0 -36
  557. package/dist/overlays/index.d.ts +0 -2
  558. package/dist/overlays/index.js +0 -2
  559. package/dist/periodic-table/PeriodicTable.svelte +0 -469
  560. package/dist/periodic-table/PeriodicTable.svelte.d.ts +0 -55
  561. package/dist/periodic-table/PeriodicTableControls.svelte +0 -557
  562. package/dist/periodic-table/PeriodicTableControls.svelte.d.ts +0 -24
  563. package/dist/periodic-table/PropertySelect.svelte +0 -37
  564. package/dist/periodic-table/PropertySelect.svelte.d.ts +0 -13
  565. package/dist/periodic-table/TableInset.svelte.d.ts +0 -9
  566. package/dist/periodic-table/index.d.ts +0 -10
  567. package/dist/periodic-table/index.js +0 -4
  568. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +0 -1086
  569. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +0 -44
  570. package/dist/phase-diagram/PhaseDiagramControls.svelte +0 -451
  571. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +0 -30
  572. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +0 -126
  573. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +0 -15
  574. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +0 -192
  575. package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +0 -19
  576. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +0 -392
  577. package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +0 -16
  578. package/dist/phase-diagram/TdbInfoPanel.svelte +0 -203
  579. package/dist/phase-diagram/TdbInfoPanel.svelte.d.ts +0 -12
  580. package/dist/phase-diagram/build-diagram.d.ts +0 -11
  581. package/dist/phase-diagram/build-diagram.js +0 -167
  582. package/dist/phase-diagram/colors.d.ts +0 -35
  583. package/dist/phase-diagram/colors.js +0 -51
  584. package/dist/phase-diagram/diagram-input.d.ts +0 -33
  585. package/dist/phase-diagram/diagram-input.js +0 -3
  586. package/dist/phase-diagram/index.d.ts +0 -13
  587. package/dist/phase-diagram/index.js +0 -13
  588. package/dist/phase-diagram/parse.d.ts +0 -55
  589. package/dist/phase-diagram/parse.js +0 -276
  590. package/dist/phase-diagram/svg-to-diagram.d.ts +0 -2
  591. package/dist/phase-diagram/svg-to-diagram.js +0 -869
  592. package/dist/phase-diagram/types.d.ts +0 -99
  593. package/dist/phase-diagram/types.js +0 -1
  594. package/dist/phase-diagram/utils.d.ts +0 -118
  595. package/dist/phase-diagram/utils.js +0 -606
  596. package/dist/plot/AxisLabel.svelte +0 -51
  597. package/dist/plot/AxisLabel.svelte.d.ts +0 -16
  598. package/dist/plot/BarPlot.svelte +0 -2256
  599. package/dist/plot/BarPlot.svelte.d.ts +0 -82
  600. package/dist/plot/BarPlotControls.svelte +0 -66
  601. package/dist/plot/BarPlotControls.svelte.d.ts +0 -18
  602. package/dist/plot/ColorBar.svelte +0 -719
  603. package/dist/plot/ColorBar.svelte.d.ts +0 -31
  604. package/dist/plot/ColorScaleSelect.svelte +0 -54
  605. package/dist/plot/ColorScaleSelect.svelte.d.ts +0 -15
  606. package/dist/plot/ElementScatter.svelte +0 -63
  607. package/dist/plot/ElementScatter.svelte.d.ts +0 -14
  608. package/dist/plot/FillArea.svelte +0 -226
  609. package/dist/plot/FillArea.svelte.d.ts +0 -20
  610. package/dist/plot/Histogram.svelte +0 -1654
  611. package/dist/plot/Histogram.svelte.d.ts +0 -50
  612. package/dist/plot/HistogramControls.svelte +0 -212
  613. package/dist/plot/HistogramControls.svelte.d.ts +0 -22
  614. package/dist/plot/InteractiveAxisLabel.svelte +0 -94
  615. package/dist/plot/InteractiveAxisLabel.svelte.d.ts +0 -14
  616. package/dist/plot/Line.svelte +0 -85
  617. package/dist/plot/Line.svelte.d.ts +0 -15
  618. package/dist/plot/PlotControls.svelte +0 -537
  619. package/dist/plot/PlotControls.svelte.d.ts +0 -4
  620. package/dist/plot/PlotLegend.svelte +0 -498
  621. package/dist/plot/PlotLegend.svelte.d.ts +0 -25
  622. package/dist/plot/PlotTooltip.svelte +0 -67
  623. package/dist/plot/PlotTooltip.svelte.d.ts +0 -17
  624. package/dist/plot/PortalSelect.svelte +0 -253
  625. package/dist/plot/PortalSelect.svelte.d.ts +0 -16
  626. package/dist/plot/ReferenceLine.svelte.d.ts +0 -20
  627. package/dist/plot/ReferenceLine3D.svelte +0 -154
  628. package/dist/plot/ReferenceLine3D.svelte.d.ts +0 -14
  629. package/dist/plot/ReferencePlane.svelte +0 -178
  630. package/dist/plot/ReferencePlane.svelte.d.ts +0 -14
  631. package/dist/plot/ScatterPlot.svelte +0 -2831
  632. package/dist/plot/ScatterPlot.svelte.d.ts +0 -92
  633. package/dist/plot/ScatterPlot3D.svelte +0 -499
  634. package/dist/plot/ScatterPlot3D.svelte.d.ts +0 -94
  635. package/dist/plot/ScatterPlot3DControls.svelte +0 -437
  636. package/dist/plot/ScatterPlot3DControls.svelte.d.ts +0 -20
  637. package/dist/plot/ScatterPlot3DScene.svelte +0 -912
  638. package/dist/plot/ScatterPlot3DScene.svelte.d.ts +0 -74
  639. package/dist/plot/ScatterPlotControls.svelte +0 -307
  640. package/dist/plot/ScatterPlotControls.svelte.d.ts +0 -17
  641. package/dist/plot/ScatterPoint.svelte +0 -185
  642. package/dist/plot/ScatterPoint.svelte.d.ts +0 -19
  643. package/dist/plot/SpacegroupBarPlot.svelte +0 -292
  644. package/dist/plot/SpacegroupBarPlot.svelte.d.ts +0 -9
  645. package/dist/plot/Surface3D.svelte +0 -200
  646. package/dist/plot/Surface3D.svelte.d.ts +0 -13
  647. package/dist/plot/ZeroLines.svelte +0 -96
  648. package/dist/plot/ZeroLines.svelte.d.ts +0 -32
  649. package/dist/plot/ZoomRect.svelte +0 -23
  650. package/dist/plot/ZoomRect.svelte.d.ts +0 -8
  651. package/dist/plot/axis-utils.d.ts +0 -19
  652. package/dist/plot/axis-utils.js +0 -80
  653. package/dist/plot/data-cleaning.d.ts +0 -37
  654. package/dist/plot/data-cleaning.js +0 -855
  655. package/dist/plot/data-transform.d.ts +0 -16
  656. package/dist/plot/data-transform.js +0 -45
  657. package/dist/plot/defaults.d.ts +0 -19
  658. package/dist/plot/defaults.js +0 -9
  659. package/dist/plot/fill-utils.d.ts +0 -51
  660. package/dist/plot/fill-utils.js +0 -337
  661. package/dist/plot/hover-lock.svelte.d.ts +0 -14
  662. package/dist/plot/hover-lock.svelte.js +0 -46
  663. package/dist/plot/index.d.ts +0 -43
  664. package/dist/plot/index.js +0 -37
  665. package/dist/plot/interactions.d.ts +0 -12
  666. package/dist/plot/interactions.js +0 -100
  667. package/dist/plot/layout.d.ts +0 -60
  668. package/dist/plot/layout.js +0 -230
  669. package/dist/plot/reference-line.d.ts +0 -60
  670. package/dist/plot/reference-line.js +0 -316
  671. package/dist/plot/scales.d.ts +0 -48
  672. package/dist/plot/scales.js +0 -484
  673. package/dist/plot/svg.d.ts +0 -1
  674. package/dist/plot/svg.js +0 -11
  675. package/dist/plot/types.d.ts +0 -863
  676. package/dist/plot/types.js +0 -103
  677. package/dist/plot/utils/label-placement.d.ts +0 -47
  678. package/dist/plot/utils/label-placement.js +0 -256
  679. package/dist/plot/utils/series-visibility.d.ts +0 -9
  680. package/dist/plot/utils/series-visibility.js +0 -67
  681. package/dist/plot/utils.d.ts +0 -1
  682. package/dist/plot/utils.js +0 -14
  683. package/dist/rdf/RdfPlot.svelte +0 -247
  684. package/dist/rdf/RdfPlot.svelte.d.ts +0 -27
  685. package/dist/rdf/calc-rdf.d.ts +0 -4
  686. package/dist/rdf/calc-rdf.js +0 -111
  687. package/dist/rdf/index.d.ts +0 -23
  688. package/dist/rdf/index.js +0 -2
  689. package/dist/sanitize.d.ts +0 -4
  690. package/dist/sanitize.js +0 -107
  691. package/dist/settings.d.ts +0 -253
  692. package/dist/settings.js +0 -1123
  693. package/dist/spectral/Bands.svelte +0 -1040
  694. package/dist/spectral/Bands.svelte.d.ts +0 -40
  695. package/dist/spectral/BandsAndDos.svelte +0 -128
  696. package/dist/spectral/BandsAndDos.svelte.d.ts +0 -18
  697. package/dist/spectral/BrillouinBandsDos.svelte +0 -248
  698. package/dist/spectral/BrillouinBandsDos.svelte.d.ts +0 -20
  699. package/dist/spectral/Dos.svelte +0 -697
  700. package/dist/spectral/Dos.svelte.d.ts +0 -29
  701. package/dist/spectral/helpers.d.ts +0 -117
  702. package/dist/spectral/helpers.js +0 -1023
  703. package/dist/spectral/index.d.ts +0 -6
  704. package/dist/spectral/index.js +0 -7
  705. package/dist/spectral/types.d.ts +0 -84
  706. package/dist/spectral/types.js +0 -2
  707. package/dist/state.svelte.d.ts +0 -25
  708. package/dist/state.svelte.js +0 -45
  709. package/dist/structure/Arrow.svelte +0 -72
  710. package/dist/structure/Arrow.svelte.d.ts +0 -15
  711. package/dist/structure/AtomLegend.svelte +0 -798
  712. package/dist/structure/AtomLegend.svelte.d.ts +0 -34
  713. package/dist/structure/Bond.svelte +0 -140
  714. package/dist/structure/Bond.svelte.d.ts +0 -9
  715. package/dist/structure/CanvasTooltip.svelte +0 -33
  716. package/dist/structure/CanvasTooltip.svelte.d.ts +0 -12
  717. package/dist/structure/CellSelect.svelte +0 -351
  718. package/dist/structure/CellSelect.svelte.d.ts +0 -13
  719. package/dist/structure/Cylinder.svelte +0 -45
  720. package/dist/structure/Cylinder.svelte.d.ts +0 -10
  721. package/dist/structure/Lattice.svelte +0 -196
  722. package/dist/structure/Lattice.svelte.d.ts +0 -17
  723. package/dist/structure/Structure.svelte +0 -1857
  724. package/dist/structure/Structure.svelte.d.ts +0 -83
  725. package/dist/structure/StructureControls.svelte +0 -1184
  726. package/dist/structure/StructureControls.svelte.d.ts +0 -31
  727. package/dist/structure/StructureExportPane.svelte +0 -251
  728. package/dist/structure/StructureExportPane.svelte.d.ts +0 -17
  729. package/dist/structure/StructureInfoPane.svelte +0 -434
  730. package/dist/structure/StructureInfoPane.svelte.d.ts +0 -18
  731. package/dist/structure/StructureScene.svelte +0 -1574
  732. package/dist/structure/StructureScene.svelte.d.ts +0 -104
  733. package/dist/structure/atom-properties.d.ts +0 -37
  734. package/dist/structure/atom-properties.js +0 -198
  735. package/dist/structure/bonding.d.ts +0 -33
  736. package/dist/structure/bonding.js +0 -304
  737. package/dist/structure/export.d.ts +0 -20
  738. package/dist/structure/export.js +0 -725
  739. package/dist/structure/ferrox-wasm-types.d.ts +0 -46
  740. package/dist/structure/ferrox-wasm-types.js +0 -18
  741. package/dist/structure/ferrox-wasm.d.ts +0 -94
  742. package/dist/structure/ferrox-wasm.js +0 -249
  743. package/dist/structure/index.d.ts +0 -110
  744. package/dist/structure/index.js +0 -168
  745. package/dist/structure/measure.d.ts +0 -6
  746. package/dist/structure/measure.js +0 -29
  747. package/dist/structure/parse.d.ts +0 -65
  748. package/dist/structure/parse.js +0 -1374
  749. package/dist/structure/partial-occupancy.d.ts +0 -25
  750. package/dist/structure/partial-occupancy.js +0 -99
  751. package/dist/structure/pbc.d.ts +0 -9
  752. package/dist/structure/pbc.js +0 -123
  753. package/dist/structure/supercell.d.ts +0 -8
  754. package/dist/structure/supercell.js +0 -137
  755. package/dist/structure/validation.d.ts +0 -2
  756. package/dist/structure/validation.js +0 -10
  757. package/dist/symmetry/SymmetryStats.svelte +0 -226
  758. package/dist/symmetry/SymmetryStats.svelte.d.ts +0 -21
  759. package/dist/symmetry/WyckoffTable.svelte +0 -113
  760. package/dist/symmetry/WyckoffTable.svelte.d.ts +0 -11
  761. package/dist/symmetry/cell-transform.d.ts +0 -12
  762. package/dist/symmetry/cell-transform.js +0 -77
  763. package/dist/symmetry/index.d.ts +0 -43
  764. package/dist/symmetry/index.js +0 -229
  765. package/dist/symmetry/spacegroups.d.ts +0 -9
  766. package/dist/symmetry/spacegroups.js +0 -394
  767. package/dist/table/HeatmapTable.svelte +0 -1854
  768. package/dist/table/HeatmapTable.svelte.d.ts +0 -49
  769. package/dist/table/ToggleMenu.svelte +0 -376
  770. package/dist/table/ToggleMenu.svelte.d.ts +0 -11
  771. package/dist/table/index.d.ts +0 -74
  772. package/dist/table/index.js +0 -38
  773. package/dist/theme/ThemeControl.svelte +0 -53
  774. package/dist/theme/ThemeControl.svelte.d.ts +0 -9
  775. package/dist/theme/index.d.ts +0 -29
  776. package/dist/theme/index.js +0 -79
  777. package/dist/theme/themes.mjs +0 -285
  778. package/dist/time.d.ts +0 -4
  779. package/dist/time.js +0 -70
  780. package/dist/tooltip/TooltipContent.svelte +0 -58
  781. package/dist/tooltip/TooltipContent.svelte.d.ts +0 -31
  782. package/dist/tooltip/index.d.ts +0 -2
  783. package/dist/tooltip/index.js +0 -2
  784. package/dist/tooltip/types.d.ts +0 -8
  785. package/dist/tooltip/types.js +0 -1
  786. package/dist/trajectory/Trajectory.svelte +0 -1517
  787. package/dist/trajectory/Trajectory.svelte.d.ts +0 -77
  788. package/dist/trajectory/TrajectoryError.svelte +0 -128
  789. package/dist/trajectory/TrajectoryError.svelte.d.ts +0 -13
  790. package/dist/trajectory/TrajectoryExportPane.svelte +0 -357
  791. package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +0 -17
  792. package/dist/trajectory/TrajectoryInfoPane.svelte +0 -387
  793. package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +0 -17
  794. package/dist/trajectory/constants.d.ts +0 -6
  795. package/dist/trajectory/constants.js +0 -7
  796. package/dist/trajectory/extract.d.ts +0 -5
  797. package/dist/trajectory/extract.js +0 -162
  798. package/dist/trajectory/format-detect.d.ts +0 -9
  799. package/dist/trajectory/format-detect.js +0 -76
  800. package/dist/trajectory/frame-reader.d.ts +0 -17
  801. package/dist/trajectory/frame-reader.js +0 -332
  802. package/dist/trajectory/helpers.d.ts +0 -14
  803. package/dist/trajectory/helpers.js +0 -172
  804. package/dist/trajectory/index.d.ts +0 -63
  805. package/dist/trajectory/index.js +0 -126
  806. package/dist/trajectory/parse/ase.d.ts +0 -2
  807. package/dist/trajectory/parse/ase.js +0 -77
  808. package/dist/trajectory/parse/hdf5.d.ts +0 -2
  809. package/dist/trajectory/parse/hdf5.js +0 -129
  810. package/dist/trajectory/parse/index.d.ts +0 -12
  811. package/dist/trajectory/parse/index.js +0 -299
  812. package/dist/trajectory/parse/lammps.d.ts +0 -5
  813. package/dist/trajectory/parse/lammps.js +0 -179
  814. package/dist/trajectory/parse/vasp.d.ts +0 -2
  815. package/dist/trajectory/parse/vasp.js +0 -68
  816. package/dist/trajectory/parse/xyz.d.ts +0 -2
  817. package/dist/trajectory/parse/xyz.js +0 -110
  818. package/dist/trajectory/plotting.d.ts +0 -28
  819. package/dist/trajectory/plotting.js +0 -423
  820. package/dist/trajectory/types.d.ts +0 -11
  821. package/dist/trajectory/types.js +0 -1
  822. package/dist/utils.d.ts +0 -5
  823. package/dist/utils.js +0 -36
  824. package/dist/xrd/XrdPlot.svelte +0 -615
  825. package/dist/xrd/XrdPlot.svelte.d.ts +0 -28
  826. package/dist/xrd/broadening.d.ts +0 -20
  827. package/dist/xrd/broadening.js +0 -97
  828. package/dist/xrd/calc-xrd.d.ts +0 -37
  829. package/dist/xrd/calc-xrd.js +0 -337
  830. package/dist/xrd/index.d.ts +0 -37
  831. package/dist/xrd/index.js +0 -4
  832. package/dist/xrd/parse.d.ts +0 -13
  833. package/dist/xrd/parse.js +0 -749
  834. /package/dist/{EmptyState.svelte → src/lib/EmptyState.svelte} +0 -0
  835. /package/dist/{Icon.svelte → src/lib/Icon.svelte} +0 -0
  836. /package/dist/{chempot-diagram → src/lib/chempot-diagram}/ChemPotScene3D.svelte +0 -0
  837. /package/dist/{colors → src/lib/colors}/alloy-colors.json +0 -0
  838. /package/dist/{colors → src/lib/colors}/dark-mode-colors.json +0 -0
  839. /package/dist/{colors → src/lib/colors}/jmol-colors.json +0 -0
  840. /package/dist/{colors → src/lib/colors}/muted-colors.json +0 -0
  841. /package/dist/{colors → src/lib/colors}/pastel-colors.json +0 -0
  842. /package/dist/{colors → src/lib/colors}/vesta-colors.json +0 -0
  843. /package/dist/{element → src/lib/element}/Nucleus.svelte +0 -0
  844. /package/dist/{element → src/lib/element}/data.json +0 -0
  845. /package/dist/{element → src/lib/element}/data.json.gz +0 -0
  846. /package/dist/{element → src/lib/element}/data.schema.json +0 -0
  847. /package/dist/{element-image-urls.json → src/lib/element-image-urls.json} +0 -0
  848. /package/dist/{feedback → src/lib/feedback}/Spinner.svelte +0 -0
  849. /package/dist/{feedback → src/lib/feedback}/StatusMessage.svelte +0 -0
  850. /package/dist/{periodic-table → src/lib/periodic-table}/TableInset.svelte +0 -0
  851. /package/dist/{plot → src/lib/plot}/ReferenceLine.svelte +0 -0
  852. /package/dist/{xrd → src/lib/xrd}/atomic_scattering_params.json +0 -0
@@ -1,1374 +0,0 @@
1
- import { COMPRESSION_EXTENSIONS_REGEX, CONFIG_DIRS_REGEX, STRUCT_KEYWORDS_REGEX, STRUCT_KEYWORDS_STRICT_REGEX, STRUCTURE_EXTENSIONS_REGEX, TRAJ_KEYWORDS_REGEX, VASP_FILES_REGEX, XYZ_EXTXYZ_REGEX, } from '../constants';
2
- import { ELEM_SYMBOLS } from '../labels';
3
- import * as math from '../math';
4
- import { wrap_to_unit_cell } from './pbc';
5
- import { normalize_scientific_notation } from '../utils';
6
- import { load as yaml_load } from 'js-yaml';
7
- // Parse a coordinate value that might be in various scientific notation formats
8
- function parse_coordinate(str) {
9
- const normalized = normalize_scientific_notation(str.trim());
10
- const value = parseFloat(normalized);
11
- if (isNaN(value))
12
- throw new Error(`Invalid coordinate value: ${str}`);
13
- return value;
14
- }
15
- // Parse coordinates from a line, handling malformed formatting
16
- function parse_coordinate_line(line) {
17
- let tokens = line.trim().split(/\s+/);
18
- // Handle malformed coordinates like "1.0-2.0-3.0" (missing spaces)
19
- if (tokens.length < 3) {
20
- // Insert a space only for subtraction between numbers, not exponent signs (e/E)
21
- const sanitized = line
22
- .trim()
23
- // Add space when '-' follows a digit and precedes a digit or dot
24
- .replace(/(\d)-(?=[\d.])/g, `$1 -`)
25
- // Revert accidental spaces after exponent markers
26
- .replace(/([eE])\s-\s/g, `$1-`);
27
- tokens = sanitized.split(/\s+/);
28
- }
29
- if (tokens.length < 3)
30
- throw new Error(`Insufficient coordinates in line: ${line}`);
31
- return tokens.slice(0, 3).map(parse_coordinate);
32
- }
33
- // Validate element symbol and provide fallback
34
- function validate_element_symbol(symbol, index) {
35
- // Clean symbol (remove suffixes like _pv, /hash)
36
- const clean_symbol = symbol.split(/[_/]/)[0];
37
- if (ELEM_SYMBOLS && ELEM_SYMBOLS.includes(clean_symbol)) {
38
- return clean_symbol;
39
- }
40
- // Fallback to default elements by atomic number
41
- const fallback_elements = [`H`, `He`, `Li`, `Be`, `B`, `C`, `N`, `O`, `F`, `Ne`];
42
- const fallback = fallback_elements[index % fallback_elements.length];
43
- console.warn(`Invalid element symbol '${symbol}', using fallback '${fallback}'`);
44
- return fallback;
45
- }
46
- const try_create_cart_to_frac = (lattice_matrix) => {
47
- try {
48
- return math.create_cart_to_frac(lattice_matrix);
49
- }
50
- catch {
51
- return null;
52
- }
53
- };
54
- const approximate_cart_to_frac = (xyz, axis_lengths) => [
55
- Math.abs(axis_lengths[0]) > math.EPS ? xyz[0] / axis_lengths[0] : 0,
56
- Math.abs(axis_lengths[1]) > math.EPS ? xyz[1] / axis_lengths[1] : 0,
57
- Math.abs(axis_lengths[2]) > math.EPS ? xyz[2] / axis_lengths[2] : 0,
58
- ];
59
- // Parse VASP POSCAR file format
60
- export function parse_poscar(content) {
61
- try {
62
- const lines = content.replace(/^\s+/, ``).split(/\r?\n/);
63
- if (lines.length < 8) {
64
- console.error(`POSCAR file too short`);
65
- return null;
66
- }
67
- // Parse scaling factor (line 2)
68
- let scale_factor = parseFloat(lines[1]);
69
- if (isNaN(scale_factor)) {
70
- console.error(`Invalid scaling factor in POSCAR`);
71
- return null;
72
- }
73
- // Parse lattice vectors (lines 3-5)
74
- const parse_vector = (line, line_num) => {
75
- const coords = line.trim().split(/\s+/).map(parse_coordinate);
76
- if (coords.length !== 3) {
77
- throw new Error(`Invalid lattice vector on line ${line_num}: expected 3 coordinates, got ${coords.length}`);
78
- }
79
- return coords;
80
- };
81
- const lattice_vecs = [
82
- parse_vector(lines[2], 3),
83
- parse_vector(lines[3], 4),
84
- parse_vector(lines[4], 5),
85
- ];
86
- // Handle negative scale factor (volume-based scaling)
87
- if (scale_factor < 0) {
88
- const volume = Math.abs(math.det_3x3(lattice_vecs));
89
- scale_factor = Math.pow(-scale_factor / volume, 1 / 3);
90
- }
91
- // Scale lattice vectors
92
- const scaled_lattice = [
93
- math.scale(lattice_vecs[0], scale_factor),
94
- math.scale(lattice_vecs[1], scale_factor),
95
- math.scale(lattice_vecs[2], scale_factor),
96
- ];
97
- // Parse element symbols and atom counts (may span multiple lines)
98
- let line_index = 5;
99
- let element_symbols = [];
100
- let atom_counts = [];
101
- // Detect if this is VASP 5+ format (has element symbols)
102
- // Try to parse the first token as a number - if it succeeds, it's VASP 4 format
103
- const first_token = lines[line_index].trim().split(/\s+/)[0];
104
- const first_token_as_number = parseInt(first_token);
105
- const has_element_symbols = isNaN(first_token_as_number);
106
- if (has_element_symbols) {
107
- // VASP 5+ format - parse element symbols (may span multiple lines)
108
- let symbol_lines = 1;
109
- // Look ahead to find where numbers start (atom counts)
110
- for (let lookahead_idx = 1; lookahead_idx < 10; lookahead_idx++) {
111
- if (line_index + lookahead_idx >= lines.length)
112
- break;
113
- const next_line_first_token = lines[line_index + lookahead_idx].trim().split(/\s+/)[0];
114
- const next_token_as_number = parseInt(next_line_first_token);
115
- if (!isNaN(next_token_as_number)) {
116
- symbol_lines = lookahead_idx;
117
- break;
118
- }
119
- }
120
- // Collect all element symbols from the symbol lines
121
- for (let symbol_line_idx = 0; symbol_line_idx < symbol_lines; symbol_line_idx++) {
122
- if (line_index + symbol_line_idx < lines.length) {
123
- element_symbols.push(...lines[line_index + symbol_line_idx].trim().split(/\s+/));
124
- }
125
- }
126
- // Parse atom counts (may span multiple lines)
127
- for (let count_line_idx = 0; count_line_idx < symbol_lines; count_line_idx++) {
128
- if (line_index + symbol_lines + count_line_idx < lines.length) {
129
- const counts = lines[line_index + symbol_lines + count_line_idx]
130
- .trim()
131
- .split(/\s+/)
132
- .map(Number);
133
- atom_counts.push(...counts);
134
- }
135
- }
136
- line_index += 2 * symbol_lines;
137
- }
138
- else {
139
- // VASP 4 format - only atom counts, generate default element symbols
140
- atom_counts = lines[line_index].trim().split(/\s+/).map(Number);
141
- element_symbols = atom_counts.map((_, idx) => validate_element_symbol(`Element${idx}`, idx));
142
- line_index += 1;
143
- }
144
- if (element_symbols.length !== atom_counts.length) {
145
- console.error(`Mismatch between element symbols and atom counts`);
146
- return null;
147
- }
148
- // Check for selective dynamics
149
- let has_selective_dynamics = false;
150
- if (line_index < lines.length) {
151
- let coordinate_mode = lines[line_index].trim().toUpperCase();
152
- if (coordinate_mode.startsWith(`S`)) {
153
- has_selective_dynamics = true;
154
- line_index += 1;
155
- if (line_index < lines.length) {
156
- coordinate_mode = lines[line_index].trim().toUpperCase();
157
- }
158
- else {
159
- console.error(`Missing coordinate mode after selective dynamics`);
160
- return null;
161
- }
162
- }
163
- // Determine coordinate mode
164
- const is_direct = coordinate_mode.startsWith(`D`);
165
- const is_cartesian = coordinate_mode.startsWith(`C`) || coordinate_mode.startsWith(`K`);
166
- if (!is_direct && !is_cartesian) {
167
- console.error(`Unknown coordinate mode in POSCAR: ${coordinate_mode}`);
168
- return null;
169
- }
170
- // Parse atomic positions
171
- const poscar_axis_lengths = scaled_lattice.map((lattice_vec) => Math.hypot(...lattice_vec));
172
- const poscar_frac_to_cart = math.create_frac_to_cart(scaled_lattice);
173
- const poscar_cart_to_frac = try_create_cart_to_frac(scaled_lattice);
174
- if (!is_direct && !poscar_cart_to_frac) {
175
- console.warn(`POSCAR: singular lattice, using axis-length fallback for cart→frac`);
176
- }
177
- const sites = [];
178
- let atom_index = 0;
179
- for (let elem_idx = 0; elem_idx < element_symbols.length; elem_idx++) {
180
- const element = validate_element_symbol(element_symbols[elem_idx], elem_idx);
181
- const count = atom_counts[elem_idx];
182
- for (let atom_count_idx = 0; atom_count_idx < count; atom_count_idx++) {
183
- const coord_line_idx = line_index + 1 + atom_index + atom_count_idx;
184
- if (coord_line_idx >= lines.length) {
185
- console.error(`Not enough coordinate lines in POSCAR`);
186
- return null;
187
- }
188
- const coords = parse_coordinate_line(lines[coord_line_idx]);
189
- // Parse selective dynamics if present
190
- let selective_dynamics;
191
- if (has_selective_dynamics) {
192
- const tokens = lines[coord_line_idx].trim().split(/\s+/);
193
- if (tokens.length >= 6) {
194
- selective_dynamics = [tokens[3] === `T`, tokens[4] === `T`, tokens[5] === `T`];
195
- }
196
- }
197
- let xyz;
198
- let abc;
199
- const [x, y, z] = coords;
200
- if (is_direct) {
201
- // Store fractional coordinates, wrapping to [0, 1) range
202
- abc = wrap_to_unit_cell([x, y, z]);
203
- xyz = poscar_frac_to_cart(abc);
204
- }
205
- else {
206
- // Already Cartesian, scale if needed
207
- xyz = math.scale([x, y, z], scale_factor);
208
- const raw_abc = poscar_cart_to_frac
209
- ? poscar_cart_to_frac(xyz)
210
- : approximate_cart_to_frac(xyz, poscar_axis_lengths);
211
- // Wrap fractional coordinates to [0, 1) range
212
- abc = wrap_to_unit_cell(raw_abc);
213
- }
214
- const site = {
215
- species: [{ element, occu: 1, oxidation_state: 0 }],
216
- abc,
217
- xyz,
218
- label: `${element}${atom_index + atom_count_idx + 1}`,
219
- properties: selective_dynamics ? { selective_dynamics: selective_dynamics } : {},
220
- };
221
- sites.push(site);
222
- }
223
- atom_index += count;
224
- }
225
- const lattice_params = math.calc_lattice_params(scaled_lattice);
226
- const structure = {
227
- sites,
228
- lattice: { matrix: scaled_lattice, ...lattice_params },
229
- };
230
- return structure;
231
- }
232
- else {
233
- console.error(`Missing coordinate mode line in POSCAR`);
234
- return null;
235
- }
236
- }
237
- catch (error) {
238
- console.error(`Error parsing POSCAR file:`, error);
239
- return null;
240
- }
241
- }
242
- // Parse XYZ file format. Supports both standard XYZ and extended XYZ formats with multi-frame support
243
- export function parse_xyz(content) {
244
- try {
245
- const normalized_content = content.trim();
246
- if (!normalized_content) {
247
- console.error(`Empty XYZ file`);
248
- return null;
249
- }
250
- // Split into frames by reading the atom count and slicing lines
251
- const all_lines = normalized_content.split(/\r?\n/);
252
- const frames = [];
253
- let line_idx = 0;
254
- while (line_idx < all_lines.length) {
255
- const numAtoms = parseInt(all_lines[line_idx].trim(), 10);
256
- if (!isNaN(numAtoms) && numAtoms > 0 && line_idx + numAtoms + 1 < all_lines.length) {
257
- const frameLines = all_lines.slice(line_idx, line_idx + numAtoms + 2);
258
- frames.push(frameLines.join(`\n`));
259
- line_idx += numAtoms + 2;
260
- }
261
- else
262
- line_idx++;
263
- }
264
- // If no frames found, try simple parsing
265
- if (frames.length === 0)
266
- frames.push(normalized_content);
267
- // Parse the last frame (or only frame)
268
- const frame_content = frames.at(-1) ?? ``;
269
- const lines = frame_content.trim().split(/\r?\n/);
270
- if (lines.length < 2) {
271
- console.error(`XYZ frame too short`);
272
- return null;
273
- }
274
- // Parse number of atoms (line 1)
275
- const num_atoms = parseInt(lines[0].trim());
276
- if (isNaN(num_atoms) || num_atoms <= 0) {
277
- console.error(`Invalid number of atoms in XYZ file`);
278
- return null;
279
- }
280
- // Parse comment line (line 2) - may contain lattice info for extended XYZ
281
- const comment_line = lines[1];
282
- let lattice;
283
- // Check for extended XYZ lattice information in comment line
284
- const lattice_match = /Lattice="([^"]+)"/.exec(comment_line);
285
- if (lattice_match) {
286
- const lattice_values = lattice_match[1].split(/\s+/).map(parse_coordinate);
287
- if (lattice_values.length === 9) {
288
- const lattice_vectors = [
289
- [lattice_values[0], lattice_values[1], lattice_values[2]],
290
- [lattice_values[3], lattice_values[4], lattice_values[5]],
291
- [lattice_values[6], lattice_values[7], lattice_values[8]],
292
- ];
293
- const lattice_params = math.calc_lattice_params(lattice_vectors);
294
- lattice = { matrix: lattice_vectors, ...lattice_params };
295
- }
296
- }
297
- // Parse atomic coordinates (starting from line 3)
298
- const xyz_axis_lengths = lattice ? [lattice.a, lattice.b, lattice.c] : null;
299
- let xyz_frac_to_cart = null;
300
- let xyz_cart_to_frac = null;
301
- if (lattice) {
302
- xyz_frac_to_cart = math.create_frac_to_cart(lattice.matrix);
303
- xyz_cart_to_frac = try_create_cart_to_frac(lattice.matrix);
304
- }
305
- const sites = [];
306
- for (let atom_idx = 0; atom_idx < num_atoms; atom_idx++) {
307
- const line_idx = atom_idx + 2;
308
- if (line_idx >= lines.length) {
309
- console.error(`Not enough coordinate lines in XYZ file`);
310
- return null;
311
- }
312
- const parts = lines[line_idx].trim().split(/\s+/);
313
- if (parts.length < 4) {
314
- console.error(`Invalid coordinate line in XYZ file`);
315
- return null;
316
- }
317
- const element = validate_element_symbol(parts[0], atom_idx);
318
- const coords = [
319
- parse_coordinate(parts[1]),
320
- parse_coordinate(parts[2]),
321
- parse_coordinate(parts[3]),
322
- ];
323
- // For XYZ files, coordinates are typically in Cartesian
324
- const xyz = [coords[0], coords[1], coords[2]];
325
- // Calculate fractional coordinates if lattice is available
326
- let abc = [0, 0, 0];
327
- if (lattice && xyz_frac_to_cart && xyz_axis_lengths) {
328
- abc = xyz_cart_to_frac
329
- ? xyz_cart_to_frac(xyz)
330
- : approximate_cart_to_frac(xyz, xyz_axis_lengths);
331
- // Ensure fractional coordinates are wrapped into [0, 1) for consistency
332
- abc = wrap_to_unit_cell(abc);
333
- // Keep rendered atoms inside primary unit cell by recomputing xyz
334
- const wrapped_xyz = xyz_frac_to_cart(abc);
335
- xyz[0] = wrapped_xyz[0];
336
- xyz[1] = wrapped_xyz[1];
337
- xyz[2] = wrapped_xyz[2];
338
- }
339
- const species = [{ element, occu: 1, oxidation_state: 0 }];
340
- const label = `${element}${atom_idx + 1}`;
341
- const site = { species, abc, xyz, label, properties: {} };
342
- sites.push(site);
343
- }
344
- const structure = { sites, ...(lattice && { lattice }) };
345
- return structure;
346
- }
347
- catch (error) {
348
- console.error(`Error parsing XYZ file:`, error);
349
- return null;
350
- }
351
- }
352
- // Parse a single symmetry expression dimension (e.g., "x-y+1/3" or "-x+y")
353
- // Returns the numeric coefficient for each variable and the translation constant
354
- const parse_symmetry_expression = (expr_input) => {
355
- const coefficients = [0, 0, 0];
356
- let translation = 0;
357
- // Remove all whitespace
358
- const expr = expr_input.replace(/\s+/g, ``);
359
- if (!expr)
360
- return { coefficients, translation };
361
- // Tokenize: split into terms while preserving signs
362
- // E.g., "x-y+1/3" → ["x", "-y", "+1/3"] or "-x+y" → ["-x", "+y"]
363
- const tokens = [];
364
- let current_token = ``;
365
- for (let idx = 0; idx < expr.length; idx++) {
366
- const char = expr[idx];
367
- if ((char === `+` || char === `-`) && current_token.length > 0) {
368
- tokens.push(current_token);
369
- current_token = char;
370
- }
371
- else {
372
- current_token += char;
373
- }
374
- }
375
- if (current_token)
376
- tokens.push(current_token);
377
- for (const token of tokens) {
378
- // Check if this token is a variable term (x, y, or z with optional sign)
379
- const var_match = /^([+-]?)([xyz])$/.exec(token);
380
- if (var_match) {
381
- const sign = var_match[1] === `-` ? -1 : 1;
382
- const var_char = var_match[2];
383
- const var_idx = var_char === `x` ? 0 : var_char === `y` ? 1 : 2;
384
- coefficients[var_idx] += sign;
385
- continue;
386
- }
387
- // Check if this is a numeric term (integer, decimal, or fraction)
388
- let sign = 1;
389
- let num_str = token;
390
- // Handle leading sign
391
- if (num_str.startsWith(`+`)) {
392
- num_str = num_str.slice(1);
393
- }
394
- else if (num_str.startsWith(`-`)) {
395
- sign = -1;
396
- num_str = num_str.slice(1);
397
- }
398
- // Skip empty tokens (from dangling operators like "x+")
399
- if (!num_str || num_str === `+` || num_str === `-`)
400
- continue;
401
- if (num_str.includes(`/`)) {
402
- // Fraction
403
- const parts = num_str.split(`/`);
404
- if (parts.length === 2) {
405
- const numerator = parseFloat(parts[0]);
406
- const denominator = parseFloat(parts[1]);
407
- if (!isNaN(numerator) && !isNaN(denominator) && denominator !== 0) {
408
- translation += sign * (numerator / denominator);
409
- }
410
- }
411
- }
412
- else {
413
- // Integer or decimal
414
- const val = parseFloat(num_str);
415
- if (!isNaN(val)) {
416
- translation += sign * val;
417
- }
418
- }
419
- }
420
- return { coefficients, translation };
421
- };
422
- // Apply symmetry operations to generate equivalent positions
423
- const apply_symmetry_ops = (atom, symmetry_ops, wrap_fractional_coords) => {
424
- if (symmetry_ops.length === 0)
425
- return [atom];
426
- const equivalent_atoms = [];
427
- const seen = new Set();
428
- const wrap = (coords) => wrap_fractional_coords ? wrap_to_unit_cell(coords) : coords;
429
- // Use 6 decimal places for deduplication to handle floating point imprecision
430
- // from compound symmetry operations like x-y, -x+y which can produce small errors
431
- const key = (coords) => `${coords[0].toFixed(6)},${coords[1].toFixed(6)},${coords[2].toFixed(6)}`;
432
- // Always include base atom (optionally wrapped)
433
- const base_coords = wrap(atom.coords);
434
- seen.add(key(base_coords));
435
- equivalent_atoms.push({ ...atom, coords: base_coords });
436
- for (const operation of symmetry_ops) {
437
- const operation_match = /['"]([^'"]+)['"]/.exec(operation);
438
- const expr_str = operation_match ? operation_match[1] : operation.trim();
439
- const parts = expr_str.split(`,`).map((part) => part.trim());
440
- if (parts.length !== 3)
441
- continue;
442
- const new_coords = [0, 0, 0];
443
- for (let dim = 0; dim < 3; dim++) {
444
- const { coefficients, translation } = parse_symmetry_expression(parts[dim]);
445
- // Apply: new_coord = coeff_x * x + coeff_y * y + coeff_z * z + translation
446
- new_coords[dim] =
447
- coefficients[0] * atom.coords[0] +
448
- coefficients[1] * atom.coords[1] +
449
- coefficients[2] * atom.coords[2] +
450
- translation;
451
- }
452
- // Wrap and deduplicate transformed coordinates
453
- const wrapped = wrap(new_coords);
454
- const cache_key = key(wrapped);
455
- if (seen.has(cache_key))
456
- continue;
457
- seen.add(cache_key);
458
- equivalent_atoms.push({
459
- ...atom,
460
- coords: wrapped,
461
- id: `${atom.id}_${equivalent_atoms.length}`,
462
- });
463
- }
464
- return equivalent_atoms;
465
- };
466
- const extract_cif_cell_parameters = (text, type, strict = true) => text
467
- .split(`\n`)
468
- .filter((line) => line.startsWith(`_${type}`))
469
- .map((line) => {
470
- const tokens = line.split(/\s+/).filter((token) => token.length > 0);
471
- if (tokens.length < 2) {
472
- if (strict)
473
- throw new Error(`Invalid CIF cell parameter line format: ${line}`);
474
- return null;
475
- }
476
- const value = parseFloat((tokens.at(-1) ?? ``).split(`(`)[0]);
477
- if (isNaN(value)) {
478
- if (strict)
479
- throw new Error(`Invalid CIF cell parameter in line: ${line}`);
480
- return null; // Return null for invalid values in non-strict mode
481
- }
482
- return value;
483
- })
484
- .filter((val) => val !== null);
485
- // build header index mapping for atom site data (supports fract and Cartn coordinates)
486
- const build_cif_atom_site_header_indices = (headers) => {
487
- const indices = {};
488
- const mappings = [
489
- [`_atom_site_label`, `label`],
490
- [`_atom_site_type_symbol`, `symbol`],
491
- [`_atom_site_fract_x`, `x`],
492
- [`_atom_site_fract_y`, `y`],
493
- [`_atom_site_fract_z`, `z`],
494
- [`_atom_site_cartn_x`, `cart_x`],
495
- [`_atom_site_cartn_y`, `cart_y`],
496
- [`_atom_site_cartn_z`, `cart_z`],
497
- [`_atom_site_occupancy`, `occupancy`],
498
- [`_atom_site_disorder_group`, `disorder`],
499
- ];
500
- headers.forEach((header, idx) => {
501
- const lower = header.trim().toLowerCase();
502
- const mapping = mappings.find(([suffix]) => lower.endsWith(suffix));
503
- if (mapping)
504
- indices[mapping[1]] = idx;
505
- });
506
- return indices;
507
- };
508
- // Parse atom data from CIF with robust error handling
509
- const parse_cif_atom_data = (raw_data, indices, coords_type) => {
510
- const { label = 0, symbol = -1, occupancy = -1 } = indices;
511
- const coord_indices = coords_type === `fract`
512
- ? [indices.x, indices.y, indices.z]
513
- : [indices.cart_x, indices.cart_y, indices.cart_z];
514
- if (coord_indices.some((idx) => idx === undefined)) {
515
- throw new Error(`Missing coordinate indices`);
516
- }
517
- const coords_triplet = coord_indices.map((idx) => {
518
- if (idx === undefined)
519
- throw new Error(`Invalid coordinate index`);
520
- const coord_str = raw_data[idx];
521
- if (!coord_str)
522
- throw new Error(`Missing coordinate at index ${idx}`);
523
- const coord = parseFloat(coord_str.split(`(`)[0]);
524
- if (isNaN(coord))
525
- throw new Error(`Invalid coordinate: ${coord_str}`);
526
- return coord;
527
- });
528
- const occu = occupancy >= 0 && raw_data[occupancy]
529
- ? parseFloat(raw_data[occupancy].split(`(`)[0]) || 1.0
530
- : 1.0;
531
- const element_symbol = (symbol >= 0 && /^([A-Z][a-z]*)/.exec(raw_data[symbol])?.[1]) ||
532
- raw_data[label]?.match(/([A-Z][a-z]*)/g)?.[0] ||
533
- (() => {
534
- throw new Error(`Could not extract element symbol from: ${raw_data.join(` `)}`);
535
- })();
536
- return {
537
- id: raw_data[label],
538
- element: element_symbol,
539
- coords: coords_triplet,
540
- coords_type,
541
- occupancy: occu,
542
- };
543
- };
544
- // Parse CIF (Crystallographic Information File) format
545
- export function parse_cif(content, wrap_fractional_coords = true, strict = true) {
546
- try {
547
- const text = content.trim();
548
- if (!text) {
549
- console.error(`CIF file is empty`);
550
- return null;
551
- }
552
- // Find atom site loop that actually contains coordinates (fract or Cartn)
553
- const lines = text.split(`\n`);
554
- let atom_headers = [];
555
- const atom_data_lines = [];
556
- const symmetry_ops = [];
557
- for (let ii = 0; ii < lines.length; ii++) {
558
- if (lines[ii].trim() !== `loop_`)
559
- continue;
560
- let jj = ii + 1;
561
- const headers = [];
562
- // Collect headers for this loop
563
- while (jj < lines.length && lines[jj].trim().startsWith(`_`)) {
564
- headers.push(lines[jj].trim());
565
- jj++;
566
- }
567
- // Check if this is a symmetry operations loop
568
- if (headers.some((header) => header.includes(`_symmetry_equiv_pos_as_xyz`) ||
569
- header.includes(`_space_group_symop_operation_xyz`))) {
570
- // Collect symmetry operations
571
- while (jj < lines.length) {
572
- const line = lines[jj].trim();
573
- if (line === `loop_` || line.startsWith(`data_`))
574
- break;
575
- if (line && !line.startsWith(`#`) && !line.startsWith(`;`)) {
576
- symmetry_ops.push(line);
577
- }
578
- jj++;
579
- }
580
- continue;
581
- }
582
- // Not an atom-site loop → continue search
583
- if (!headers.some((header) => header.includes(`_atom_site_`)))
584
- continue;
585
- // Check if this loop contains coordinate headers
586
- const indices_preview = build_cif_atom_site_header_indices(headers);
587
- const has_coords = (indices_preview.x !== undefined &&
588
- indices_preview.y !== undefined &&
589
- indices_preview.z !== undefined) ||
590
- (indices_preview.cart_x !== undefined &&
591
- indices_preview.cart_y !== undefined &&
592
- indices_preview.cart_z !== undefined);
593
- if (!has_coords) {
594
- ii = jj - 1;
595
- continue;
596
- }
597
- // This is the desired atom-site loop with coordinates: collect data lines
598
- atom_headers = headers;
599
- while (jj < lines.length) {
600
- const line = lines[jj].trim();
601
- if (line === `loop_` || line.startsWith(`data_`))
602
- break;
603
- if (line && !line.startsWith(`#`)) {
604
- if (line.startsWith(`;`)) {
605
- let multi_line_data = ``;
606
- while (jj < lines.length && !lines[jj].trim().endsWith(`;`)) {
607
- multi_line_data += lines[jj] + `\n`;
608
- jj++;
609
- }
610
- multi_line_data += lines[jj];
611
- atom_data_lines.push(multi_line_data.trim());
612
- }
613
- else {
614
- atom_data_lines.push(line);
615
- }
616
- }
617
- jj++;
618
- }
619
- if (atom_data_lines.length > 0)
620
- break;
621
- }
622
- if (!atom_headers.length || !atom_data_lines.length) {
623
- console.error(`No valid atom site loop found in CIF file`);
624
- return null;
625
- }
626
- // Parse atom data with error handling
627
- const header_indices = build_cif_atom_site_header_indices(atom_headers);
628
- // Determine available coordinate type
629
- const coords_type = header_indices.x !== undefined &&
630
- header_indices.y !== undefined &&
631
- header_indices.z !== undefined
632
- ? `fract`
633
- : header_indices.cart_x !== undefined &&
634
- header_indices.cart_y !== undefined &&
635
- header_indices.cart_z !== undefined
636
- ? `cart`
637
- : null;
638
- if (!coords_type) {
639
- console.error(`CIF atom site loop missing coordinates (fract or Cartn)`);
640
- return null;
641
- }
642
- // Collect required coordinate indices
643
- const required_indices = coords_type === `fract`
644
- ? [header_indices.x, header_indices.y, header_indices.z]
645
- : [header_indices.cart_x, header_indices.cart_y, header_indices.cart_z];
646
- const atoms = atom_data_lines
647
- .map((line) => {
648
- // Handle quoted multi-word values by splitting only on whitespace
649
- // that is not inside quotes.
650
- const tokens = line.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) || [];
651
- return tokens.map((token) => token.replace(/['"]/g, ``));
652
- })
653
- .filter((tokens) => {
654
- const { disorder } = header_indices;
655
- const max_required_idx = Math.max(...required_indices);
656
- return (!(disorder !== undefined && tokens[disorder] === `2`) &&
657
- tokens.length > max_required_idx);
658
- })
659
- .map((tokens) => {
660
- try {
661
- return parse_cif_atom_data(tokens, header_indices, coords_type);
662
- }
663
- catch (error) {
664
- console.warn(`Skipping invalid atom data: ${error}`);
665
- return null;
666
- }
667
- })
668
- .filter((atom) => atom !== null);
669
- if (!atoms.length) {
670
- console.error(`No valid atoms found in CIF file`);
671
- return null;
672
- }
673
- // Extract cell parameters and build lattice
674
- const lengths = extract_cif_cell_parameters(text, `cell_length`, strict);
675
- const angles = extract_cif_cell_parameters(text, `cell_angle`, strict);
676
- if (lengths.length < 3 || angles.length < 3) {
677
- console.error(`Insufficient cell parameters in CIF file`);
678
- return null;
679
- }
680
- // Build lattice and create sites
681
- const [a, b, c] = lengths;
682
- const [alpha, beta, gamma] = angles;
683
- const lattice_matrix = math.cell_to_lattice_matrix(a, b, c, alpha, beta, gamma);
684
- const lattice_params = math.calc_lattice_params(lattice_matrix);
685
- const frac_to_cart = math.create_frac_to_cart(lattice_matrix);
686
- const cart_to_frac = try_create_cart_to_frac(lattice_matrix);
687
- // Create sites with coordinate conversion and symmetry operations
688
- const wrap_vec3 = (v) => (wrap_fractional_coords ? wrap_to_unit_cell(v) : v);
689
- // Apply symmetry operations to generate all equivalent positions
690
- const all_sites = [];
691
- // Normalize symmetry operations (trim/strip quotes) but preserve duplicates; we deduplicate positions later
692
- const normalized_ops = symmetry_ops
693
- .map((op) => /['"]([^'"]+)['"]/.exec(op)?.[1] || op.trim())
694
- .map((op) => op.replace(/\s+/g, ``));
695
- // Rely on symmetry operations list for all centering/translations to avoid double-counting
696
- // TODO: Support conventional cells with centering by discovering centering from space group metadata
697
- // when present (e.g. P, I, F, C, R centering types)
698
- const centering_vectors = [[0, 0, 0]];
699
- // Inspect optional _atom_type_number_in_cell loop to see if atom sites are already expanded
700
- const atom_type_counts = (() => {
701
- const map = {};
702
- const text_lines = text.split(`\n`);
703
- for (let li = 0; li < text_lines.length; li++) {
704
- if (text_lines[li].trim() !== `loop_`) {
705
- continue;
706
- }
707
- let lj = li + 1;
708
- const hdrs = [];
709
- while (lj < text_lines.length && text_lines[lj].trim().startsWith(`_`)) {
710
- hdrs.push(text_lines[lj].trim().toLowerCase());
711
- lj++;
712
- }
713
- const sym_idx = hdrs.findIndex((hdr) => hdr.endsWith(`_atom_type_symbol`));
714
- const num_idx = hdrs.findIndex((hdr) => hdr.endsWith(`_atom_type_number_in_cell`));
715
- if (sym_idx !== -1 && num_idx !== -1) {
716
- while (lj < text_lines.length) {
717
- const line = text_lines[lj].trim();
718
- if (!line || line === `loop_` || line.startsWith(`data_`))
719
- break;
720
- if (line.startsWith(`#`)) {
721
- lj++;
722
- continue;
723
- }
724
- const toks = (line.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) || []).map((tok) => tok.replace(/['"]/g, ``));
725
- if (toks.length > Math.max(sym_idx, num_idx)) {
726
- // Normalize type symbol to bare element (e.g. 'Sn2+' -> 'Sn')
727
- const match = /^([A-Z][a-z]*)/.exec(toks[sym_idx]);
728
- const sym = match ? match[1] : toks[sym_idx];
729
- const num = parseInt(toks[num_idx]);
730
- if (sym && !Number.isNaN(num))
731
- map[sym] = num;
732
- }
733
- lj++;
734
- }
735
- break;
736
- }
737
- }
738
- return map;
739
- })();
740
- const observed_counts = {};
741
- for (const a of atoms) {
742
- observed_counts[a.element] = (observed_counts[a.element] || 0) + 1;
743
- }
744
- const has_expected_counts = Object.keys(atom_type_counts).length > 0;
745
- const already_enumerated = has_expected_counts &&
746
- Object.entries(atom_type_counts).every(([el, exp]) => (observed_counts[el] || 0) >= exp);
747
- const ops_to_use = already_enumerated ? [] : normalized_ops;
748
- // Global deduplication of final sites (per element + coordinates + label)
749
- // Use 6 decimal places to handle floating point imprecision from compound symmetry ops
750
- const seen_site_keys = new Set();
751
- const site_key = (element, abc, label) => `${element}|${label}|${abc[0].toFixed(6)},${abc[1].toFixed(6)},${abc[2].toFixed(6)}`;
752
- for (const atom of atoms) {
753
- const element = validate_element_symbol(atom.element, all_sites.length);
754
- // Convert to fractional coordinates if needed
755
- let fractional_atom;
756
- if (atom.coords_type === `fract`) {
757
- fractional_atom = {
758
- ...atom,
759
- coords: wrap_vec3(atom.coords),
760
- coords_type: `fract`,
761
- };
762
- }
763
- else {
764
- const xyz_base = [atom.coords[0], atom.coords[1], atom.coords[2]];
765
- const atom_abc = wrap_vec3(cart_to_frac
766
- ? cart_to_frac(xyz_base)
767
- : approximate_cart_to_frac(xyz_base, [a, b, c]));
768
- fractional_atom = { ...atom, coords: atom_abc, coords_type: `fract` };
769
- }
770
- // First apply symmetry operations in fractional space
771
- const equiv_atoms = apply_symmetry_ops(fractional_atom, ops_to_use, wrap_fractional_coords);
772
- // Then apply lattice centering shifts to each equivalent position
773
- for (const equiv_atom of equiv_atoms) {
774
- for (const cv of centering_vectors) {
775
- const abc = wrap_vec3([
776
- equiv_atom.coords[0] + cv[0],
777
- equiv_atom.coords[1] + cv[1],
778
- equiv_atom.coords[2] + cv[2],
779
- ]);
780
- const key = site_key(element, abc, equiv_atom.id);
781
- if (seen_site_keys.has(key))
782
- continue;
783
- seen_site_keys.add(key);
784
- const xyz = frac_to_cart(abc);
785
- all_sites.push({
786
- species: [{ element, occu: equiv_atom.occupancy, oxidation_state: 0 }],
787
- abc,
788
- xyz,
789
- label: equiv_atom.id,
790
- properties: {},
791
- });
792
- }
793
- }
794
- }
795
- const sites = all_sites;
796
- return { sites, lattice: { matrix: lattice_matrix, ...lattice_params } };
797
- }
798
- catch (error) {
799
- console.error(`Error parsing CIF file:`, error);
800
- return null;
801
- }
802
- }
803
- // Convert phonopy cell to ParsedStructure
804
- function convert_phonopy_cell(cell) {
805
- const sites = [];
806
- // Phonopy stores lattice vectors as rows, use them directly
807
- const lattice_matrix = cell.lattice;
808
- // Process each atomic site
809
- const phonopy_frac_to_cart = math.create_frac_to_cart(lattice_matrix);
810
- for (const point of cell.points) {
811
- const element = validate_element_symbol(point.symbol, sites.length);
812
- const abc = [point.coordinates[0], point.coordinates[1], point.coordinates[2]];
813
- const xyz = phonopy_frac_to_cart(abc);
814
- const properties = {
815
- mass: point.mass,
816
- ...(point.reduced_to !== undefined && { reduced_to: point.reduced_to }),
817
- };
818
- const species = [{ element, occu: 1.0, oxidation_state: 0 }];
819
- const site = { species, abc, xyz, label: point.symbol, properties };
820
- sites.push(site);
821
- }
822
- // Calculate lattice parameters
823
- const calculated_lattice_params = math.calc_lattice_params(lattice_matrix);
824
- return { sites, lattice: { matrix: lattice_matrix, ...calculated_lattice_params } };
825
- }
826
- // Parse phonopy YAML file and return the requested cell type (or preferred single structure)
827
- export function parse_phonopy_yaml(content, cell_type) {
828
- try {
829
- // Parse YAML content but exclude large phonon_displacements array for performance
830
- const lines = content.split(`\n`);
831
- const filtered_lines = [];
832
- let skip_displacements = false;
833
- for (const line of lines) {
834
- // Skip phonon_displacements section for performance
835
- if (line.trim().startsWith(`phonon_displacements:`)) {
836
- skip_displacements = true;
837
- continue;
838
- }
839
- // Check if we're still in the phonon_displacements section
840
- if (skip_displacements) {
841
- if (/^[a-zA-Z_]/.exec(line)) {
842
- // New top-level key, stop skipping
843
- skip_displacements = false;
844
- }
845
- else
846
- continue; // Still in phonon_displacements, skip this line
847
- }
848
- filtered_lines.push(line);
849
- }
850
- const filtered_content = filtered_lines.join(`\n`);
851
- const data = yaml_load(filtered_content);
852
- if (!data) {
853
- console.error(`Failed to parse phonopy YAML`);
854
- return null;
855
- }
856
- // If specific cell type requested, parse only that one
857
- if (cell_type && cell_type !== `auto`) {
858
- const cell = data[cell_type];
859
- if (cell)
860
- return convert_phonopy_cell(cell);
861
- else {
862
- console.error(`Requested cell type '${cell_type}' not found in phonopy YAML`);
863
- return null;
864
- }
865
- }
866
- // Auto mode: return preferred structure in order of preference
867
- // 1. supercell (most detailed)
868
- // 2. phonon_supercell
869
- // 3. unit_cell
870
- // 4. phonon_primitive_cell
871
- // 5. primitive_cell
872
- if (data.supercell)
873
- return convert_phonopy_cell(data.supercell);
874
- else if (data.phonon_supercell)
875
- return convert_phonopy_cell(data.phonon_supercell);
876
- else if (data.unit_cell)
877
- return convert_phonopy_cell(data.unit_cell);
878
- else if (data.phonon_primitive_cell) {
879
- return convert_phonopy_cell(data.phonon_primitive_cell);
880
- }
881
- else if (data.primitive_cell)
882
- return convert_phonopy_cell(data.primitive_cell);
883
- console.error(`No valid cells found in phonopy YAML`);
884
- return null;
885
- }
886
- catch (error) {
887
- console.error(`Error parsing phonopy YAML:`, error);
888
- return null;
889
- }
890
- }
891
- // Recursively search for a valid structure object in nested JSON
892
- function find_structure_in_json(obj, visited = new WeakSet()) {
893
- // Check if current object is null or undefined
894
- if (obj == null)
895
- return null;
896
- if (typeof obj !== `object`)
897
- return null; // If it's not an object, skip it
898
- if (visited.has(obj))
899
- return null; // Check for circular references
900
- visited.add(obj);
901
- // If it's an array, search through each element
902
- if (Array.isArray(obj)) {
903
- for (const item of obj) {
904
- const result = find_structure_in_json(item, visited);
905
- if (result)
906
- return result;
907
- }
908
- return null;
909
- }
910
- // Check if this object looks like a valid structure
911
- if (is_parsed_structure(obj))
912
- return obj;
913
- // Otherwise, recursively search through all properties
914
- for (const value of Object.values(obj)) {
915
- const result = find_structure_in_json(value, visited);
916
- if (result)
917
- return result;
918
- }
919
- return null;
920
- }
921
- // Type guard to validate structure-like objects
922
- function is_parsed_structure(obj) {
923
- if (!obj || typeof obj !== `object`)
924
- return false;
925
- const parsed_obj = obj;
926
- const sites = parsed_obj.sites;
927
- if (!Array.isArray(sites) || sites.length === 0)
928
- return false;
929
- const first_site = sites[0];
930
- if (!first_site || typeof first_site !== `object`)
931
- return false;
932
- const first_site_obj = first_site;
933
- const species = first_site_obj.species;
934
- const abc = first_site_obj.abc;
935
- const xyz = first_site_obj.xyz;
936
- const has_species = Array.isArray(species) && species.length > 0;
937
- const has_coords = Array.isArray(abc) || Array.isArray(xyz);
938
- return has_species && has_coords;
939
- }
940
- // Normalize structure coordinates: wrap fractional coords to [0,1) and recompute Cartesian
941
- // Only normalizes when lattice matrix is available to ensure abc/xyz stay consistent
942
- export function normalize_fractional_coords(structure) {
943
- if (!structure.sites || structure.sites.length === 0)
944
- return structure;
945
- // Require lattice to ensure we can keep abc and xyz consistent after wrapping
946
- if (!structure.lattice?.matrix)
947
- return structure;
948
- // Check if any sites have fractional coords outside [0, 1) range
949
- const needs_wrapping = structure.sites.some((site) => site.abc?.some((coord) => coord < 0 || coord >= 1));
950
- if (!needs_wrapping)
951
- return structure;
952
- const frac_to_cart = math.create_frac_to_cart(structure.lattice.matrix);
953
- // Wrap fractional coordinates and recompute Cartesian
954
- const normalized_sites = structure.sites.map((site) => {
955
- if (!site.abc)
956
- return site;
957
- const wrapped_abc = wrap_to_unit_cell(site.abc);
958
- return { ...site, abc: wrapped_abc, xyz: frac_to_cart(wrapped_abc) };
959
- });
960
- return { ...structure, sites: normalized_sites };
961
- }
962
- // Auto-detect file format and parse accordingly
963
- export function parse_structure_file(content, filename) {
964
- // If a filename is provided, try to detect format by file extension first
965
- if (filename) {
966
- // Handle compressed files by removing compression extensions
967
- let base_filename = filename.toLowerCase();
968
- while (COMPRESSION_EXTENSIONS_REGEX.test(base_filename)) {
969
- base_filename = base_filename.replace(COMPRESSION_EXTENSIONS_REGEX, ``);
970
- }
971
- const ext = base_filename.split(`.`).pop();
972
- // Try to detect format by file extension
973
- if (ext === `xyz` || ext === `extxyz`)
974
- return parse_xyz(content);
975
- // CIF files
976
- if (ext === `cif`)
977
- return parse_cif(content);
978
- // JSON files - try OPTIMADE JSON structure format first, then pymatgen
979
- if (ext === `json`) {
980
- try {
981
- // Parse once, reuse for detection and parsing
982
- const parsed = JSON.parse(content);
983
- if (is_optimade_raw(parsed)) {
984
- const result = parse_optimade_from_raw(parsed);
985
- if (result)
986
- return result;
987
- }
988
- // Otherwise, try to parse as pymatgen/nested structure JSON
989
- const structure = find_structure_in_json(parsed);
990
- if (structure)
991
- return normalize_fractional_coords(structure);
992
- console.error(`JSON file does not contain a valid structure format`);
993
- return null;
994
- }
995
- catch (error) {
996
- console.error(`Error parsing JSON file:`, error);
997
- return null;
998
- }
999
- }
1000
- // YAML files (phonopy)
1001
- if (ext === `yaml` || ext === `yml`)
1002
- return parse_phonopy_yaml(content);
1003
- // POSCAR files may not have extensions or have various names
1004
- if (ext === `poscar` || base_filename.includes(`poscar`)) {
1005
- return parse_poscar(content);
1006
- }
1007
- }
1008
- // Try to auto-detect based on content
1009
- const lines = content.trim().split(/\r?\n/);
1010
- if (lines.length < 2) {
1011
- console.error(`File too short to determine format`);
1012
- return null;
1013
- }
1014
- // JSON format detection: try to parse as JSON first
1015
- try {
1016
- const parsed = JSON.parse(content);
1017
- if (is_optimade_raw(parsed)) {
1018
- const result = parse_optimade_from_raw(parsed);
1019
- if (result)
1020
- return result;
1021
- }
1022
- // Otherwise try parsing as regular JSON structure
1023
- const structure = find_structure_in_json(parsed);
1024
- if (structure) {
1025
- return normalize_fractional_coords(structure);
1026
- }
1027
- }
1028
- catch {
1029
- // Not JSON, continue with other format detection
1030
- }
1031
- // XYZ format detection: first line should be a number, second line is comment
1032
- const first_line_number = parseInt(lines[0].trim());
1033
- if (!isNaN(first_line_number) && first_line_number > 0) {
1034
- // Check if this looks like XYZ format
1035
- if (lines.length >= first_line_number + 2) {
1036
- // Try to parse a coordinate line to see if it looks like XYZ
1037
- const coord_line_idx = 2; // First coordinate line in XYZ
1038
- if (coord_line_idx < lines.length) {
1039
- const parts = lines[coord_line_idx].trim().split(/\s+/);
1040
- // XYZ format: element symbol followed by 3 coordinates
1041
- if (parts.length >= 4) {
1042
- const first_token = parts[0];
1043
- const coords = parts.slice(1, 4);
1044
- // Check if first token looks like an element symbol (not a number)
1045
- // and the next 3 tokens look like coordinates (numbers)
1046
- const is_element_symbol = isNaN(parseInt(first_token)) && first_token.length <= 3;
1047
- const are_coordinates = coords.every((coord) => !isNaN(parseFloat(coord)));
1048
- if (is_element_symbol && are_coordinates) {
1049
- // First token is likely an element symbol, likely XYZ
1050
- return parse_xyz(content);
1051
- }
1052
- }
1053
- }
1054
- }
1055
- }
1056
- // POSCAR format detection: look for typical structure
1057
- if (lines.length >= 8) {
1058
- const second_line_number = parseFloat(lines[1].trim());
1059
- // Second line is a number (scale factor), likely POSCAR
1060
- if (!isNaN(second_line_number))
1061
- return parse_poscar(content);
1062
- }
1063
- // CIF format detection: look for CIF-specific keywords
1064
- const has_cif_keywords = lines.some((line) => line.startsWith(`data_`) ||
1065
- line.includes(`_cell_length_`) ||
1066
- line.includes(`_atom_site_`) ||
1067
- line.trim() === `loop_`);
1068
- if (has_cif_keywords)
1069
- return parse_cif(content);
1070
- // YAML format detection: look for phonopy-specific keywords
1071
- const has_phonopy_keywords = lines.some((line) => line.includes(`phono3py:`) ||
1072
- line.includes(`phonopy:`) ||
1073
- line.includes(`primitive_cell:`) ||
1074
- line.includes(`supercell:`) ||
1075
- line.includes(`phonon_supercell:`));
1076
- if (has_phonopy_keywords)
1077
- return parse_phonopy_yaml(content);
1078
- console.error(`Unable to determine file format`);
1079
- return null;
1080
- }
1081
- // Universal parser that handles JSON and structure files
1082
- export function parse_any_structure(content, filename) {
1083
- // Try JSON first, but handle nested structures properly
1084
- try {
1085
- const parsed = JSON.parse(content);
1086
- // Check if it's already a valid structure using proper type guard
1087
- if (is_parsed_structure(parsed)) {
1088
- // Ensure PBC is set for structures with lattice
1089
- if (parsed.lattice && !parsed.lattice.pbc) {
1090
- parsed.lattice.pbc = [true, true, true];
1091
- }
1092
- // Normalize coordinates (wrap fractional to [0,1) and recompute Cartesian)
1093
- return normalize_fractional_coords(parsed);
1094
- }
1095
- // If not, use parse_structure_file to find nested structures
1096
- const structure = parse_structure_file(content, filename);
1097
- if (structure) {
1098
- return {
1099
- sites: structure.sites,
1100
- charge: 0,
1101
- ...(structure.lattice && {
1102
- lattice: { ...structure.lattice, pbc: [true, true, true] },
1103
- }),
1104
- };
1105
- }
1106
- else
1107
- return null;
1108
- }
1109
- catch {
1110
- // Try structure file formats
1111
- const parsed = parse_structure_file(content, filename);
1112
- if (parsed) {
1113
- return {
1114
- sites: parsed.sites,
1115
- charge: 0,
1116
- ...(parsed.lattice && {
1117
- lattice: { ...parsed.lattice, pbc: [true, true, true] },
1118
- }),
1119
- };
1120
- }
1121
- else
1122
- return null;
1123
- }
1124
- }
1125
- // Parse OPTIMADE JSON format
1126
- export function parse_optimade_json(content) {
1127
- try {
1128
- const raw = JSON.parse(content);
1129
- return parse_optimade_from_raw(raw);
1130
- }
1131
- catch (error) {
1132
- console.error(`Error parsing OPTIMADE JSON:`, error);
1133
- return null;
1134
- }
1135
- }
1136
- // Parse OPTIMADE from already-parsed JSON
1137
- export function parse_optimade_from_raw(raw) {
1138
- try {
1139
- const structure = extract_optimade_structure_from_raw(raw);
1140
- if (!structure) {
1141
- console.error(`No valid OPTIMADE structure found in JSON`);
1142
- return null;
1143
- }
1144
- const attrs = structure.attributes;
1145
- // Inline validation for conciseness
1146
- const positions_raw = attrs.cartesian_site_positions;
1147
- const species_raw = attrs.species_at_sites;
1148
- if (!(Array.isArray(positions_raw) && Array.isArray(species_raw))) {
1149
- console.error(`OPTIMADE JSON missing required position or species data`);
1150
- return null;
1151
- }
1152
- if (positions_raw.length !== species_raw.length) {
1153
- console.error(`OPTIMADE JSON position/species count mismatch`);
1154
- return null;
1155
- }
1156
- const positions = positions_raw;
1157
- const species = species_raw;
1158
- // Optimade stores lattice vectors as rows, so use as is
1159
- const lattice_matrix = attrs.lattice_vectors;
1160
- const optimade_lattice_params = lattice_matrix
1161
- ? math.calc_lattice_params(lattice_matrix)
1162
- : null;
1163
- // Parse atomic sites
1164
- const optimade_exact_cart_to_frac = lattice_matrix
1165
- ? try_create_cart_to_frac(lattice_matrix)
1166
- : null;
1167
- const optimade_cart_to_frac = lattice_matrix && optimade_lattice_params
1168
- ? (optimade_exact_cart_to_frac ??
1169
- ((xyz) => approximate_cart_to_frac(xyz, [
1170
- optimade_lattice_params.a,
1171
- optimade_lattice_params.b,
1172
- optimade_lattice_params.c,
1173
- ])))
1174
- : null;
1175
- if (lattice_matrix && !optimade_exact_cart_to_frac) {
1176
- console.warn(`Failed to create exact coordinate converter for OPTIMADE structure`);
1177
- }
1178
- const sites = [];
1179
- for (let idx = 0; idx < positions.length; idx++) {
1180
- const pos = positions[idx];
1181
- const element_symbol = species[idx];
1182
- if (!pos || pos.length < 3) {
1183
- console.warn(`Invalid position data at site ${idx}`);
1184
- continue;
1185
- }
1186
- const element = validate_element_symbol(element_symbol, idx);
1187
- const xyz = [pos[0], pos[1], pos[2]];
1188
- // Calculate fractional coordinates if lattice is available
1189
- const abc = optimade_cart_to_frac ? optimade_cart_to_frac(xyz) : [0, 0, 0];
1190
- const site = {
1191
- species: [{ element, occu: 1, oxidation_state: 0 }],
1192
- abc,
1193
- xyz,
1194
- label: `${element}${idx + 1}`,
1195
- properties: {},
1196
- };
1197
- sites.push(site);
1198
- }
1199
- if (sites.length === 0) {
1200
- console.error(`No valid sites found in OPTIMADE JSON`);
1201
- return null;
1202
- }
1203
- // Create structure object
1204
- let lattice;
1205
- if (lattice_matrix && optimade_lattice_params) {
1206
- lattice = { matrix: lattice_matrix, ...optimade_lattice_params };
1207
- }
1208
- const structure_result = {
1209
- sites,
1210
- ...(lattice && { lattice }),
1211
- };
1212
- return structure_result;
1213
- }
1214
- catch (error) {
1215
- console.error(`Error parsing OPTIMADE JSON:`, error);
1216
- return null;
1217
- }
1218
- }
1219
- // Check if JSON content is OPTIMADE format by looking for structure attributes
1220
- export function is_optimade_json(content) {
1221
- try {
1222
- const raw = JSON.parse(content);
1223
- return is_optimade_raw(raw);
1224
- }
1225
- catch {
1226
- return false;
1227
- }
1228
- }
1229
- // Check if already-parsed JSON is OPTIMADE-like
1230
- export const is_optimade_raw = (raw) => Boolean(extract_optimade_structure_from_raw(raw));
1231
- // Shared helper to extract an OPTIMADE structure from raw JSON-like data
1232
- function extract_optimade_structure_from_raw(raw) {
1233
- const payload = unwrap_data(raw);
1234
- const candidate = Array.isArray(payload) ? payload[0] : payload;
1235
- return is_optimade_structure_object(candidate) ? candidate : null;
1236
- }
1237
- const unwrap_data = (value) => value && typeof value === `object` && `data` in value
1238
- ? value.data
1239
- : value;
1240
- // Type guard: verify minimal OPTIMADE structure shape
1241
- function is_optimade_structure_object(value) {
1242
- if (!value || typeof value !== `object`)
1243
- return false;
1244
- const obj = value;
1245
- const type = obj.type;
1246
- const id = obj.id;
1247
- const attributes = obj.attributes;
1248
- return (type === `structures` &&
1249
- typeof id === `string` &&
1250
- typeof attributes === `object` &&
1251
- attributes !== null);
1252
- }
1253
- // Convert OPTIMADE structure to Crystal format
1254
- export function optimade_to_crystal(optimade_structure) {
1255
- const { lattice_vectors, cartesian_site_positions, species_at_sites, species, ...properties } = optimade_structure.attributes;
1256
- if (!lattice_vectors || !cartesian_site_positions || !species_at_sites) {
1257
- console.error(`Missing required OPTIMADE structure data`);
1258
- return null;
1259
- }
1260
- try {
1261
- const lattice_matrix = [
1262
- lattice_vectors[0],
1263
- lattice_vectors[1],
1264
- lattice_vectors[2],
1265
- ];
1266
- const lattice_params = math.calc_lattice_params(lattice_matrix);
1267
- // Build species lookup for site properties (mass, concentration, etc.)
1268
- const species_map = new Map(species?.map((spec) => [spec.name, spec]));
1269
- const crystal_cart_to_frac = try_create_cart_to_frac(lattice_matrix) ??
1270
- ((xyz) => approximate_cart_to_frac(xyz, [lattice_params.a, lattice_params.b, lattice_params.c]));
1271
- const sites = cartesian_site_positions.map((pos, idx) => {
1272
- const element_symbol = species_at_sites[idx];
1273
- if (!element_symbol)
1274
- throw new Error(`Missing species for site ${idx}`);
1275
- const element = validate_element_symbol(element_symbol, idx);
1276
- const xyz = [pos[0], pos[1], pos[2]];
1277
- const abc = crystal_cart_to_frac ? crystal_cart_to_frac(xyz) : [0, 0, 0];
1278
- // Extract mass/concentration from species data
1279
- const spec = species_map.get(element_symbol);
1280
- const site_props = {};
1281
- if (spec?.mass?.[0] !== undefined)
1282
- site_props.mass = spec.mass[0];
1283
- if (spec?.concentration?.[0] !== undefined && spec.concentration[0] !== 1) {
1284
- site_props.concentration = spec.concentration[0];
1285
- }
1286
- return {
1287
- species: [{ element, occu: 1, oxidation_state: 0 }],
1288
- abc,
1289
- xyz,
1290
- label: `${element}${idx + 1}`,
1291
- properties: site_props,
1292
- };
1293
- });
1294
- return {
1295
- sites,
1296
- lattice: { matrix: lattice_matrix, ...lattice_params, pbc: [true, true, true] },
1297
- id: optimade_structure.id,
1298
- properties,
1299
- };
1300
- }
1301
- catch (err) {
1302
- console.error(`Error converting OPTIMADE to Crystal format:`, err);
1303
- return null;
1304
- }
1305
- }
1306
- // Check if filename indicates a structure file
1307
- export function is_structure_file(filename) {
1308
- const name = filename.toLowerCase();
1309
- // Trajectory-only formats (can't be structures)
1310
- if (/\.(traj|xtc|h5|hdf5)$/i.test(name) || /xdatcar/i.test(name))
1311
- return false;
1312
- // Always structure formats
1313
- if (STRUCTURE_EXTENSIONS_REGEX.test(name))
1314
- return true;
1315
- if (VASP_FILES_REGEX.test(name))
1316
- return true;
1317
- // .xyz/.extxyz files: structure unless they have trajectory keywords
1318
- if (/\.(xyz|extxyz)$/i.test(name))
1319
- return !TRAJ_KEYWORDS_REGEX.test(name);
1320
- // Keyword-based detection for YAML/XML
1321
- if (/\.(yaml|yml|xml)$/i.test(name) && STRUCT_KEYWORDS_REGEX.test(name))
1322
- return true;
1323
- // More restrictive keyword detection for JSON files
1324
- if (/\.json$/i.test(name) &&
1325
- STRUCT_KEYWORDS_STRICT_REGEX.test(name) &&
1326
- !TRAJ_KEYWORDS_REGEX.test(name) &&
1327
- !CONFIG_DIRS_REGEX.test(name))
1328
- return true;
1329
- // Compressed files - check base filename recursively
1330
- if (COMPRESSION_EXTENSIONS_REGEX.test(name)) {
1331
- return is_structure_file(name.replace(COMPRESSION_EXTENSIONS_REGEX, ``));
1332
- }
1333
- return false;
1334
- }
1335
- export const detect_structure_type = (filename, content) => {
1336
- const lower_filename = filename.toLowerCase();
1337
- // Normalize compressed suffixes (gz, gzip, zip, xz, bz2) for detection parity
1338
- let name_to_check = lower_filename;
1339
- while (COMPRESSION_EXTENSIONS_REGEX.test(name_to_check)) {
1340
- name_to_check = name_to_check.replace(COMPRESSION_EXTENSIONS_REGEX, ``);
1341
- }
1342
- if (name_to_check.endsWith(`.json`)) {
1343
- try {
1344
- const parsed = JSON.parse(content);
1345
- // Check for crystal indicators: lattice, lattice_vectors, or periodic dimensions
1346
- const dims = parsed.data?.attributes?.dimension_types;
1347
- if (parsed.lattice ||
1348
- parsed.data?.attributes?.lattice_vectors ||
1349
- (Array.isArray(dims) && dims.some((dim) => dim > 0)) ||
1350
- parsed.data?.attributes?.nperiodic_dimensions > 0) {
1351
- return `crystal`;
1352
- }
1353
- return `molecule`;
1354
- }
1355
- catch {
1356
- return `unknown`;
1357
- }
1358
- }
1359
- if (name_to_check.endsWith(`.cif`))
1360
- return `crystal`;
1361
- if (name_to_check.includes(`poscar`))
1362
- return `crystal`;
1363
- if (name_to_check.endsWith(`.yaml`) || name_to_check.endsWith(`.yml`)) {
1364
- const lower_content = content.toLowerCase();
1365
- return lower_content.includes(`phono3py:`) || lower_content.includes(`phonopy:`)
1366
- ? `crystal`
1367
- : `unknown`;
1368
- }
1369
- if (XYZ_EXTXYZ_REGEX.test(name_to_check)) {
1370
- const lines = content.trim().split(/\r?\n/);
1371
- return lines.length >= 2 && lines[1].includes(`Lattice=`) ? `crystal` : `molecule`;
1372
- }
1373
- return `unknown`;
1374
- };