matterviz 0.4.1 → 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 (395) 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 +75 -85
  7. package/dist/brillouin/BrillouinZone.svelte.d.ts +5 -7
  8. package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
  9. package/dist/brillouin/BrillouinZoneExportPane.svelte +18 -14
  10. package/dist/brillouin/BrillouinZoneInfoPane.svelte +6 -10
  11. package/dist/brillouin/BrillouinZoneScene.svelte +26 -39
  12. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
  13. package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
  14. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +62 -74
  15. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +1 -1
  16. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +511 -547
  17. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +1 -1
  18. package/dist/chempot-diagram/async-compute.svelte.js +1 -1
  19. package/dist/chempot-diagram/controls-state.svelte.js +1 -1
  20. package/dist/colors/index.d.ts +0 -4
  21. package/dist/colors/index.js +19 -20
  22. package/dist/composition/BarChart.svelte +37 -31
  23. package/dist/composition/BubbleChart.svelte +17 -17
  24. package/dist/composition/Composition.svelte +7 -11
  25. package/dist/composition/Formula.svelte +18 -25
  26. package/dist/composition/FormulaFilter.svelte +92 -95
  27. package/dist/composition/PieChart.svelte +55 -41
  28. package/dist/composition/format.js +1 -1
  29. package/dist/composition/index.d.ts +2 -0
  30. package/dist/composition/index.js +14 -0
  31. package/dist/composition/parse.d.ts +2 -2
  32. package/dist/composition/parse.js +11 -10
  33. package/dist/constants.js +11 -9
  34. package/dist/convex-hull/ConvexHull.svelte +12 -15
  35. package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
  36. package/dist/convex-hull/ConvexHull2D.svelte +93 -92
  37. package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
  38. package/dist/convex-hull/ConvexHull3D.svelte +109 -140
  39. package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
  40. package/dist/convex-hull/ConvexHull4D.svelte +75 -94
  41. package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
  42. package/dist/convex-hull/ConvexHullChrome.svelte +36 -40
  43. package/dist/convex-hull/ConvexHullControls.svelte +46 -48
  44. package/dist/convex-hull/ConvexHullStats.svelte +193 -195
  45. package/dist/convex-hull/ConvexHullTooltip.svelte +5 -12
  46. package/dist/convex-hull/GasPressureControls.svelte +5 -12
  47. package/dist/convex-hull/StructurePopup.svelte +17 -21
  48. package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
  49. package/dist/convex-hull/TemperatureSlider.svelte +4 -10
  50. package/dist/convex-hull/canvas-interactions.svelte.js +2 -1
  51. package/dist/convex-hull/helpers.d.ts +8 -10
  52. package/dist/convex-hull/helpers.js +36 -36
  53. package/dist/convex-hull/hull-state.svelte.d.ts +1 -1
  54. package/dist/convex-hull/thermodynamics.js +18 -17
  55. package/dist/coordination/CoordinationBarPlot.svelte +38 -33
  56. package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
  57. package/dist/coordination/calc-coordination.d.ts +1 -1
  58. package/dist/coordination/calc-coordination.js +28 -25
  59. package/dist/element/BohrAtom.svelte +5 -8
  60. package/dist/element/ElementHeading.svelte +4 -1
  61. package/dist/element/ElementPhoto.svelte +11 -9
  62. package/dist/element/ElementStats.svelte +12 -10
  63. package/dist/element/ElementTile.svelte +24 -29
  64. package/dist/element/Nucleus.svelte +4 -2
  65. package/dist/element/data.d.ts +1 -2
  66. package/dist/element/helpers.d.ts +4 -0
  67. package/dist/element/helpers.js +18 -0
  68. package/dist/element/index.d.ts +1 -4
  69. package/dist/element/index.js +3 -18
  70. package/dist/feedback/DragOverlay.svelte +5 -5
  71. package/dist/feedback/DragOverlay.svelte.d.ts +2 -2
  72. package/dist/feedback/StatusMessage.svelte +7 -4
  73. package/dist/fermi-surface/FermiSlice.svelte +21 -18
  74. package/dist/fermi-surface/FermiSurface.svelte +14 -22
  75. package/dist/fermi-surface/FermiSurface.svelte.d.ts +5 -7
  76. package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
  77. package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
  78. package/dist/fermi-surface/FermiSurfaceScene.svelte +37 -64
  79. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
  80. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
  81. package/dist/fermi-surface/compute.js +3 -3
  82. package/dist/fermi-surface/parse.js +22 -24
  83. package/dist/heatmap-matrix/HeatmapMatrix.svelte +109 -148
  84. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +2 -2
  85. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +9 -7
  86. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +1 -1
  87. package/dist/heatmap-matrix/index.d.ts +5 -0
  88. package/dist/icons.d.ts +4 -0
  89. package/dist/icons.js +4 -0
  90. package/dist/io/ExportPane.svelte +10 -6
  91. package/dist/io/decompress.d.ts +2 -1
  92. package/dist/io/decompress.js +22 -35
  93. package/dist/io/export.d.ts +4 -0
  94. package/dist/io/export.js +5 -1
  95. package/dist/io/fetch.d.ts +0 -3
  96. package/dist/io/fetch.js +0 -11
  97. package/dist/io/index.d.ts +0 -1
  98. package/dist/io/index.js +2 -9
  99. package/dist/io/is-binary.d.ts +9 -0
  100. package/dist/io/is-binary.js +45 -1
  101. package/dist/io/url-drop.js +13 -25
  102. package/dist/isosurface/Isosurface.svelte +17 -23
  103. package/dist/isosurface/IsosurfaceControls.svelte +37 -42
  104. package/dist/isosurface/parse-vaspwave.d.ts +3 -0
  105. package/dist/isosurface/parse-vaspwave.js +138 -0
  106. package/dist/isosurface/parse.js +6 -6
  107. package/dist/labels.d.ts +6 -2
  108. package/dist/labels.js +43 -13
  109. package/dist/layout/FullscreenButton.svelte +2 -1
  110. package/dist/layout/FullscreenToggle.svelte +10 -4
  111. package/dist/layout/InfoCard.svelte +7 -18
  112. package/dist/layout/InfoTag.svelte +1 -3
  113. package/dist/layout/NumberRangeInput.svelte +46 -0
  114. package/dist/layout/NumberRangeInput.svelte.d.ts +12 -0
  115. package/dist/layout/PropertyFilter.svelte +2 -6
  116. package/dist/layout/SettingsSection.svelte +21 -17
  117. package/dist/layout/SubpageGrid.svelte +3 -1
  118. package/dist/layout/ViewerChrome.svelte +9 -10
  119. package/dist/layout/ViewerChrome.svelte.d.ts +2 -1
  120. package/dist/layout/fullscreen.js +3 -5
  121. package/dist/layout/fullscreen.svelte.js +1 -2
  122. package/dist/layout/index.d.ts +1 -0
  123. package/dist/layout/index.js +1 -0
  124. package/dist/layout/json-tree/JsonNode.svelte +8 -11
  125. package/dist/layout/json-tree/JsonTree.svelte +53 -77
  126. package/dist/layout/json-tree/JsonValue.svelte +7 -15
  127. package/dist/layout/json-tree/utils.js +14 -23
  128. package/dist/math.d.ts +2 -0
  129. package/dist/math.js +19 -0
  130. package/dist/overlays/ContextMenu.svelte +4 -2
  131. package/dist/overlays/CopyButton.svelte +11 -5
  132. package/dist/overlays/DragControlTab.svelte +6 -1
  133. package/dist/overlays/DraggablePane.svelte +81 -26
  134. package/dist/overlays/DraggablePane.svelte.d.ts +1 -0
  135. package/dist/overlays/GlassChip.svelte +30 -0
  136. package/dist/overlays/GlassChip.svelte.d.ts +8 -0
  137. package/dist/overlays/InfoPaneCards.svelte +11 -23
  138. package/dist/overlays/index.d.ts +7 -0
  139. package/dist/overlays/index.js +26 -0
  140. package/dist/overlays/portal.d.ts +2 -0
  141. package/dist/overlays/portal.js +14 -0
  142. package/dist/periodic-table/PeriodicTable.svelte +113 -145
  143. package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
  144. package/dist/periodic-table/PeriodicTableControls.svelte +11 -63
  145. package/dist/periodic-table/TableInset.svelte +9 -4
  146. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +50 -71
  147. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
  148. package/dist/phase-diagram/PhaseDiagramControls.svelte +70 -94
  149. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
  150. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
  151. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +12 -12
  152. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
  153. package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
  154. package/dist/phase-diagram/build-diagram.js +3 -3
  155. package/dist/phase-diagram/diagram-input.d.ts +1 -2
  156. package/dist/phase-diagram/parse.js +15 -15
  157. package/dist/phase-diagram/svg-to-diagram.js +21 -15
  158. package/dist/phase-diagram/utils.js +2 -3
  159. package/dist/plot/bar/BarPlot.svelte +430 -391
  160. package/dist/plot/bar/BarPlot.svelte.d.ts +2 -0
  161. package/dist/plot/bar/BarPlotControls.svelte +1 -3
  162. package/dist/plot/bar/BarPlotControls.svelte.d.ts +4 -6
  163. package/dist/plot/bar/SpacegroupBarPlot.svelte +29 -36
  164. package/dist/plot/bar/data.d.ts +5 -4
  165. package/dist/plot/bar/data.js +2 -1
  166. package/dist/plot/box/BoxPlot.svelte +301 -209
  167. package/dist/plot/box/BoxPlot.svelte.d.ts +2 -0
  168. package/dist/plot/box/Violin.svelte.d.ts +1 -0
  169. package/dist/plot/box/box-plot.js +1 -1
  170. package/dist/plot/core/auto-place.js +1 -1
  171. package/dist/plot/core/axis-utils.d.ts +12 -7
  172. package/dist/plot/core/axis-utils.js +48 -48
  173. package/dist/plot/core/components/AxisLabel.svelte +82 -20
  174. package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
  175. package/dist/plot/core/components/ColorBar.svelte +101 -106
  176. package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
  177. package/dist/plot/core/components/FillArea.svelte +10 -17
  178. package/dist/plot/core/components/HierarchyControls.svelte +249 -0
  179. package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
  180. package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
  181. package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
  182. package/dist/plot/core/components/Line.svelte +18 -9
  183. package/dist/plot/core/components/Line.svelte.d.ts +2 -0
  184. package/dist/plot/core/components/PlotAxis.svelte +40 -17
  185. package/dist/plot/core/components/PlotControls.svelte +65 -41
  186. package/dist/plot/core/components/PlotLegend.svelte +31 -35
  187. package/dist/plot/core/components/PlotMarginals.svelte +616 -0
  188. package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
  189. package/dist/plot/core/components/PlotTooltip.svelte +1 -1
  190. package/dist/plot/core/components/PortalSelect.svelte +4 -8
  191. package/dist/plot/core/components/ReferenceLine.svelte +27 -24
  192. package/dist/plot/core/components/ReferenceLine3D.svelte +54 -57
  193. package/dist/plot/core/components/ReferencePlane.svelte +7 -8
  194. package/dist/plot/core/components/ZeroLines.svelte +4 -8
  195. package/dist/plot/core/components/ZoomRect.svelte +1 -2
  196. package/dist/plot/core/components/index.d.ts +1 -0
  197. package/dist/plot/core/components/index.js +1 -0
  198. package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
  199. package/dist/plot/core/data-cleaning-signal.js +467 -0
  200. package/dist/plot/core/data-cleaning.d.ts +2 -42
  201. package/dist/plot/core/data-cleaning.js +27 -474
  202. package/dist/plot/core/data-transform.js +9 -5
  203. package/dist/plot/core/fill-utils.d.ts +3 -1
  204. package/dist/plot/core/fill-utils.js +28 -6
  205. package/dist/plot/core/index.d.ts +1 -0
  206. package/dist/plot/core/index.js +1 -0
  207. package/dist/plot/core/interactions.js +0 -2
  208. package/dist/plot/core/layout.d.ts +3 -1
  209. package/dist/plot/core/layout.js +22 -13
  210. package/dist/plot/core/marginals.d.ts +170 -0
  211. package/dist/plot/core/marginals.js +436 -0
  212. package/dist/plot/core/reference-line.js +1 -1
  213. package/dist/plot/core/scales.d.ts +23 -0
  214. package/dist/plot/core/scales.js +39 -13
  215. package/dist/plot/core/types/fills.d.ts +101 -0
  216. package/dist/plot/core/types/fills.js +15 -0
  217. package/dist/plot/core/types/plot-3d.d.ts +87 -0
  218. package/dist/plot/core/types/plot-3d.js +4 -0
  219. package/dist/plot/core/types/reference-lines.d.ts +140 -0
  220. package/dist/plot/core/types/reference-lines.js +9 -0
  221. package/dist/plot/core/types.d.ts +29 -324
  222. package/dist/plot/core/types.js +23 -20
  223. package/dist/plot/core/utils/hierarchy-chart.d.ts +51 -0
  224. package/dist/plot/core/utils/hierarchy-chart.js +179 -0
  225. package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
  226. package/dist/plot/core/utils/hierarchy-labels.js +99 -0
  227. package/dist/plot/core/utils/label-placement.js +2 -2
  228. package/dist/plot/histogram/Histogram.svelte +304 -325
  229. package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
  230. package/dist/plot/histogram/HistogramControls.svelte +30 -28
  231. package/dist/plot/histogram/histogram.d.ts +31 -0
  232. package/dist/plot/histogram/histogram.js +70 -0
  233. package/dist/plot/histogram/index.d.ts +1 -0
  234. package/dist/plot/histogram/index.js +1 -0
  235. package/dist/plot/index.d.ts +1 -0
  236. package/dist/plot/index.js +1 -0
  237. package/dist/plot/sankey/Sankey.svelte +78 -69
  238. package/dist/plot/sankey/Sankey.svelte.d.ts +2 -2
  239. package/dist/plot/sankey/SankeyControls.svelte +22 -16
  240. package/dist/plot/scatter/BinnedScatterPlot.svelte +263 -109
  241. package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +7 -0
  242. package/dist/plot/scatter/ElementScatter.svelte +4 -1
  243. package/dist/plot/scatter/ScatterPlot.svelte +477 -385
  244. package/dist/plot/scatter/ScatterPlot.svelte.d.ts +2 -0
  245. package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
  246. package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
  247. package/dist/plot/scatter/ScatterPoint.svelte +16 -9
  248. package/dist/plot/scatter/binned-scatter-types.d.ts +3 -2
  249. package/dist/plot/scatter/binned-scatter-types.js +6 -1
  250. package/dist/plot/scatter/scatter-data.d.ts +1 -1
  251. package/dist/plot/scatter/scatter-data.js +8 -7
  252. package/dist/plot/scatter-3d/ScatterPlot3D.svelte +25 -34
  253. package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +2 -2
  254. package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +8 -5
  255. package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +113 -116
  256. package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +2 -2
  257. package/dist/plot/scatter-3d/Surface3D.svelte +4 -13
  258. package/dist/plot/sunburst/Sunburst.svelte +251 -329
  259. package/dist/plot/sunburst/Sunburst.svelte.d.ts +2 -2
  260. package/dist/plot/sunburst/index.d.ts +1 -1
  261. package/dist/plot/sunburst/index.js +2 -1
  262. package/dist/plot/sunburst/render.d.ts +2 -2
  263. package/dist/plot/sunburst/render.js +47 -22
  264. package/dist/plot/sunburst/sunburst.d.ts +5 -1
  265. package/dist/plot/sunburst/sunburst.js +10 -3
  266. package/dist/plot/treemap/Treemap.svelte +907 -0
  267. package/dist/plot/treemap/Treemap.svelte.d.ts +84 -0
  268. package/dist/plot/treemap/index.d.ts +3 -0
  269. package/dist/plot/treemap/index.js +4 -0
  270. package/dist/plot/treemap/treemap.d.ts +26 -0
  271. package/dist/plot/treemap/treemap.js +99 -0
  272. package/dist/rdf/RdfPlot.svelte +22 -26
  273. package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
  274. package/dist/rdf/calc-rdf.js +4 -8
  275. package/dist/sanitize.js +1 -1
  276. package/dist/scene/bind-renderer.svelte.js +14 -6
  277. package/dist/settings.d.ts +19 -9
  278. package/dist/settings.js +77 -50
  279. package/dist/spectral/Bands.svelte +223 -230
  280. package/dist/spectral/BandsAndDos.svelte +11 -9
  281. package/dist/spectral/BrillouinBandsDos.svelte +19 -27
  282. package/dist/spectral/Dos.svelte +70 -73
  283. package/dist/spectral/helpers.d.ts +3 -3
  284. package/dist/spectral/helpers.js +25 -35
  285. package/dist/state.svelte.js +5 -18
  286. package/dist/structure/Arrow.svelte +5 -18
  287. package/dist/structure/ArrowInstances.svelte +160 -0
  288. package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
  289. package/dist/structure/AtomLegend.svelte +115 -75
  290. package/dist/structure/AtomLegend.svelte.d.ts +1 -1
  291. package/dist/structure/Bond.svelte +31 -23
  292. package/dist/structure/CanvasTooltip.svelte +15 -3
  293. package/dist/structure/CellSelect.svelte +11 -26
  294. package/dist/structure/Cylinder.svelte +24 -40
  295. package/dist/structure/InstancedAtoms.svelte +114 -0
  296. package/dist/structure/InstancedAtoms.svelte.d.ts +15 -0
  297. package/dist/structure/Lattice.svelte +85 -149
  298. package/dist/structure/SiteLabels.svelte +122 -0
  299. package/dist/structure/SiteLabels.svelte.d.ts +18 -0
  300. package/dist/structure/Structure.svelte +473 -419
  301. package/dist/structure/Structure.svelte.d.ts +4 -2
  302. package/dist/structure/StructureCarousel.svelte +630 -0
  303. package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
  304. package/dist/structure/StructureControls.svelte +157 -399
  305. package/dist/structure/StructureControls.svelte.d.ts +1 -1
  306. package/dist/structure/StructureExportPane.svelte +17 -21
  307. package/dist/structure/StructureInfoPane.svelte +72 -66
  308. package/dist/structure/StructureInfoPane.svelte.d.ts +1 -1
  309. package/dist/structure/StructureScene.svelte +467 -476
  310. package/dist/structure/StructureScene.svelte.d.ts +3 -1
  311. package/dist/structure/StructureViewport.svelte +386 -0
  312. package/dist/structure/StructureViewport.svelte.d.ts +63 -0
  313. package/dist/structure/atom-label-placement.d.ts +16 -12
  314. package/dist/structure/atom-label-placement.js +70 -37
  315. package/dist/structure/atom-properties.d.ts +2 -0
  316. package/dist/structure/atom-properties.js +104 -38
  317. package/dist/structure/bonding.d.ts +10 -3
  318. package/dist/structure/bonding.js +84 -28
  319. package/dist/structure/edit-history.d.ts +6 -0
  320. package/dist/structure/edit-history.js +27 -0
  321. package/dist/structure/export.d.ts +1 -0
  322. package/dist/structure/export.js +39 -31
  323. package/dist/structure/format-detect.d.ts +1 -0
  324. package/dist/structure/format-detect.js +22 -0
  325. package/dist/structure/geometry.d.ts +9 -0
  326. package/dist/structure/geometry.js +27 -0
  327. package/dist/structure/index.d.ts +16 -1
  328. package/dist/structure/index.js +13 -2
  329. package/dist/structure/measure.d.ts +1 -1
  330. package/dist/structure/measure.js +6 -12
  331. package/dist/structure/parse.d.ts +2 -1
  332. package/dist/structure/parse.js +243 -222
  333. package/dist/structure/partial-occupancy.js +4 -2
  334. package/dist/structure/pbc.js +78 -98
  335. package/dist/structure/polyhedra.d.ts +0 -1
  336. package/dist/structure/polyhedra.js +3 -18
  337. package/dist/structure/supercell.d.ts +1 -2
  338. package/dist/structure/supercell.js +7 -13
  339. package/dist/symmetry/SymmetryElements.svelte +11 -15
  340. package/dist/symmetry/SymmetryStats.svelte +56 -68
  341. package/dist/symmetry/WyckoffTable.svelte +5 -24
  342. package/dist/symmetry/cell-transform.js +1 -0
  343. package/dist/symmetry/index.d.ts +1 -0
  344. package/dist/symmetry/index.js +8 -2
  345. package/dist/symmetry/spacegroups.js +3 -2
  346. package/dist/table/HeatmapTable.svelte +1102 -365
  347. package/dist/table/HeatmapTable.svelte.d.ts +12 -2
  348. package/dist/table/ToggleMenu.svelte +5 -12
  349. package/dist/table/index.d.ts +21 -6
  350. package/dist/table/index.js +34 -21
  351. package/dist/theme/ThemeControl.svelte +16 -8
  352. package/dist/theme/index.d.ts +1 -5
  353. package/dist/theme/index.js +4 -10
  354. package/dist/theme/themes.mjs +14 -7
  355. package/dist/tooltip/KCoords.svelte +4 -1
  356. package/dist/tooltip/TooltipContent.svelte +2 -5
  357. package/dist/trajectory/Trajectory.svelte +515 -308
  358. package/dist/trajectory/Trajectory.svelte.d.ts +1 -1
  359. package/dist/trajectory/TrajectoryError.svelte +11 -8
  360. package/dist/trajectory/TrajectoryExportPane.svelte +14 -31
  361. package/dist/trajectory/TrajectoryInfoPane.svelte +85 -97
  362. package/dist/trajectory/extract.js +56 -34
  363. package/dist/trajectory/format-detect.js +11 -9
  364. package/dist/trajectory/frame-reader.d.ts +2 -0
  365. package/dist/trajectory/frame-reader.js +33 -29
  366. package/dist/trajectory/helpers.d.ts +2 -0
  367. package/dist/trajectory/helpers.js +18 -7
  368. package/dist/trajectory/index.d.ts +1 -0
  369. package/dist/trajectory/index.js +3 -0
  370. package/dist/trajectory/parse/h5-utils.d.ts +13 -0
  371. package/dist/trajectory/parse/h5-utils.js +109 -0
  372. package/dist/trajectory/parse/hdf5.d.ts +1 -1
  373. package/dist/trajectory/parse/hdf5.js +116 -106
  374. package/dist/trajectory/parse/index.d.ts +2 -3
  375. package/dist/trajectory/parse/index.js +17 -20
  376. package/dist/trajectory/parse/lammps.js +8 -12
  377. package/dist/trajectory/parse/vasp.js +10 -7
  378. package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
  379. package/dist/trajectory/parse/vaspout-electronic.js +207 -0
  380. package/dist/trajectory/parse/vaspout-h5.d.ts +5 -0
  381. package/dist/trajectory/parse/vaspout-h5.js +284 -0
  382. package/dist/trajectory/parse/xyz.js +11 -7
  383. package/dist/trajectory/plotting.d.ts +8 -9
  384. package/dist/trajectory/plotting.js +99 -27
  385. package/dist/utils.d.ts +3 -0
  386. package/dist/utils.js +7 -0
  387. package/dist/xrd/XrdPlot.svelte +47 -61
  388. package/dist/xrd/broadening.js +2 -1
  389. package/dist/xrd/calc-xrd.js +2 -4
  390. package/dist/xrd/parse.d.ts +0 -1
  391. package/dist/xrd/parse.js +56 -73
  392. package/package.json +61 -33
  393. package/dist/api/mp.d.ts +0 -6
  394. package/dist/api/mp.js +0 -22
  395. package/dist/plot/sunburst/SunburstControls.svelte +0 -200
