matterviz 0.3.7 → 0.4.1

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 (486) hide show
  1. package/dist/Icon.svelte +7 -4
  2. package/dist/MillerIndexInput.svelte +1 -1
  3. package/dist/api/optimade.js +32 -26
  4. package/dist/app.css +0 -3
  5. package/dist/brillouin/BrillouinZone.svelte +76 -148
  6. package/dist/brillouin/BrillouinZone.svelte.d.ts +6 -14
  7. package/dist/brillouin/BrillouinZoneExportPane.svelte +43 -96
  8. package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
  9. package/dist/brillouin/BrillouinZoneInfoPane.svelte +9 -32
  10. package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
  11. package/dist/brillouin/BrillouinZoneScene.svelte +97 -205
  12. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +4 -23
  13. package/dist/brillouin/BrillouinZoneTooltip.svelte +16 -25
  14. package/dist/brillouin/ReciprocalVectors.svelte +39 -0
  15. package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
  16. package/dist/brillouin/compute.d.ts +2 -0
  17. package/dist/brillouin/compute.js +89 -90
  18. package/dist/brillouin/geometry.d.ts +8 -0
  19. package/dist/brillouin/geometry.js +57 -0
  20. package/dist/brillouin/index.d.ts +2 -0
  21. package/dist/brillouin/index.js +2 -0
  22. package/dist/brillouin/types.d.ts +2 -2
  23. package/dist/chempot-diagram/ChemPotDiagram.svelte +14 -13
  24. package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
  25. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +109 -203
  26. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
  27. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +180 -470
  28. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
  29. package/dist/chempot-diagram/async-compute.svelte.js +3 -1
  30. package/dist/chempot-diagram/chempot-worker.js +2 -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 +4 -4
  34. package/dist/chempot-diagram/compute.js +20 -20
  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.js +8 -7
  45. package/dist/composition/FormulaFilter.svelte +18 -11
  46. package/dist/composition/PieChart.svelte +11 -10
  47. package/dist/composition/chem-sys.d.ts +8 -0
  48. package/dist/composition/chem-sys.js +86 -0
  49. package/dist/composition/format.js +7 -4
  50. package/dist/composition/index.d.ts +1 -0
  51. package/dist/composition/index.js +1 -0
  52. package/dist/composition/parse.d.ts +0 -1
  53. package/dist/composition/parse.js +41 -31
  54. package/dist/controls.d.ts +1 -0
  55. package/dist/controls.js +0 -1
  56. package/dist/convex-hull/ConvexHull.svelte +8 -10
  57. package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
  58. package/dist/convex-hull/ConvexHull2D.svelte +106 -185
  59. package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
  60. package/dist/convex-hull/ConvexHull3D.svelte +179 -683
  61. package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
  62. package/dist/convex-hull/ConvexHull4D.svelte +183 -687
  63. package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
  64. package/dist/convex-hull/ConvexHullChrome.svelte +268 -0
  65. package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
  66. package/dist/convex-hull/ConvexHullControls.svelte +88 -7
  67. package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
  68. package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
  69. package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
  70. package/dist/convex-hull/ConvexHullStats.svelte +36 -175
  71. package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
  72. package/dist/convex-hull/ConvexHullTooltip.svelte +11 -2
  73. package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
  74. package/dist/convex-hull/GasPressureControls.svelte +4 -4
  75. package/dist/convex-hull/TemperatureSlider.svelte +2 -2
  76. package/dist/convex-hull/barycentric-coords.d.ts +2 -4
  77. package/dist/convex-hull/barycentric-coords.js +6 -33
  78. package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
  79. package/dist/convex-hull/canvas-interactions.svelte.js +278 -0
  80. package/dist/convex-hull/demo-temperature.d.ts +1 -1
  81. package/dist/convex-hull/demo-temperature.js +20 -22
  82. package/dist/convex-hull/gas-thermodynamics.d.ts +2 -2
  83. package/dist/convex-hull/gas-thermodynamics.js +22 -30
  84. package/dist/convex-hull/helpers.d.ts +42 -7
  85. package/dist/convex-hull/helpers.js +171 -78
  86. package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
  87. package/dist/convex-hull/hull-state.svelte.js +124 -0
  88. package/dist/convex-hull/index.d.ts +10 -8
  89. package/dist/convex-hull/index.js +7 -2
  90. package/dist/convex-hull/thermodynamics.js +136 -960
  91. package/dist/convex-hull/types.d.ts +13 -5
  92. package/dist/convex-hull/types.js +12 -0
  93. package/dist/coordination/CoordinationBarPlot.svelte +27 -34
  94. package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
  95. package/dist/element/BohrAtom.svelte +2 -1
  96. package/dist/element/index.d.ts +4 -0
  97. package/dist/element/index.js +18 -0
  98. package/dist/feedback/DragOverlay.svelte +3 -1
  99. package/dist/feedback/DragOverlay.svelte.d.ts +1 -0
  100. package/dist/feedback/StatusMessage.svelte +13 -3
  101. package/dist/fermi-surface/FermiSlice.svelte +13 -5
  102. package/dist/fermi-surface/FermiSurface.svelte +78 -151
  103. package/dist/fermi-surface/FermiSurface.svelte.d.ts +5 -14
  104. package/dist/fermi-surface/FermiSurfaceControls.svelte +1 -1
  105. package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
  106. package/dist/fermi-surface/FermiSurfaceScene.svelte +72 -221
  107. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
  108. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +8 -34
  109. package/dist/fermi-surface/compute.js +67 -66
  110. package/dist/fermi-surface/export.js +6 -16
  111. package/dist/fermi-surface/index.d.ts +0 -1
  112. package/dist/fermi-surface/index.js +0 -1
  113. package/dist/fermi-surface/parse.d.ts +1 -1
  114. package/dist/fermi-surface/parse.js +71 -79
  115. package/dist/fermi-surface/types.d.ts +3 -2
  116. package/dist/heatmap-matrix/HeatmapMatrix.svelte +69 -52
  117. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +4 -3
  118. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +3 -2
  119. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
  120. package/dist/heatmap-matrix/index.d.ts +3 -2
  121. package/dist/heatmap-matrix/index.js +1 -1
  122. package/dist/index.d.ts +1 -0
  123. package/dist/index.js +1 -0
  124. package/dist/io/ExportPane.svelte +166 -0
  125. package/dist/io/ExportPane.svelte.d.ts +17 -0
  126. package/dist/io/decompress.js +5 -4
  127. package/dist/io/export.d.ts +9 -5
  128. package/dist/io/export.js +77 -51
  129. package/dist/io/fetch.d.ts +2 -1
  130. package/dist/io/fetch.js +5 -1
  131. package/dist/io/file-drop.d.ts +8 -1
  132. package/dist/io/file-drop.js +48 -36
  133. package/dist/io/index.d.ts +2 -0
  134. package/dist/io/index.js +10 -0
  135. package/dist/io/types.d.ts +13 -0
  136. package/dist/io/url-drop.js +64 -33
  137. package/dist/isosurface/parse.js +52 -51
  138. package/dist/isosurface/slice.js +5 -4
  139. package/dist/isosurface/types.js +1 -1
  140. package/dist/keyboard.d.ts +3 -0
  141. package/dist/keyboard.js +23 -0
  142. package/dist/labels.d.ts +1 -1
  143. package/dist/labels.js +9 -8
  144. package/dist/layout/FullscreenButton.svelte +33 -0
  145. package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
  146. package/dist/layout/FullscreenToggle.svelte +8 -14
  147. package/dist/layout/PropertyFilter.svelte +3 -2
  148. package/dist/layout/SettingsSection.svelte +1 -1
  149. package/dist/layout/ViewerChrome.svelte +116 -0
  150. package/dist/layout/ViewerChrome.svelte.d.ts +17 -0
  151. package/dist/layout/fullscreen.d.ts +4 -0
  152. package/dist/layout/fullscreen.svelte.d.ts +8 -0
  153. package/dist/layout/fullscreen.svelte.js +37 -0
  154. package/dist/layout/index.d.ts +3 -0
  155. package/dist/layout/index.js +3 -0
  156. package/dist/layout/json-tree/JsonNode.svelte +1 -1
  157. package/dist/layout/json-tree/JsonTree.svelte +2 -2
  158. package/dist/layout/json-tree/utils.js +5 -4
  159. package/dist/marching-cubes.js +8 -13
  160. package/dist/math.d.ts +12 -4
  161. package/dist/math.js +42 -30
  162. package/dist/overlays/DraggablePane.svelte +4 -4
  163. package/dist/overlays/index.d.ts +4 -0
  164. package/dist/periodic-table/PeriodicTable.svelte +27 -15
  165. package/dist/periodic-table/PropertySelect.svelte +1 -0
  166. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +9 -3
  167. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
  168. package/dist/phase-diagram/PhaseDiagramControls.svelte +3 -2
  169. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
  170. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +4 -2
  171. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
  172. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +47 -132
  173. package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
  174. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +1 -1
  175. package/dist/phase-diagram/build-diagram.js +2 -2
  176. package/dist/phase-diagram/colors.js +1 -1
  177. package/dist/phase-diagram/parse.d.ts +2 -1
  178. package/dist/phase-diagram/parse.js +6 -5
  179. package/dist/phase-diagram/types.d.ts +1 -1
  180. package/dist/phase-diagram/utils.d.ts +3 -3
  181. package/dist/phase-diagram/utils.js +8 -12
  182. package/dist/plot/{BarPlot.svelte → bar/BarPlot.svelte} +246 -841
  183. package/dist/plot/{BarPlot.svelte.d.ts → bar/BarPlot.svelte.d.ts} +8 -16
  184. package/dist/plot/{BarPlotControls.svelte → bar/BarPlotControls.svelte} +6 -5
  185. package/dist/plot/{BarPlotControls.svelte.d.ts → bar/BarPlotControls.svelte.d.ts} +3 -3
  186. package/dist/plot/{SpacegroupBarPlot.svelte → bar/SpacegroupBarPlot.svelte} +8 -7
  187. package/dist/plot/{SpacegroupBarPlot.svelte.d.ts → bar/SpacegroupBarPlot.svelte.d.ts} +1 -1
  188. package/dist/plot/bar/data.d.ts +40 -0
  189. package/dist/plot/bar/data.js +154 -0
  190. package/dist/plot/bar/geometry.d.ts +39 -0
  191. package/dist/plot/bar/geometry.js +60 -0
  192. package/dist/plot/bar/index.d.ts +3 -0
  193. package/dist/plot/bar/index.js +3 -0
  194. package/dist/plot/box/BoxPlot.svelte +1292 -0
  195. package/dist/plot/box/BoxPlot.svelte.d.ts +95 -0
  196. package/dist/plot/box/BoxPlotControls.svelte +109 -0
  197. package/dist/plot/box/BoxPlotControls.svelte.d.ts +19 -0
  198. package/dist/plot/box/Violin.svelte +14 -0
  199. package/dist/plot/box/Violin.svelte.d.ts +70 -0
  200. package/dist/plot/box/box-plot.d.ts +56 -0
  201. package/dist/plot/box/box-plot.js +129 -0
  202. package/dist/plot/box/index.d.ts +5 -0
  203. package/dist/plot/box/index.js +5 -0
  204. package/dist/plot/box/kde.d.ts +17 -0
  205. package/dist/plot/box/kde.js +160 -0
  206. package/dist/plot/box/quantile.d.ts +3 -0
  207. package/dist/plot/box/quantile.js +53 -0
  208. package/dist/plot/{auto-place.d.ts → core/auto-place.d.ts} +1 -1
  209. package/dist/plot/{auto-place.js → core/auto-place.js} +6 -3
  210. package/dist/plot/core/axis-utils.d.ts +46 -0
  211. package/dist/plot/core/axis-utils.js +110 -0
  212. package/dist/plot/{AxisLabel.svelte → core/components/AxisLabel.svelte} +2 -2
  213. package/dist/plot/{AxisLabel.svelte.d.ts → core/components/AxisLabel.svelte.d.ts} +1 -1
  214. package/dist/plot/{ColorBar.svelte → core/components/ColorBar.svelte} +41 -38
  215. package/dist/plot/{ColorBar.svelte.d.ts → core/components/ColorBar.svelte.d.ts} +7 -6
  216. package/dist/plot/{ColorScaleSelect.svelte → core/components/ColorScaleSelect.svelte} +4 -3
  217. package/dist/plot/{ColorScaleSelect.svelte.d.ts → core/components/ColorScaleSelect.svelte.d.ts} +2 -2
  218. package/dist/plot/core/components/ControlPane.svelte +46 -0
  219. package/dist/plot/core/components/ControlPane.svelte.d.ts +13 -0
  220. package/dist/plot/{FillArea.svelte → core/components/FillArea.svelte} +17 -6
  221. package/dist/plot/{FillArea.svelte.d.ts → core/components/FillArea.svelte.d.ts} +1 -1
  222. package/dist/plot/{InteractiveAxisLabel.svelte → core/components/InteractiveAxisLabel.svelte} +3 -3
  223. package/dist/plot/{InteractiveAxisLabel.svelte.d.ts → core/components/InteractiveAxisLabel.svelte.d.ts} +2 -2
  224. package/dist/plot/{Line.svelte → core/components/Line.svelte} +33 -15
  225. package/dist/plot/{Line.svelte.d.ts → core/components/Line.svelte.d.ts} +3 -2
  226. package/dist/plot/{PlotAxis.svelte → core/components/PlotAxis.svelte} +9 -6
  227. package/dist/plot/{PlotAxis.svelte.d.ts → core/components/PlotAxis.svelte.d.ts} +5 -3
  228. package/dist/plot/{PlotControls.svelte → core/components/PlotControls.svelte} +17 -29
  229. package/dist/plot/core/components/PlotControls.svelte.d.ts +4 -0
  230. package/dist/plot/{PlotLegend.svelte → core/components/PlotLegend.svelte} +21 -10
  231. package/dist/plot/{PlotLegend.svelte.d.ts → core/components/PlotLegend.svelte.d.ts} +3 -2
  232. package/dist/plot/{PlotTooltip.svelte → core/components/PlotTooltip.svelte} +17 -1
  233. package/dist/plot/{PlotTooltip.svelte.d.ts → core/components/PlotTooltip.svelte.d.ts} +8 -0
  234. package/dist/plot/{PortalSelect.svelte → core/components/PortalSelect.svelte} +11 -7
  235. package/dist/plot/{ReferenceLine.svelte → core/components/ReferenceLine.svelte} +3 -3
  236. package/dist/plot/{ReferenceLine.svelte.d.ts → core/components/ReferenceLine.svelte.d.ts} +1 -1
  237. package/dist/plot/{ReferenceLine3D.svelte → core/components/ReferenceLine3D.svelte} +5 -5
  238. package/dist/plot/{ReferenceLine3D.svelte.d.ts → core/components/ReferenceLine3D.svelte.d.ts} +5 -5
  239. package/dist/plot/{ReferencePlane.svelte → core/components/ReferencePlane.svelte} +8 -8
  240. package/dist/plot/{ReferencePlane.svelte.d.ts → core/components/ReferencePlane.svelte.d.ts} +5 -5
  241. package/dist/plot/{ZeroLines.svelte → core/components/ZeroLines.svelte} +3 -3
  242. package/dist/plot/{ZeroLines.svelte.d.ts → core/components/ZeroLines.svelte.d.ts} +3 -3
  243. package/dist/plot/{ZoomRect.svelte → core/components/ZoomRect.svelte} +1 -1
  244. package/dist/plot/{ZoomRect.svelte.d.ts → core/components/ZoomRect.svelte.d.ts} +1 -1
  245. package/dist/plot/core/components/index.d.ts +17 -0
  246. package/dist/plot/core/components/index.js +17 -0
  247. package/dist/plot/{data-cleaning.d.ts → core/data-cleaning.d.ts} +71 -1
  248. package/dist/plot/{data-cleaning.js → core/data-cleaning.js} +21 -23
  249. package/dist/plot/{data-transform.d.ts → core/data-transform.d.ts} +2 -2
  250. package/dist/plot/{data-transform.js → core/data-transform.js} +3 -3
  251. package/dist/plot/core/fill-utils.d.ts +34 -0
  252. package/dist/plot/core/fill-utils.js +391 -0
  253. package/dist/plot/core/index.d.ts +10 -0
  254. package/dist/plot/core/index.js +11 -0
  255. package/dist/plot/core/interactions.d.ts +39 -0
  256. package/dist/plot/core/interactions.js +209 -0
  257. package/dist/plot/{layout.d.ts → core/layout.d.ts} +1 -0
  258. package/dist/plot/{layout.js → core/layout.js} +16 -8
  259. package/dist/plot/core/pan-zoom.svelte.d.ts +35 -0
  260. package/dist/plot/core/pan-zoom.svelte.js +221 -0
  261. package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
  262. package/dist/plot/core/placed-tween.svelte.js +68 -0
  263. package/dist/plot/{reference-line.d.ts → core/reference-line.d.ts} +11 -11
  264. package/dist/plot/{reference-line.js → core/reference-line.js} +29 -42
  265. package/dist/plot/core/scales.d.ts +40 -0
  266. package/dist/plot/{scales.js → core/scales.js} +94 -93
  267. package/dist/plot/core/svg.d.ts +3 -0
  268. package/dist/plot/core/svg.js +41 -0
  269. package/dist/plot/{types.d.ts → core/types.d.ts} +36 -85
  270. package/dist/plot/{types.js → core/types.js} +1 -1
  271. package/dist/plot/{utils → core/utils}/label-placement.d.ts +3 -3
  272. package/dist/plot/{utils → core/utils}/label-placement.js +3 -3
  273. package/dist/plot/core/utils/series-visibility.d.ts +26 -0
  274. package/dist/plot/{utils → core/utils}/series-visibility.js +29 -2
  275. package/dist/plot/core/utils.d.ts +12 -0
  276. package/dist/plot/core/utils.js +27 -0
  277. package/dist/plot/{Histogram.svelte → histogram/Histogram.svelte} +174 -551
  278. package/dist/plot/{Histogram.svelte.d.ts → histogram/Histogram.svelte.d.ts} +2 -2
  279. package/dist/plot/{HistogramControls.svelte → histogram/HistogramControls.svelte} +6 -6
  280. package/dist/plot/{HistogramControls.svelte.d.ts → histogram/HistogramControls.svelte.d.ts} +4 -4
  281. package/dist/plot/histogram/index.d.ts +2 -0
  282. package/dist/plot/histogram/index.js +2 -0
  283. package/dist/plot/index.d.ts +8 -41
  284. package/dist/plot/index.js +10 -39
  285. package/dist/plot/sankey/Sankey.svelte +697 -0
  286. package/dist/plot/sankey/Sankey.svelte.d.ts +74 -0
  287. package/dist/plot/sankey/SankeyControls.svelte +98 -0
  288. package/dist/plot/sankey/SankeyControls.svelte.d.ts +19 -0
  289. package/dist/plot/sankey/index.d.ts +4 -0
  290. package/dist/plot/sankey/index.js +3 -0
  291. package/dist/plot/sankey/sankey-types.d.ts +42 -0
  292. package/dist/plot/sankey/sankey-types.js +4 -0
  293. package/dist/plot/sankey/sankey.d.ts +52 -0
  294. package/dist/plot/sankey/sankey.js +189 -0
  295. package/dist/plot/{BinnedScatterPlot.svelte → scatter/BinnedScatterPlot.svelte} +64 -64
  296. package/dist/plot/{BinnedScatterPlot.svelte.d.ts → scatter/BinnedScatterPlot.svelte.d.ts} +6 -6
  297. package/dist/plot/{ElementScatter.svelte → scatter/ElementScatter.svelte} +6 -6
  298. package/dist/plot/{ElementScatter.svelte.d.ts → scatter/ElementScatter.svelte.d.ts} +2 -2
  299. package/dist/plot/{ScatterPlot.svelte → scatter/ScatterPlot.svelte} +297 -1008
  300. package/dist/plot/{ScatterPlot.svelte.d.ts → scatter/ScatterPlot.svelte.d.ts} +10 -18
  301. package/dist/plot/{ScatterPlotControls.svelte → scatter/ScatterPlotControls.svelte} +6 -5
  302. package/dist/plot/{ScatterPlotControls.svelte.d.ts → scatter/ScatterPlotControls.svelte.d.ts} +2 -2
  303. package/dist/plot/{ScatterPoint.svelte → scatter/ScatterPoint.svelte} +7 -7
  304. package/dist/plot/{ScatterPoint.svelte.d.ts → scatter/ScatterPoint.svelte.d.ts} +3 -3
  305. package/dist/plot/{adaptive-density.d.ts → scatter/adaptive-density.d.ts} +14 -4
  306. package/dist/plot/{adaptive-density.js → scatter/adaptive-density.js} +46 -20
  307. package/dist/plot/{binned-scatter-types.d.ts → scatter/binned-scatter-types.d.ts} +5 -12
  308. package/dist/plot/scatter/index.d.ts +7 -0
  309. package/dist/plot/scatter/index.js +5 -0
  310. package/dist/plot/scatter/scatter-data.d.ts +19 -0
  311. package/dist/plot/scatter/scatter-data.js +212 -0
  312. package/dist/plot/{ScatterPlot3D.svelte → scatter-3d/ScatterPlot3D.svelte} +25 -34
  313. package/dist/plot/{ScatterPlot3D.svelte.d.ts → scatter-3d/ScatterPlot3D.svelte.d.ts} +9 -17
  314. package/dist/plot/{ScatterPlot3DControls.svelte → scatter-3d/ScatterPlot3DControls.svelte} +14 -14
  315. package/dist/plot/{ScatterPlot3DControls.svelte.d.ts → scatter-3d/ScatterPlot3DControls.svelte.d.ts} +6 -6
  316. package/dist/plot/{ScatterPlot3DScene.svelte → scatter-3d/ScatterPlot3DScene.svelte} +129 -128
  317. package/dist/plot/{ScatterPlot3DScene.svelte.d.ts → scatter-3d/ScatterPlot3DScene.svelte.d.ts} +6 -15
  318. package/dist/plot/{Surface3D.svelte → scatter-3d/Surface3D.svelte} +7 -6
  319. package/dist/plot/{Surface3D.svelte.d.ts → scatter-3d/Surface3D.svelte.d.ts} +5 -4
  320. package/dist/plot/scatter-3d/index.d.ts +4 -0
  321. package/dist/plot/scatter-3d/index.js +4 -0
  322. package/dist/plot/sunburst/Sunburst.svelte +1041 -0
  323. package/dist/plot/sunburst/Sunburst.svelte.d.ts +97 -0
  324. package/dist/plot/sunburst/SunburstControls.svelte +200 -0
  325. package/dist/plot/sunburst/SunburstControls.svelte.d.ts +26 -0
  326. package/dist/plot/sunburst/index.d.ts +4 -0
  327. package/dist/plot/sunburst/index.js +4 -0
  328. package/dist/plot/sunburst/render.d.ts +34 -0
  329. package/dist/plot/sunburst/render.js +122 -0
  330. package/dist/plot/sunburst/sunburst.d.ts +62 -0
  331. package/dist/plot/sunburst/sunburst.js +269 -0
  332. package/dist/rdf/RdfPlot.svelte +2 -1
  333. package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
  334. package/dist/rdf/calc-rdf.js +11 -24
  335. package/dist/sanitize.js +14 -3
  336. package/dist/scene/SceneCamera.svelte +62 -0
  337. package/dist/scene/SceneCamera.svelte.d.ts +19 -0
  338. package/dist/scene/bind-renderer.svelte.d.ts +2 -0
  339. package/dist/scene/bind-renderer.svelte.js +14 -0
  340. package/dist/scene/index.d.ts +4 -0
  341. package/dist/scene/index.js +5 -0
  342. package/dist/scene/props.js +52 -0
  343. package/dist/scene/types.d.ts +26 -0
  344. package/dist/scene/types.js +1 -0
  345. package/dist/settings.d.ts +79 -3
  346. package/dist/settings.js +321 -1
  347. package/dist/spectral/Bands.svelte +47 -36
  348. package/dist/spectral/Bands.svelte.d.ts +6 -6
  349. package/dist/spectral/BandsAndDos.svelte +23 -25
  350. package/dist/spectral/BrillouinBandsDos.svelte +42 -30
  351. package/dist/spectral/Dos.svelte +15 -23
  352. package/dist/spectral/Dos.svelte.d.ts +4 -3
  353. package/dist/spectral/helpers.d.ts +8 -6
  354. package/dist/spectral/helpers.js +137 -65
  355. package/dist/state.svelte.d.ts +0 -7
  356. package/dist/state.svelte.js +0 -6
  357. package/dist/structure/Arrow.svelte +2 -4
  358. package/dist/structure/AtomLegend.svelte +8 -9
  359. package/dist/structure/AtomLegend.svelte.d.ts +1 -1
  360. package/dist/structure/CanvasTooltip.svelte +1 -0
  361. package/dist/structure/CellSelect.svelte +12 -5
  362. package/dist/structure/CellSelect.svelte.d.ts +2 -1
  363. package/dist/structure/Cylinder.svelte +12 -8
  364. package/dist/structure/Cylinder.svelte.d.ts +4 -1
  365. package/dist/structure/Lattice.svelte +2 -2
  366. package/dist/structure/Structure.svelte +365 -423
  367. package/dist/structure/Structure.svelte.d.ts +5 -15
  368. package/dist/structure/StructureControls.svelte +217 -2
  369. package/dist/structure/StructureControls.svelte.d.ts +5 -3
  370. package/dist/structure/StructureExportPane.svelte +54 -156
  371. package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
  372. package/dist/structure/StructureInfoPane.svelte +10 -9
  373. package/dist/structure/StructureInfoPane.svelte.d.ts +5 -5
  374. package/dist/structure/StructureScene.svelte +376 -208
  375. package/dist/structure/StructureScene.svelte.d.ts +22 -20
  376. package/dist/structure/{label-placement.d.ts → atom-label-placement.d.ts} +3 -3
  377. package/dist/structure/{label-placement.js → atom-label-placement.js} +15 -5
  378. package/dist/structure/atom-properties.d.ts +1 -1
  379. package/dist/structure/atom-properties.js +17 -22
  380. package/dist/structure/bond-order-perception.js +3 -5
  381. package/dist/structure/bonding.d.ts +4 -0
  382. package/dist/structure/bonding.js +134 -63
  383. package/dist/structure/export.d.ts +24 -4
  384. package/dist/structure/export.js +89 -143
  385. package/dist/structure/index.d.ts +4 -4
  386. package/dist/structure/index.js +3 -3
  387. package/dist/structure/measure.d.ts +3 -2
  388. package/dist/structure/measure.js +6 -5
  389. package/dist/structure/parse.d.ts +3 -2
  390. package/dist/structure/parse.js +419 -438
  391. package/dist/structure/partial-occupancy.d.ts +0 -1
  392. package/dist/structure/partial-occupancy.js +1 -1
  393. package/dist/structure/pbc.d.ts +1 -1
  394. package/dist/structure/pbc.js +190 -13
  395. package/dist/structure/polyhedra.d.ts +41 -0
  396. package/dist/structure/polyhedra.js +602 -0
  397. package/dist/structure/site.d.ts +4 -0
  398. package/dist/structure/site.js +1 -0
  399. package/dist/structure/supercell.js +3 -2
  400. package/dist/structure/validation.js +5 -6
  401. package/dist/symmetry/SymmetryElementControls.svelte +69 -0
  402. package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
  403. package/dist/symmetry/SymmetryElements.svelte +354 -0
  404. package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
  405. package/dist/symmetry/SymmetryStats.svelte +113 -8
  406. package/dist/symmetry/WyckoffTable.svelte +68 -7
  407. package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
  408. package/dist/symmetry/cell-transform.js +7 -14
  409. package/dist/symmetry/index.d.ts +14 -4
  410. package/dist/symmetry/index.js +291 -72
  411. package/dist/symmetry/spacegroups.d.ts +12 -1
  412. package/dist/symmetry/spacegroups.js +63 -14
  413. package/dist/symmetry/symmetry-elements.d.ts +33 -0
  414. package/dist/symmetry/symmetry-elements.js +521 -0
  415. package/dist/symmetry/wyckoff-db.d.ts +9 -0
  416. package/dist/symmetry/wyckoff-db.js +87 -0
  417. package/dist/table/HeatmapTable.svelte +66 -25
  418. package/dist/table/HeatmapTable.svelte.d.ts +1 -1
  419. package/dist/table/index.d.ts +1 -3
  420. package/dist/table/index.js +1 -1
  421. package/dist/theme/index.js +8 -8
  422. package/dist/tooltip/KCoords.svelte +45 -0
  423. package/dist/tooltip/KCoords.svelte.d.ts +8 -0
  424. package/dist/tooltip/index.d.ts +1 -0
  425. package/dist/tooltip/index.js +1 -0
  426. package/dist/trajectory/Trajectory.svelte +123 -100
  427. package/dist/trajectory/Trajectory.svelte.d.ts +11 -22
  428. package/dist/trajectory/TrajectoryExportPane.svelte +17 -25
  429. package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
  430. package/dist/trajectory/TrajectoryInfoPane.svelte +5 -3
  431. package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
  432. package/dist/trajectory/constants.js +6 -2
  433. package/dist/trajectory/extract.js +17 -37
  434. package/dist/trajectory/format-detect.d.ts +1 -1
  435. package/dist/trajectory/format-detect.js +27 -19
  436. package/dist/trajectory/frame-reader.d.ts +0 -1
  437. package/dist/trajectory/frame-reader.js +63 -162
  438. package/dist/trajectory/helpers.d.ts +10 -2
  439. package/dist/trajectory/helpers.js +56 -36
  440. package/dist/trajectory/index.js +1 -1
  441. package/dist/trajectory/parse/ase.d.ts +9 -1
  442. package/dist/trajectory/parse/ase.js +47 -32
  443. package/dist/trajectory/parse/diagnostics.d.ts +3 -0
  444. package/dist/trajectory/parse/diagnostics.js +14 -0
  445. package/dist/trajectory/parse/hdf5.js +1 -1
  446. package/dist/trajectory/parse/index.d.ts +1 -1
  447. package/dist/trajectory/parse/index.js +65 -105
  448. package/dist/trajectory/parse/lammps.d.ts +0 -2
  449. package/dist/trajectory/parse/lammps.js +8 -6
  450. package/dist/trajectory/parse/pymatgen.d.ts +2 -0
  451. package/dist/trajectory/parse/pymatgen.js +74 -0
  452. package/dist/trajectory/parse/vasp.js +38 -18
  453. package/dist/trajectory/parse/xyz.d.ts +13 -1
  454. package/dist/trajectory/parse/xyz.js +102 -94
  455. package/dist/trajectory/plotting.d.ts +1 -2
  456. package/dist/trajectory/plotting.js +16 -113
  457. package/dist/utils.d.ts +2 -0
  458. package/dist/utils.js +7 -5
  459. package/dist/xrd/XrdPlot.svelte +16 -30
  460. package/dist/xrd/broadening.d.ts +2 -1
  461. package/dist/xrd/calc-xrd.js +18 -20
  462. package/dist/xrd/index.d.ts +2 -2
  463. package/dist/xrd/parse.js +2 -2
  464. package/package.json +43 -26
  465. package/dist/element/data.json +0 -11864
  466. package/dist/fermi-surface/marching-cubes.d.ts +0 -2
  467. package/dist/fermi-surface/marching-cubes.js +0 -2
  468. package/dist/plot/PlotControls.svelte.d.ts +0 -4
  469. package/dist/plot/axis-utils.d.ts +0 -19
  470. package/dist/plot/axis-utils.js +0 -78
  471. package/dist/plot/defaults.d.ts +0 -19
  472. package/dist/plot/defaults.js +0 -9
  473. package/dist/plot/fill-utils.d.ts +0 -46
  474. package/dist/plot/fill-utils.js +0 -322
  475. package/dist/plot/hover-lock.svelte.d.ts +0 -14
  476. package/dist/plot/hover-lock.svelte.js +0 -46
  477. package/dist/plot/interactions.d.ts +0 -12
  478. package/dist/plot/interactions.js +0 -101
  479. package/dist/plot/scales.d.ts +0 -48
  480. package/dist/plot/svg.d.ts +0 -1
  481. package/dist/plot/svg.js +0 -11
  482. package/dist/plot/utils/series-visibility.d.ts +0 -15
  483. package/dist/plot/utils.d.ts +0 -1
  484. package/dist/plot/utils.js +0 -14
  485. /package/dist/plot/{PortalSelect.svelte.d.ts → core/components/PortalSelect.svelte.d.ts} +0 -0
  486. /package/dist/plot/{binned-scatter-types.js → scatter/binned-scatter-types.js} +0 -0
