matterviz 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (527) hide show
  1. package/dist/EmptyState.svelte +10 -4
  2. package/dist/FilePicker.svelte +12 -14
  3. package/dist/Icon.svelte +7 -4
  4. package/dist/MillerIndexInput.svelte +2 -2
  5. package/dist/app.css +53 -0
  6. package/dist/brillouin/BrillouinZone.svelte +132 -219
  7. package/dist/brillouin/BrillouinZone.svelte.d.ts +9 -20
  8. package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
  9. package/dist/brillouin/BrillouinZoneExportPane.svelte +47 -96
  10. package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
  11. package/dist/brillouin/BrillouinZoneInfoPane.svelte +15 -42
  12. package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
  13. package/dist/brillouin/BrillouinZoneScene.svelte +63 -230
  14. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +3 -23
  15. package/dist/brillouin/ReciprocalVectors.svelte +39 -0
  16. package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
  17. package/dist/brillouin/compute.d.ts +2 -0
  18. package/dist/brillouin/compute.js +80 -77
  19. package/dist/brillouin/geometry.d.ts +8 -0
  20. package/dist/brillouin/geometry.js +57 -0
  21. package/dist/brillouin/index.d.ts +2 -0
  22. package/dist/brillouin/index.js +2 -0
  23. package/dist/brillouin/types.d.ts +2 -2
  24. package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
  25. package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
  26. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +143 -246
  27. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
  28. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +652 -976
  29. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
  30. package/dist/chempot-diagram/async-compute.svelte.js +1 -1
  31. package/dist/chempot-diagram/color.d.ts +3 -6
  32. package/dist/chempot-diagram/color.js +5 -5
  33. package/dist/chempot-diagram/compute.d.ts +3 -3
  34. package/dist/chempot-diagram/compute.js +3 -1
  35. package/dist/chempot-diagram/controls-state.svelte.d.ts +10 -0
  36. package/dist/chempot-diagram/controls-state.svelte.js +42 -0
  37. package/dist/chempot-diagram/export.d.ts +47 -0
  38. package/dist/chempot-diagram/export.js +133 -0
  39. package/dist/chempot-diagram/index.d.ts +1 -0
  40. package/dist/chempot-diagram/index.js +1 -0
  41. package/dist/chempot-diagram/pointer.d.ts +0 -10
  42. package/dist/chempot-diagram/pointer.js +4 -4
  43. package/dist/chempot-diagram/types.d.ts +3 -3
  44. package/dist/colors/index.d.ts +0 -4
  45. package/dist/colors/index.js +21 -22
  46. package/dist/composition/BarChart.svelte +37 -31
  47. package/dist/composition/BubbleChart.svelte +17 -17
  48. package/dist/composition/Composition.svelte +7 -11
  49. package/dist/composition/Formula.svelte +18 -25
  50. package/dist/composition/FormulaFilter.svelte +96 -98
  51. package/dist/composition/PieChart.svelte +60 -46
  52. package/dist/composition/chem-sys.js +3 -2
  53. package/dist/composition/format.js +4 -3
  54. package/dist/composition/index.d.ts +2 -0
  55. package/dist/composition/index.js +14 -0
  56. package/dist/composition/parse.d.ts +2 -3
  57. package/dist/composition/parse.js +27 -28
  58. package/dist/constants.js +11 -9
  59. package/dist/controls.d.ts +1 -0
  60. package/dist/controls.js +0 -1
  61. package/dist/convex-hull/ConvexHull.svelte +20 -25
  62. package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
  63. package/dist/convex-hull/ConvexHull2D.svelte +176 -256
  64. package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
  65. package/dist/convex-hull/ConvexHull3D.svelte +269 -804
  66. package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
  67. package/dist/convex-hull/ConvexHull4D.svelte +236 -755
  68. package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
  69. package/dist/convex-hull/ConvexHullChrome.svelte +264 -0
  70. package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
  71. package/dist/convex-hull/ConvexHullControls.svelte +128 -49
  72. package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
  73. package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
  74. package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
  75. package/dist/convex-hull/ConvexHullStats.svelte +210 -351
  76. package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
  77. package/dist/convex-hull/ConvexHullTooltip.svelte +16 -14
  78. package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
  79. package/dist/convex-hull/GasPressureControls.svelte +5 -12
  80. package/dist/convex-hull/StructurePopup.svelte +17 -21
  81. package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
  82. package/dist/convex-hull/TemperatureSlider.svelte +4 -10
  83. package/dist/convex-hull/barycentric-coords.d.ts +2 -4
  84. package/dist/convex-hull/barycentric-coords.js +6 -33
  85. package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
  86. package/dist/convex-hull/canvas-interactions.svelte.js +279 -0
  87. package/dist/convex-hull/helpers.d.ts +47 -17
  88. package/dist/convex-hull/helpers.js +186 -101
  89. package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
  90. package/dist/convex-hull/hull-state.svelte.js +124 -0
  91. package/dist/convex-hull/index.d.ts +9 -7
  92. package/dist/convex-hull/index.js +7 -2
  93. package/dist/convex-hull/thermodynamics.js +109 -937
  94. package/dist/convex-hull/types.d.ts +12 -4
  95. package/dist/convex-hull/types.js +12 -0
  96. package/dist/coordination/CoordinationBarPlot.svelte +41 -43
  97. package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
  98. package/dist/coordination/calc-coordination.d.ts +1 -1
  99. package/dist/coordination/calc-coordination.js +28 -25
  100. package/dist/element/BohrAtom.svelte +6 -8
  101. package/dist/element/ElementHeading.svelte +4 -1
  102. package/dist/element/ElementPhoto.svelte +11 -9
  103. package/dist/element/ElementStats.svelte +12 -10
  104. package/dist/element/ElementTile.svelte +24 -29
  105. package/dist/element/ElementTile.svelte.d.ts +1 -1
  106. package/dist/element/Nucleus.svelte +4 -2
  107. package/dist/element/data.d.ts +1 -2
  108. package/dist/element/helpers.d.ts +4 -0
  109. package/dist/element/helpers.js +18 -0
  110. package/dist/element/index.d.ts +1 -0
  111. package/dist/element/index.js +3 -0
  112. package/dist/feedback/DragOverlay.svelte +5 -3
  113. package/dist/feedback/DragOverlay.svelte.d.ts +2 -1
  114. package/dist/feedback/StatusMessage.svelte +20 -7
  115. package/dist/fermi-surface/FermiSlice.svelte +21 -18
  116. package/dist/fermi-surface/FermiSurface.svelte +78 -165
  117. package/dist/fermi-surface/FermiSurface.svelte.d.ts +9 -20
  118. package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
  119. package/dist/fermi-surface/FermiSurfaceScene.svelte +93 -272
  120. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
  121. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
  122. package/dist/fermi-surface/compute.js +14 -13
  123. package/dist/fermi-surface/export.js +4 -15
  124. package/dist/fermi-surface/index.d.ts +0 -1
  125. package/dist/fermi-surface/index.js +0 -1
  126. package/dist/fermi-surface/parse.d.ts +1 -1
  127. package/dist/fermi-surface/parse.js +84 -97
  128. package/dist/fermi-surface/types.d.ts +2 -2
  129. package/dist/heatmap-matrix/HeatmapMatrix.svelte +161 -185
  130. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +6 -5
  131. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +12 -9
  132. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
  133. package/dist/heatmap-matrix/index.d.ts +8 -2
  134. package/dist/icons.d.ts +4 -0
  135. package/dist/icons.js +4 -0
  136. package/dist/index.d.ts +1 -0
  137. package/dist/index.js +1 -0
  138. package/dist/io/ExportPane.svelte +170 -0
  139. package/dist/io/ExportPane.svelte.d.ts +17 -0
  140. package/dist/io/decompress.d.ts +2 -1
  141. package/dist/io/decompress.js +22 -36
  142. package/dist/io/export.d.ts +9 -1
  143. package/dist/io/export.js +37 -29
  144. package/dist/io/fetch.d.ts +2 -4
  145. package/dist/io/fetch.js +0 -11
  146. package/dist/io/file-drop.d.ts +7 -0
  147. package/dist/io/file-drop.js +13 -0
  148. package/dist/io/index.d.ts +1 -0
  149. package/dist/io/index.js +3 -0
  150. package/dist/io/is-binary.d.ts +9 -0
  151. package/dist/io/is-binary.js +45 -1
  152. package/dist/io/types.d.ts +13 -0
  153. package/dist/io/url-drop.js +13 -25
  154. package/dist/isosurface/Isosurface.svelte +17 -23
  155. package/dist/isosurface/IsosurfaceControls.svelte +37 -42
  156. package/dist/isosurface/parse-vaspwave.d.ts +3 -0
  157. package/dist/isosurface/parse-vaspwave.js +138 -0
  158. package/dist/isosurface/parse.js +50 -48
  159. package/dist/labels.d.ts +6 -2
  160. package/dist/labels.js +44 -14
  161. package/dist/layout/FullscreenButton.svelte +34 -0
  162. package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
  163. package/dist/layout/FullscreenToggle.svelte +12 -12
  164. package/dist/layout/InfoCard.svelte +7 -18
  165. package/dist/layout/InfoTag.svelte +1 -3
  166. package/dist/layout/NumberRangeInput.svelte +46 -0
  167. package/dist/layout/NumberRangeInput.svelte.d.ts +12 -0
  168. package/dist/layout/PropertyFilter.svelte +2 -6
  169. package/dist/layout/SettingsSection.svelte +21 -17
  170. package/dist/layout/SubpageGrid.svelte +3 -1
  171. package/dist/layout/ViewerChrome.svelte +115 -0
  172. package/dist/layout/ViewerChrome.svelte.d.ts +18 -0
  173. package/dist/layout/fullscreen.d.ts +4 -0
  174. package/dist/layout/fullscreen.js +3 -5
  175. package/dist/layout/fullscreen.svelte.d.ts +8 -0
  176. package/dist/layout/fullscreen.svelte.js +36 -0
  177. package/dist/layout/index.d.ts +4 -0
  178. package/dist/layout/index.js +4 -0
  179. package/dist/layout/json-tree/JsonNode.svelte +8 -11
  180. package/dist/layout/json-tree/JsonTree.svelte +53 -77
  181. package/dist/layout/json-tree/JsonValue.svelte +7 -15
  182. package/dist/layout/json-tree/utils.js +14 -23
  183. package/dist/math.d.ts +9 -3
  184. package/dist/math.js +37 -21
  185. package/dist/overlays/ContextMenu.svelte +4 -2
  186. package/dist/overlays/CopyButton.svelte +11 -5
  187. package/dist/overlays/DragControlTab.svelte +6 -1
  188. package/dist/overlays/DraggablePane.svelte +81 -26
  189. package/dist/overlays/DraggablePane.svelte.d.ts +1 -0
  190. package/dist/overlays/GlassChip.svelte +30 -0
  191. package/dist/overlays/GlassChip.svelte.d.ts +8 -0
  192. package/dist/overlays/InfoPaneCards.svelte +11 -23
  193. package/dist/overlays/index.d.ts +11 -0
  194. package/dist/overlays/index.js +26 -0
  195. package/dist/overlays/portal.d.ts +2 -0
  196. package/dist/overlays/portal.js +14 -0
  197. package/dist/periodic-table/PeriodicTable.svelte +115 -146
  198. package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
  199. package/dist/periodic-table/PeriodicTableControls.svelte +11 -63
  200. package/dist/periodic-table/TableInset.svelte +9 -4
  201. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +50 -71
  202. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
  203. package/dist/phase-diagram/PhaseDiagramControls.svelte +73 -96
  204. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
  205. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +4 -2
  206. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
  207. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +49 -134
  208. package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
  209. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
  210. package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
  211. package/dist/phase-diagram/build-diagram.js +3 -3
  212. package/dist/phase-diagram/colors.js +1 -1
  213. package/dist/phase-diagram/diagram-input.d.ts +1 -2
  214. package/dist/phase-diagram/parse.d.ts +2 -1
  215. package/dist/phase-diagram/parse.js +15 -15
  216. package/dist/phase-diagram/svg-to-diagram.js +21 -15
  217. package/dist/phase-diagram/utils.js +2 -3
  218. package/dist/plot/bar/BarPlot.svelte +494 -692
  219. package/dist/plot/bar/BarPlot.svelte.d.ts +9 -15
  220. package/dist/plot/bar/BarPlotControls.svelte +1 -3
  221. package/dist/plot/bar/BarPlotControls.svelte.d.ts +5 -7
  222. package/dist/plot/bar/SpacegroupBarPlot.svelte +31 -37
  223. package/dist/plot/bar/data.d.ts +5 -4
  224. package/dist/plot/bar/data.js +2 -1
  225. package/dist/plot/box/BoxPlot.svelte +361 -439
  226. package/dist/plot/box/BoxPlot.svelte.d.ts +6 -3
  227. package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
  228. package/dist/plot/box/Violin.svelte.d.ts +2 -1
  229. package/dist/plot/box/box-plot.d.ts +3 -2
  230. package/dist/plot/box/box-plot.js +6 -3
  231. package/dist/plot/box/kde.d.ts +2 -1
  232. package/dist/plot/box/kde.js +4 -4
  233. package/dist/plot/core/auto-place.d.ts +1 -1
  234. package/dist/plot/core/auto-place.js +5 -2
  235. package/dist/plot/core/axis-utils.d.ts +12 -7
  236. package/dist/plot/core/axis-utils.js +48 -48
  237. package/dist/plot/core/components/AxisLabel.svelte +82 -20
  238. package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
  239. package/dist/plot/core/components/ColorBar.svelte +106 -111
  240. package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
  241. package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
  242. package/dist/plot/core/components/FillArea.svelte +10 -17
  243. package/dist/plot/core/components/HierarchyControls.svelte +249 -0
  244. package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
  245. package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
  246. package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
  247. package/dist/plot/core/components/Line.svelte +21 -11
  248. package/dist/plot/core/components/Line.svelte.d.ts +5 -2
  249. package/dist/plot/core/components/PlotAxis.svelte +42 -18
  250. package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
  251. package/dist/plot/core/components/PlotControls.svelte +65 -41
  252. package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
  253. package/dist/plot/core/components/PlotLegend.svelte +31 -35
  254. package/dist/plot/core/components/PlotMarginals.svelte +616 -0
  255. package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
  256. package/dist/plot/core/components/PlotTooltip.svelte +1 -1
  257. package/dist/plot/core/components/PortalSelect.svelte +4 -8
  258. package/dist/plot/core/components/ReferenceLine.svelte +27 -24
  259. package/dist/plot/core/components/ReferenceLine3D.svelte +56 -59
  260. package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
  261. package/dist/plot/core/components/ReferencePlane.svelte +9 -10
  262. package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
  263. package/dist/plot/core/components/ZeroLines.svelte +4 -8
  264. package/dist/plot/core/components/ZoomRect.svelte +1 -2
  265. package/dist/plot/core/components/index.d.ts +1 -0
  266. package/dist/plot/core/components/index.js +1 -0
  267. package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
  268. package/dist/plot/core/data-cleaning-signal.js +467 -0
  269. package/dist/plot/core/data-cleaning.d.ts +2 -42
  270. package/dist/plot/core/data-cleaning.js +29 -476
  271. package/dist/plot/core/data-transform.js +9 -5
  272. package/dist/plot/core/fill-utils.d.ts +7 -4
  273. package/dist/plot/core/fill-utils.js +34 -9
  274. package/dist/plot/core/index.d.ts +1 -0
  275. package/dist/plot/core/index.js +1 -0
  276. package/dist/plot/core/interactions.d.ts +5 -1
  277. package/dist/plot/core/interactions.js +14 -2
  278. package/dist/plot/core/layout.d.ts +3 -1
  279. package/dist/plot/core/layout.js +22 -13
  280. package/dist/plot/core/marginals.d.ts +170 -0
  281. package/dist/plot/core/marginals.js +436 -0
  282. package/dist/plot/core/pan-zoom.svelte.d.ts +35 -0
  283. package/dist/plot/core/pan-zoom.svelte.js +221 -0
  284. package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
  285. package/dist/plot/core/placed-tween.svelte.js +68 -0
  286. package/dist/plot/core/reference-line.d.ts +10 -10
  287. package/dist/plot/core/reference-line.js +7 -7
  288. package/dist/plot/core/scales.d.ts +40 -25
  289. package/dist/plot/core/scales.js +49 -21
  290. package/dist/plot/core/svg.d.ts +2 -1
  291. package/dist/plot/core/types/fills.d.ts +101 -0
  292. package/dist/plot/core/types/fills.js +15 -0
  293. package/dist/plot/core/types/plot-3d.d.ts +87 -0
  294. package/dist/plot/core/types/plot-3d.js +4 -0
  295. package/dist/plot/core/types/reference-lines.d.ts +140 -0
  296. package/dist/plot/core/types/reference-lines.js +9 -0
  297. package/dist/plot/core/types.d.ts +47 -331
  298. package/dist/plot/core/types.js +23 -20
  299. package/dist/plot/core/utils/hierarchy-chart.d.ts +51 -0
  300. package/dist/plot/core/utils/hierarchy-chart.js +179 -0
  301. package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
  302. package/dist/plot/core/utils/hierarchy-labels.js +99 -0
  303. package/dist/plot/core/utils/label-placement.d.ts +1 -1
  304. package/dist/plot/core/utils/label-placement.js +5 -5
  305. package/dist/plot/core/utils.d.ts +2 -1
  306. package/dist/plot/histogram/Histogram.svelte +373 -631
  307. package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
  308. package/dist/plot/histogram/HistogramControls.svelte +30 -28
  309. package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
  310. package/dist/plot/histogram/histogram.d.ts +31 -0
  311. package/dist/plot/histogram/histogram.js +70 -0
  312. package/dist/plot/histogram/index.d.ts +1 -0
  313. package/dist/plot/histogram/index.js +1 -0
  314. package/dist/plot/index.d.ts +1 -0
  315. package/dist/plot/index.js +1 -0
  316. package/dist/plot/sankey/Sankey.svelte +79 -73
  317. package/dist/plot/sankey/Sankey.svelte.d.ts +3 -3
  318. package/dist/plot/sankey/SankeyControls.svelte +22 -16
  319. package/dist/plot/sankey/sankey.js +3 -1
  320. package/dist/plot/scatter/BinnedScatterPlot.svelte +264 -112
  321. package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +11 -4
  322. package/dist/plot/scatter/ElementScatter.svelte +4 -1
  323. package/dist/plot/scatter/ScatterPlot.svelte +623 -821
  324. package/dist/plot/scatter/ScatterPlot.svelte.d.ts +9 -15
  325. package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
  326. package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
  327. package/dist/plot/scatter/ScatterPoint.svelte +16 -9
  328. package/dist/plot/scatter/binned-scatter-types.d.ts +6 -12
  329. package/dist/plot/scatter/binned-scatter-types.js +6 -1
  330. package/dist/plot/scatter/index.d.ts +1 -1
  331. package/dist/plot/scatter/scatter-data.d.ts +1 -1
  332. package/dist/plot/scatter/scatter-data.js +8 -7
  333. package/dist/plot/scatter-3d/ScatterPlot3D.svelte +40 -60
  334. package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
  335. package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +17 -15
  336. package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
  337. package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +232 -234
  338. package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
  339. package/dist/plot/scatter-3d/Surface3D.svelte +9 -17
  340. package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
  341. package/dist/plot/sunburst/Sunburst.svelte +256 -338
  342. package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
  343. package/dist/plot/sunburst/index.d.ts +1 -1
  344. package/dist/plot/sunburst/index.js +2 -1
  345. package/dist/plot/sunburst/render.d.ts +2 -2
  346. package/dist/plot/sunburst/render.js +47 -22
  347. package/dist/plot/sunburst/sunburst.d.ts +5 -1
  348. package/dist/plot/sunburst/sunburst.js +14 -4
  349. package/dist/plot/treemap/Treemap.svelte +907 -0
  350. package/dist/plot/treemap/Treemap.svelte.d.ts +84 -0
  351. package/dist/plot/treemap/index.d.ts +3 -0
  352. package/dist/plot/treemap/index.js +4 -0
  353. package/dist/plot/treemap/treemap.d.ts +26 -0
  354. package/dist/plot/treemap/treemap.js +99 -0
  355. package/dist/rdf/RdfPlot.svelte +22 -26
  356. package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
  357. package/dist/rdf/calc-rdf.js +4 -8
  358. package/dist/sanitize.js +14 -3
  359. package/dist/scene/SceneCamera.svelte +62 -0
  360. package/dist/scene/SceneCamera.svelte.d.ts +19 -0
  361. package/dist/scene/bind-renderer.svelte.d.ts +2 -0
  362. package/dist/scene/bind-renderer.svelte.js +22 -0
  363. package/dist/scene/index.d.ts +4 -0
  364. package/dist/scene/index.js +5 -0
  365. package/dist/scene/props.js +52 -0
  366. package/dist/scene/types.d.ts +26 -0
  367. package/dist/scene/types.js +1 -0
  368. package/dist/settings.d.ts +33 -11
  369. package/dist/settings.js +136 -51
  370. package/dist/spectral/Bands.svelte +231 -237
  371. package/dist/spectral/Bands.svelte.d.ts +3 -2
  372. package/dist/spectral/BandsAndDos.svelte +29 -29
  373. package/dist/spectral/BrillouinBandsDos.svelte +21 -29
  374. package/dist/spectral/Dos.svelte +75 -77
  375. package/dist/spectral/Dos.svelte.d.ts +2 -1
  376. package/dist/spectral/helpers.d.ts +9 -9
  377. package/dist/spectral/helpers.js +66 -70
  378. package/dist/state.svelte.d.ts +0 -7
  379. package/dist/state.svelte.js +5 -24
  380. package/dist/structure/Arrow.svelte +6 -21
  381. package/dist/structure/ArrowInstances.svelte +160 -0
  382. package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
  383. package/dist/structure/AtomLegend.svelte +115 -75
  384. package/dist/structure/AtomLegend.svelte.d.ts +1 -1
  385. package/dist/structure/Bond.svelte +31 -23
  386. package/dist/structure/CanvasTooltip.svelte +16 -3
  387. package/dist/structure/CellSelect.svelte +22 -29
  388. package/dist/structure/CellSelect.svelte.d.ts +2 -1
  389. package/dist/structure/Cylinder.svelte +24 -40
  390. package/dist/structure/InstancedAtoms.svelte +114 -0
  391. package/dist/structure/InstancedAtoms.svelte.d.ts +15 -0
  392. package/dist/structure/Lattice.svelte +85 -149
  393. package/dist/structure/SiteLabels.svelte +122 -0
  394. package/dist/structure/SiteLabels.svelte.d.ts +18 -0
  395. package/dist/structure/Structure.svelte +725 -735
  396. package/dist/structure/Structure.svelte.d.ts +8 -16
  397. package/dist/structure/StructureCarousel.svelte +630 -0
  398. package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
  399. package/dist/structure/StructureControls.svelte +298 -325
  400. package/dist/structure/StructureControls.svelte.d.ts +5 -3
  401. package/dist/structure/StructureExportPane.svelte +62 -168
  402. package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
  403. package/dist/structure/StructureInfoPane.svelte +77 -69
  404. package/dist/structure/StructureInfoPane.svelte.d.ts +6 -6
  405. package/dist/structure/StructureScene.svelte +758 -600
  406. package/dist/structure/StructureScene.svelte.d.ts +24 -20
  407. package/dist/structure/StructureViewport.svelte +386 -0
  408. package/dist/structure/StructureViewport.svelte.d.ts +63 -0
  409. package/dist/structure/atom-label-placement.d.ts +18 -0
  410. package/dist/structure/atom-label-placement.js +115 -0
  411. package/dist/structure/atom-properties.d.ts +3 -1
  412. package/dist/structure/atom-properties.js +115 -54
  413. package/dist/structure/bond-order-perception.js +2 -4
  414. package/dist/structure/bonding.d.ts +12 -2
  415. package/dist/structure/bonding.js +172 -73
  416. package/dist/structure/edit-history.d.ts +6 -0
  417. package/dist/structure/edit-history.js +27 -0
  418. package/dist/structure/export.d.ts +25 -4
  419. package/dist/structure/export.js +103 -153
  420. package/dist/structure/format-detect.d.ts +1 -0
  421. package/dist/structure/format-detect.js +22 -0
  422. package/dist/structure/geometry.d.ts +9 -0
  423. package/dist/structure/geometry.js +27 -0
  424. package/dist/structure/index.d.ts +18 -1
  425. package/dist/structure/index.js +15 -2
  426. package/dist/structure/measure.d.ts +1 -1
  427. package/dist/structure/measure.js +6 -12
  428. package/dist/structure/parse.d.ts +5 -3
  429. package/dist/structure/parse.js +551 -567
  430. package/dist/structure/partial-occupancy.d.ts +0 -1
  431. package/dist/structure/partial-occupancy.js +5 -3
  432. package/dist/structure/pbc.d.ts +1 -1
  433. package/dist/structure/pbc.js +204 -51
  434. package/dist/structure/polyhedra.d.ts +40 -0
  435. package/dist/structure/polyhedra.js +587 -0
  436. package/dist/structure/site.d.ts +4 -0
  437. package/dist/structure/site.js +1 -0
  438. package/dist/structure/supercell.d.ts +1 -2
  439. package/dist/structure/supercell.js +10 -15
  440. package/dist/structure/validation.js +5 -6
  441. package/dist/symmetry/SymmetryElementControls.svelte +69 -0
  442. package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
  443. package/dist/symmetry/SymmetryElements.svelte +350 -0
  444. package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
  445. package/dist/symmetry/SymmetryStats.svelte +142 -49
  446. package/dist/symmetry/WyckoffTable.svelte +58 -16
  447. package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
  448. package/dist/symmetry/cell-transform.js +8 -14
  449. package/dist/symmetry/index.d.ts +15 -4
  450. package/dist/symmetry/index.js +308 -81
  451. package/dist/symmetry/spacegroups.d.ts +5 -1
  452. package/dist/symmetry/spacegroups.js +18 -3
  453. package/dist/symmetry/symmetry-elements.d.ts +33 -0
  454. package/dist/symmetry/symmetry-elements.js +521 -0
  455. package/dist/symmetry/wyckoff-db.d.ts +9 -0
  456. package/dist/symmetry/wyckoff-db.js +87 -0
  457. package/dist/table/HeatmapTable.svelte +1104 -378
  458. package/dist/table/HeatmapTable.svelte.d.ts +12 -2
  459. package/dist/table/ToggleMenu.svelte +5 -12
  460. package/dist/table/index.d.ts +21 -6
  461. package/dist/table/index.js +34 -21
  462. package/dist/theme/ThemeControl.svelte +16 -8
  463. package/dist/theme/index.d.ts +1 -5
  464. package/dist/theme/index.js +4 -10
  465. package/dist/theme/themes.mjs +14 -7
  466. package/dist/tooltip/KCoords.svelte +4 -1
  467. package/dist/tooltip/TooltipContent.svelte +2 -5
  468. package/dist/trajectory/Trajectory.svelte +556 -352
  469. package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
  470. package/dist/trajectory/TrajectoryError.svelte +11 -8
  471. package/dist/trajectory/TrajectoryExportPane.svelte +28 -54
  472. package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
  473. package/dist/trajectory/TrajectoryInfoPane.svelte +88 -99
  474. package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
  475. package/dist/trajectory/constants.js +6 -2
  476. package/dist/trajectory/extract.js +73 -71
  477. package/dist/trajectory/format-detect.d.ts +0 -1
  478. package/dist/trajectory/format-detect.js +13 -17
  479. package/dist/trajectory/frame-reader.d.ts +2 -1
  480. package/dist/trajectory/frame-reader.js +74 -136
  481. package/dist/trajectory/helpers.d.ts +12 -2
  482. package/dist/trajectory/helpers.js +68 -37
  483. package/dist/trajectory/index.d.ts +1 -0
  484. package/dist/trajectory/index.js +3 -0
  485. package/dist/trajectory/parse/ase.d.ts +9 -1
  486. package/dist/trajectory/parse/ase.js +47 -32
  487. package/dist/trajectory/parse/diagnostics.d.ts +3 -0
  488. package/dist/trajectory/parse/diagnostics.js +14 -0
  489. package/dist/trajectory/parse/h5-utils.d.ts +13 -0
  490. package/dist/trajectory/parse/h5-utils.js +109 -0
  491. package/dist/trajectory/parse/hdf5.d.ts +1 -1
  492. package/dist/trajectory/parse/hdf5.js +116 -106
  493. package/dist/trajectory/parse/index.d.ts +3 -4
  494. package/dist/trajectory/parse/index.js +68 -119
  495. package/dist/trajectory/parse/lammps.d.ts +0 -2
  496. package/dist/trajectory/parse/lammps.js +14 -16
  497. package/dist/trajectory/parse/pymatgen.d.ts +2 -0
  498. package/dist/trajectory/parse/pymatgen.js +74 -0
  499. package/dist/trajectory/parse/vasp.js +13 -9
  500. package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
  501. package/dist/trajectory/parse/vaspout-electronic.js +207 -0
  502. package/dist/trajectory/parse/vaspout-h5.d.ts +5 -0
  503. package/dist/trajectory/parse/vaspout-h5.js +284 -0
  504. package/dist/trajectory/parse/xyz.d.ts +9 -21
  505. package/dist/trajectory/parse/xyz.js +38 -39
  506. package/dist/trajectory/plotting.d.ts +8 -10
  507. package/dist/trajectory/plotting.js +102 -127
  508. package/dist/utils.d.ts +4 -0
  509. package/dist/utils.js +8 -1
  510. package/dist/xrd/XrdPlot.svelte +56 -85
  511. package/dist/xrd/broadening.d.ts +2 -1
  512. package/dist/xrd/broadening.js +2 -1
  513. package/dist/xrd/calc-xrd.js +8 -15
  514. package/dist/xrd/index.d.ts +2 -2
  515. package/dist/xrd/parse.d.ts +0 -1
  516. package/dist/xrd/parse.js +56 -73
  517. package/package.json +77 -36
  518. package/dist/api/mp.d.ts +0 -6
  519. package/dist/api/mp.js +0 -22
  520. package/dist/element/data.json +0 -11864
  521. package/dist/fermi-surface/marching-cubes.d.ts +0 -2
  522. package/dist/fermi-surface/marching-cubes.js +0 -2
  523. package/dist/plot/core/hover-lock.svelte.d.ts +0 -14
  524. package/dist/plot/core/hover-lock.svelte.js +0 -45
  525. package/dist/plot/sunburst/SunburstControls.svelte +0 -200
  526. package/dist/structure/label-placement.d.ts +0 -14
  527. package/dist/structure/label-placement.js +0 -72
