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