@@ -1,3 +1,4 @@
1
+ import type { PaneProps, PaneToggleProps } from '../overlays';
1
2
  import DraggablePane from '../overlays/DraggablePane.svelte';
2
3
  import type { ComponentProps } from 'svelte';
3
4
  import type { TrajectoryType } from './index';
@@ -9,8 +10,8 @@ type $$ComponentProps = Omit<ComponentProps<typeof DraggablePane>, `children`> &
9
10
  file_size?: number | null;
10
11
  file_object?: File | null;
11
12
  pane_open?: boolean;
12
- toggle_props?: ComponentProps<typeof DraggablePane>[`toggle_props`];
13
- pane_props?: ComponentProps<typeof DraggablePane>[`pane_props`];
13
+ toggle_props?: PaneToggleProps;
14
+ pane_props?: PaneProps;
14
15
  };
15
16
  declare const TrajectoryInfoPane: import("svelte").Component<$$ComponentProps, {}, "pane_open">;
16
17
  type TrajectoryInfoPane = ReturnType<typeof TrajectoryInfoPane>;
@@ -1,7 +1,11 @@
1
1
  // Constants for trajectory parsing and large file handling
2
+ import { DEFAULTS } from '../settings';
2
3
  export const MAX_SAFE_STRING_LENGTH = 0x1fffffe8 * 0.5; // 50% of JS max string length as safety
