matterviz 0.4.0 → 0.4.2

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 (527) hide show
  1. package/dist/EmptyState.svelte +10 -4
  2. package/dist/FilePicker.svelte +12 -14
  3. package/dist/Icon.svelte +7 -4
  4. package/dist/MillerIndexInput.svelte +2 -2
  5. package/dist/app.css +53 -0
  6. package/dist/brillouin/BrillouinZone.svelte +132 -219
  7. package/dist/brillouin/BrillouinZone.svelte.d.ts +9 -20
  8. package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
  9. package/dist/brillouin/BrillouinZoneExportPane.svelte +47 -96
  10. package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
  11. package/dist/brillouin/BrillouinZoneInfoPane.svelte +15 -42
  12. package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
  13. package/dist/brillouin/BrillouinZoneScene.svelte +63 -230
  14. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +3 -23
  15. package/dist/brillouin/ReciprocalVectors.svelte +39 -0
  16. package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
  17. package/dist/brillouin/compute.d.ts +2 -0
  18. package/dist/brillouin/compute.js +80 -77
  19. package/dist/brillouin/geometry.d.ts +8 -0
  20. package/dist/brillouin/geometry.js +57 -0
  21. package/dist/brillouin/index.d.ts +2 -0
  22. package/dist/brillouin/index.js +2 -0
  23. package/dist/brillouin/types.d.ts +2 -2
  24. package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
  25. package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
  26. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +143 -246
  27. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
  28. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +652 -976
  29. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
  30. package/dist/chempot-diagram/async-compute.svelte.js +1 -1
  31. package/dist/chempot-diagram/color.d.ts +3 -6
  32. package/dist/chempot-diagram/color.js +5 -5
  33. package/dist/chempot-diagram/compute.d.ts +3 -3
  34. package/dist/chempot-diagram/compute.js +3 -1
  35. package/dist/chempot-diagram/controls-state.svelte.d.ts +10 -0
  36. package/dist/chempot-diagram/controls-state.svelte.js +42 -0
  37. package/dist/chempot-diagram/export.d.ts +47 -0
  38. package/dist/chempot-diagram/export.js +133 -0
  39. package/dist/chempot-diagram/index.d.ts +1 -0
  40. package/dist/chempot-diagram/index.js +1 -0
  41. package/dist/chempot-diagram/pointer.d.ts +0 -10
  42. package/dist/chempot-diagram/pointer.js +4 -4
  43. package/dist/chempot-diagram/types.d.ts +3 -3
  44. package/dist/colors/index.d.ts +0 -4
  45. package/dist/colors/index.js +21 -22
  46. package/dist/composition/BarChart.svelte +37 -31
  47. package/dist/composition/BubbleChart.svelte +17 -17
  48. package/dist/composition/Composition.svelte +7 -11
  49. package/dist/composition/Formula.svelte +18 -25
  50. package/dist/composition/FormulaFilter.svelte +96 -98
  51. package/dist/composition/PieChart.svelte +60 -46
  52. package/dist/composition/chem-sys.js +3 -2
  53. package/dist/composition/format.js +4 -3
  54. package/dist/composition/index.d.ts +2 -0
  55. package/dist/composition/index.js +14 -0
  56. package/dist/composition/parse.d.ts +2 -3
  57. package/dist/composition/parse.js +27 -28
  58. package/dist/constants.js +11 -9
  59. package/dist/controls.d.ts +1 -0
  60. package/dist/controls.js +0 -1
  61. package/dist/convex-hull/ConvexHull.svelte +20 -25
  62. package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
  63. package/dist/convex-hull/ConvexHull2D.svelte +176 -256
  64. package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
  65. package/dist/convex-hull/ConvexHull3D.svelte +269 -804
  66. package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
  67. package/dist/convex-hull/ConvexHull4D.svelte +236 -755
  68. package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
  69. package/dist/convex-hull/ConvexHullChrome.svelte +264 -0
  70. package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
  71. package/dist/convex-hull/ConvexHullControls.svelte +128 -49
  72. package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
  73. package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
  74. package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
  75. package/dist/convex-hull/ConvexHullStats.svelte +210 -351
  76. package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
  77. package/dist/convex-hull/ConvexHullTooltip.svelte +16 -14
  78. package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
  79. package/dist/convex-hull/GasPressureControls.svelte +5 -12
  80. package/dist/convex-hull/StructurePopup.svelte +17 -21
  81. package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
  82. package/dist/convex-hull/TemperatureSlider.svelte +4 -10
  83. package/dist/convex-hull/barycentric-coords.d.ts +2 -4
  84. package/dist/convex-hull/barycentric-coords.js +6 -33
  85. package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
  86. package/dist/convex-hull/canvas-interactions.svelte.js +279 -0
  87. package/dist/convex-hull/helpers.d.ts +47 -17
  88. package/dist/convex-hull/helpers.js +186 -101
  89. package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
  90. package/dist/convex-hull/hull-state.svelte.js +124 -0
  91. package/dist/convex-hull/index.d.ts +9 -7
  92. package/dist/convex-hull/index.js +7 -2
  93. package/dist/convex-hull/thermodynamics.js +109 -937
  94. package/dist/convex-hull/types.d.ts +12 -4
  95. package/dist/convex-hull/types.js +12 -0
  96. package/dist/coordination/CoordinationBarPlot.svelte +41 -43
  97. package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
  98. package/dist/coordination/calc-coordination.d.ts +1 -1
  99. package/dist/coordination/calc-coordination.js +28 -25
  100. package/dist/element/BohrAtom.svelte +6 -8
  101. package/dist/element/ElementHeading.svelte +4 -1
  102. package/dist/element/ElementPhoto.svelte +11 -9
  103. package/dist/element/ElementStats.svelte +12 -10
  104. package/dist/element/ElementTile.svelte +24 -29
  105. package/dist/element/ElementTile.svelte.d.ts +1 -1
  106. package/dist/element/Nucleus.svelte +4 -2
  107. package/dist/element/data.d.ts +1 -2
  108. package/dist/element/helpers.d.ts +4 -0
  109. package/dist/element/helpers.js +18 -0
  110. package/dist/element/index.d.ts +1 -0
  111. package/dist/element/index.js +3 -0
  112. package/dist/feedback/DragOverlay.svelte +5 -3
  113. package/dist/feedback/DragOverlay.svelte.d.ts +2 -1
  114. package/dist/feedback/StatusMessage.svelte +20 -7
  115. package/dist/fermi-surface/FermiSlice.svelte +21 -18
  116. package/dist/fermi-surface/FermiSurface.svelte +78 -165
  117. package/dist/fermi-surface/FermiSurface.svelte.d.ts +9 -20
  118. package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
  119. package/dist/fermi-surface/FermiSurfaceScene.svelte +93 -272
  120. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
  121. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
  122. package/dist/fermi-surface/compute.js +14 -13
  123. package/dist/fermi-surface/export.js +4 -15
  124. package/dist/fermi-surface/index.d.ts +0 -1
  125. package/dist/fermi-surface/index.js +0 -1
  126. package/dist/fermi-surface/parse.d.ts +1 -1
  127. package/dist/fermi-surface/parse.js +84 -97
  128. package/dist/fermi-surface/types.d.ts +2 -2
  129. package/dist/heatmap-matrix/HeatmapMatrix.svelte +161 -185
  130. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +6 -5
  131. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +12 -9
  132. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
  133. package/dist/heatmap-matrix/index.d.ts +8 -2
  134. package/dist/icons.d.ts +4 -0
  135. package/dist/icons.js +4 -0
  136. package/dist/index.d.ts +1 -0
  137. package/dist/index.js +1 -0
  138. package/dist/io/ExportPane.svelte +170 -0
  139. package/dist/io/ExportPane.svelte.d.ts +17 -0
  140. package/dist/io/decompress.d.ts +2 -1
  141. package/dist/io/decompress.js +22 -36
  142. package/dist/io/export.d.ts +9 -1
  143. package/dist/io/export.js +37 -29
  144. package/dist/io/fetch.d.ts +2 -4
  145. package/dist/io/fetch.js +0 -11
  146. package/dist/io/file-drop.d.ts +7 -0
  147. package/dist/io/file-drop.js +13 -0
  148. package/dist/io/index.d.ts +1 -0
  149. package/dist/io/index.js +3 -0
  150. package/dist/io/is-binary.d.ts +9 -0
  151. package/dist/io/is-binary.js +45 -1
  152. package/dist/io/types.d.ts +13 -0
  153. package/dist/io/url-drop.js +13 -25
  154. package/dist/isosurface/Isosurface.svelte +17 -23
  155. package/dist/isosurface/IsosurfaceControls.svelte +37 -42
  156. package/dist/isosurface/parse-vaspwave.d.ts +3 -0
  157. package/dist/isosurface/parse-vaspwave.js +138 -0
  158. package/dist/isosurface/parse.js +50 -48
  159. package/dist/labels.d.ts +6 -2
  160. package/dist/labels.js +44 -14
  161. package/dist/layout/FullscreenButton.svelte +34 -0
  162. package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
  163. package/dist/layout/FullscreenToggle.svelte +12 -12
  164. package/dist/layout/InfoCard.svelte +7 -18
  165. package/dist/layout/InfoTag.svelte +1 -3
  166. package/dist/layout/NumberRangeInput.svelte +46 -0
  167. package/dist/layout/NumberRangeInput.svelte.d.ts +12 -0
  168. package/dist/layout/PropertyFilter.svelte +2 -6
  169. package/dist/layout/SettingsSection.svelte +21 -17
  170. package/dist/layout/SubpageGrid.svelte +3 -1
  171. package/dist/layout/ViewerChrome.svelte +115 -0
  172. package/dist/layout/ViewerChrome.svelte.d.ts +18 -0
  173. package/dist/layout/fullscreen.d.ts +4 -0
  174. package/dist/layout/fullscreen.js +3 -5
  175. package/dist/layout/fullscreen.svelte.d.ts +8 -0
  176. package/dist/layout/fullscreen.svelte.js +36 -0
  177. package/dist/layout/index.d.ts +4 -0
  178. package/dist/layout/index.js +4 -0
  179. package/dist/layout/json-tree/JsonNode.svelte +8 -11
  180. package/dist/layout/json-tree/JsonTree.svelte +53 -77
  181. package/dist/layout/json-tree/JsonValue.svelte +7 -15
  182. package/dist/layout/json-tree/utils.js +14 -23
  183. package/dist/math.d.ts +9 -3
  184. package/dist/math.js +37 -21
  185. package/dist/overlays/ContextMenu.svelte +4 -2
  186. package/dist/overlays/CopyButton.svelte +11 -5
  187. package/dist/overlays/DragControlTab.svelte +6 -1
  188. package/dist/overlays/DraggablePane.svelte +81 -26
  189. package/dist/overlays/DraggablePane.svelte.d.ts +1 -0
  190. package/dist/overlays/GlassChip.svelte +30 -0
  191. package/dist/overlays/GlassChip.svelte.d.ts +8 -0
  192. package/dist/overlays/InfoPaneCards.svelte +11 -23
  193. package/dist/overlays/index.d.ts +11 -0
  194. package/dist/overlays/index.js +26 -0
  195. package/dist/overlays/portal.d.ts +2 -0
  196. package/dist/overlays/portal.js +14 -0
  197. package/dist/periodic-table/PeriodicTable.svelte +115 -146
  198. package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
  199. package/dist/periodic-table/PeriodicTableControls.svelte +11 -63
  200. package/dist/periodic-table/TableInset.svelte +9 -4
  201. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +50 -71
  202. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
  203. package/dist/phase-diagram/PhaseDiagramControls.svelte +73 -96
  204. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
  205. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +4 -2
  206. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
  207. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +49 -134
  208. package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
  209. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
  210. package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
  211. package/dist/phase-diagram/build-diagram.js +3 -3
  212. package/dist/phase-diagram/colors.js +1 -1
  213. package/dist/phase-diagram/diagram-input.d.ts +1 -2
  214. package/dist/phase-diagram/parse.d.ts +2 -1
  215. package/dist/phase-diagram/parse.js +15 -15
  216. package/dist/phase-diagram/svg-to-diagram.js +21 -15
  217. package/dist/phase-diagram/utils.js +2 -3
  218. package/dist/plot/bar/BarPlot.svelte +494 -692
  219. package/dist/plot/bar/BarPlot.svelte.d.ts +9 -15
  220. package/dist/plot/bar/BarPlotControls.svelte +1 -3
  221. package/dist/plot/bar/BarPlotControls.svelte.d.ts +5 -7
  222. package/dist/plot/bar/SpacegroupBarPlot.svelte +31 -37
  223. package/dist/plot/bar/data.d.ts +5 -4
  224. package/dist/plot/bar/data.js +2 -1
  225. package/dist/plot/box/BoxPlot.svelte +361 -439
  226. package/dist/plot/box/BoxPlot.svelte.d.ts +6 -3
  227. package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
  228. package/dist/plot/box/Violin.svelte.d.ts +2 -1
  229. package/dist/plot/box/box-plot.d.ts +3 -2
  230. package/dist/plot/box/box-plot.js +6 -3
  231. package/dist/plot/box/kde.d.ts +2 -1
  232. package/dist/plot/box/kde.js +4 -4
  233. package/dist/plot/core/auto-place.d.ts +1 -1
  234. package/dist/plot/core/auto-place.js +5 -2
  235. package/dist/plot/core/axis-utils.d.ts +12 -7
  236. package/dist/plot/core/axis-utils.js +48 -48
  237. package/dist/plot/core/components/AxisLabel.svelte +82 -20
  238. package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
  239. package/dist/plot/core/components/ColorBar.svelte +106 -111
  240. package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
  241. package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
  242. package/dist/plot/core/components/FillArea.svelte +10 -17
  243. package/dist/plot/core/components/HierarchyControls.svelte +249 -0
  244. package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
  245. package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
  246. package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
  247. package/dist/plot/core/components/Line.svelte +21 -11
  248. package/dist/plot/core/components/Line.svelte.d.ts +5 -2
  249. package/dist/plot/core/components/PlotAxis.svelte +42 -18
  250. package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
  251. package/dist/plot/core/components/PlotControls.svelte +65 -41
  252. package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
  253. package/dist/plot/core/components/PlotLegend.svelte +31 -35
  254. package/dist/plot/core/components/PlotMarginals.svelte +616 -0
  255. package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
  256. package/dist/plot/core/components/PlotTooltip.svelte +1 -1
  257. package/dist/plot/core/components/PortalSelect.svelte +4 -8
  258. package/dist/plot/core/components/ReferenceLine.svelte +27 -24
  259. package/dist/plot/core/components/ReferenceLine3D.svelte +56 -59
  260. package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
  261. package/dist/plot/core/components/ReferencePlane.svelte +9 -10
  262. package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
  263. package/dist/plot/core/components/ZeroLines.svelte +4 -8
  264. package/dist/plot/core/components/ZoomRect.svelte +1 -2
  265. package/dist/plot/core/components/index.d.ts +1 -0
  266. package/dist/plot/core/components/index.js +1 -0
  267. package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
  268. package/dist/plot/core/data-cleaning-signal.js +467 -0
  269. package/dist/plot/core/data-cleaning.d.ts +2 -42
  270. package/dist/plot/core/data-cleaning.js +29 -476
  271. package/dist/plot/core/data-transform.js +9 -5
  272. package/dist/plot/core/fill-utils.d.ts +7 -4
  273. package/dist/plot/core/fill-utils.js +34 -9
  274. package/dist/plot/core/index.d.ts +1 -0
  275. package/dist/plot/core/index.js +1 -0
  276. package/dist/plot/core/interactions.d.ts +5 -1
  277. package/dist/plot/core/interactions.js +14 -2
  278. package/dist/plot/core/layout.d.ts +3 -1
  279. package/dist/plot/core/layout.js +22 -13
  280. package/dist/plot/core/marginals.d.ts +170 -0
  281. package/dist/plot/core/marginals.js +436 -0
  282. package/dist/plot/core/pan-zoom.svelte.d.ts +35 -0
  283. package/dist/plot/core/pan-zoom.svelte.js +221 -0
  284. package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
  285. package/dist/plot/core/placed-tween.svelte.js +68 -0
  286. package/dist/plot/core/reference-line.d.ts +10 -10
  287. package/dist/plot/core/reference-line.js +7 -7
  288. package/dist/plot/core/scales.d.ts +40 -25
  289. package/dist/plot/core/scales.js +49 -21
  290. package/dist/plot/core/svg.d.ts +2 -1
  291. package/dist/plot/core/types/fills.d.ts +101 -0
  292. package/dist/plot/core/types/fills.js +15 -0
  293. package/dist/plot/core/types/plot-3d.d.ts +87 -0
  294. package/dist/plot/core/types/plot-3d.js +4 -0
  295. package/dist/plot/core/types/reference-lines.d.ts +140 -0
  296. package/dist/plot/core/types/reference-lines.js +9 -0
  297. package/dist/plot/core/types.d.ts +47 -331
  298. package/dist/plot/core/types.js +23 -20
  299. package/dist/plot/core/utils/hierarchy-chart.d.ts +51 -0
  300. package/dist/plot/core/utils/hierarchy-chart.js +179 -0
  301. package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
  302. package/dist/plot/core/utils/hierarchy-labels.js +99 -0
  303. package/dist/plot/core/utils/label-placement.d.ts +1 -1
  304. package/dist/plot/core/utils/label-placement.js +5 -5
  305. package/dist/plot/core/utils.d.ts +2 -1
  306. package/dist/plot/histogram/Histogram.svelte +373 -631
  307. package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
  308. package/dist/plot/histogram/HistogramControls.svelte +30 -28
  309. package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
  310. package/dist/plot/histogram/histogram.d.ts +31 -0
  311. package/dist/plot/histogram/histogram.js +70 -0
  312. package/dist/plot/histogram/index.d.ts +1 -0
  313. package/dist/plot/histogram/index.js +1 -0
  314. package/dist/plot/index.d.ts +1 -0
  315. package/dist/plot/index.js +1 -0
  316. package/dist/plot/sankey/Sankey.svelte +79 -73
  317. package/dist/plot/sankey/Sankey.svelte.d.ts +3 -3
  318. package/dist/plot/sankey/SankeyControls.svelte +22 -16
  319. package/dist/plot/sankey/sankey.js +3 -1
  320. package/dist/plot/scatter/BinnedScatterPlot.svelte +264 -112
  321. package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +11 -4
  322. package/dist/plot/scatter/ElementScatter.svelte +4 -1
  323. package/dist/plot/scatter/ScatterPlot.svelte +623 -821
  324. package/dist/plot/scatter/ScatterPlot.svelte.d.ts +9 -15
  325. package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
  326. package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
  327. package/dist/plot/scatter/ScatterPoint.svelte +16 -9
  328. package/dist/plot/scatter/binned-scatter-types.d.ts +6 -12
  329. package/dist/plot/scatter/binned-scatter-types.js +6 -1
  330. package/dist/plot/scatter/index.d.ts +1 -1
  331. package/dist/plot/scatter/scatter-data.d.ts +1 -1
  332. package/dist/plot/scatter/scatter-data.js +8 -7
  333. package/dist/plot/scatter-3d/ScatterPlot3D.svelte +40 -60
  334. package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
  335. package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +17 -15
  336. package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
  337. package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +232 -234
  338. package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
  339. package/dist/plot/scatter-3d/Surface3D.svelte +9 -17
  340. package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
  341. package/dist/plot/sunburst/Sunburst.svelte +256 -338
  342. package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
  343. package/dist/plot/sunburst/index.d.ts +1 -1
  344. package/dist/plot/sunburst/index.js +2 -1
  345. package/dist/plot/sunburst/render.d.ts +2 -2
  346. package/dist/plot/sunburst/render.js +47 -22
  347. package/dist/plot/sunburst/sunburst.d.ts +5 -1
  348. package/dist/plot/sunburst/sunburst.js +14 -4
  349. package/dist/plot/treemap/Treemap.svelte +907 -0
  350. package/dist/plot/treemap/Treemap.svelte.d.ts +84 -0
  351. package/dist/plot/treemap/index.d.ts +3 -0
  352. package/dist/plot/treemap/index.js +4 -0
  353. package/dist/plot/treemap/treemap.d.ts +26 -0
  354. package/dist/plot/treemap/treemap.js +99 -0
  355. package/dist/rdf/RdfPlot.svelte +22 -26
  356. package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
  357. package/dist/rdf/calc-rdf.js +4 -8
  358. package/dist/sanitize.js +14 -3
  359. package/dist/scene/SceneCamera.svelte +62 -0
  360. package/dist/scene/SceneCamera.svelte.d.ts +19 -0
  361. package/dist/scene/bind-renderer.svelte.d.ts +2 -0
  362. package/dist/scene/bind-renderer.svelte.js +22 -0
  363. package/dist/scene/index.d.ts +4 -0
  364. package/dist/scene/index.js +5 -0
  365. package/dist/scene/props.js +52 -0
  366. package/dist/scene/types.d.ts +26 -0
  367. package/dist/scene/types.js +1 -0
  368. package/dist/settings.d.ts +33 -11
  369. package/dist/settings.js +136 -51
  370. package/dist/spectral/Bands.svelte +231 -237
  371. package/dist/spectral/Bands.svelte.d.ts +3 -2
  372. package/dist/spectral/BandsAndDos.svelte +29 -29
  373. package/dist/spectral/BrillouinBandsDos.svelte +21 -29
  374. package/dist/spectral/Dos.svelte +75 -77
  375. package/dist/spectral/Dos.svelte.d.ts +2 -1
  376. package/dist/spectral/helpers.d.ts +9 -9
  377. package/dist/spectral/helpers.js +66 -70
  378. package/dist/state.svelte.d.ts +0 -7
  379. package/dist/state.svelte.js +5 -24
  380. package/dist/structure/Arrow.svelte +6 -21
  381. package/dist/structure/ArrowInstances.svelte +160 -0
  382. package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
  383. package/dist/structure/AtomLegend.svelte +115 -75
  384. package/dist/structure/AtomLegend.svelte.d.ts +1 -1
  385. package/dist/structure/Bond.svelte +31 -23
  386. package/dist/structure/CanvasTooltip.svelte +16 -3
  387. package/dist/structure/CellSelect.svelte +22 -29
  388. package/dist/structure/CellSelect.svelte.d.ts +2 -1
  389. package/dist/structure/Cylinder.svelte +24 -40
  390. package/dist/structure/InstancedAtoms.svelte +114 -0
  391. package/dist/structure/InstancedAtoms.svelte.d.ts +15 -0
  392. package/dist/structure/Lattice.svelte +85 -149
  393. package/dist/structure/SiteLabels.svelte +122 -0
  394. package/dist/structure/SiteLabels.svelte.d.ts +18 -0
  395. package/dist/structure/Structure.svelte +725 -735
  396. package/dist/structure/Structure.svelte.d.ts +8 -16
  397. package/dist/structure/StructureCarousel.svelte +630 -0
  398. package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
  399. package/dist/structure/StructureControls.svelte +298 -325
  400. package/dist/structure/StructureControls.svelte.d.ts +5 -3
  401. package/dist/structure/StructureExportPane.svelte +62 -168
  402. package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
  403. package/dist/structure/StructureInfoPane.svelte +77 -69
  404. package/dist/structure/StructureInfoPane.svelte.d.ts +6 -6
  405. package/dist/structure/StructureScene.svelte +758 -600
  406. package/dist/structure/StructureScene.svelte.d.ts +24 -20
  407. package/dist/structure/StructureViewport.svelte +386 -0
  408. package/dist/structure/StructureViewport.svelte.d.ts +63 -0
  409. package/dist/structure/atom-label-placement.d.ts +18 -0
  410. package/dist/structure/atom-label-placement.js +115 -0
  411. package/dist/structure/atom-properties.d.ts +3 -1
  412. package/dist/structure/atom-properties.js +115 -54
  413. package/dist/structure/bond-order-perception.js +2 -4
  414. package/dist/structure/bonding.d.ts +12 -2
  415. package/dist/structure/bonding.js +172 -73
  416. package/dist/structure/edit-history.d.ts +6 -0
  417. package/dist/structure/edit-history.js +27 -0
  418. package/dist/structure/export.d.ts +25 -4
  419. package/dist/structure/export.js +103 -153
  420. package/dist/structure/format-detect.d.ts +1 -0
  421. package/dist/structure/format-detect.js +22 -0
  422. package/dist/structure/geometry.d.ts +9 -0
  423. package/dist/structure/geometry.js +27 -0
  424. package/dist/structure/index.d.ts +18 -1
  425. package/dist/structure/index.js +15 -2
  426. package/dist/structure/measure.d.ts +1 -1
  427. package/dist/structure/measure.js +6 -12
  428. package/dist/structure/parse.d.ts +5 -3
  429. package/dist/structure/parse.js +551 -567
  430. package/dist/structure/partial-occupancy.d.ts +0 -1
  431. package/dist/structure/partial-occupancy.js +5 -3
  432. package/dist/structure/pbc.d.ts +1 -1
  433. package/dist/structure/pbc.js +204 -51
  434. package/dist/structure/polyhedra.d.ts +40 -0
  435. package/dist/structure/polyhedra.js +587 -0
  436. package/dist/structure/site.d.ts +4 -0
  437. package/dist/structure/site.js +1 -0
  438. package/dist/structure/supercell.d.ts +1 -2
  439. package/dist/structure/supercell.js +10 -15
  440. package/dist/structure/validation.js +5 -6
  441. package/dist/symmetry/SymmetryElementControls.svelte +69 -0
  442. package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
  443. package/dist/symmetry/SymmetryElements.svelte +350 -0
  444. package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
  445. package/dist/symmetry/SymmetryStats.svelte +142 -49
  446. package/dist/symmetry/WyckoffTable.svelte +58 -16
  447. package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
  448. package/dist/symmetry/cell-transform.js +8 -14
  449. package/dist/symmetry/index.d.ts +15 -4
  450. package/dist/symmetry/index.js +308 -81
  451. package/dist/symmetry/spacegroups.d.ts +5 -1
  452. package/dist/symmetry/spacegroups.js +18 -3
  453. package/dist/symmetry/symmetry-elements.d.ts +33 -0
  454. package/dist/symmetry/symmetry-elements.js +521 -0
  455. package/dist/symmetry/wyckoff-db.d.ts +9 -0
  456. package/dist/symmetry/wyckoff-db.js +87 -0
  457. package/dist/table/HeatmapTable.svelte +1104 -378
  458. package/dist/table/HeatmapTable.svelte.d.ts +12 -2
  459. package/dist/table/ToggleMenu.svelte +5 -12
  460. package/dist/table/index.d.ts +21 -6
  461. package/dist/table/index.js +34 -21
  462. package/dist/theme/ThemeControl.svelte +16 -8
  463. package/dist/theme/index.d.ts +1 -5
  464. package/dist/theme/index.js +4 -10
  465. package/dist/theme/themes.mjs +14 -7
  466. package/dist/tooltip/KCoords.svelte +4 -1
  467. package/dist/tooltip/TooltipContent.svelte +2 -5
  468. package/dist/trajectory/Trajectory.svelte +556 -352
  469. package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
  470. package/dist/trajectory/TrajectoryError.svelte +11 -8
  471. package/dist/trajectory/TrajectoryExportPane.svelte +28 -54
  472. package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
  473. package/dist/trajectory/TrajectoryInfoPane.svelte +88 -99
  474. package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
  475. package/dist/trajectory/constants.js +6 -2
  476. package/dist/trajectory/extract.js +73 -71
  477. package/dist/trajectory/format-detect.d.ts +0 -1
  478. package/dist/trajectory/format-detect.js +13 -17
  479. package/dist/trajectory/frame-reader.d.ts +2 -1
  480. package/dist/trajectory/frame-reader.js +74 -136
  481. package/dist/trajectory/helpers.d.ts +12 -2
  482. package/dist/trajectory/helpers.js +68 -37
  483. package/dist/trajectory/index.d.ts +1 -0
  484. package/dist/trajectory/index.js +3 -0
  485. package/dist/trajectory/parse/ase.d.ts +9 -1
  486. package/dist/trajectory/parse/ase.js +47 -32
  487. package/dist/trajectory/parse/diagnostics.d.ts +3 -0
  488. package/dist/trajectory/parse/diagnostics.js +14 -0
  489. package/dist/trajectory/parse/h5-utils.d.ts +13 -0
  490. package/dist/trajectory/parse/h5-utils.js +109 -0
  491. package/dist/trajectory/parse/hdf5.d.ts +1 -1
  492. package/dist/trajectory/parse/hdf5.js +116 -106
  493. package/dist/trajectory/parse/index.d.ts +3 -4
  494. package/dist/trajectory/parse/index.js +68 -119
  495. package/dist/trajectory/parse/lammps.d.ts +0 -2
  496. package/dist/trajectory/parse/lammps.js +14 -16
  497. package/dist/trajectory/parse/pymatgen.d.ts +2 -0
  498. package/dist/trajectory/parse/pymatgen.js +74 -0
  499. package/dist/trajectory/parse/vasp.js +13 -9
  500. package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
  501. package/dist/trajectory/parse/vaspout-electronic.js +207 -0
  502. package/dist/trajectory/parse/vaspout-h5.d.ts +5 -0
  503. package/dist/trajectory/parse/vaspout-h5.js +284 -0
  504. package/dist/trajectory/parse/xyz.d.ts +9 -21
  505. package/dist/trajectory/parse/xyz.js +38 -39
  506. package/dist/trajectory/plotting.d.ts +8 -10
  507. package/dist/trajectory/plotting.js +102 -127
  508. package/dist/utils.d.ts +4 -0
  509. package/dist/utils.js +8 -1
  510. package/dist/xrd/XrdPlot.svelte +56 -85
  511. package/dist/xrd/broadening.d.ts +2 -1
  512. package/dist/xrd/broadening.js +2 -1
  513. package/dist/xrd/calc-xrd.js +8 -15
  514. package/dist/xrd/index.d.ts +2 -2
  515. package/dist/xrd/parse.d.ts +0 -1
  516. package/dist/xrd/parse.js +56 -73
  517. package/package.json +77 -36
  518. package/dist/api/mp.d.ts +0 -6
  519. package/dist/api/mp.js +0 -22
  520. package/dist/element/data.json +0 -11864
  521. package/dist/fermi-surface/marching-cubes.d.ts +0 -2
  522. package/dist/fermi-surface/marching-cubes.js +0 -2
  523. package/dist/plot/core/hover-lock.svelte.d.ts +0 -14
  524. package/dist/plot/core/hover-lock.svelte.js +0 -45
  525. package/dist/plot/sunburst/SunburstControls.svelte +0 -200
  526. package/dist/structure/label-placement.d.ts +0 -14
  527. package/dist/structure/label-placement.js +0 -72