@@ -0,0 +1,84 @@
1
+ import type { D3InterpolateName } from '../../colors';
2
+ import type { Vec2 } from '../../math';
3
+ import type { BasePlotProps, LegendConfig, SunburstLabelText, SunburstSort, SunburstValueMode } from '..';
4
+ import { ColorBar } from '..';
5
+ import type { Rect, Sides } from '../core/layout';
6
+ import type { PositionedArc } from '../sunburst/sunburst';
7
+ import type { TreemapNode, TreemapNodeHandlerProps } from './treemap';
8
+ import type { ComponentProps, Snippet } from 'svelte';
9
+ import type { HTMLAttributes } from 'svelte/elements';
10
+ import { type TweenOptions } from 'svelte/motion';
11
+ declare function $$render<Metadata extends Record<string, unknown> = Record<string, unknown>>(): {
12
+ props: HTMLAttributes<HTMLDivElement> & Omit<BasePlotProps, "change"> & {
13
+ data?: TreemapNode<Metadata> | TreemapNode<Metadata>[];
14
+ value_mode?: SunburstValueMode;
15
+ sort?: SunburstSort;
16
+ level_lighten?: number;
17
+ min_fraction?: number;
18
+ other_label?: string;
19
+ max_depth?: number;
20
+ padding_inner?: number;
21
+ padding_top?: number;
22
+ padding_outer?: number;
23
+ show_labels?: boolean;
24
+ label_text?: SunburstLabelText;
25
+ zoom_on_click?: boolean;
26
+ zoom_root_id?: string | number | null;
27
+ show_breadcrumbs?: boolean;
28
+ color_values?: (rect: PositionedArc<Metadata>) => number | null;
29
+ color_scale?: D3InterpolateName;
30
+ color_range?: Vec2;
31
+ colorbar?: ComponentProps<typeof ColorBar> | null;
32
+ export_buttons?: boolean;
33
+ export_filename?: string;
34
+ tween?: Omit<TweenOptions<Rect[]>, `interpolate`>;
35
+ value_format?: string;
36
+ padding?: Sides;
37
+ legend?: LegendConfig | null;
38
+ show_legend?: boolean;
39
+ tooltip?: Snippet<[TreemapNodeHandlerProps<Metadata>]>;
40
+ cell_content?: Snippet<[{
41
+ arc: PositionedArc<Metadata>;
42
+ rect: Rect;
43
+ }]>;
44
+ change?: (data: TreemapNodeHandlerProps<Metadata> | null) => void;
45
+ on_node_click?: (data: TreemapNodeHandlerProps<Metadata> & {
46
+ event: MouseEvent | KeyboardEvent;
47
+ }) => void;
48
+ on_node_hover?: (data: (TreemapNodeHandlerProps<Metadata> & {
49
+ event: MouseEvent | FocusEvent;
50
+ }) | null) => void;
51
+ on_zoom?: (data: {
52
+ root: TreemapNodeHandlerProps<Metadata> | null;
53
+ }) => void;
54
+ header_controls?: Snippet<[{
55
+ height: number;
56
+ width: number;
57
+ fullscreen: boolean;
58
+ }]>;
59
+ controls_extra?: Snippet<[{
60
+ zoom_root_id: string | number | null;
61
+ }]>;
62
+ };
63
+ exports: {};
64
+ bindings: "show_controls" | "data" | "show_labels" | "fullscreen" | "hovered" | "controls_open" | "padding_inner" | "padding_top" | "padding_outer" | "value_mode" | "max_depth" | "min_fraction" | "label_text" | "zoom_on_click" | "show_breadcrumbs" | "zoom_root_id";
65
+ slots: {};
66
+ events: {};
67
+ };
68
+ declare class __sveltets_Render<Metadata extends Record<string, unknown> = Record<string, unknown>> {
69
+ props(): ReturnType<typeof $$render<Metadata>>['props'];
70
+ events(): ReturnType<typeof $$render<Metadata>>['events'];
71
+ slots(): ReturnType<typeof $$render<Metadata>>['slots'];
72
+ bindings(): "show_controls" | "data" | "show_labels" | "fullscreen" | "hovered" | "controls_open" | "padding_inner" | "padding_top" | "padding_outer" | "value_mode" | "max_depth" | "min_fraction" | "label_text" | "zoom_on_click" | "show_breadcrumbs" | "zoom_root_id";
73
+ exports(): {};
74
+ }
75
+ interface $$IsomorphicComponent {
76
+ new <Metadata extends Record<string, unknown> = Record<string, unknown>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Metadata>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Metadata>['props']>, ReturnType<__sveltets_Render<Metadata>['events']>, ReturnType<__sveltets_Render<Metadata>['slots']>> & {
77
+ $$bindings?: ReturnType<__sveltets_Render<Metadata>['bindings']>;
78
+ } & ReturnType<__sveltets_Render<Metadata>['exports']>;
79
+ <Metadata extends Record<string, unknown> = Record<string, unknown>>(internal: unknown, props: ReturnType<__sveltets_Render<Metadata>['props']> & {}): ReturnType<__sveltets_Render<Metadata>['exports']>;
80
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
81
+ }
82
+ declare const Treemap: $$IsomorphicComponent;
83
+ type Treemap<Metadata extends Record<string, unknown> = Record<string, unknown>> = InstanceType<typeof Treemap<Metadata>>;
84
+ export default Treemap;
@@ -0,0 +1,3 @@
1
+ export * from './treemap';
2
+ export { default as Treemap } from './Treemap.svelte';
3
+ export { default as TreemapControls } from '../core/components/HierarchyControls.svelte';
@@ -0,0 +1,4 @@
1
+ export * from './treemap';
2
+ export { default as Treemap } from './Treemap.svelte';
3
+ // Shared with Sunburst; pass chart="treemap"
4
+ export { default as TreemapControls } from '../core/components/HierarchyControls.svelte';
@@ -0,0 +1,26 @@
1
+ import type { Rect } from '../core/layout';
2
+ import type { PositionedArc, SunburstLayoutOptions, SunburstNode, SunburstNodeHandlerProps } from '../sunburst/sunburst';
3
+ export type TreemapNode<Metadata = Record<string, unknown>> = SunburstNode<Metadata>;
4
+ export type TreemapArc<Metadata = Record<string, unknown>> = PositionedArc<Metadata>;
5
+ export type TreemapNodeHandlerProps<Metadata = Record<string, unknown>> = SunburstNodeHandlerProps<Metadata>;
6
+ export type TreemapLayoutOptions = SunburstLayoutOptions;
7
+ export interface TilePadding {
8
+ padding_inner: number;
9
+ padding_top: number;
10
+ padding_outer: number;
11
+ }
12
+ export declare function tile_rects<Metadata>(arcs: readonly PositionedArc<Metadata>[], root_idx: number, size: {
13
+ width: number;
14
+ height: number;
15
+ }, pad: TilePadding): Rect[];
16
+ export declare function lerp_rects(prev: readonly Rect[], next: readonly Rect[], t: number): Rect[];
17
+ export interface TreemapLayoutResult<Metadata = Record<string, unknown>> {
18
+ arcs: TreemapArc<Metadata>[];
19
+ rects: Rect[];
20
+ root: TreemapArc<Metadata> | null;
21
+ max_depth: number;
22
+ }
23
+ export declare function compute_treemap_layout<Metadata = Record<string, unknown>>(data: TreemapNode<Metadata> | TreemapNode<Metadata>[], size: {
24
+ width: number;
25
+ height: number;
26
+ }, opts?: TreemapLayoutOptions & Partial<TilePadding>): TreemapLayoutResult<Metadata>;
@@ -0,0 +1,99 @@
1
+ // Layout helpers for Treemap charts. All tree semantics (value modes, sorting,
2
+ // 'Other' bucketing, color inheritance, stable ids, pre-order indexing) are
3
+ // delegated to compute_sunburst_layout — a treemap is the same hierarchy with
4
+ // squarified pixel rects instead of polar partition coordinates, so the two
5
+ // charts share data builders (sunburst_from_paths, chem_sys_sunburst_data, …)
6
+ // and value semantics (plotly branchvalues) by construction.
7
+ import { hierarchy, treemap, treemapSquarify } from 'd3-hierarchy';
8
+ import { compute_sunburst_layout } from '../sunburst/sunburst';
9
+ import { DEFAULTS } from '../../settings';
10
+ // Fresh object per call: returned rect arrays hand these to consumers, and a
11
+ // shared constant would let mutating one zero rect corrupt every other one
12
+ const zero_rect = () => ({ x: 0, y: 0, width: 0, height: 0 });
13
+ // Squarify the subtree under arcs[root_idx] into pixel rects filling `size`.
14
+ // Returns an array aligned with `arcs` by node_idx (nodes outside the subtree
15
+ // get zero rects). Separate from tree-semantics so zooming re-tiles the new
16
+ // root's subtree to the full viewport (plotly behavior) — unlike the sunburst's
17
+ // size-independent partition, squarified tiling depends on the target aspect
18
+ // ratio, so projecting one fixed layout through a zoom window would distort
19
+ // cells and scale up the fixed-px header strips.
20
+ export function tile_rects(arcs, root_idx, size, pad) {
21
+ const rects = arcs.map(zero_rect);
22
+ const root_arc = arcs[root_idx];
23
+ if (!root_arc || !(size.width > 0) || !(size.height > 0))
24
+ return rects;
25
+ // Rebuild the (already value-resolved, sorted and bucketed) subtree from the
26
+ // flat pre-order arcs: children of arc N are the top-level subtree ranges in
27
+ // (N, N.subtree_end].
28
+ const children_of = (arc) => {
29
+ const kids = [];
30
+ for (let idx = arc.node_idx + 1; idx <= arc.subtree_end; idx = arcs[idx].subtree_end + 1) {
31
+ kids.push(arcs[idx]);
32
+ }
33
+ return kids;
34
+ };
35
+ const root = hierarchy(root_arc, children_of);
36
+ // Values are assigned manually (the documented d3 way to bypass .sum()) so all
37
+ // three value modes carry over — with 'total', children summing to less than
38
+ // their parent leave unfilled space in the parent cell, matching plotly.
39
+ // Non-finite/negative values would make d3's tiling emit NaN/out-of-bounds
40
+ // rects; coerce them to zero-size instead of corrupting the whole chart.
41
+ root.each((node) => {
42
+ const { value } = node.data;
43
+ node.value = Number.isFinite(value) && value >= 0 ? value : 0;
44
+ });
45
+ const tiled = treemap()
46
+ .tile(treemapSquarify)
47
+ .size([size.width, size.height])
48
+ .paddingInner(pad.padding_inner)
49
+ // inset children within branch cells below the tiling root (the root fills
50
+ // the viewport and is labeled by breadcrumbs, not a frame + header) …
51
+ .paddingOuter((node) => (node.depth > 0 ? pad.padding_outer : 0))
52
+ // … with the top inset enlarged into the label header strip. paddingTop is
53
+ // applied after paddingOuter, overriding its top component.
54
+ .paddingTop((node) => node.depth > 0 && node.children ? Math.max(pad.padding_top, pad.padding_outer) : 0)(root);
55
+ // Clamp to the tiling area: with value_mode 'total', children exceeding their
56
+ // parent's value overflow the parent rect (d3 scales children by parent value;
57
+ // compute_sunburst_layout warns). Clamping keeps overflow inside the chart,
58
+ // mirroring the sunburst's clamp01 window projection.
59
+ const clamp_x = (val) => Math.min(Math.max(val, 0), size.width);
60
+ const clamp_y = (val) => Math.min(Math.max(val, 0), size.height);
61
+ tiled.each((node) => {
62
+ const x = clamp_x(node.x0);
63
+ const y = clamp_y(node.y0);
64
+ rects[node.data.node_idx] = {
65
+ x,
66
+ y,
67
+ width: Math.max(0, clamp_x(node.x1) - x),
68
+ height: Math.max(0, clamp_y(node.y1) - y),
69
+ };
70
+ });
71
+ return rects;
72
+ }
73
+ // Interpolate between two tilings (zoom animation). Rects are aligned by
74
+ // node_idx; frames allocate one array but reuse rect objects at t = 0/1.
75
+ export function lerp_rects(prev, next, t) {
76
+ if (t >= 1 || prev.length !== next.length)
77
+ return next;
78
+ if (t <= 0)
79
+ return prev;
80
+ return next.map((to, idx) => {
81
+ const from = prev[idx];
82
+ return {
83
+ x: from.x + (to.x - from.x) * t,
84
+ y: from.y + (to.y - from.y) * t,
85
+ width: from.width + (to.width - from.width) * t,
86
+ height: from.height + (to.height - from.height) * t,
87
+ };
88
+ });
89
+ }
90
+ // One-shot semantic layout + root tiling (tests and non-zooming callers; the
91
+ // component calls compute_sunburst_layout and tile_rects separately so zoom
92
+ // re-tiles without recomputing tree semantics).
93
+ export function compute_treemap_layout(data, size, opts = {}) {
94
+ // padding fallbacks derive from DEFAULTS.treemap to prevent drift with the component
95
+ const { padding_inner = DEFAULTS.treemap.padding_inner, padding_top = DEFAULTS.treemap.padding_top, padding_outer = DEFAULTS.treemap.padding_outer, ...tree_opts } = opts;
96
+ const { arcs, root, max_depth } = compute_sunburst_layout(data, tree_opts);
97
+ const rects = tile_rects(arcs, 0, size, { padding_inner, padding_top, padding_outer });
98
+ return { arcs, rects, root, max_depth };
99
+ }
@@ -56,9 +56,7 @@
56
56
 