@@ -1,4 +1,5 @@
1
- import { element_data, is_elem_symbol } from '../element';
1
+ import { default as element_data } from '../element/data';
2
+ import { is_elem_symbol } from '../element/helpers';
2
3
  import { ELEM_SYMBOLS } from '../labels';
3
4
  // Create symbol/number/mass/electronegativity lookup maps for O(1) access
4
5
  export const ATOMIC_NUMBER_TO_SYMBOL = {};
@@ -24,7 +25,7 @@ const is_atomic_number_composition = (obj) => {
24
25
  atomic_nums.every((atomic_num) => Number.isInteger(atomic_num) && Object.hasOwn(ATOMIC_NUMBER_TO_SYMBOL, atomic_num)));
25
26
  };
26
27
  const format_state = (state) => (state > 0 ? `+` : ``) + state;
27
- const parse_count = (count) => (count ? parseFloat(count) : 1);
28
+ const parse_count = (count) => (count ? Number(count) : 1);
28
29
  const format_count = (count) => {
29
30
  if (!Number.isFinite(count))
30
31
  return `${count}`;
@@ -63,9 +64,9 @@ export const atomic_symbol_to_num = (symbol_composition) => {
63
64
  // Expand parentheses in chemical formulas
64
65
  const expand_parentheses = (formula) => {
65
66
  while (formula.includes(`(`)) {
66
- const expanded = formula.replaceAll(/\(([^()]+)\)(\d+(?:\.\d+)?|\.\d+)?/g, (_match, group, multiplier) => {
67
+ const expanded = formula.replaceAll(/\((?<group>[^()]+)\)(?<multiplier>\d+(?:\.\d+)?|\.\d+)?/g, (_match, group, multiplier) => {
67
68
  const mult = parse_count(multiplier);
68
- return group.replaceAll(/([A-Z][a-z]?)(\d+(?:\.\d+)?|\.\d+)?/g, (_m, element, count) => {
69
+ return group.replaceAll(/(?<element>[A-Z][a-z]?)(?<count>\d+(?:\.\d+)?|\.\d+)?/g, (_m, element, count) => {
69
70
  const count_str = format_count(parse_count(count) * mult);
70
71
  return element + (count_str === `1` ? `` : count_str);
71
72
  });
@@ -87,9 +88,9 @@ export const parse_formula = (formula) => {
87
88
  for (const [seg_idx, segment] of segments.entries()) {
88
89
  // only hydrate segments (after a separator) carry a leading multiplier
89
90
  const coeff = seg_idx > 0 ? /^(?:\d+(?:\.\d+)?|\.\d+)/.exec(segment)?.[0] : undefined;
90
- const multiplier = coeff ? parseFloat(coeff) : 1;
91
+ const multiplier = coeff ? Number(coeff) : 1;
91
92
  const expanded = expand_parentheses(segment.slice(coeff?.length ?? 0));
92
- for (const match of expanded.matchAll(/([A-Z][a-z]?)(\d+(?:\.\d+)?|\.\d+)?/g)) {
93
+ for (const match of expanded.matchAll(/(?<element>[A-Z][a-z]?)(?<count>\d+(?:\.\d+)?|\.\d+)?/g)) {
93
94
  const [, element, count] = match;
94
95
  if (!is_elem_symbol(element))
95
96
  throw new Error(`Invalid element symbol: ${element}`);
@@ -206,12 +207,12 @@ const parse_oxidation_state = (oxidation_str) => {
206
207
  return oxidation_str === `+` ? 1 : -1;
207
208
  }
208
209
  // Handle formats like "2+", "+2", "2-", "-2"
209
- const ox_match = /([+-]?)(\d+)([+-]?)/.exec(oxidation_str);
210
+ const ox_match = /(?<sign_before>[+-]?)(?<number>\d+)(?<sign_after>[+-]?)/.exec(oxidation_str);
210
211
  if (!ox_match)
211
212
  return 0;
212
213
  const [, sign_before, number, sign_after] = ox_match;
213
214
  const sign = sign_before || sign_after || `+`;
214
- return sign === `-` ? -parseInt(number, 10) : parseInt(number, 10);
215
+ return sign === `-` ? -Number(number) : Number(number);
215
216
  };
216
217
  // Parse chemical formula string with oxidation states into structured data.
217
218
  // Supports both ^2+ and [2+] syntax for oxidation states.
@@ -229,7 +230,7 @@ export const parse_formula_with_oxidation = (formula, strict = false) => {
229
230
  // - just oxidation: (?:\^([+-]?\d+[+-]?|[+-])|\[([+-]?\d+[+-]?|[+-])\])
230
231
  // - just count: count
231
232
  // - neither
232
- const regex = /([A-Z][a-z]?)(?:(?:\^([+-]?\d+[+-]?|[+-])|\[([+-]?\d+[+-]?|[+-])\])((?:\d+(?:\.\d+)?|\.\d+)?)|((?:\d+(?:\.\d+)?|\.\d+))(?:\^([+-]?\d+[+-]?|[+-])|\[([+-]?\d+[+-]?|[+-])\])?)?/g;
233
+ const regex = /(?<element>[A-Z][a-z]?)(?:(?:\^(?<oxi_caret>[+-]?\d+[+-]?|[+-])|\[(?<oxi_bracket>[+-]?\d+[+-]?|[+-])\])(?<count_after>(?:\d+(?:\.\d+)?|\.\d+)?)|(?<count_before>(?:\d+(?:\.\d+)?|\.\d+))(?:\^(?<oxi_caret_2>[+-]?\d+[+-]?|[+-])|\[(?<oxi_bracket_2>[+-]?\d+[+-]?|[+-])\])?)?/g;
233
234
  let match;
234
235
  let orig_idx = 0;
235
236
  while ((match = regex.exec(cleaned_formula)) !== null) {
@@ -387,7 +388,7 @@ export function parse_formula_with_wildcards(formula) {
387
388
  // Regex to match either:
388
389
  // 1. Standard element symbol with optional decimal count
389
390
  // 2. Wildcard with optional decimal count
390
- const regex = /([A-Z][a-z]?)((?:\d+(?:\.\d+)?|\.\d+)?)|(\*)((?:\d+(?:\.\d+)?|\.\d+)?)/g;
391
+ const regex = /(?<element>[A-Z][a-z]?)(?<count>(?:\d+(?:\.\d+)?|\.\d+)?)|(?<wildcard>\*)(?<wildcard_count>(?:\d+(?:\.\d+)?|\.\d+)?)/g;
391
392
  let match;
392
393
  while ((match = regex.exec(cleaned)) !== null) {
393
394
  if (match[3] === `*`) {
package/dist/constants.js CHANGED
@@ -61,9 +61,11 @@ export const TRAJ_KEYWORDS_REGEX = new RegExp(`(^|[-_.])(${TRAJ_KEYWORDS.join(`|
61
61
  export const STRUCT_KEYWORDS_REGEX = new RegExp(`(${STRUCT_KEYWORDS.join(`|`)})`, `i`);
62
62
  export const STRUCT_KEYWORDS_STRICT_REGEX = new RegExp(`(${STRUCT_KEYWORDS_STRICT.join(`|`)})`, `i`);
63
63
  export const TRAJ_KEYWORDS_SIMPLE_REGEX = new RegExp(`(${TRAJ_KEYWORDS.join(`|`)})`, `i`);
64
+ // Build a case-insensitive `\.(ext1|ext2|...)$` regex from extensions (leading dots stripped)
65
+ const ext_regex = (exts) => new RegExp(`\\.(${exts.map((ext) => ext.slice(1)).join(`|`)})$`, `i`);
64
66
  // File extensions for different file types
65
67
  export const TRAJ_EXTENSIONS = Object.freeze([`.traj`, `.xtc`, `.lammpstrj`]);
66
- export const TRAJ_EXTENSIONS_REGEX = new RegExp(`\\.(${TRAJ_EXTENSIONS.map((ext) => ext.slice(1)).join(`|`)})$`, `i`);
68
+ export const TRAJ_EXTENSIONS_REGEX = ext_regex(TRAJ_EXTENSIONS);
67
69
  export const STRUCTURE_EXTENSIONS = Object.freeze([
68
70
  `.cif`,
69
71
  `.mcif`,
@@ -79,7 +81,7 @@ export const STRUCTURE_EXTENSIONS = Object.freeze([
79
81
  `.sdf`,
80
82
  `.mmcif`,
81
83
  ]);
82
- export const STRUCTURE_EXTENSIONS_REGEX = new RegExp(`\\.(${STRUCTURE_EXTENSIONS.map((ext) => ext.slice(1)).join(`|`)})$`, `i`);
84
+ export const STRUCTURE_EXTENSIONS_REGEX = ext_regex(STRUCTURE_EXTENSIONS);
83
85
  export const TRAJ_FALLBACK_EXTENSIONS = Object.freeze([
84
86
  `.dat`,
85
87
  `.data`,
@@ -87,13 +89,13 @@ export const TRAJ_FALLBACK_EXTENSIONS = Object.freeze([
87
89
  `.out`,
88
90
  `.json`,
89
91
  ]);
90
- export const TRAJ_FALLBACK_EXTENSIONS_REGEX = new RegExp(`\\.(${TRAJ_FALLBACK_EXTENSIONS.map((ext) => ext.slice(1)).join(`|`)})$`, `i`);
92
+ export const TRAJ_FALLBACK_EXTENSIONS_REGEX = ext_regex(TRAJ_FALLBACK_EXTENSIONS);
91
93
  // Special regex patterns
92
- export const VASP_FILES_REGEX = /(?:^|[\\/_.-])(poscar|contcar|potcar|incar|kpoints|outcar)(?:[\\/_.-]|$)/i;
93
- export const VASP_VOLUMETRIC_REGEX = /(?:^|[\\/_.-])(chgcar|aeccar[012]?|elfcar|locpot|parchg)(?:[\\/_.-]|$)/i;
94
+ export const VASP_FILES_REGEX = /(?:^|[\\/_.-])(?:poscar|contcar|potcar|incar|kpoints|outcar)(?:[\\/_.-]|$)/i;
95
+ export const VASP_VOLUMETRIC_REGEX = /(?:^|[\\/_.-])(?:chgcar|aeccar[012]?|elfcar|locpot|parchg)(?:[\\/_.-]|$)/i;
94
96
  export const XDATCAR_REGEX = /xdatcar/i;
95
- export const CONFIG_DIRS_REGEX = /(?:^|[\\/])(\.vscode|\.idea|\.nyc_output|\.cache|\.tmp|\.temp|node_modules|dist|build|coverage)(?:[\\/]|$)/i;
96
- export const MD_SIM_EXCLUDE_REGEX = /md_simulation\.(out|txt|yml|py|csv|html|css|md|js|ts)$/i;
97
- export const XYZ_EXTXYZ_REGEX = /\.(xyz|extxyz)$/i;
97
+ export const CONFIG_DIRS_REGEX = /(?:^|[\\/])(?:\.vscode|\.idea|\.nyc_output|\.cache|\.tmp|\.temp|node_modules|dist|build|coverage)(?:[\\/]|$)/i;
98
+ export const MD_SIM_EXCLUDE_REGEX = /md_simulation\.(?:out|txt|yml|py|csv|html|css|md|js|ts)$/i;
99
+ export const XYZ_EXTXYZ_REGEX = /\.(?:xyz|extxyz)$/i;
98
100
  // Compression extensions regex (shared across files)
99
- export const COMPRESSION_EXTENSIONS_REGEX = new RegExp(`\\.(${COMPRESSION_EXTENSIONS.map((ext) => ext.slice(1)).join(`|`)})$`, `i`);
101
+ export const COMPRESSION_EXTENSIONS_REGEX = ext_regex(COMPRESSION_EXTENSIONS);
@@ -12,10 +12,11 @@
12
12
  // Union type combining all possible props from 2D, 3D, and 4D components
13
13
  // each specific component will only use its relevant props from this super set
14
14
  // (gas_config/gas_pressures already come from BaseConvexHullProps)
15
- type ConvexHullProps = BaseConvexHullProps & Hull3DProps & {
16
- x_axis?: AxisConfig
17
- y_axis?: AxisConfig
18
- }
15
+ type ConvexHullProps = BaseConvexHullProps &
16
+ Hull3DProps & {
17
+ x_axis?: AxisConfig
18
+ y_axis?: AxisConfig
19
+ }
19
20
 
20
21
  let {
21
22
  entries = [],
@@ -26,9 +27,7 @@
26
27
  show_unstable = $bindable(true),
27
28
  hidden_categories = $bindable([]),
28
29
  show_hull_faces = $bindable(true),
29
- hull_face_opacity: hull_face_opacity_prop = $bindable(
30
- undefined as number | undefined,
31
- ),
30
+ hull_face_opacity: hull_face_opacity_prop = $bindable(undefined as number | undefined),
32
31
  color_mode = $bindable(`energy`),
33
32
  color_scale = $bindable(`interpolateViridis`),
34
33
  info_pane_open = $bindable(false),
@@ -88,8 +87,7 @@
88
87
  // while each component declares only its dimension's props (2D lacks Hull3DProps, 3D/4D
89
88
  // lack x/y_axis), so a constructor union wouldn't compile. Svelte ignores extra props.
90
89
  const ConvexHullComponent = $derived(
91
- { 2: ConvexHull2D, 3: ConvexHull3D, 4: ConvexHull4D }[element_count] ??
92
- null,
90
+ { 2: ConvexHull2D, 3: ConvexHull3D, 4: ConvexHull4D }[element_count] ?? null,
93
91
  ) as Component<ConvexHullProps> | null
94
92
  </script>
95
93
 
@@ -125,14 +123,13 @@
125
123
  {:else}
126
124
  <!-- Error state for unsupported dimensionalities -->
127
125
  <div class="convex-hull-error">
128
- <div
129
- style="text-align: center; padding: 2em; color: var(--convex-hull-text-color, #666)"
130
- >
126
+ <div style="text-align: center; padding: 2em; color: var(--convex-hull-text-color, #666)">
131
127
  <h3 id="unsupported-chemical-system" style="margin: 0 0 1em 0">Unsupported Chemical System</h3>
132
128
  <p style="margin: 0">
133
- Convex hulls require 2, 3, or 4 elements. Found {element_count} element{
134
- element_count === 1 ? `` : `s`
135
- }:
129
+ Convex hulls require 2, 3, or 4 elements. Found {element_count} element{element_count ===
130
+ 1
131
+ ? ``
132
+ : `s`}:
136
133
  </p>
137
134
  <p style="margin: 0.5em 0 0 0; font-weight: bold">
138
135
  {elements.join(`, `)}
@@ -5,6 +5,6 @@ type ConvexHullProps = BaseConvexHullProps & Hull3DProps & {
5
5
  x_axis?: AxisConfig;
6
6
  y_axis?: AxisConfig;
7
7
  };
8
- declare const ConvexHull: Component<ConvexHullProps, {}, "display" | "temperature" | "fullscreen" | "wrapper" | "controls_open" | "color_scale" | "info_pane_open" | "show_hull_faces" | "hull_face_opacity" | "color_mode" | "show_stable" | "show_unstable" | "show_stable_labels" | "show_unstable_labels" | "max_hull_dist_show_phases" | "max_hull_dist_show_labels" | "hidden_categories" | "energy_source_mode" | "stable_entries" | "unstable_entries" | "phase_stats" | "highlighted_entries" | "selected_entry" | "gas_pressures">;
8
+ declare const ConvexHull: Component<ConvexHullProps, {}, "display" | "fullscreen" | "wrapper" | "controls_open" | "color_scale" | "info_pane_open" | "temperature" | "show_hull_faces" | "hull_face_opacity" | "color_mode" | "show_stable" | "show_unstable" | "show_stable_labels" | "show_unstable_labels" | "max_hull_dist_show_phases" | "max_hull_dist_show_labels" | "hidden_categories" | "energy_source_mode" | "stable_entries" | "unstable_entries" | "phase_stats" | "highlighted_entries" | "selected_entry" | "gas_pressures">;
9
9
  type ConvexHull = ReturnType<typeof ConvexHull>;
10
10
  export default ConvexHull;
@@ -32,12 +32,7 @@
32
32
  import StructurePopup from './StructurePopup.svelte'
33
33
  import TemperatureSlider from './TemperatureSlider.svelte'
34
34
  import * as thermo from './thermodynamics'
35
- import type {
36
- ConvexHullEntry,
37
- HighlightStyle,
38
- HoverData3D,
39
- PhaseData,
40
- } from './types'
35
+ import type { ConvexHullEntry, HighlightStyle, HoverData3D, PhaseData } from './types'
41
36
  import { MAGNETIC_ORDERING_CATEGORY } from './types'
42
37
 
43
38
  // Binary convex hull rendered as energy vs composition (x in [0, 1])
@@ -58,9 +53,7 @@
58
53
  entry_category = MAGNETIC_ORDERING_CATEGORY,
59
54
  hidden_categories = $bindable([]),
60
55
  color_mode = $bindable(DEFAULTS.convex_hull.binary.color_mode),
61
- color_scale = $bindable(
62
- DEFAULTS.convex_hull.binary.color_scale as D3InterpolateName,
63
- ),
56
+ color_scale = $bindable(DEFAULTS.convex_hull.binary.color_scale as D3InterpolateName),
64
57
  info_pane_open = $bindable(DEFAULTS.convex_hull.binary.info_pane_open),
65
58
  controls_open = $bindable(DEFAULTS.convex_hull.binary.legend_pane_open),
66
59
  max_hull_dist_show_phases = $bindable(
@@ -70,9 +63,7 @@
70
63
  DEFAULTS.convex_hull.binary.max_hull_dist_show_labels,
71
64
  ),
72
65
  show_stable_labels = $bindable(DEFAULTS.convex_hull.binary.show_stable_labels),
73
- show_unstable_labels = $bindable(
74
- DEFAULTS.convex_hull.binary.show_unstable_labels,
75
- ),
66
+ show_unstable_labels = $bindable(DEFAULTS.convex_hull.binary.show_unstable_labels),
76
67
  on_file_drop,
77
68
  enable_click_selection = true,
78
69
  enable_structure_preview = true,
@@ -117,9 +108,7 @@
117
108
  const show_hull_line = $derived(merged_config.show_hull)
118
109
 
119
110
  // Merge highlight style with defaults (consistent with 3D/4D)
120
- const merged_highlight_style = $derived(
121
- helpers.merge_highlight_style(highlight_style),
122
- )
111
+ const merged_highlight_style = $derived(helpers.merge_highlight_style(highlight_style))
123
112
 
124
113
  // Helper to check if entry is highlighted
125
114
  const is_highlighted = (entry: ConvexHullEntry): boolean =>
@@ -142,12 +131,11 @@
142
131
  show_unstable: () => show_unstable,
143
132
  entry_category: () => entry_category,
144
133
  hidden_categories: () => hidden_categories,
145
- keep_plot_entry: (entry, max_dist) =>
146
- helpers.entry_is_stable(entry) || (entry.e_above_hull ?? 0) <= max_dist,
147
- set_temperature: (next_temp) => temperature = next_temp,
148
- set_max_hull_dist_show_phases: (value) => max_hull_dist_show_phases = value,
149
- set_stable_entries: (value) => stable_entries = value,
150
- set_unstable_entries: (value) => unstable_entries = value,
134
+ keep_plot_entry: helpers.entry_within_hull_dist,
135
+ set_temperature: (next_temp) => (temperature = next_temp),
136
+ set_max_hull_dist_show_phases: (value) => (max_hull_dist_show_phases = value),
137
+ set_stable_entries: (value) => (stable_entries = value),
138
+ set_unstable_entries: (value) => (unstable_entries = value),
151
139
  })
152
140
  const merged_gas_config = $derived(hull_data.merged_gas_config)
153
141
  const elements = $derived(hull_data.elements)
@@ -210,30 +198,35 @@
210
198
  return { all_enriched_entries: [], hull_points: [] }
211
199
  }
212
200
 
213
- // Build lower hull input: one minimum-energy point per composition x.
214
- // Excluded entries don't participate in hull construction.
215
- const min_y_by_x = new SvelteMap<number, number>()
216
- for (const entry of coords_entries) {
217
- if (entry.exclude_from_hull) continue
218
- const current_min_y = min_y_by_x.get(entry.x)
219
- if (current_min_y === undefined || entry.y < current_min_y) {
220
- min_y_by_x.set(entry.x, entry.y)
201
+ // Build lower hull input: one minimum-energy point per composition x.
202
+ // Excluded entries don't participate in hull construction.
203
+ const min_y_by_x = new SvelteMap<number, number>()
204
+ for (const entry of coords_entries) {
205
+ if (entry.exclude_from_hull) continue
206
+ const current_min_y = min_y_by_x.get(entry.x)
207
+ if (current_min_y === undefined || entry.y < current_min_y) {
208
+ min_y_by_x.set(entry.x, entry.y)
209
+ }
221
210
  }
222
- }
223
211
 
224
- const hull_input = [...min_y_by_x].map(([x_coord, min_y]) => ({
225
- x: x_coord,
226
- y: min_y,
227
- }))
228
- const computed_hull_points = thermo.compute_lower_hull_2d(hull_input)
229
-
230
- const enriched_entries = coords_entries.map((entry) => {
231
- const y_hull = thermo.interpolate_hull_2d(computed_hull_points, entry.x)
232
- const raw_dist = y_hull == null ? 0 : entry.y - y_hull
233
- return { ...entry, ...helpers.compute_hull_stability(raw_dist, entry.exclude_from_hull) }
234
- })
235
- return { all_enriched_entries: enriched_entries, hull_points: computed_hull_points }
236
- })
212
+ const hull_input = [...min_y_by_x].map(([x_coord, min_y]) => ({
213
+ x: x_coord,
214
+ y: min_y,
215
+ }))
216
+ const computed_hull_points = thermo.compute_lower_hull_2d(hull_input)
217
+
218
+ const enriched_entries = coords_entries.map((entry) => {
219
+ const y_hull = thermo.interpolate_hull_2d(computed_hull_points, entry.x)
220
+ // degenerate hull (<2 points): y_hull null -> unknown distance (not 0/stable)
221
+ const raw_dist = y_hull == null ? undefined : entry.y - y_hull
222
+ return {
223
+ ...entry,
224
+ ...helpers.compute_hull_stability(raw_dist, entry.exclude_from_hull),
225
+ }
226
+ })
227
+ return { all_enriched_entries: enriched_entries, hull_points: computed_hull_points }
228
+ },
229
+ )
237
230
 
238
231
  let reset_counter = $state(0)
239
232
  // Drag and drop state (to match 3D/4D components)
@@ -259,13 +252,12 @@
259
252
  const y_domain = $derived.by((): Vec2 => {
260
253
  const ys = plot_entries.map((entry) => entry.y)
261
254
  if (ys.length === 0) return [-1, 0]
262
- const min_y_data = Math.min(...ys)
263
- const max_y_data = Math.max(...ys)
255
+ const min_y_data = helpers.array_min(ys)
256
+ const max_y_data = helpers.array_max(ys)
264
257
  const span = Math.max(1e-9, max_y_data - min_y_data)
265
258
  const pad = 0.05 * span
266
259
  return [min_y_data - pad, max_y_data + pad]
267
260
  })
268
-
269
261
  // Build ScatterPlot series --------------------------------------------------
270
262
 
271
263
  // Map MarkerSymbol to D3SymbolName (type-safe via symbol_map lookup)
@@ -296,15 +288,19 @@
296
288
  const hl = is_highlighted(entry) ? merged_highlight_style : null
297
289
 
298
290
  point_style[idx] = {
299
- fill: hl?.effect === `color` || hl?.effect === `both`
300
- ? hl?.color
301
- : is_energy_mode
302
- ? undefined
303
- : (is_stable ? stable_color : unstable_color),
291
+ fill:
292
+ hl?.effect === `color` || hl?.effect === `both`
293
+ ? hl?.color
294
+ : is_energy_mode
295
+ ? undefined
296
+ : is_stable
297
+ ? stable_color
298
+ : unstable_color,
304
299
  stroke: is_stable ? `#ffffff` : `#000000`,
305
- radius: hl?.effect === `size` || hl?.effect === `both`
306
- ? base_radius * (hl?.size_multiplier ?? 1)
307
- : base_radius,
300
+ radius:
301
+ hl?.effect === `size` || hl?.effect === `both`
302
+ ? base_radius * (hl?.size_multiplier ?? 1)
303
+ : base_radius,
308
304
  symbol_type: marker_to_d3_symbol(entry.marker),
309
305
  is_highlighted: Boolean(hl),
310
306
  highlight_effect: hl?.effect,
@@ -400,8 +396,7 @@
400
396
  show_unstable_labels !== DEFAULTS.convex_hull.binary.show_unstable_labels ||
401
397
  // Compare with auto-computed threshold, with small tolerance for floating point
402
398
  Math.abs(max_hull_dist_show_phases - auto_default_threshold) > 0.001 ||
403
- max_hull_dist_show_labels !==
404
- DEFAULTS.convex_hull.binary.max_hull_dist_show_labels,
399
+ max_hull_dist_show_labels !== DEFAULTS.convex_hull.binary.max_hull_dist_show_labels,
405
400
  )
406
401
 
407
402
  // Custom hover tooltip state used with ScatterPlot events
@@ -422,11 +417,13 @@
422
417
  const current_popup = helpers.current_entry(structure_popup.entry, plot_entries)
423
418
  if (structure_popup.open) {
424
419
  const structure = current_popup && extract_structure_from_entry(current_popup)
425
- if (!structure) structure_popup = { open: false, structure: null, entry: null, place_right: true }
420
+ if (!structure)
421
+ structure_popup = { open: false, structure: null, entry: null, place_right: true }
426
422
  else if (
427
423
  current_popup !== structure_popup.entry ||
428
424
  structure !== structure_popup.structure
429
- ) structure_popup = { ...structure_popup, entry: current_popup, structure }
425
+ )
426
+ structure_popup = { ...structure_popup, entry: current_popup, structure }
430
427
  }
431
428
  })
432
429
 
@@ -434,10 +431,10 @@
434
431
  const target = event.target
435
432
  if (target instanceof HTMLElement && target.tagName.match(/INPUT|TEXTAREA/)) return
436
433
  const actions: Record<string, () => void> = {
437
- b: () => color_mode = color_mode === `stability` ? `energy` : `stability`,
438
- s: () => show_stable = !show_stable,
439
- u: () => show_unstable = !show_unstable,
440
- l: () => show_stable_labels = !show_stable_labels,
434
+ b: () => (color_mode = color_mode === `stability` ? `energy` : `stability`),
435
+ s: () => (show_stable = !show_stable),
436
+ u: () => (show_unstable = !show_unstable),
437
+ l: () => (show_stable_labels = !show_stable_labels),
441
438
  }
442
439
  actions[event.key.toLowerCase()]?.()
443
440
  }
@@ -448,14 +445,16 @@
448
445
  if (data) on_file_drop?.(data)
449
446
  }
450
447
 
451
- async function copy_entry_data(
452
- entry: ConvexHullEntry,
453
- position: { x: number; y: number },
454
- ) {
455
- await helpers.copy_entry_to_clipboard(entry, position, (visible, pos) => {
456
- copy_feedback.visible = visible
457
- copy_feedback.position = pos
458
- }, entry_category)
448
+ async function copy_entry_data(entry: ConvexHullEntry, position: { x: number; y: number }) {
449
+ await helpers.copy_entry_to_clipboard(
450
+ entry,
451
+ position,
452
+ (visible, pos) => {
453
+ copy_feedback.visible = visible
454
+ copy_feedback.position = pos
455
+ },
456
+ entry_category,
457
+ )
459
458
  }
460
459
 
461
460
  function close_structure_popup() {
@@ -472,8 +471,7 @@
472
471
  if (!entry) return
473
472
 
474
473
  const now = Date.now()
475
- const is_double_click = last_clicked_entry === entry &&
476
- now - last_click_time < 300
474
+ const is_double_click = last_clicked_entry === entry && now - last_click_time < 300
477
475
 
478
476
  if (is_double_click) {
479
477
  // Double-click: copy to clipboard
@@ -524,9 +522,8 @@
524
522
  <!-- Hover tooltip matching 3D/4D style (content only; container handled by ScatterPlot) -->
525
523
  {#snippet tooltip(point: ScatterHandlerProps<ConvexHullEntry>)}
526
524
  {@const entry = point.metadata}
527
- {@const entry_highlight = entry && is_highlighted(entry)
528
- ? merged_highlight_style
529
- : undefined}
525
+ {@const entry_highlight =
526
+ entry && is_highlighted(entry) ? merged_highlight_style : undefined}
530
527
  {#if entry}
531
528
  <ConvexHullTooltip
532
529
  {entry}
@@ -600,9 +597,14 @@
600
597
  {/if}
601
598
  {/snippet}
602
599
 
603
- {#snippet user_content(
604
- { x_scale_fn, pad, height, y_scale_fn, y_range, width }: UserContentProps,
605
- )}
600
+ {#snippet user_content({
601
+ x_scale_fn,
602
+ pad,
603
+ height,
604
+ y_scale_fn,
605
+ y_range,
606
+ width,
607
+ }: UserContentProps)}
606
608
  {@const [x0, x1, y0] = [x_scale_fn(0), x_scale_fn(1), y_scale_fn(y_range[0])]}
607
609
  {@const stroke = {
608
610
  stroke: `var(--scatter-grid-stroke, gray)`,
@@ -616,7 +618,7 @@
616
618
  {#key reset_counter}
617
619
  <ScatterPlot
618
620
  {...rest}
619
- class="convex-hull-2d {rest.class ?? ``} {drag_over ? `dragover` : ``}"
621
+ class={[`convex-hull-2d`, rest.class, drag_over && `dragover`]}
620
622
  style={`${style}; ${rest.style ?? ``}`}
621
623
  data-has-selection={selected_entry !== null}
622
624
  bind:wrapper
@@ -668,9 +670,7 @@
668
670
  return
669
671
  }
670
672
  const { metadata: entry, event } = data
671
- hover_data = entry
672
- ? { entry, position: { x: event.clientX, y: event.clientY } }
673
- : null
673
+ hover_data = entry ? { entry, position: { x: event.clientX, y: event.clientY } } : null
674
674
  on_point_hover?.(hover_data)
675
675
  }}
676
676
  padding={{ t: 30, b: 60, l: 60, r: 30 }}
@@ -685,14 +685,14 @@
685
685
  {@html sanitize_html(merged_controls.title || phase_stats?.chemical_system || ``)}
686
686
  </h3>
687
687
 
688
- <ClickFeedback
689
- bind:visible={copy_feedback.visible}
690
- position={copy_feedback.position}
691
- />
692
- <DragOverlay visible={drag_over} />
688
+ <ClickFeedback bind:visible={copy_feedback.visible} position={copy_feedback.position} />
689
+ <DragOverlay visible={drag_over} message="Drop JSON file to load phase diagram data" />
693
690
 
694
691
  {#if hull_data.has_temp_data && temperature !== undefined}
695
- <TemperatureSlider available_temperatures={hull_data.available_temperatures} bind:temperature />
692
+ <TemperatureSlider
693
+ available_temperatures={hull_data.available_temperatures}
694
+ bind:temperature
695
+ />
696
696
  {/if}
697
697
 
698
698
  {#if hull_data.gas_analysis.has_gas_dependent_elements && merged_gas_config}
@@ -720,8 +720,7 @@
720
720
 
721
721
  <style>
722
722
  :global(.convex-hull-2d:fullscreen) {
723
- background: var(--hull-2d-bg-fullscreen, var(--hull-2d-bg, var(--hull-bg)))
724
- !important;
723
+ background: var(--hull-2d-bg-fullscreen, var(--hull-2d-bg, var(--hull-bg))) !important;
725
724
  overflow: hidden;
726
725
  }
727
726
  :global(.convex-hull-2d.dragover) {
@@ -736,9 +735,11 @@
736
735
  cursor: pointer;
737
736
  border-radius: 3px;
738
737
  color: var(--text-color, currentColor);
739
- transition: background-color 0.2s, opacity 0.2s;
738
+ transition:
739
+ background-color 0.2s,
740
+ opacity 0.2s;
740
741
  display: flex;
741
- font-size: clamp(0.85em, 2cqmin, 1.3em);
742
+ font-size: var(--ctrl-btn-icon-size, clamp(0.7rem, 2cqmin, 0.85rem));
742
743
  }
743
744
  :global(.convex-hull-2d :is(.control-btn, .fullscreen-btn):hover) {
744
745
  background-color: color-mix(in srgb, currentColor 8%, transparent);
@@ -6,6 +6,6 @@ type $$ComponentProps = BaseConvexHullProps<ConvexHullEntry> & {
6
6
  x_axis?: AxisConfig;
7
7
  y_axis?: AxisConfig;
8
8
  };
9
- declare const ConvexHull2D: import("svelte").Component<$$ComponentProps, {}, "display" | "temperature" | "fullscreen" | "wrapper" | "controls_open" | "color_scale" | "info_pane_open" | "color_mode" | "show_stable" | "show_unstable" | "show_stable_labels" | "show_unstable_labels" | "max_hull_dist_show_phases" | "max_hull_dist_show_labels" | "hidden_categories" | "energy_source_mode" | "stable_entries" | "unstable_entries" | "phase_stats" | "highlighted_entries" | "selected_entry" | "gas_pressures">;
9
+ declare const ConvexHull2D: import("svelte").Component<$$ComponentProps, {}, "display" | "fullscreen" | "wrapper" | "controls_open" | "color_scale" | "info_pane_open" | "temperature" | "color_mode" | "show_stable" | "show_unstable" | "show_stable_labels" | "show_unstable_labels" | "max_hull_dist_show_phases" | "max_hull_dist_show_labels" | "hidden_categories" | "energy_source_mode" | "stable_entries" | "unstable_entries" | "phase_stats" | "highlighted_entries" | "selected_entry" | "gas_pressures">;
10
10
  type ConvexHull2D = ReturnType<typeof ConvexHull2D>;
11
11
  export default ConvexHull2D;