@@ -1,10 +1,24 @@
1
1
  // Parsers for volumetric data file formats (VASP CHGCAR, Gaussian .cube)
2
- import { COMPRESSION_EXTENSIONS_REGEX, VASP_VOLUMETRIC_REGEX } from '../constants';
3
- import { ELEM_SYMBOLS } from '../labels';
2
+ import { ATOMIC_NUMBER_TO_SYMBOL } from '../composition/parse';
3
+ import { VASP_VOLUMETRIC_REGEX } from '../constants';
4
+ import { coerce_elem_symbol, FALLBACK_ELEMENTS } from '../element/helpers';
5
+ import { strip_compression_extensions } from '../io/decompress';
4
6
  import * as math from '../math';
5
7
  import { wrap_to_unit_cell } from '../structure/pbc';
8
+ import { make_site } from '../structure/site';
9
+ import { parse_leading_num } from '../utils';
6
10
  // Bohr radius in Angstroms (for Gaussian .cube unit conversion)
7
11
  const BOHR_TO_ANGSTROM = 0.529177249;
12
+ // === Parse error contract ===
13
+ // parse_chgcar/parse_cube return null and record reasons here (mirrored to console.error).
14
+ // parse_volumetric_file resets per call and throws when the FILENAME identifies a volumetric
15
+ // format that fails to parse, but returns null when content doesn't look volumetric at all
16
+ // (probe semantics — callers then fall back to structure parsing).
17
+ let vol_parse_errors = [];
18
+ const vol_error = (message) => {
19
+ vol_parse_errors.push(message);
20
+ console.error(message);
21
+ };
8
22
  // === Fast number parsing utilities ===