57
57
  const compute_and_add = (content: string | ArrayBuffer, filename: string) => {
58
58
  try {
59
- const text = content instanceof ArrayBuffer
60
- ? new TextDecoder().decode(content)
61
- : content
59
+ const text = content instanceof ArrayBuffer ? new TextDecoder().decode(content) : content
62
60
  const parsed_struct = parse_any_structure(text, filename)
63
61
  if (is_crystal(parsed_struct)) {
64
62
  drag_dropped = [...drag_dropped, parsed_struct]
@@ -66,16 +64,13 @@
66
64
  error_msg = `Crystal has no lattice or sites; cannot compute RDF`
67
65
  }
68
66
  } catch (exc) {
69
- error_msg = `Failed to process structure: ${
70
- to_error(exc).message
71
- }`
67
+ error_msg = `Failed to process structure: ${to_error(exc).message}`
72
68
  }
73
69
  }
74
70
 
75
71
  const handle_drop = create_file_drop_handler({
76
72
  allow: () => enable_drop,
77
- on_drop: (content, filename) =>
78
- (on_file_drop || compute_and_add)(content, filename),
73
+ on_drop: (content, filename) => (on_file_drop || compute_and_add)(content, filename),
79
74
  on_error: (msg) => {
80
75
  error_msg = msg
81
76
  },
@@ -85,9 +80,9 @@
85
80
  },
86
81
  })