3
4
  export const MAX_METADATA_SIZE = 50 * 1024 * 1024; // 50MB limit for metadata
4
5
  export const LARGE_FILE_THRESHOLD = 400 * 1024 * 1024; // 400MB
5
6
  export const INDEX_SAMPLE_RATE = 100; // Default sample rate for frame indexing
6
- export const MAX_BIN_FILE_SIZE = 100 * 1024 * 1024; // 100MB default for ArrayBuffer files
7
- export const MAX_TEXT_FILE_SIZE = 50 * 1024 * 1024; // 50MB default for string files
7
+ // Fallback thresholds for component usage without loading_options, derived from the
8
+ // settings schema so settings-driven contexts (e.g. the VSCode extension) and direct
9
+ // component use agree on when large-file/indexed loading kicks in.
10
+ export const MAX_BIN_FILE_SIZE = DEFAULTS.trajectory.bin_file_threshold; // 50MB
11
+ export const MAX_TEXT_FILE_SIZE = DEFAULTS.trajectory.text_file_threshold; // 25MB
@@ -1,5 +1,6 @@
1
1
  // Data extraction functions for trajectory analysis and plotting
2
2
  import { get_density } from '../structure/index';
3
+ import { calc_force_stats, copy_numeric_fields } from './helpers';
3
4
  // Common data extractor that extracts energy and structural properties