9
23
  // Parse whitespace-separated numbers directly from a string, starting at `pos`.
10
24
  // Writes into a pre-allocated Float64Array and returns { count, end_pos }.
@@ -175,9 +189,9 @@ export function parse_chgcar(content) {
175
189
  pos = cur.next;
176
190
  // Line 1: scale factor
177
191
  cur = read_line(content, pos);
178
- const scale_factor = parseFloat(cur.line);
192
+ const scale_factor = parse_leading_num(cur.line);
179
193
  if (isNaN(scale_factor)) {
180
- console.error(`Invalid scaling factor in CHGCAR`);
194
+ vol_error(`Invalid scaling factor in CHGCAR`);
181
195
  return null;
182
196
  }
183
197
  pos = cur.next;
@@ -195,30 +209,28 @@ export function parse_chgcar(content) {
195
209
  let atom_counts = [];
196
210
  cur = read_line(content, pos);
197
211
  if (pos >= content.length) {
198
- console.error(`CHGCAR: file ends before element/count lines`);
212
+ vol_error(`CHGCAR: file ends before element/count lines`);
199
213
  return null;
200
214
  }
201
215
  // Detect VASP 5+ format (has element symbols before counts)
202
- const first_token = cur.line.trim().split(/\s+/)[0];
203
- const has_element_symbols = isNaN(parseInt(first_token, 10));
216
+ const has_element_symbols = isNaN(parse_leading_num(cur.line));
204
217
  if (has_element_symbols) {
205
218
  element_symbols = cur.line.trim().split(/\s+/);
206
219
  pos = cur.next;
207
220
  cur = read_line(content, pos);
208
221
  if (pos >= content.length) {
209
- console.error(`CHGCAR: file ends before atom counts line`);
222
+ vol_error(`CHGCAR: file ends before atom counts line`);
210
223
  return null;
211
224
  }
212
225
  atom_counts = cur.line.trim().split(/\s+/).map(Number);
213
226
  }
214
227
  else {
215
228
  atom_counts = cur.line.trim().split(/\s+/).map(Number);
216
- const fallback_elements = [`H`, `He`, `Li`, `Be`, `B`, `C`, `N`, `O`, `F`, `Ne`];
217
- element_symbols = atom_counts.map((_count, idx) => fallback_elements[idx % fallback_elements.length]);
229
+ element_symbols = atom_counts.map((_count, idx) => FALLBACK_ELEMENTS[idx % FALLBACK_ELEMENTS.length]);
218
230
  }
219
231
  pos = cur.next;
220
232
  if (pos >= content.length) {
221
- console.error(`CHGCAR: file ends before coordinate mode line`);
233
+ vol_error(`CHGCAR: file ends before coordinate mode line`);
222
234
  return null;
223
235
  }
224
236
  // Check for selective dynamics line
@@ -228,7 +240,7 @@ export function parse_chgcar(content) {
228
240
  cur = read_line(content, pos);
229
241
  }
230
242
  if (pos >= content.length) {
231
- console.error(`CHGCAR: file ends before coordinate mode line`);
243
+ vol_error(`CHGCAR: file ends before coordinate mode line`);
232
244
  return null;
233
245
  }
234
246
  // Coordinate mode line
@@ -242,18 +254,18 @@ export function parse_chgcar(content) {
242
254
  ({ cart_to_frac, frac_to_cart } = math.create_lattice_converters(lattice));
243
255
  }
244
256
  catch {
245
- console.error(`CHGCAR: lattice matrix is singular; cannot convert coordinates`);
257
+ vol_error(`CHGCAR: lattice matrix is singular; cannot convert coordinates`);
246
258
  return null;
247
259
  }
248
260
  const sites = [];
249
261
  let atom_idx = 0;
250
262
  for (let elem_idx = 0; elem_idx < element_symbols.length; elem_idx++) {
251
263
  const symbol = element_symbols[elem_idx].split(/[_/]/)[0];
252
- const element = (ELEM_SYMBOLS.includes(symbol) ? symbol : `H`);
264
+ const element = coerce_elem_symbol(symbol) ?? `H`;
253
265
  const count = atom_counts[elem_idx];
254
266
  for (let count_idx = 0; count_idx < count; count_idx++) {
255
267
  if (pos >= content.length) {
256
- console.error(`CHGCAR: file ends before all atom coordinates are read`);
268
+ vol_error(`CHGCAR: file ends before all atom coordinates are read`);
257
269
  return null;
258
270
  }
259
271
  cur = read_line(content, pos);
@@ -270,13 +282,7 @@ export function parse_chgcar(content) {
270
282
  const raw = cart_to_frac(xyz);
271
283
  abc = wrap_to_unit_cell(raw);
272
284
  }
273
- sites.push({
274
- species: [{ element, occu: 1, oxidation_state: 0 }],
275
- abc,
276
- xyz,
277
- label: `${element}${atom_idx + count_idx + 1}`,
278
- properties: {},
279
- });
285
+ sites.push(make_site(element, abc, xyz, `${element}${atom_idx + count_idx + 1}`));
280
286
  }
281
287
  atom_idx += count;
282
288
  }
@@ -348,7 +354,7 @@ export function parse_chgcar(content) {
348
354
  }
349
355
  }
350
356
  if (volumes.length === 0) {
351
- console.error(`No volumetric data found in CHGCAR`);
357
+ vol_error(`No volumetric data found in CHGCAR`);
352
358
  return null;
353
359
  }
354
360
  return { structure, volumes };
@@ -365,7 +371,7 @@ export function parse_cube(content, options = {}) {
365
371
  line_count++;
366
372
  }
367
373
  if (line_count < 6) {
368
- console.error(`.cube file too short`);
374
+ vol_error(`.cube file too short`);
369
375
  return null;
370
376
  }
371
377
  // Parse header (first 6 lines + atom lines)
@@ -376,7 +382,7 @@ export function parse_cube(content, options = {}) {
376
382
  // (negative n_atoms indicates orbital data with extra header line)
377
383
  const line2 = header.lines[2].split(/\s+/).map(Number);
378
384
  if (line2.length < 4 || line2.some(isNaN)) {
379
- console.error(`.cube header line 3 malformed: expected 4 numbers`);
385
+ vol_error(`.cube header line 3 malformed: expected 4 numbers`);
380
386
  return null;
381
387
  }
382
388
  const n_atoms = Math.abs(line2[0]);
@@ -390,7 +396,7 @@ export function parse_cube(content, options = {}) {
390
396
  header.lines[5].split(/\s+/).map(Number),
391
397
  ];
392
398
  if (voxel_lines.some((line) => line.length < 4 || line.some(isNaN))) {
393
- console.error(`.cube voxel lines malformed: expected 4 numbers per line`);
399
+ vol_error(`.cube voxel lines malformed: expected 4 numbers per line`);
394
400
  return null;
395
401
  }
396
402
  const n_grid = [
@@ -423,7 +429,7 @@ export function parse_cube(content, options = {}) {
423
429
  }
424
430
  catch {
425
431
  // Non-periodic system (molecule), use identity
426
- cube_cart_to_frac = (v) => [v[0], v[1], v[2]];
432
+ cube_cart_to_frac = (vec) => [vec[0], vec[1], vec[2]];
427
433
  }
428
434
  for (let atom_idx = 0; atom_idx < n_atoms; atom_idx++) {
429
435
  const cur = read_line(content, pos);
@@ -444,13 +450,7 @@ export function parse_cube(content, options = {}) {
444
450
  const xyz = math.subtract(raw_xyz, origin);
445
451
  const abc = cube_cart_to_frac(xyz);
446
452
  const element = atomic_number_to_symbol(atom_line[0]);
447
- sites.push({
448
- species: [{ element, occu: 1, oxidation_state: 0 }],
449
- abc,
450
- xyz,
451
- label: `${element}${atom_idx + 1}`,
452
- properties: {},
453
- });
453
+ sites.push(make_site(element, abc, xyz, `${element}${atom_idx + 1}`));
454
454
  }
455
455
  // Build structure
456
456
  const lattice_params = math.calc_lattice_params(lattice);
@@ -474,7 +474,7 @@ export function parse_cube(content, options = {}) {
474
474
  if (parsed_count < total_points) {
475
475
  console.warn(`.cube: expected ${total_points} data values, got ${parsed_count}`);
476
476
  if (parsed_count === 0) {
477
- console.error(`No volumetric data found in .cube file`);
477
+ vol_error(`No volumetric data found in .cube file`);
478
478
  return null;
479
479
  }
480
480
  }
@@ -499,22 +499,24 @@ export function parse_cube(content, options = {}) {
499
499
  ];
500
500
  return { structure, volumes };
501
501
  }
502
- // Convert atomic number to element symbol using ELEM_SYMBOLS (1-indexed: H=1, He=2, ...)
503
- function atomic_number_to_symbol(atomic_number) {
504
- // ELEM_SYMBOLS is 0-indexed (H at index 0), atomic numbers are 1-indexed
505
- const idx = atomic_number - 1;
506
- return idx >= 0 && idx < ELEM_SYMBOLS.length ? ELEM_SYMBOLS[idx] : `H`;
507
- }
508
- // Auto-detect and parse volumetric file format based on filename and content
502
+ // Convert atomic number to element symbol (falls back to H for unknown numbers)
503
+ const atomic_number_to_symbol = (atomic_number) => ATOMIC_NUMBER_TO_SYMBOL[atomic_number] ?? `H`;
504
+ // Auto-detect and parse volumetric file by filename + content (see parse error contract at top)
509
505
  export function parse_volumetric_file(content, filename) {
506
+ vol_parse_errors = [];
507
+ const fail = (format) => {
508
+ const detail = vol_parse_errors.length ? `: ${vol_parse_errors.join(`; `)}` : ``;
509
+ throw new Error(`Failed to parse ${format} file${filename ? ` '${filename}'` : ``}${detail}`);
510
+ };
510
511
  // Strip compression suffixes so "CHGCAR.gz" and "molecule.cube.bz2" match correctly
511
- const lower_name = (filename ?? ``).toLowerCase().replace(COMPRESSION_EXTENSIONS_REGEX, ``);
512
- // Extension-based detection
512
+ const lower_name = strip_compression_extensions(filename ?? ``);
513
+ // Extension-based detection (filename is authoritative: parse failure throws)
513
514
  if (lower_name.endsWith(`.cube`))
514
- return parse_cube(content);
515
+ return parse_cube(content) ?? fail(`.cube`);
515
516
  // VASP volumetric file detection by filename
516
- if (VASP_VOLUMETRIC_REGEX.test(lower_name))
517
- return parse_chgcar(content);
517
+ if (VASP_VOLUMETRIC_REGEX.test(lower_name)) {
518
+ return parse_chgcar(content) ?? fail(`VASP volumetric (CHGCAR-like)`);
519
+ }
518
520
  // Content-based detection (only parse first few lines, not the whole file)
519
521
  // Find enough lines for detection without splitting the entire string
520
522
  const detection_end = find_line_offset(content, 10);
@@ -534,7 +536,7 @@ export function parse_volumetric_file(content, filename) {
534
536
  // CHGCAR detection: requires POSCAR-like header (scale factor on line 2) AND
535
537
  // a grid dimensions line (3 integers) somewhere after the header. This distinguishes
536
538
  // CHGCAR from plain POSCAR/CONTCAR files which share the same header format.
537
- if (lines.length > 2 && !isNaN(parseFloat(lines[1].trim()))) {
539
+ if (lines.length > 2 && !isNaN(parse_leading_num(lines[1]))) {
538
540
  // Scan for grid dimensions line (3 integers) starting from ~line 7
539
541
  let scan_pos = find_line_offset(content, 7);
540
542
  // Only scan a limited window, not the entire file
package/dist/labels.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare const ELEM_HEATMAP_KEYS: (keyof ChemicalElement)[];
12
12
  export declare const ELEM_HEATMAP_LABELS: Partial<Record<string, keyof ChemicalElement>>;
13
13
  export declare const DEFAULT_FMT: [string, string];
14
14
  export declare const FRACTION_GLYPHS: readonly (readonly [number, string])[];
15
+ export declare const format_value_or_num: (value: number, fmt?: string) => string;
15
16
  export declare const format_num: (num: number, fmt?: string | number) => string;
16
17
  export declare const format_vec3: (vec: Readonly<Vec3>, fmt_spec?: string) => string;
17
18
  export declare const format_bytes: (bytes?: number) => string;
@@ -47,7 +48,10 @@ export declare const SUBSCRIPT_MAP: {
47
48
  readonly '9': "₉";
48
49
  };
49
50
  export declare const superscript_digits: (input: string) => string;
50
- export declare const trajectory_property_config: Record<string, {
51
+ export declare const SCF_AXIS_GROUP = "eV (SCF)";
52
+ export interface TrajPropertyConfig {
51
53
  label: string;
52
54
  unit: string;
53
- }>;
55
+ axis_group?: string;
56
+ }
57
+ export declare const trajectory_property_config: Record<string, TrajPropertyConfig>;
package/dist/labels.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { normalize_unicode_minus } from './utils';
1
2
  import { format } from 'd3-format';
2
3
  import * as d3_symbols from 'd3-shape';
3
4
  import { timeFormat } from 'd3-time-format';
@@ -16,7 +17,7 @@ export const symbol_names = [
16
17
  ...new Set([...d3_symbols.symbolsFill, ...d3_symbols.symbolsStroke]),
17
18
  ]
18
19
  .map(name_for_symbol)
19
- .filter((n) => n !== null);
20
+ .filter((name) => name !== null);
20
21
  export const symbol_map = Object.fromEntries(
21
22
  // Symbol lookup from d3-shape
22
23
  symbol_names.map((name) => [name, d3_symbols[`symbol${name}`]]));
@@ -33,12 +34,11 @@ export function format_value(value, formatter) {
33
34
  return `Infinity`;
34
35
  if (Number.isNaN(value))
35
36
  return `NaN`;
36
- // Format and normalize unicode minus
37
- const formatted = format(formatter)(value).replaceAll('−', `-`);
37
+ const formatted = normalize_unicode_minus(format(formatter)(value));
38
38
  // Handle percentage formatting - remove trailing zeros
39
39
  if (formatter.includes(`%`)) {
40
40
  return formatted.includes(`.`)
41
- ? formatted.replace(/(\.\d*?)0+%$/, `$1%`).replace(/\.%$/, `%`)
41
+ ? formatted.replace(/(?<decimals>\.\d*?)0+%$/, `$1%`).replace(/\.%$/, `%`)
42
42
  : formatted;
43
43
  }
44
44
  // Handle currency formatting - preserve precision if specified
@@ -47,26 +47,44 @@ export function format_value(value, formatter) {
47
47
  }
48
48
  // Remove trailing zeros after decimal point
49
49
  const out = formatted.includes(`.`)
50
- ? formatted.replace(/(\.\d*?)0+$/, `$1`).replace(/\.$/, ``)
50
+ ? formatted.replace(/(?<decimals>\.\d*?)0+$/, `$1`).replace(/\.$/, ``)
51
51
  : formatted;
52
52
  return out === `-0` ? `0` : out;
53
53
  }
54
- // TODO add labels and units for all elemental properties
54
+ // Human-readable label + unit (null when dimensionless) for displayable element
55
+ // properties. Omitted: Record-valued (ionic_radii, shannon_radii), assets
56
+ // (cpk-hex, spectral_img), heading/summary fields (name, symbol, category,
57
+ // discoverer, year, summary) and electronegativity_pauling (identical to
58
+ // electronegativity).
55
59
  export const ELEM_PROPERTY_LABELS = {
60
+ appearance: [`Appearance`, null],
56
61
  atomic_mass: [`Atomic Mass`, `u`],
57
62
  atomic_radius: [`Atomic Radius`, `Å`],
58
63
  boiling_point: [`Boiling Point`, `K`],
64
+ column: [`Group`, null],
65
+ common_oxidation_states: [`Common Oxidation States`, null],
59
66
  covalent_radius: [`Covalent Radius`, `Å`],
60
67
  density: [`Density`, `g/cm³`],
61
- electron_affinity: [`Electron Affinity`, null],
68
+ electron_affinity: [`Electron Affinity`, `kJ/mol`],
69
+ electron_configuration: [`Electron Configuration`, null],
70
+ electron_configuration_semantic: [`Electron Configuration (semantic)`, null],
62
71
  electronegativity: [`Electronegativity`, null],
72
+ electrons: [`Electrons`, null],
63
73
  first_ionization: [`First Ionization Energy`, `eV`],
74
+ icsd_oxidation_states: [`ICSD Oxidation States`, null],
75
+ ionization_energies: [`Ionization Energies`, `kJ/mol`],
64
76
  melting_point: [`Melting Point`, `K`],
65
77
  mendeleev_number: [`Mendeleev Number`, null],
66
- // molar_heat: [`Molar Heat`, `J/(mol·K)`],
78
+ molar_heat: [`Molar Heat`, `J/(mol·K)`],
67
79
  n_shells: [`Number of Shells`, null],
68
80
  n_valence: [`Electron Valency`, null],
81
+ neutrons: [`Neutrons`, null],
69
82
  number: [`Atomic Number`, null],
83
+ number_of_isotopes: [`Number of Isotopes`, null],
84
+ oxidation_states: [`Oxidation States`, null],
85
+ period: [`Period`, null],
86
+ phase: [`Phase`, null],
87
+ protons: [`Protons`, null],
70
88
  shells: [`Electron Shell Occupations`, null],
71
89
  specific_heat: [`Specific Heat`, `J/(g K)`],
72
90
  };
@@ -108,6 +126,10 @@ export const FRACTION_GLYPHS = [
108
126
  [7 / 8, `⁷⁄₈`],
109
127
  [11 / 12, `¹¹⁄₁₂`],
110
128
  ];
129
+ // format_value when an explicit format is given, else format_num's adaptive
130
+ // default: SI prefixes for |value| >= 1 (4500 -> 4.5k) but plain decimals
131
+ // below 1 (0.2 stays 0.2, never the SI milli form "200m")
132
+ export const format_value_or_num = (value, fmt) => fmt ? format_value(value, fmt) : format_num(value);
111
133
  // fmt as number only allowed to support [].map(format_num) without type error
112
134
  export const format_num = (num, fmt) => {
113
135
  if (num === null)
@@ -157,10 +179,10 @@ export function parse_si_float(value) {
157
179
  if (typeof value !== `string`)
158
180
  return value;
159
181
  // Remove whitespace and commas
160
- const cleaned = value.trim().replaceAll(/(\d),(\d)/g, `$1$2`);
182
+ const cleaned = value.trim().replaceAll(/(?<before>\d),(?<after>\d)/g, `$1$2`);
161
183
  // SI-formatted number (e.g. "1.23k", "789µ"). Suffixes are case-sensitive (m=milli vs
162
184
  // M=mega), so no `i` flag: mismatched-case suffixes return the string as-is.
163
- const match = /^([-+]?\d*\.?\d+)\s*([yzafpnµmkMGTPEZY])?$/.exec(cleaned);
185
+ const match = /^(?<num_part>[-+]?\d*\.?\d+)\s*(?<suffix>[yzafpnµmkMGTPEZY])?$/.exec(cleaned);
164
186
  if (match) {
165
187
  const [, num_part, suffix] = match;
166
188
  let multiplier = 1;
@@ -171,11 +193,12 @@ export function parse_si_float(value) {
171
193
  multiplier = 1000 ** (index - 8);
172
194
  }
173
195
  }
174
- return parseFloat(num_part) * multiplier;
196
+ return Number(num_part) * multiplier;
175
197
  }
176
- // If it's a number without SI suffix, try parsing it
198
+ // If it's a number without SI suffix, try parsing it (dropping stray commas
199
+ // not already stripped above, e.g. trailing ones)
177
200
  if (/^[-+]?[\d,]+\.?\d*$/.test(cleaned))
178
- return parseFloat(cleaned);
201
+ return Number(cleaned.replaceAll(`,`, ``));
179
202
  // If the value is not a formatted number, return as is
180
203
  return value;
181
204
  }
@@ -234,7 +257,9 @@ export const SUBSCRIPT_MAP = {
234
257
  };
235
258
  // replaces all signs and digits with their unicode superscript equivalent
236
259
  export const superscript_digits = (input) => input.replaceAll(/[\d+-]/g, (match) => is_superscript_key(match) ? SUPERSCRIPT_MAP[match] : match);
237
- // Trajectory property configuration: clean labels and units as structured data
260
+ // Axis-group key for SCF convergence series: shared between the property config
261
+ // below and the log-scale detection in trajectory/plotting.ts so the two can't drift
262
+ export const SCF_AXIS_GROUP = `eV (SCF)`;
238
263
  export const trajectory_property_config = {
239
264
  // Energy properties
240
265
  energy: { label: `Energy`, unit: `eV` },
@@ -275,4 +300,9 @@ export const trajectory_property_config = {
275
300
  Pressure: { label: `Pressure`, unit: `GPa` },
276
301
  stress_max: { label: `σ<sub>max</sub>`, unit: `GPa` },
277
302
  stress_frobenius: { label: `σ<sub>F</sub>`, unit: `GPa` },
303
+ // SCF/electronic convergence properties (e.g. from VASP vaspout.h5 OSZICAR data)
304
+ n_scf_steps: { label: `SCF steps`, unit: `steps` },
305
+ scf_energy_delta: { label: `|ΔE<sub>SCF</sub>|`, unit: `eV`, axis_group: SCF_AXIS_GROUP },
306
+ scf_rms: { label: `ρ residual (rms)`, unit: `a.u.` },
307
+ scf_charge_rms: { label: `ρ<sub>c</sub> residual (rms(c))`, unit: `a.u.` },
278
308
  };
@@ -0,0 +1,34 @@
1
+ <script lang="ts">
2
+ // Fullscreen toggle button (default Icon or custom snippet content), shared by the
3
+ // Trajectory/ChemPotDiagram3D/ConvexHull viewer chromes
4
+ import Icon from '../Icon.svelte'
5
+ import type { HTMLButtonAttributes } from 'svelte/elements'
6
+ import { type FullscreenToggleProp, toggle_fullscreen } from './fullscreen'
7
+
8
+ let {
9
+ fullscreen = false,
10
+ toggle = true, // pass a snippet to render custom button content
11
+ wrapper = undefined, // element sent fullscreen
12
+ ...rest
13
+ }: HTMLButtonAttributes & {
14
+ fullscreen?: boolean
15
+ toggle?: FullscreenToggleProp
16
+ wrapper?: HTMLDivElement
17
+ } = $props()
18
+ </script>
19
+
20
+ <button
21
+ type="button"
22
+ onclick={() => toggle_fullscreen(wrapper)}
23
+ title="{fullscreen ? `Exit` : `Enter`} fullscreen"
24
+ aria-label="{fullscreen ? `Exit` : `Enter`} fullscreen"
25
+ aria-pressed={fullscreen}
26
+ {...rest}
27
+ class={[`fullscreen-btn`, rest.class]}
28
+ >
29
+ {#if typeof toggle === `function`}
30
+ {@render toggle({ fullscreen })}
31
+ {:else}
32
+ <Icon icon={fullscreen ? `ExitFullscreen` : `Fullscreen`} />
33
+ {/if}
34
+ </button>
@@ -0,0 +1,10 @@
1
+ import type { HTMLButtonAttributes } from 'svelte/elements';
2
+ import { type FullscreenToggleProp } from './fullscreen';
3
+ type $$ComponentProps = HTMLButtonAttributes & {
4
+ fullscreen?: boolean;
5
+ toggle?: FullscreenToggleProp;
6
+ wrapper?: HTMLDivElement;
7
+ };
8
+ declare const FullscreenButton: import("svelte").Component<$$ComponentProps, {}, "">;
9
+ type FullscreenButton = ReturnType<typeof FullscreenButton>;
10
+ export default FullscreenButton;
@@ -1,10 +1,11 @@
1
1
  <script lang="ts">
2
+ // Toggles a bindable `fullscreen` flag (plot components manage browser fullscreen
3
+ // themselves). For chromes that call the browser API directly, use FullscreenButton.
2
4
  import Icon from '../Icon.svelte'
3
5
  import type { HTMLButtonAttributes } from 'svelte/elements'
4
6
 
5
7
  let {
6
8
  fullscreen = $bindable(false),
7
- class: className,
8
9
  ...rest
9
10
  }: HTMLButtonAttributes & {
10
11
  fullscreen?: boolean
@@ -12,17 +13,13 @@
12
13
  </script>
13
14
 
14
15
  <button
15
- class="fullscreen-toggle {className ?? ``}"
16
+ {...rest}
17
+ class={[`fullscreen-toggle`, rest.class]}
16
18
  onclick={() => (fullscreen = !fullscreen)}
17
19
  aria-label={fullscreen ? `Exit fullscreen` : `Enter fullscreen`}
18
20
  type="button"
19
- {...rest}
20
21
  >
21
- <Icon
22
- icon={fullscreen ? `ExitFullscreen` : `Fullscreen`}
23
- width="18"
24
- height="18"
25
- />
22
+ <Icon icon="{fullscreen ? `Exit` : ``}Fullscreen" width="18" height="18" />
26
23
  </button>
27
24
 
28
25
  <style>
@@ -39,12 +36,15 @@
39
36
  background-color: transparent;
40
37
  cursor: pointer;
41
38
  opacity: 0;
42
- transition: opacity 0.2s, background-color 0.2s;
39
+ transition:
40
+ opacity 0.2s,
41
+ background-color 0.2s;
43
42
  }
44
- .fullscreen-toggle:hover, .fullscreen-toggle:focus {
43
+ .fullscreen-toggle:hover,
44
+ .fullscreen-toggle:focus {
45
45
  background-color: color-mix(in srgb, currentColor 8%, transparent);
46
46
  opacity: var(--fullscreen-btn-hover-opacity, 1);
47
47
  }
48
- /* Note: Parent component should add styles to show on parent hover */
49
- /* Example: .parent:hover :global(.fullscreen-toggle) { opacity: 1; } */
48
+ /* Note: Parent component should add styles to show on parent hover
49
+ Example: .parent:hover :global(.fullscreen-toggle) { opacity: 1; } */
50
50
  </style>
@@ -4,8 +4,9 @@
4
4
  import type { Snippet } from 'svelte'
5
5
  import type { HTMLAttributes } from 'svelte/elements'
6
6
 
7
- interface Props<T extends keyof HTMLElementTagNameMap = `section`>
8
- extends HTMLAttributes<HTMLElementTagNameMap[T]> {
7
+ interface Props<T extends keyof HTMLElementTagNameMap = `section`> extends HTMLAttributes<
8
+ HTMLElementTagNameMap[T]
9
+ > {
9
10
  data?: {
10
11
  title: string
11
12
  value?: string | number | number[] | null
@@ -35,7 +36,7 @@
35
36
  let default_fmt = $derived(fmt) // rename fmt to default_fmt for internal use
36
37
  </script>
37
38
 
38
- <svelte:element this={as} {...rest} class="info-card {rest.class ?? ``}">
39
+ <svelte:element this={as} {...rest} class={[`info-card`, rest.class]}>
39
40
  {#if title || title_snippet}
40
41
  <h2>
41
42
  {#if title_snippet}{@render title_snippet()}{:else}
@@ -43,13 +44,7 @@
43
44
  {/if}
44
45
  </h2>
45
46
  {/if}
46
- {#each data.filter((itm) =>
47
- (!(`condition` in itm) || itm?.condition) && itm.value !== undefined &&
48
- itm.value !== null
49
- ) as
50
- { title, value, unit, fmt = default_fmt, tooltip }
51
- (title + value + unit + fmt)
52
- }
47
+ {#each data.filter((itm) => (!(`condition` in itm) || itm?.condition) && itm.value !== undefined && itm.value !== null) as { title, value, unit, fmt = default_fmt, tooltip } (title + value + unit + fmt)}
53
48
  <div>
54
49
  <span class="title" {title}>
55
50
  {@html sanitize_html(title)}
@@ -77,10 +72,7 @@
77
72
  padding: var(--ic-padding, 10pt 12pt);
78
73
  margin: var(--ic-margin, 1em 0);
79
74
  gap: var(--ic-gap, 10pt 5%);
80
- background-color: var(
81
- --ic-bg,
82
- light-dark(rgba(0, 0, 0, 0.05), rgba(255, 255, 255, 0.1))
83
- );
75
+ background-color: var(--ic-bg, light-dark(rgba(0, 0, 0, 0.05), rgba(255, 255, 255, 0.1)));
84
76
  font-size: var(--ic-font-size);
85
77
  width: var(--ic-width);
86
78
  }
@@ -88,10 +80,7 @@
88
80
  grid-column: 1 / -1;
89
81
  margin: 0;
90
82
  border-bottom: 1px solid
91
- var(
92
- --ic-title-border-color,
93
- light-dark(rgba(0, 0, 0, 0.15), rgba(255, 255, 255, 0.3))
94
- );
83
+ var(--ic-title-border-color, light-dark(rgba(0, 0, 0, 0.15), rgba(255, 255, 255, 0.3)));
95
84
  }
96
85
  div {
97
86
  display: flex;
@@ -49,9 +49,7 @@
49
49
  else void copy_to_clipboard()
50
50
  }
51
51
 
52
- function handle_keydown(
53
- event: KeyboardEvent & { currentTarget: HTMLElement },
54
- ): void {
52
+ function handle_keydown(event: KeyboardEvent & { currentTarget: HTMLElement }): void {
55
53
  if (disabled || (event.key !== `Enter` && event.key !== ` `)) return
56
54
  event.preventDefault()
57
55
  event.currentTarget.click()
@@ -0,0 +1,46 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+ import type { HTMLAttributes } from 'svelte/elements'
4
+ import { tooltip } from 'svelte-multiselect/attachments'
5
+
6
+ // Paired number + range input bound to the same value, wrapped in a flex <label>.
7
+ // The label text/markup is passed as children (supports inline units like <small>Å</small>).
8
+ // Pass a `title` (via rest) to show a tooltip; wrapping <label> only names the number input
9
+ // so range slider reuses that `title` as its accessible name.
10
+ let {
11
+ value = $bindable(),
12
+ min,
13
+ max,
14
+ step,
15
+ children,
16
+ ...rest
17
+ }: {
18
+ value: number | undefined
19
+ min: number | string
20
+ max: number | string
21
+ step: number | string
22
+ children?: Snippet
23
+ } & HTMLAttributes<HTMLLabelElement> = $props()
24
+ </script>
25
+
26
+ <label {@attach tooltip()} {...rest}>
27
+ {@render children?.()}
28
+ <input type="number" {min} {max} {step} bind:value />
29
+ <input type="range" {min} {max} {step} bind:value aria-label={rest.title} />
30
+ </label>
31
+
32
+ <style>
33
+ label {
34
+ display: flex;
35
+ align-items: center;
36
+ gap: 10pt;
37
+ }
38
+ input {
39
+ font-size: inherit;
40
+ font-family: inherit;
41
+ }
42
+ input[type='range'] {
43
+ flex: 1;
44
+ min-width: 40px;
45
+ }
46
+ </style>
@@ -0,0 +1,12 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ type $$ComponentProps = {
4
+ value: number | undefined;
5
+ min: number | string;
6
+ max: number | string;
7
+ step: number | string;
8
+ children?: Snippet;
9
+ } & HTMLAttributes<HTMLLabelElement>;
10
+ declare const NumberRangeInput: import("svelte").Component<$$ComponentProps, {}, "value">;
11
+ type NumberRangeInput = ReturnType<typeof NumberRangeInput>;
12
+ export default NumberRangeInput;
@@ -40,9 +40,7 @@
40
40
  onclear?: () => void // Callback when clear button is clicked (fires before onchange)
41
41
  } & HTMLAttributes<HTMLDivElement> = $props()
42
42
 
43
- let show_histogram = $derived(
44
- histogram_position !== `none` && histogram_data?.length,
45
- )
43
+ let show_histogram = $derived(histogram_position !== `none` && histogram_data?.length)
46
44
 
47
45
  // Active when either bound is set (undefined = unbounded)
48
46
  let active = $derived(min_value !== undefined || max_value !== undefined)
@@ -56,9 +54,7 @@
56
54
  return histogram_data.filter((val) => val >= min && val <= max)
57
55
  })
58
56
 
59
- function onkeydown(
60
- event: KeyboardEvent & { currentTarget: HTMLInputElement },
61
- ): void {
57
+ function onkeydown(event: KeyboardEvent & { currentTarget: HTMLInputElement }): void {
62
58
  if (event.key === `Enter`) {
63
59
  event.preventDefault()
64
60
  event.currentTarget.blur()