87
82
 
88
- function handle_dragover(ev: DragEvent) {
89
- ev.preventDefault()
90
- if (ev.dataTransfer) ev.dataTransfer.dropEffect = `copy`
83
+ function handle_dragover(event: DragEvent) {
84
+ event.preventDefault()
85
+ if (event.dataTransfer) event.dataTransfer.dropEffect = `copy`
91
86
  dragging = true
92
87
  }
93
88
 
@@ -108,7 +103,7 @@
108
103
  struct_list.push({
109
104
  struct,
110
105
  label: format_structure_label(struct, `Crystal ${idx + 1}`),
111
- })
106
+ }),
112
107
  )
113
108
  } else if (is_crystal(structures)) {
114
109
  struct_list.push({
@@ -117,7 +112,7 @@
117
112
  })
118
113
  } else {
119
114
  Object.entries(structures).forEach(([label, struct]) =>
120
- struct_list.push({ struct, label: format_structure_label(struct, label) })
115
+ struct_list.push({ struct, label: format_structure_label(struct, label) }),
121
116
  )
122
117
  }
123
118
  }
@@ -125,17 +120,21 @@
125
120
  struct_list.push({
126
121
  struct,
127
122
  label: format_structure_label(struct, `Dropped ${idx + 1}`),
128
- })
123
+ }),
129
124
  )