4
5
  export const energy_data_extractor = (frame) => {
5
6
  const data = {
@@ -7,18 +8,13 @@ export const energy_data_extractor = (frame) => {
7
8
  };
8
9
  if (frame.metadata) {
9
10
  // Extract energy-related properties
10
- const energy_fields = [
11
+ copy_numeric_fields(data, frame.metadata, [
11
12
  `energy`,
12
13
  `energy_per_atom`,
13
14
  `potential_energy`,
14
15
  `kinetic_energy`,
15
16
  `total_energy`,
16
- ];
17
- for (const field of energy_fields) {
18
- if (field in frame.metadata && typeof frame.metadata[field] === `number`) {
19
- data[field] = frame.metadata[field];
20
- }
21
- }
17
+ ]);
22
18
  }
23
19
  return data;
24
20
  };
@@ -30,13 +26,8 @@ export const force_stress_data_extractor = (frame) => {
30
26
  if (frame.metadata) {
31
27
  // Calculate force properties from forces array if available (preferred)
32
28
  if (frame.metadata.forces && Array.isArray(frame.metadata.forces)) {
33
- const forces = frame.metadata.forces;
34
- if (forces.length > 0) {
35
- const force_magnitudes = forces.map((force) => Math.hypot(...force));
36
- data.force_max = Math.max(...force_magnitudes);
37
- // Calculate RMS (root mean square) of force magnitudes
38
- data.force_norm = Math.sqrt(force_magnitudes.reduce((sum, f) => sum + f ** 2, 0) / force_magnitudes.length);
39
- }
29
+ // Object.assign ignores the null calc_force_stats returns for empty forces
30
+ Object.assign(data, calc_force_stats(frame.metadata.forces));
40
31
  }
41
32
  else {
42
33
  // Fallback to metadata values if forces array not available
@@ -52,12 +43,12 @@ export const force_stress_data_extractor = (frame) => {
52
43
  }
53
44
  }
54
45
  // Extract other stress and pressure properties (no duplicates expected)
55
- const other_stress_fields = [`stress_max`, `stress_frobenius`, `stress_trace`, `pressure`];
56
- for (const field of other_stress_fields) {
57
- if (field in frame.metadata && typeof frame.metadata[field] === `number`) {
58
- data[field] = frame.metadata[field];
59
- }
60
- }
46
+ copy_numeric_fields(data, frame.metadata, [
47
+ `stress_max`,
48
+ `stress_frobenius`,
49
+ `stress_trace`,
50
+ `pressure`,
51
+ ]);
61
52
  }
62
53
  return data;
63
54
  };
@@ -79,31 +70,20 @@ export const structural_data_extractor = (frame) => {
79
70
  }
80
71
  if (frame.metadata) {
81
72
  // Extract other structural properties, avoiding volume duplicate
82
- const structural_fields = [`temperature`];
83
- for (const field of structural_fields) {
84
- if (field in frame.metadata && typeof frame.metadata[field] === `number`)
85
- data[field] = frame.metadata[field];
86
- }
87
- // Handle density separately - prefer metadata, but calculate if not available
88
- if (frame.metadata.density && typeof frame.metadata.density === `number`) {
73
+ copy_numeric_fields(data, frame.metadata, [`temperature`]);
74
+ // Prefer metadata density (fall back to calculating from structure below).
75
+ // Finite-number check (not truthiness) so a legitimate density of 0 is kept.
76
+ if (typeof frame.metadata.density === `number` &&
77
+ Number.isFinite(frame.metadata.density)) {
89
78
  data.density = frame.metadata.density;
90
79
  }
91
- else if (`lattice` in frame.structure) {
92
- try {
93
- data.density = get_density(frame.structure);
94
- }
95
- catch (error) {
96
- console.warn(`Failed to calculate density for frame ${frame.step}:`, error);
97
- }
98
- }
99
80
  // Only use metadata volume if lattice volume is not available
100
81
  if (!data.volume && frame.metadata.volume && typeof frame.metadata.volume === `number`) {
101
82
  data.volume = frame.metadata.volume;
102
83
  }
103
84
  // Note: pressure is handled by force_stress_data_extractor to avoid duplication
104
85
  }
105
- else if (`lattice` in frame.structure) {
106
- // Calculate density even when no metadata is available
86
+ if (data.density === undefined && `lattice` in frame.structure) {
107
87
  try {
108
88
  data.density = get_density(frame.structure);
109
89
  }
@@ -1,4 +1,4 @@
1
- export declare function strip_compression_extensions(filename: string): string;
1
+ export declare function ext_hint(filename: string | undefined, ext_regex: RegExp): boolean | null;
2
2
  export declare const FORMAT_PATTERNS: {
3
3
  readonly ase: (data: unknown, filename?: string) => boolean;
4
4
  readonly hdf5: (data: unknown, filename?: string) => boolean;
@@ -1,33 +1,43 @@
1
1
  // Format detection for trajectory files
2
- import { COMPRESSION_EXTENSIONS_REGEX, CONFIG_DIRS_REGEX, MD_SIM_EXCLUDE_REGEX, TRAJ_EXTENSIONS_REGEX, TRAJ_FALLBACK_EXTENSIONS_REGEX, TRAJ_KEYWORDS_SIMPLE_REGEX, XDATCAR_REGEX, } from '../constants';
2
+ import { CONFIG_DIRS_REGEX, MD_SIM_EXCLUDE_REGEX, TRAJ_EXTENSIONS_REGEX, TRAJ_FALLBACK_EXTENSIONS_REGEX, TRAJ_KEYWORDS_SIMPLE_REGEX, XDATCAR_REGEX, } from '../constants';
3
+ import { strip_compression_extensions } from '../io';
3
4
  import { count_xyz_frames } from './helpers';
4
- export function strip_compression_extensions(filename) {
5
- let base_name = filename.toLowerCase();
6
- while (COMPRESSION_EXTENSIONS_REGEX.test(base_name)) {
7
- base_name = base_name.replace(COMPRESSION_EXTENSIONS_REGEX, ``);
8
- }
9
- return base_name;
5
+ // Extensions that explicitly identify a format — when present, format detection trusts
6
+ // the extension instead of sniffing content
7
+ const KNOWN_FORMAT_EXT_REGEX = /\.(xyz|extxyz|traj|h5|hdf5|lammpstrj|json|cif|poscar|vasp|yaml|yml|xml|csv)$/;
8
+ // Classify the filename hint for a format whose extensions match ext_regex:
9
+ // true = filename matches, false = filename names a different known format,
10
+ // null = no usable hint (missing filename or unrecognized extension, e.g. the UUID
11
+ // basenames of blob: object URLs) — callers should fall back to content detection
12
+ export function ext_hint(filename, ext_regex) {
13
+ if (!filename)
14
+ return null;
15
+ const base = strip_compression_extensions(filename);
16
+ if (ext_regex.test(base))
17
+ return true;
18
+ return KNOWN_FORMAT_EXT_REGEX.test(base) ? false : null;
10
19
  }
11
- // Unified format detection
20
+ // Unified format detection. Each pattern trusts a matching file extension when present
21
+ // but falls back to content/magic-byte detection when the filename gives no hint
22
+ // (e.g. blob: object URLs, extensionless API endpoints).
12
23
  export const FORMAT_PATTERNS = {
13
24
  ase: (data, filename) => {
14
- const base_name = filename ? strip_compression_extensions(filename) : undefined;
15
- if (!base_name?.endsWith(`.traj`) || !(data instanceof ArrayBuffer)) {
25
+ if (ext_hint(filename, /\.traj$/) === false || !(data instanceof ArrayBuffer)) {
16
26
  return false;
17
27
  }
18
28
  const view = new Uint8Array(data.slice(0, 24));
19
29
  return [0x2d, 0x20, 0x6f, 0x66, 0x20, 0x55, 0x6c, 0x6d].every((byte, idx) => view[idx] === byte);
20
30
  },
21
31
  hdf5: (data, filename) => {
22
- const base_name = filename ? strip_compression_extensions(filename) : undefined;
23
- const has_ext = base_name?.match(/\.(h5|hdf5)$/);
24
- if (!has_ext || !(data instanceof ArrayBuffer) || data.byteLength < 8)
32
+ if (ext_hint(filename, /\.(h5|hdf5)$/) === false)
33
+ return false;
34
+ if (!(data instanceof ArrayBuffer) || data.byteLength < 8)
25
35
  return false;
26
36
  const signature = new Uint8Array(data.slice(0, 8));
27
- return [0x89, 0x48, 0x44, 0x46, 0x0d, 0x0a, 0x1a, 0x0a].every((b, idx) => signature[idx] === b);
37
+ return [0x89, 0x48, 0x44, 0x46, 0x0d, 0x0a, 0x1a, 0x0a].every((byte, idx) => signature[idx] === byte);
28
38
  },
29
39
  vasp: (data, filename) => {
30
- const basename = filename?.toLowerCase().split(`/`).pop() || ``;
40
+ const basename = filename?.toLowerCase().split(`/`).pop() ?? ``;
31
41
  if (basename === `xdatcar` || basename.startsWith(`xdatcar`))
32
42
  return true;
33
43
  const lines = data.trim().split(/\r?\n/);
@@ -37,14 +47,12 @@ export const FORMAT_PATTERNS = {
37
47
  lines.slice(2, 5).every((line) => line.trim().split(/\s+/).length === 3));
38
48
  },
39
49
  xyz_multi: (data, filename) => {
40
- const base = filename ? strip_compression_extensions(filename) : ``;
41
- if (!/\.(xyz|extxyz)$/.test(base))
50
+ if (ext_hint(filename, /\.(xyz|extxyz)$/) === false)
42
51
  return false;
43
52
  return count_xyz_frames(data) >= 2;
44
53
  },
45
54
  lammpstrj: (data, filename) => {
46
- const base = filename ? strip_compression_extensions(filename) : ``;
47
- if (!base.endsWith(`.lammpstrj`))
55
+ if (ext_hint(filename, /\.lammpstrj$/) === false)
48
56
  return false;
49
57
  return data.includes(`ITEM: TIMESTEP`) && data.includes(`ITEM: ATOMS`);
50
58
  },
@@ -12,6 +12,5 @@ export declare class TrajFrameReader implements FrameLoader {
12
12
  }, on_progress?: (progress: ParseProgress) => void): Promise<TrajectoryMetadata[]>;
13
13
  private load_xyz_frame;
14
14
  private load_ase_frame;
15
- private parse_xyz_metadata;
16
15
  private parse_ase_metadata;
17
16
  }
@@ -1,7 +1,16 @@
1
+ // Unified frame loader for XYZ and ASE trajectories (large file indexing)
1
2
  import * as math from '../math';
2
3
  import { MAX_METADATA_SIZE } from './constants';
3
- import { coerce_element_symbol, convert_atomic_numbers, count_xyz_frames, create_trajectory_frame, read_ndarray_from_view, validate_3x3_matrix, } from './helpers';
4
- import { strip_compression_extensions } from './format-detect';
4
+ import { copy_numeric_fields, count_xyz_frames, iter_xyz_frames, validate_3x3_matrix, } from './helpers';
5
+ import { strip_compression_extensions } from '../io';
6
+ import { decode_ase_frame, read_ase_header } from './parse/ase';
7
+ import { build_xyz_frame, parse_xyz_comment_metadata } from './parse/xyz';
8
+ // Restrict frame metadata to the requested property keys (no-op when unset)
9
+ const filter_properties = (metadata, properties) => {
10
+ if (!properties)
11
+ return;
12
+ metadata.properties = Object.fromEntries(Object.entries(metadata.properties).filter(([key]) => properties.includes(key)));
13
+ };
5
14
  export class TrajFrameReader {
6
15
  format;
7
16
  global_numbers;
@@ -17,8 +26,7 @@ export class TrajFrameReader {
17
26
  }
18
27
  if (!(data instanceof ArrayBuffer))
19
28
  throw new Error(`ASE loader requires binary data`);
20
- const view = new DataView(data);
21
- return Number(view.getBigInt64(32, true));
29
+ return read_ase_header(new DataView(data)).n_items;
22
30
  }
23
31
  async build_frame_index(data, sample_rate, on_progress) {
24
32
  const total_frames = await this.get_total_frames(data);
@@ -29,35 +37,25 @@ export class TrajFrameReader {
29
37
  const encoder = new TextEncoder();
30
38
  const newline_sequence = data_str.includes(`\r\n`) ? `\r\n` : `\n`;
31
39
  const newline_byte_len = encoder.encode(newline_sequence).length;
32
- let [current_frame, line_idx, byte_offset] = [0, 0, 0];
33
- while (line_idx < lines.length && current_frame < total_frames) {
34
- if (!lines[line_idx]?.trim()) {
35
- byte_offset += encoder.encode(lines[line_idx]).length + newline_byte_len;
36
- line_idx++;
37
- continue;
38
- }
39
- const num_atoms = parseInt(lines[line_idx].trim(), 10);
40
- if (isNaN(num_atoms) || num_atoms <= 0 || line_idx + num_atoms + 1 >= lines.length) {
41
- byte_offset += encoder.encode(lines[line_idx]).length + newline_byte_len;
42
- line_idx++;
43
- continue;
44
- }
40
+ const line_bytes = (idx) => encoder.encode(lines[idx]).length + newline_byte_len;
41
+ // cursor = next line whose bytes haven't been added to byte_offset yet
42
+ let [current_frame, cursor, byte_offset] = [0, 0, 0];
43
+ for (const { start, num_atoms } of iter_xyz_frames(lines)) {
44
+ if (current_frame >= total_frames)
45
+ break;
46
+ // Accumulate bytes of blank/invalid lines skipped before this frame
47
+ for (; cursor < start; cursor++)
48
+ byte_offset += line_bytes(cursor);
49
+ let frame_size = 0;
50
+ for (; cursor < start + num_atoms + 2; cursor++)
51
+ frame_size += line_bytes(cursor);
45
52
  if (current_frame % sample_rate === 0) {
46
53
  frame_index.push({
47
54
  frame_number: current_frame,
48
55
  byte_offset,
49
- estimated_size: 0,
56
+ estimated_size: frame_size,
50
57
  });
51
58
  }
52
- const frame_start = line_idx;
53
- line_idx += 2 + num_atoms;
54
- let frame_size = 0;
55
- for (let idx = frame_start; idx < line_idx; idx++) {
56
- frame_size += encoder.encode(lines[idx]).length + newline_byte_len;
57
- }
58
- if (current_frame % sample_rate === 0) {
59
- frame_index[frame_index.length - 1].estimated_size = frame_size;
60
- }
61
59
  byte_offset += frame_size;
62
60
  current_frame++;
63
61
  if (on_progress && current_frame % 1000 === 0) {
@@ -71,7 +69,7 @@ export class TrajFrameReader {
71
69
  }
72
70
  else {
73
71
  const view = new DataView(data);
74
- const offsets_pos = Number(view.getBigInt64(40, true));
72
+ const { offsets_pos } = read_ase_header(view);
75
73
  for (let idx = 0; idx < total_frames; idx += sample_rate) {
76
74
  const frame_offset = Number(view.getBigInt64(offsets_pos + idx * 8, true));
77
75
  frame_index.push({
@@ -109,34 +107,28 @@ export class TrajFrameReader {
109
107
  const total_frames = await this.get_total_frames(data);
110
108
  if (this.format === `xyz`) {
111
109
  const lines = data.trim().split(/\r?\n/);
112
- let [current_frame, line_idx] = [0, 0];
113
- while (line_idx < lines.length && current_frame < total_frames) {
114
- if (!lines[line_idx]?.trim()) {
115
- line_idx++;
116
- continue;
117
- }
118
- const num_atoms = parseInt(lines[line_idx].trim(), 10);
119
- if (isNaN(num_atoms) || num_atoms <= 0 || line_idx + num_atoms + 1 >= lines.length) {
120
- line_idx++;
121
- continue;
122
- }
110
+ let current_frame = 0;
111
+ for (const { start, comment } of iter_xyz_frames(lines)) {
112
+ if (current_frame >= total_frames)
113
+ break;
123
114
  if (current_frame % sample_rate === 0) {
124
- const comment = lines[line_idx + 1] || ``;
125
115
  let frame_metadata = null;
126
116
  try {
127
- frame_metadata = this.parse_xyz_metadata(comment, current_frame);
117
+ const { step, properties: props } = parse_xyz_comment_metadata(comment);
118
+ frame_metadata = {
119
+ frame_number: current_frame,
120
+ step: step ?? current_frame,
121
+ properties: props,
122
+ };
128
123
  }
129
124
  catch (error) {
130
- console.warn(`Failed to parse XYZ metadata for frame ${current_frame} at line ${line_idx + 1}:`, error);
131
- }
132
- if (frame_metadata && properties) {
133
- const filtered = Object.fromEntries(Object.entries(frame_metadata.properties).filter(([key]) => properties.includes(key)));
134
- frame_metadata.properties = filtered;
125
+ console.warn(`Failed to parse XYZ metadata for frame ${current_frame} at line ${start + 1}:`, error);
135
126
  }
136
- if (frame_metadata)
127
+ if (frame_metadata) {
128
+ filter_properties(frame_metadata, properties);
137
129
  metadata_list.push(frame_metadata);
130
+ }
138
131
  }
139
- line_idx += 2 + num_atoms;
140
132
  current_frame++;
141
133
  if (on_progress && current_frame % 5000 === 0) {
142
134
  on_progress({
@@ -149,8 +141,7 @@ export class TrajFrameReader {
149
141
  }
150
142
  else if (this.format === `ase`) {
151
143
  const view = new DataView(data);
152
- const n_items = Number(view.getBigInt64(32, true));
153
- const offsets_pos = Number(view.getBigInt64(40, true));
144
+ const { n_items, offsets_pos } = read_ase_header(view);
154
145
  for (let idx = 0; idx < n_items; idx += sample_rate) {
155
146
  try {
156
147
  const frame_offset = Number(view.getBigInt64(offsets_pos + idx * 8, true));
@@ -161,10 +152,7 @@ export class TrajFrameReader {
161
152
  }
162
153
  const frame_data = JSON.parse(new TextDecoder().decode(new Uint8Array(data, frame_offset + 8, json_length)));
163
154
  const frame_metadata = this.parse_ase_metadata(frame_data, idx);
164
- if (properties) {
165
- const filtered = Object.fromEntries(Object.entries(frame_metadata.properties).filter(([key]) => properties.includes(key)));
166
- frame_metadata.properties = filtered;
167
- }
155
+ filter_properties(frame_metadata, properties);
168
156
  metadata_list.push(frame_metadata);
169
157
  if (on_progress && idx % 5000 === 0) {
170
158
  on_progress({
@@ -183,140 +171,53 @@ export class TrajFrameReader {
183
171
  }
184
172
  load_xyz_frame(data, frame_number) {
185
173
  const lines = data.trim().split(/\r?\n/);
186
- let [current_frame, line_idx] = [0, 0];
187
- while (line_idx < lines.length && current_frame < frame_number) {
188
- if (!lines[line_idx]?.trim()) {
189
- line_idx++;
190
- continue;
191
- }
192
- const num_atoms = parseInt(lines[line_idx].trim(), 10);
193
- if (isNaN(num_atoms) || num_atoms <= 0) {
194
- line_idx++;
195
- continue;
196
- }
197
- line_idx += 2 + num_atoms;
198
- current_frame++;
199
- }
200
- if (line_idx >= lines.length)
201
- return null;
202
- const num_atoms = parseInt(lines[line_idx].trim(), 10);
203
- if (isNaN(num_atoms) || line_idx + num_atoms + 1 >= lines.length)
204
- return null;
205
- const comment = lines[line_idx + 1] || ``;
206
- const positions = [];
207
- const elements = [];
208
- for (let idx = 0; idx < num_atoms; idx++) {
209
- const parts = lines[line_idx + 2 + idx]?.trim().split(/\s+/);
210
- if (parts?.length >= 4) {
211
- const x_coord = parseFloat(parts[1]);
212
- const y_coord = parseFloat(parts[2]);
213
- const z_coord = parseFloat(parts[3]);
214
- if (!Number.isFinite(x_coord) ||
215
- !Number.isFinite(y_coord) ||
216
- !Number.isFinite(z_coord)) {
217
- console.warn(`Skipping XYZ atom with invalid coordinates in indexed frame ${frame_number} at line ${line_idx + 2 + idx}`);
218
- continue;
219
- }
220
- const raw_symbol = parts[0];
221
- const element_symbol = coerce_element_symbol(raw_symbol);
222
- if (!element_symbol) {
223
- console.warn(`Skipping XYZ atom with unknown element symbol "${raw_symbol}" in indexed frame ${frame_number}`);
224
- continue;
225
- }
226
- elements.push(element_symbol);
227
- positions.push([x_coord, y_coord, z_coord]);
228
- }
174
+ let current_frame = 0;
175
+ for (const frame of iter_xyz_frames(lines)) {
176
+ if (current_frame++ < frame_number)
177
+ continue; // skip frames before the target
178
+ return build_xyz_frame(lines, frame, {
179
+ frame_label: `indexed frame ${frame_number}`,
180
+ default_step: frame_number,
181
+ });
229
182
  }
230
- const metadata = this.parse_xyz_metadata(comment, frame_number);
231
- return create_trajectory_frame(positions, elements, undefined, undefined, metadata.step, metadata.properties);
183
+ return null;
232
184
  }
233
185
  load_ase_frame(data, frame_number) {
234
186
  try {
235
187
  const view = new DataView(data);
236
- const n_items = Number(view.getBigInt64(32, true));
237
- const offsets_pos = Number(view.getBigInt64(40, true));
188
+ const { n_items, offsets_pos } = read_ase_header(view);
238
189
  if (frame_number >= n_items)
239
190
  return null;
240
191
  const frame_offset = Number(view.getBigInt64(offsets_pos + frame_number * 8, true));
241
- const json_length = Number(view.getBigInt64(frame_offset, true));
242
- const frame_data = JSON.parse(new TextDecoder().decode(new Uint8Array(data, frame_offset + 8, json_length)));
243
- const positions_ref = frame_data[`positions.`] ?? frame_data.positions;
244
- const positions = positions_ref?.ndarray
245
- ? read_ndarray_from_view(view, positions_ref)
246
- : positions_ref;
247
- const numbers_ref = frame_data[`numbers.`] ?? frame_data.numbers ?? this.global_numbers;
248
- const numbers = numbers_ref?.ndarray
249
- ? read_ndarray_from_view(view, numbers_ref).flat()
250
- : numbers_ref;
251
- if (numbers)
252
- this.global_numbers = numbers;
253
- if (!numbers || !positions)
254
- throw new Error(`Missing atomic numbers or positions`);
255
- const cell = frame_data.cell ? validate_3x3_matrix(frame_data.cell) : undefined;
256
- const metadata = {
257
- step: frame_number,
258
- ...frame_data.calculator,
259
- ...frame_data.info,
260
- };
261
- if (cell) {
262
- try {
263
- metadata.volume = Math.abs(math.det_3x3(cell));
264
- }
265
- catch (error) {
266
- console.warn(`Failed to calculate volume for frame ${frame_number}:`, error);
267
- }
268
- }
269
- return create_trajectory_frame(positions, convert_atomic_numbers(numbers), cell, frame_data.pbc ?? [true, true, true], frame_number, metadata);
192
+ const { frame, numbers } = decode_ase_frame(view, data, frame_offset, frame_number, this.global_numbers);
193
+ this.global_numbers = numbers;
194
+ return frame;
270
195
  }
271
196
  catch (error) {
272
197
  console.warn(`Failed to load ASE frame ${frame_number}:`, error);
273
198
  return null;
274
199
  }
275
200
  }
276
- parse_xyz_metadata(comment, frame_number) {
277
- const properties = {};
278
- const patterns = {
279
- energy: /(?:energy|E|etot)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
280
- volume: /(?:volume|vol|V)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
281
- pressure: /(?:pressure|press|P)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
282
- force_max: /(?:max_force|fmax)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
283
- };
284
- Object.entries(patterns).forEach(([key, pattern]) => {
285
- const match = pattern.exec(comment);
286
- if (match)
287
- properties[key] = parseFloat(match[1]);
288
- });
289
- const step_match = /(?:step|frame)\s*[=:]?\s*(\d+)/i.exec(comment);
290
- const step = step_match ? parseInt(step_match[1]) : frame_number;
291
- return { frame_number, step, properties };
292
- }
293
201
  parse_ase_metadata(frame_data, frame_number) {
294
202
  const properties = {};
295
203
  const step = frame_number;
296
204
  if (frame_data.calculator && typeof frame_data.calculator === `object`) {
297
- const calculator = frame_data.calculator;
298
- const calc_properties = [`energy`, `potential_energy`, `kinetic_energy`, `total_energy`];
299
- for (const prop of calc_properties) {
300
- if (prop in calculator && typeof calculator[prop] === `number`) {
301
- properties[prop] = calculator[prop];
302
- }
303
- }
205
+ copy_numeric_fields(properties, frame_data.calculator, [
206
+ `energy`,
207
+ `potential_energy`,
208
+ `kinetic_energy`,
209
+ `total_energy`,
210
+ ]);
304
211
  }
305
212
  if (frame_data.info && typeof frame_data.info === `object`) {
306
- const info = frame_data.info;
307
- const info_properties = [
213
+ copy_numeric_fields(properties, frame_data.info, [
308
214
  `force_max`,
309
215
  `force_norm`,
310
216
  `stress_max`,
311
217
  `stress_frobenius`,
312
218
  `pressure`,
313
219
  `temperature`,
314
- ];
315
- for (const prop of info_properties) {
316
- if (prop in info && typeof info[prop] === `number`) {
317
- properties[prop] = info[prop];
318
- }
319
- }
220
+ ]);
320
221
  }
321
222
  if (frame_data.cell && Array.isArray(frame_data.cell)) {
322
223
  try {
@@ -3,8 +3,6 @@ import * as math from '../math';
3
3
  import type { AnyStructure } from '../structure/index';
4
4
  import type { Pbc } from '../structure/pbc';
5
5
  import type { TrajectoryFrame } from './index';
6
- export declare const is_valid_element_symbol: (symbol: string) => symbol is ElementSymbol;
7
- export declare const coerce_element_symbol: (symbol: string) => ElementSymbol | undefined;
8
6
  export declare function validate_3x3_matrix(data: unknown): math.Matrix3x3;
9
7
  export declare const convert_atomic_numbers: (numbers: number[]) => ElementSymbol[];
10
8
  export declare const create_structure: (positions: number[][], elements: ElementSymbol[], lattice_matrix?: math.Matrix3x3, pbc?: Pbc, force_data?: number[][]) => AnyStructure;
@@ -12,4 +10,14 @@ export declare const create_trajectory_frame: (positions: number[][], elements:
12
10
  export declare const read_ndarray_from_view: (view: DataView, ref: {
13
11
  ndarray: unknown[];
14
12
  }) => number[][];
13
+ export declare const copy_numeric_fields: (target: Record<string, number>, source: Record<string, unknown>, fields: readonly string[]) => void;
14
+ export declare function calc_force_stats(forces: number[][]): {
15
+ force_max: number;
16
+ force_norm: number;
17
+ } | null;
18
+ export declare function iter_xyz_frames(lines: string[]): Generator<{
19
+ start: number;
20
+ num_atoms: number;
21
+ comment: string;
22
+ }>;
15
23
  export declare function count_xyz_frames(data: string): number;