130
125
 
131
126
  for (const { struct, label } of struct_list) {
132
127
  if (mode === `element_pairs`) {
133
128
  const pairs = calculate_all_pair_rdfs(struct, { cutoff, n_bins, pbc })
134
- result.push(...pairs.map((pair) => ({
135
- label: pair.element_pair ? `${pair.element_pair[0]}-${pair.element_pair[1]}` : label,
136
- legend_group: label, // Group by structure name for multi-structure plots
137
- pattern: pair,
138
- })))
129
+ result.push(
130
+ ...pairs.map((pair) => ({
131
+ label: pair.element_pair
132
+ ? `${pair.element_pair[0]}-${pair.element_pair[1]}`
133
+ : label,
134
+ legend_group: label, // Group by structure name for multi-structure plots
135
+ pattern: pair,
136
+ })),
137
+ )
139
138
  } else {
140
139
  const pattern = calculate_rdf(struct, { cutoff, n_bins, pbc })
141
140
  result.push({ label, pattern })
@@ -146,7 +145,6 @@
146
145
 
147
146
  const max_r = $derived(Math.max(...entries.flatMap((entry) => entry.pattern.r), 0))
148
147
  const max_g = $derived(Math.max(1.2, ...entries.flatMap((entry) => entry.pattern.g_r)))
149
-
150
148
  const series = $derived<DataSeries[]>(
151
149
  entries.map((ent, idx) => ({
152
150
  x: ent.pattern.r,
@@ -182,8 +180,8 @@
182
180
  >
183
181
  <StatusMessage
184
182
  message={enable_drop
185
- ? `Drag and drop structure files here to visualize RDFs`
186
- : `No RDF data to display`}
183
+ ? `Drag and drop structure files here to visualize RDFs`
184
+ : `No RDF data to display`}
187
185
  style="border: none"
188
186
  />
189
187
  </div>
@@ -194,7 +192,7 @@
194
192
  x_axis={{ label: `r (Å)`, range: [0, max_r], ...x_axis }}
195
193
  y_axis={{ label: `g(r)`, range: [0, max_g * 1.05], ...y_axis }}
196
194
  styles={{ show_lines: true, show_points: false }}
197
- class="{rest.class ?? ``} {dragging ? `dragging` : ``}"
195
+ class={[rest.class, dragging && `dragging`]}
198
196
  style={rest.style ?? `height: 400px;`}
199
197
  ondragover={enable_drop ? handle_dragover : undefined}
200
198
  ondragleave={enable_drop ? () => (dragging = false) : undefined}
@@ -207,9 +205,7 @@
207
205
  {@const [x1, x2] = [pad.l, width - pad.r]}
208
206
  {@const [x, y] = [width - pad.r - 5, y1 - 5]}
209
207
  <line {x1} {x2} {y1} y2={y1} stroke="gray" stroke-dasharray="4" opacity="0.5" />
210
- <text {x} {y} text-anchor="end" fill="gray" font-size="0.8em">
211
- g(r) = 1
212
- </text>
208
+ <text {x} {y} text-anchor="end" fill="gray" font-size="0.8em"> g(r) = 1 </text>
213
209
  {/if}
214
210
  {/if}
215
211
  {/snippet}
@@ -22,6 +22,6 @@ type $$ComponentProps = {
22
22
  drag_dropped?: Crystal[];
23
23
  dragging?: boolean;
24
24
  } & ComponentProps<typeof ScatterPlot>;
25
- declare const RdfPlot: import("svelte").Component<$$ComponentProps, {}, "loading" | "error_msg" | "dragging" | "drag_dropped">;
25
+ declare const RdfPlot: import("svelte").Component<$$ComponentProps, {}, "dragging" | "loading" | "error_msg" | "drag_dropped">;
26
26
  type RdfPlot = ReturnType<typeof RdfPlot>;
27
27
  export default RdfPlot;
@@ -42,12 +42,11 @@ export function calculate_rdf(structure, options = {}) {
42
42
  // Get occupancy weight for a site-species pair (supports mixed occupancy)
43
43
  const centers = center_sites.filter((site) => has_species(site, center_species));
44
44
  const neighbors = sites.filter((site) => has_species(site, neighbor_species));
45
- if (centers.length === 0 || neighbors.length === 0) {
46
- const element_pair = center_species && neighbor_species
47
- ? [center_species, neighbor_species]
48
- : undefined;
45
+ const element_pair = center_species && neighbor_species
46
+ ? [center_species, neighbor_species]
47
+ : undefined;
48
+ if (centers.length === 0 || neighbors.length === 0)
49
49
  return { r, g_r, element_pair };
50
- }
51
50
  // Calculate distances and bin them with occupancy weighting
52
51
  const use_pbc = pbc.some(Boolean);
53
52
  const converters = use_pbc ? create_lattice_converters(lattice) : undefined;
@@ -78,9 +77,6 @@ export function calculate_rdf(structure, options = {}) {
78
77
  g_r[idx] /= n_pairs * ((4 * Math.PI * r[idx] ** 2 * bin_size) / volume);
79
78
  }
80
79
  }
81
- const element_pair = center_species && neighbor_species
82
- ? [center_species, neighbor_species]
83
- : undefined;
84
80
  return { r, g_r, element_pair };
85
81
  }
86
82
  // Calculate RDF for all element pairs
package/dist/sanitize.js CHANGED
@@ -3,7 +3,7 @@ import { format_formula_html } from './phase-diagram/utils';
3
3
  const SAFE_TAGS = [`a`, `b`, `i`, `em`, `strong`, `sub`, `sup`, `br`, `span`, `code`, `small`];
4
4
  const SAFE_ATTRS = [`style`, `class`, `title`, `href`, `target`, `rel`];
5
5
  // only allow safe CSS properties for text formatting
6
- const SAFE_STYLE_RE = /^\s*(color|font-weight|font-style|font-size|text-decoration|vertical-align)\s*:/;
6
+ const SAFE_STYLE_RE = /^\s*(?:color|font-weight|font-style|font-size|text-decoration|vertical-align)\s*:/;
7
7
  // Add a token to a space-separated string if not already present
8
8
  const ensure_token = (value, token) => {
9
9
  const tokens = new Set(value.split(/\s+/).filter(Boolean));
@@ -75,21 +75,32 @@ const stringify_html_input = (html) => {
75
75
  return ``;
76
76
  }
77
77
  };
78
+ // Memoize by input: two DOMPurify passes per call are costly when a component re-sanitizes
79
+ // many cells on every render (e.g. HeatmapTable). Sanitization is deterministic for the
80
+ // fixed config, so caching is output-identical.
81
+ const sanitize_cache = new Map();
78
82
  // Sanitize HTML string, allowing only safe formatting tags and links.
79
83
  // Two-pass: happy-dom promotes dangerous children when a non-allowed parent is
80
84
  // stripped (e.g. <div><script>…</script></div> → <script>…</script>). The first
81
85
  // pass explicitly removes dangerous tags so they can't survive promotion.
82
86
  export function sanitize_html(html) {
83
87
  const str = stringify_html_input(html);
88
+ const cached = sanitize_cache.get(str);
89
+ if (cached !== undefined)
90
+ return cached;
84
91
  const dp = get_purify();
85
92
  if (!dp)
86
- return str;
93
+ return str; // no DOM (SSR): return as-is, don't cache
87
94
  // oxfmt-ignore
88
95
  const safe = dp.sanitize(str, { ADD_ATTR: [`target`], FORBID_TAGS: [
89
96
  `script`, `style`, `iframe`, `object`, `embed`, `form`, `input`, `textarea`,
90
97
  `select`, `button`, `meta`, `link`, `base`, `template`, `noscript`,
91
98
  ] });
92
- return dp.sanitize(safe, { ALLOWED_TAGS: SAFE_TAGS, ALLOWED_ATTR: SAFE_ATTRS });
99
+ const result = dp.sanitize(safe, { ALLOWED_TAGS: SAFE_TAGS, ALLOWED_ATTR: SAFE_ATTRS });
100
+ if (sanitize_cache.size >= 4096)
101
+ sanitize_cache.clear(); // bound memory (rarely hit)
102
+ sanitize_cache.set(str, result);
103
+ return result;
93
104
  }
94
105
  export const compact_formula = (formula) => formula.replaceAll(/\s+/g, ``);
95
106
  // Sanitize a chemical formula with optional subscript formatting
@@ -0,0 +1,62 @@
1
+ <script lang="ts">
2
+ // Dual perspective/orthographic camera with OrbitControls + axis Gizmo, shared by BrillouinZoneScene, FermiSurfaceScene and StructureScene
3
+ import type { Vec3 } from '../math'
4
+ import { type CameraProjection, DEFAULTS } from '../settings'
5
+ import { T } from '@threlte/core'
6
+ import * as extras from '@threlte/extras'
7
+ import type { ComponentProps } from 'svelte'
8
+ import { build_gizmo_props, build_orbit_props } from './props'
9
+
10
+ let {
11
+ camera_projection = `perspective`,
12
+ position,
13
+ fov = DEFAULTS.structure.fov,
14
+ zoom = DEFAULTS.structure.initial_zoom,
15
+ near = undefined,
16
+ far = undefined,
17
+ orbit_props,
18
+ gizmo = false,
19
+ orbit_controls = $bindable(undefined),
20
+ }: {
21
+ camera_projection?: CameraProjection
22
+ position: Vec3 // camera position
23
+ fov?: number // perspective field of view
24
+ zoom?: number // orthographic zoom level
25
+ near?: number // perspective near plane (orthographic always uses -100)
26
+ far?: number // far plane (applied to either projection when provided)
27
+ orbit_props: ReturnType<typeof build_orbit_props>
28
+ gizmo?: boolean | ComponentProps<typeof extras.Gizmo>
29
+ orbit_controls?: ComponentProps<typeof extras.OrbitControls>[`ref`]
30
+ } = $props()
31
+
32
+ const gizmo_props = $derived(build_gizmo_props(gizmo))
33
+ // Only pass clipping planes that were explicitly provided so three.js defaults apply otherwise
34
+ const persp_planes = $derived({
35
+ ...(near !== undefined && { near }),
36
+ ...(far !== undefined && { far }),
37
+ })
38
+ const ortho_far = $derived(far !== undefined ? { far } : {})
39
+ </script>
40
+
41
+ {#snippet camera_contents()}
42
+ <extras.OrbitControls bind:ref={orbit_controls} {...orbit_props}>
43
+ {#if gizmo}<extras.Gizmo {...gizmo_props} />{/if}
44
+ </extras.OrbitControls>
45
+ {/snippet}
46
+
47
+ {#if camera_projection === `perspective`}
48
+ <T.PerspectiveCamera makeDefault {position} {fov} {...persp_planes}>
49
+ {@render camera_contents()}
50
+ </T.PerspectiveCamera>
51
+ {:else}
52
+ <T.OrthographicCamera makeDefault {position} {zoom} near={-100} {...ortho_far}>
53
+ {@render camera_contents()}
54
+ </T.OrthographicCamera>
55
+ {/if}
56
+
57
+ <style>
58
+ :global(.responsive-gizmo) {
59
+ width: clamp(70px, 18cqmin, 100px) !important;
60
+ height: clamp(70px, 18cqmin, 100px) !important;
61
+ }
62
+ </style>
@@ -0,0 +1,19 @@
1
+ import type { Vec3 } from '../math';
2
+ import { type CameraProjection } from '../settings';
3
+ import * as extras from '@threlte/extras';
4
+ import type { ComponentProps } from 'svelte';
5
+ import { build_orbit_props } from './props';
6
+ type $$ComponentProps = {
7
+ camera_projection?: CameraProjection;
8
+ position: Vec3;
9
+ fov?: number;
10
+ zoom?: number;
11
+ near?: number;
12
+ far?: number;
13
+ orbit_props: ReturnType<typeof build_orbit_props>;
14
+ gizmo?: boolean | ComponentProps<typeof extras.Gizmo>;
15
+ orbit_controls?: ComponentProps<typeof extras.OrbitControls>[`ref`];
16
+ };
17
+ declare const SceneCamera: import("svelte").Component<$$ComponentProps, {}, "orbit_controls">;
18
+ type SceneCamera = ReturnType<typeof SceneCamera>;
19
+ export default SceneCamera;
@@ -0,0 +1,2 @@
1
+ import type { Camera, Scene, WebGLRenderer } from 'three';
2
+ export declare function bind_renderer(on_bind: (scene: Scene, camera: Camera) => void, on_renderer?: (renderer: WebGLRenderer) => void): import("@threlte/core").ThrelteContext<WebGLRenderer>;
@@ -0,0 +1,22 @@
1
+ import { renderer_registry, scene_registry } from '../io/export';
2
+ import { useThrelte } from '@threlte/core';
3
+ // Mirror the Threlte scene + active camera into bindable props (for export panes etc.) and register the canvas->renderer/scene mappings so PNG-export and element-capture helpers can find them. Creates an $effect (call during component init). Returns the Threlte context for further use (e.g. clipping planes).
4
+ export function bind_renderer(on_bind, on_renderer) {
5
+ const threlte = useThrelte();
6
+ $effect(() => {
7
+ const renderer = threlte.renderer;
8
+ // `camera.current` is not reactive, so subscribe to be notified when the active camera changes
9
+ const unsubscribe = threlte.camera.subscribe((camera) => {
10
+ on_bind(threlte.scene, camera);
11
+ if (renderer) {
12
+ scene_registry.set(renderer.domElement, { scene: threlte.scene, camera });
13
+ }
14
+ });
15
+ if (renderer) {
16
+ on_renderer?.(renderer);
17
+ renderer_registry.set(renderer.domElement, renderer);
18
+ }
19
+ return unsubscribe;
20
+ });
21
+ return threlte;
22
+ }
@@ -0,0 +1,4 @@
1
+ export * from './bind-renderer.svelte';
2
+ export * from './props';
3
+ export { default as SceneCamera } from './SceneCamera.svelte';
4
+ export type * from './types';
@@ -0,0 +1,5 @@
1
+ // Shared Three.js/Threlte scene boilerplate (cameras, orbit controls, gizmo,
2
+ // renderer binding) used by BrillouinZoneScene, FermiSurfaceScene and StructureScene.
3
+ export * from './bind-renderer.svelte';
4
+ export * from './props';
5
+ export { default as SceneCamera } from './SceneCamera.svelte';
@@ -0,0 +1,52 @@
1
+ import { AXIS_COLORS, NEG_AXIS_COLORS } from '../colors';
2
+ // ScatterPlot3DScene keeps its own gizmo/orbit props on purpose: its gizmo offset is
3
+ // ColorBar-aware (build_gizmo_props' fixed offset would clobber it) and its orbit controls
4
+ // differ by design (no zoom-to-cursor / ortho zoom-doubling / camera-moving tracking).
5
+ // Shared Gizmo config: colored +/- axis handles, transparent background, responsive sizing. An object `gizmo` overrides the per-axis defaults.
6
+ export function build_gizmo_props(gizmo) {
7
+ return {
8
+ background: { enabled: false },
9
+ className: `responsive-gizmo`,
10
+ ...Object.fromEntries([...AXIS_COLORS, ...NEG_AXIS_COLORS].map(([axis, color, hover]) => [
11
+ axis,
12
+ {
13
+ color,
14
+ labelColor: `#111`,
15
+ opacity: axis.startsWith(`n`) ? 0.9 : 0.8,
16
+ hover: {
17
+ color: hover,
18
+ labelColor: `#222`,
19
+ opacity: axis.startsWith(`n`) ? 1 : 0.9,
20
+ },
21
+ },
22
+ ])),
23
+ ...(typeof gizmo === `object` ? gizmo : {}),
24
+ offset: { left: 5, bottom: 5 },
25
+ };
26
+ }
27
+ // Shared OrbitControls config; `onstart_extra` runs extra cleanup when the camera starts moving (e.g. StructureScene closes hover tooltips/context menus)
28
+ export function build_orbit_props(opts) {
29
+ const is_ortho = opts.camera_projection === `orthographic`;
30
+ return {
31
+ position: [0, 0, 0],
32
+ target: opts.target,
33
+ enableRotate: opts.rotate_speed > 0,
34
+ rotateSpeed: opts.rotate_speed,
35
+ enableZoom: opts.zoom_speed > 0,
36
+ zoomSpeed: is_ortho ? opts.zoom_speed * 2 : opts.zoom_speed,
37
+ zoomToCursor: opts.zoom_to_cursor,
38
+ enablePan: opts.pan_speed > 0,
39
+ panSpeed: opts.pan_speed,
40
+ maxZoom: opts.max_zoom,
41
+ minZoom: opts.min_zoom,
42
+ autoRotate: Boolean(opts.auto_rotate),
43
+ autoRotateSpeed: opts.auto_rotate,
44
+ enableDamping: Boolean(opts.rotation_damping),
45
+ dampingFactor: opts.rotation_damping,
46
+ onstart: () => {
47
+ opts.set_camera_is_moving?.(true);
48
+ opts.onstart_extra?.();
49
+ },
50
+ onend: () => opts.set_camera_is_moving?.(false),
51
+ };
52
+ }
@@ -0,0 +1,26 @@
1
+ import type { CameraProjection } from '../settings';
2
+ import type { Gizmo } from '@threlte/extras';
3
+ import type { ComponentProps } from 'svelte';
4
+ import type { Camera, Scene, Vector3 } from 'three';
5
+ export type ThreltePointerEvent = {
6
+ point: Vector3;
7
+ nativeEvent: PointerEvent;
8
+ };
9
+ export type SceneControlProps = {
10
+ camera_projection?: CameraProjection;
11
+ rotation_damping?: number;
12
+ max_zoom?: number;
13
+ min_zoom?: number;
14
+ rotate_speed?: number;
15
+ zoom_speed?: number;
16
+ pan_speed?: number;
17
+ zoom_to_cursor?: boolean;
18
+ fov?: number;
19
+ initial_zoom?: number;
20
+ ambient_light?: number;
21
+ directional_light?: number;
22
+ gizmo?: boolean | ComponentProps<typeof Gizmo>;
23
+ auto_rotate?: number;
24
+ scene?: Scene;
25
+ camera?: Camera;
26
+ };
@@ -0,0 +1 @@
1
+ export {};