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.
- package/dist/EmptyState.svelte +10 -4
- package/dist/FilePicker.svelte +12 -14
- package/dist/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +2 -2
- package/dist/app.css +53 -0
- package/dist/brillouin/BrillouinZone.svelte +132 -219
- package/dist/brillouin/BrillouinZone.svelte.d.ts +9 -20
- package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
- package/dist/brillouin/BrillouinZoneExportPane.svelte +47 -96
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +15 -42
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +63 -230
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +3 -23
- package/dist/brillouin/ReciprocalVectors.svelte +39 -0
- package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
- package/dist/brillouin/compute.d.ts +2 -0
- package/dist/brillouin/compute.js +80 -77
- package/dist/brillouin/geometry.d.ts +8 -0
- package/dist/brillouin/geometry.js +57 -0
- package/dist/brillouin/index.d.ts +2 -0
- package/dist/brillouin/index.js +2 -0
- package/dist/brillouin/types.d.ts +2 -2
- package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +143 -246
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +652 -976
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
- package/dist/chempot-diagram/async-compute.svelte.js +1 -1
- package/dist/chempot-diagram/color.d.ts +3 -6
- package/dist/chempot-diagram/color.js +5 -5
- package/dist/chempot-diagram/compute.d.ts +3 -3
- package/dist/chempot-diagram/compute.js +3 -1
- package/dist/chempot-diagram/controls-state.svelte.d.ts +10 -0
- package/dist/chempot-diagram/controls-state.svelte.js +42 -0
- package/dist/chempot-diagram/export.d.ts +47 -0
- package/dist/chempot-diagram/export.js +133 -0
- package/dist/chempot-diagram/index.d.ts +1 -0
- package/dist/chempot-diagram/index.js +1 -0
- package/dist/chempot-diagram/pointer.d.ts +0 -10
- package/dist/chempot-diagram/pointer.js +4 -4
- package/dist/chempot-diagram/types.d.ts +3 -3
- package/dist/colors/index.d.ts +0 -4
- package/dist/colors/index.js +21 -22
- package/dist/composition/BarChart.svelte +37 -31
- package/dist/composition/BubbleChart.svelte +17 -17
- package/dist/composition/Composition.svelte +7 -11
- package/dist/composition/Formula.svelte +18 -25
- package/dist/composition/FormulaFilter.svelte +96 -98
- package/dist/composition/PieChart.svelte +60 -46
- package/dist/composition/chem-sys.js +3 -2
- package/dist/composition/format.js +4 -3
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +2 -3
- package/dist/composition/parse.js +27 -28
- package/dist/constants.js +11 -9
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +0 -1
- package/dist/convex-hull/ConvexHull.svelte +20 -25
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
- package/dist/convex-hull/ConvexHull2D.svelte +176 -256
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +269 -804
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +236 -755
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +264 -0
- package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
- package/dist/convex-hull/ConvexHullControls.svelte +128 -49
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
- package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
- package/dist/convex-hull/ConvexHullStats.svelte +210 -351
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +16 -14
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
- package/dist/convex-hull/GasPressureControls.svelte +5 -12
- package/dist/convex-hull/StructurePopup.svelte +17 -21
- package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
- package/dist/convex-hull/TemperatureSlider.svelte +4 -10
- package/dist/convex-hull/barycentric-coords.d.ts +2 -4
- package/dist/convex-hull/barycentric-coords.js +6 -33
- package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
- package/dist/convex-hull/canvas-interactions.svelte.js +279 -0
- package/dist/convex-hull/helpers.d.ts +47 -17
- package/dist/convex-hull/helpers.js +186 -101
- package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
- package/dist/convex-hull/hull-state.svelte.js +124 -0
- package/dist/convex-hull/index.d.ts +9 -7
- package/dist/convex-hull/index.js +7 -2
- package/dist/convex-hull/thermodynamics.js +109 -937
- package/dist/convex-hull/types.d.ts +12 -4
- package/dist/convex-hull/types.js +12 -0
- package/dist/coordination/CoordinationBarPlot.svelte +41 -43
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
- package/dist/coordination/calc-coordination.d.ts +1 -1
- package/dist/coordination/calc-coordination.js +28 -25
- package/dist/element/BohrAtom.svelte +6 -8
- package/dist/element/ElementHeading.svelte +4 -1
- package/dist/element/ElementPhoto.svelte +11 -9
- package/dist/element/ElementStats.svelte +12 -10
- package/dist/element/ElementTile.svelte +24 -29
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/element/Nucleus.svelte +4 -2
- package/dist/element/data.d.ts +1 -2
- package/dist/element/helpers.d.ts +4 -0
- package/dist/element/helpers.js +18 -0
- package/dist/element/index.d.ts +1 -0
- package/dist/element/index.js +3 -0
- package/dist/feedback/DragOverlay.svelte +5 -3
- package/dist/feedback/DragOverlay.svelte.d.ts +2 -1
- package/dist/feedback/StatusMessage.svelte +20 -7
- package/dist/fermi-surface/FermiSlice.svelte +21 -18
- package/dist/fermi-surface/FermiSurface.svelte +78 -165
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +9 -20
- package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
- package/dist/fermi-surface/FermiSurfaceScene.svelte +93 -272
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
- package/dist/fermi-surface/compute.js +14 -13
- package/dist/fermi-surface/export.js +4 -15
- package/dist/fermi-surface/index.d.ts +0 -1
- package/dist/fermi-surface/index.js +0 -1
- package/dist/fermi-surface/parse.d.ts +1 -1
- package/dist/fermi-surface/parse.js +84 -97
- package/dist/fermi-surface/types.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +161 -185
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +6 -5
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +12 -9
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
- package/dist/heatmap-matrix/index.d.ts +8 -2
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/ExportPane.svelte +170 -0
- package/dist/io/ExportPane.svelte.d.ts +17 -0
- package/dist/io/decompress.d.ts +2 -1
- package/dist/io/decompress.js +22 -36
- package/dist/io/export.d.ts +9 -1
- package/dist/io/export.js +37 -29
- package/dist/io/fetch.d.ts +2 -4
- package/dist/io/fetch.js +0 -11
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +13 -0
- package/dist/io/index.d.ts +1 -0
- package/dist/io/index.js +3 -0
- package/dist/io/is-binary.d.ts +9 -0
- package/dist/io/is-binary.js +45 -1
- package/dist/io/types.d.ts +13 -0
- package/dist/io/url-drop.js +13 -25
- package/dist/isosurface/Isosurface.svelte +17 -23
- package/dist/isosurface/IsosurfaceControls.svelte +37 -42
- package/dist/isosurface/parse-vaspwave.d.ts +3 -0
- package/dist/isosurface/parse-vaspwave.js +138 -0
- package/dist/isosurface/parse.js +50 -48
- package/dist/labels.d.ts +6 -2
- package/dist/labels.js +44 -14
- package/dist/layout/FullscreenButton.svelte +34 -0
- package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
- package/dist/layout/FullscreenToggle.svelte +12 -12
- package/dist/layout/InfoCard.svelte +7 -18
- package/dist/layout/InfoTag.svelte +1 -3
- package/dist/layout/NumberRangeInput.svelte +46 -0
- package/dist/layout/NumberRangeInput.svelte.d.ts +12 -0
- package/dist/layout/PropertyFilter.svelte +2 -6
- package/dist/layout/SettingsSection.svelte +21 -17
- package/dist/layout/SubpageGrid.svelte +3 -1
- package/dist/layout/ViewerChrome.svelte +115 -0
- package/dist/layout/ViewerChrome.svelte.d.ts +18 -0
- package/dist/layout/fullscreen.d.ts +4 -0
- package/dist/layout/fullscreen.js +3 -5
- package/dist/layout/fullscreen.svelte.d.ts +8 -0
- package/dist/layout/fullscreen.svelte.js +36 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.js +4 -0
- package/dist/layout/json-tree/JsonNode.svelte +8 -11
- package/dist/layout/json-tree/JsonTree.svelte +53 -77
- package/dist/layout/json-tree/JsonValue.svelte +7 -15
- package/dist/layout/json-tree/utils.js +14 -23
- package/dist/math.d.ts +9 -3
- package/dist/math.js +37 -21
- package/dist/overlays/ContextMenu.svelte +4 -2
- package/dist/overlays/CopyButton.svelte +11 -5
- package/dist/overlays/DragControlTab.svelte +6 -1
- package/dist/overlays/DraggablePane.svelte +81 -26
- package/dist/overlays/DraggablePane.svelte.d.ts +1 -0
- package/dist/overlays/GlassChip.svelte +30 -0
- package/dist/overlays/GlassChip.svelte.d.ts +8 -0
- package/dist/overlays/InfoPaneCards.svelte +11 -23
- package/dist/overlays/index.d.ts +11 -0
- package/dist/overlays/index.js +26 -0
- package/dist/overlays/portal.d.ts +2 -0
- package/dist/overlays/portal.js +14 -0
- package/dist/periodic-table/PeriodicTable.svelte +115 -146
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
- package/dist/periodic-table/PeriodicTableControls.svelte +11 -63
- package/dist/periodic-table/TableInset.svelte +9 -4
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +50 -71
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
- package/dist/phase-diagram/PhaseDiagramControls.svelte +73 -96
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +4 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +49 -134
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
- package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
- package/dist/phase-diagram/build-diagram.js +3 -3
- package/dist/phase-diagram/colors.js +1 -1
- package/dist/phase-diagram/diagram-input.d.ts +1 -2
- package/dist/phase-diagram/parse.d.ts +2 -1
- package/dist/phase-diagram/parse.js +15 -15
- package/dist/phase-diagram/svg-to-diagram.js +21 -15
- package/dist/phase-diagram/utils.js +2 -3
- package/dist/plot/bar/BarPlot.svelte +494 -692
- package/dist/plot/bar/BarPlot.svelte.d.ts +9 -15
- package/dist/plot/bar/BarPlotControls.svelte +1 -3
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +5 -7
- package/dist/plot/bar/SpacegroupBarPlot.svelte +31 -37
- package/dist/plot/bar/data.d.ts +5 -4
- package/dist/plot/bar/data.js +2 -1
- package/dist/plot/box/BoxPlot.svelte +361 -439
- package/dist/plot/box/BoxPlot.svelte.d.ts +6 -3
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
- package/dist/plot/box/Violin.svelte.d.ts +2 -1
- package/dist/plot/box/box-plot.d.ts +3 -2
- package/dist/plot/box/box-plot.js +6 -3
- package/dist/plot/box/kde.d.ts +2 -1
- package/dist/plot/box/kde.js +4 -4
- package/dist/plot/core/auto-place.d.ts +1 -1
- package/dist/plot/core/auto-place.js +5 -2
- package/dist/plot/core/axis-utils.d.ts +12 -7
- package/dist/plot/core/axis-utils.js +48 -48
- package/dist/plot/core/components/AxisLabel.svelte +82 -20
- package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
- package/dist/plot/core/components/ColorBar.svelte +106 -111
- package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
- package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
- package/dist/plot/core/components/FillArea.svelte +10 -17
- package/dist/plot/core/components/HierarchyControls.svelte +249 -0
- package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
- package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
- package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/core/components/Line.svelte +21 -11
- package/dist/plot/core/components/Line.svelte.d.ts +5 -2
- package/dist/plot/core/components/PlotAxis.svelte +42 -18
- package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
- package/dist/plot/core/components/PlotControls.svelte +65 -41
- package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/core/components/PlotLegend.svelte +31 -35
- package/dist/plot/core/components/PlotMarginals.svelte +616 -0
- package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
- package/dist/plot/core/components/PlotTooltip.svelte +1 -1
- package/dist/plot/core/components/PortalSelect.svelte +4 -8
- package/dist/plot/core/components/ReferenceLine.svelte +27 -24
- package/dist/plot/core/components/ReferenceLine3D.svelte +56 -59
- package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
- package/dist/plot/core/components/ReferencePlane.svelte +9 -10
- package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
- package/dist/plot/core/components/ZeroLines.svelte +4 -8
- package/dist/plot/core/components/ZoomRect.svelte +1 -2
- package/dist/plot/core/components/index.d.ts +1 -0
- package/dist/plot/core/components/index.js +1 -0
- package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
- package/dist/plot/core/data-cleaning-signal.js +467 -0
- package/dist/plot/core/data-cleaning.d.ts +2 -42
- package/dist/plot/core/data-cleaning.js +29 -476
- package/dist/plot/core/data-transform.js +9 -5
- package/dist/plot/core/fill-utils.d.ts +7 -4
- package/dist/plot/core/fill-utils.js +34 -9
- package/dist/plot/core/index.d.ts +1 -0
- package/dist/plot/core/index.js +1 -0
- package/dist/plot/core/interactions.d.ts +5 -1
- package/dist/plot/core/interactions.js +14 -2
- package/dist/plot/core/layout.d.ts +3 -1
- package/dist/plot/core/layout.js +22 -13
- package/dist/plot/core/marginals.d.ts +170 -0
- package/dist/plot/core/marginals.js +436 -0
- package/dist/plot/core/pan-zoom.svelte.d.ts +35 -0
- package/dist/plot/core/pan-zoom.svelte.js +221 -0
- package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
- package/dist/plot/core/placed-tween.svelte.js +68 -0
- package/dist/plot/core/reference-line.d.ts +10 -10
- package/dist/plot/core/reference-line.js +7 -7
- package/dist/plot/core/scales.d.ts +40 -25
- package/dist/plot/core/scales.js +49 -21
- package/dist/plot/core/svg.d.ts +2 -1
- package/dist/plot/core/types/fills.d.ts +101 -0
- package/dist/plot/core/types/fills.js +15 -0
- package/dist/plot/core/types/plot-3d.d.ts +87 -0
- package/dist/plot/core/types/plot-3d.js +4 -0
- package/dist/plot/core/types/reference-lines.d.ts +140 -0
- package/dist/plot/core/types/reference-lines.js +9 -0
- package/dist/plot/core/types.d.ts +47 -331
- package/dist/plot/core/types.js +23 -20
- package/dist/plot/core/utils/hierarchy-chart.d.ts +51 -0
- package/dist/plot/core/utils/hierarchy-chart.js +179 -0
- package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
- package/dist/plot/core/utils/hierarchy-labels.js +99 -0
- package/dist/plot/core/utils/label-placement.d.ts +1 -1
- package/dist/plot/core/utils/label-placement.js +5 -5
- package/dist/plot/core/utils.d.ts +2 -1
- package/dist/plot/histogram/Histogram.svelte +373 -631
- package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
- package/dist/plot/histogram/HistogramControls.svelte +30 -28
- package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/histogram/histogram.d.ts +31 -0
- package/dist/plot/histogram/histogram.js +70 -0
- package/dist/plot/histogram/index.d.ts +1 -0
- package/dist/plot/histogram/index.js +1 -0
- package/dist/plot/index.d.ts +1 -0
- package/dist/plot/index.js +1 -0
- package/dist/plot/sankey/Sankey.svelte +79 -73
- package/dist/plot/sankey/Sankey.svelte.d.ts +3 -3
- package/dist/plot/sankey/SankeyControls.svelte +22 -16
- package/dist/plot/sankey/sankey.js +3 -1
- package/dist/plot/scatter/BinnedScatterPlot.svelte +264 -112
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +11 -4
- package/dist/plot/scatter/ElementScatter.svelte +4 -1
- package/dist/plot/scatter/ScatterPlot.svelte +623 -821
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +9 -15
- package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
- package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/scatter/ScatterPoint.svelte +16 -9
- package/dist/plot/scatter/binned-scatter-types.d.ts +6 -12
- package/dist/plot/scatter/binned-scatter-types.js +6 -1
- package/dist/plot/scatter/index.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.js +8 -7
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte +40 -60
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +17 -15
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +232 -234
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
- package/dist/plot/scatter-3d/Surface3D.svelte +9 -17
- package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
- package/dist/plot/sunburst/Sunburst.svelte +256 -338
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
- package/dist/plot/sunburst/index.d.ts +1 -1
- package/dist/plot/sunburst/index.js +2 -1
- package/dist/plot/sunburst/render.d.ts +2 -2
- package/dist/plot/sunburst/render.js +47 -22
- package/dist/plot/sunburst/sunburst.d.ts +5 -1
- package/dist/plot/sunburst/sunburst.js +14 -4
- package/dist/plot/treemap/Treemap.svelte +907 -0
- package/dist/plot/treemap/Treemap.svelte.d.ts +84 -0
- package/dist/plot/treemap/index.d.ts +3 -0
- package/dist/plot/treemap/index.js +4 -0
- package/dist/plot/treemap/treemap.d.ts +26 -0
- package/dist/plot/treemap/treemap.js +99 -0
- package/dist/rdf/RdfPlot.svelte +22 -26
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/calc-rdf.js +4 -8
- package/dist/sanitize.js +14 -3
- package/dist/scene/SceneCamera.svelte +62 -0
- package/dist/scene/SceneCamera.svelte.d.ts +19 -0
- package/dist/scene/bind-renderer.svelte.d.ts +2 -0
- package/dist/scene/bind-renderer.svelte.js +22 -0
- package/dist/scene/index.d.ts +4 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/props.js +52 -0
- package/dist/scene/types.d.ts +26 -0
- package/dist/scene/types.js +1 -0
- package/dist/settings.d.ts +33 -11
- package/dist/settings.js +136 -51
- package/dist/spectral/Bands.svelte +231 -237
- package/dist/spectral/Bands.svelte.d.ts +3 -2
- package/dist/spectral/BandsAndDos.svelte +29 -29
- package/dist/spectral/BrillouinBandsDos.svelte +21 -29
- package/dist/spectral/Dos.svelte +75 -77
- package/dist/spectral/Dos.svelte.d.ts +2 -1
- package/dist/spectral/helpers.d.ts +9 -9
- package/dist/spectral/helpers.js +66 -70
- package/dist/state.svelte.d.ts +0 -7
- package/dist/state.svelte.js +5 -24
- package/dist/structure/Arrow.svelte +6 -21
- package/dist/structure/ArrowInstances.svelte +160 -0
- package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
- package/dist/structure/AtomLegend.svelte +115 -75
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +31 -23
- package/dist/structure/CanvasTooltip.svelte +16 -3
- package/dist/structure/CellSelect.svelte +22 -29
- package/dist/structure/CellSelect.svelte.d.ts +2 -1
- package/dist/structure/Cylinder.svelte +24 -40
- package/dist/structure/InstancedAtoms.svelte +114 -0
- package/dist/structure/InstancedAtoms.svelte.d.ts +15 -0
- package/dist/structure/Lattice.svelte +85 -149
- package/dist/structure/SiteLabels.svelte +122 -0
- package/dist/structure/SiteLabels.svelte.d.ts +18 -0
- package/dist/structure/Structure.svelte +725 -735
- package/dist/structure/Structure.svelte.d.ts +8 -16
- package/dist/structure/StructureCarousel.svelte +630 -0
- package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
- package/dist/structure/StructureControls.svelte +298 -325
- package/dist/structure/StructureControls.svelte.d.ts +5 -3
- package/dist/structure/StructureExportPane.svelte +62 -168
- package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
- package/dist/structure/StructureInfoPane.svelte +77 -69
- package/dist/structure/StructureInfoPane.svelte.d.ts +6 -6
- package/dist/structure/StructureScene.svelte +758 -600
- package/dist/structure/StructureScene.svelte.d.ts +24 -20
- package/dist/structure/StructureViewport.svelte +386 -0
- package/dist/structure/StructureViewport.svelte.d.ts +63 -0
- package/dist/structure/atom-label-placement.d.ts +18 -0
- package/dist/structure/atom-label-placement.js +115 -0
- package/dist/structure/atom-properties.d.ts +3 -1
- package/dist/structure/atom-properties.js +115 -54
- package/dist/structure/bond-order-perception.js +2 -4
- package/dist/structure/bonding.d.ts +12 -2
- package/dist/structure/bonding.js +172 -73
- package/dist/structure/edit-history.d.ts +6 -0
- package/dist/structure/edit-history.js +27 -0
- package/dist/structure/export.d.ts +25 -4
- package/dist/structure/export.js +103 -153
- package/dist/structure/format-detect.d.ts +1 -0
- package/dist/structure/format-detect.js +22 -0
- package/dist/structure/geometry.d.ts +9 -0
- package/dist/structure/geometry.js +27 -0
- package/dist/structure/index.d.ts +18 -1
- package/dist/structure/index.js +15 -2
- package/dist/structure/measure.d.ts +1 -1
- package/dist/structure/measure.js +6 -12
- package/dist/structure/parse.d.ts +5 -3
- package/dist/structure/parse.js +551 -567
- package/dist/structure/partial-occupancy.d.ts +0 -1
- package/dist/structure/partial-occupancy.js +5 -3
- package/dist/structure/pbc.d.ts +1 -1
- package/dist/structure/pbc.js +204 -51
- package/dist/structure/polyhedra.d.ts +40 -0
- package/dist/structure/polyhedra.js +587 -0
- package/dist/structure/site.d.ts +4 -0
- package/dist/structure/site.js +1 -0
- package/dist/structure/supercell.d.ts +1 -2
- package/dist/structure/supercell.js +10 -15
- package/dist/structure/validation.js +5 -6
- package/dist/symmetry/SymmetryElementControls.svelte +69 -0
- package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
- package/dist/symmetry/SymmetryElements.svelte +350 -0
- package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
- package/dist/symmetry/SymmetryStats.svelte +142 -49
- package/dist/symmetry/WyckoffTable.svelte +58 -16
- package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
- package/dist/symmetry/cell-transform.js +8 -14
- package/dist/symmetry/index.d.ts +15 -4
- package/dist/symmetry/index.js +308 -81
- package/dist/symmetry/spacegroups.d.ts +5 -1
- package/dist/symmetry/spacegroups.js +18 -3
- package/dist/symmetry/symmetry-elements.d.ts +33 -0
- package/dist/symmetry/symmetry-elements.js +521 -0
- package/dist/symmetry/wyckoff-db.d.ts +9 -0
- package/dist/symmetry/wyckoff-db.js +87 -0
- package/dist/table/HeatmapTable.svelte +1104 -378
- package/dist/table/HeatmapTable.svelte.d.ts +12 -2
- package/dist/table/ToggleMenu.svelte +5 -12
- package/dist/table/index.d.ts +21 -6
- package/dist/table/index.js +34 -21
- package/dist/theme/ThemeControl.svelte +16 -8
- package/dist/theme/index.d.ts +1 -5
- package/dist/theme/index.js +4 -10
- package/dist/theme/themes.mjs +14 -7
- package/dist/tooltip/KCoords.svelte +4 -1
- package/dist/tooltip/TooltipContent.svelte +2 -5
- package/dist/trajectory/Trajectory.svelte +556 -352
- package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
- package/dist/trajectory/TrajectoryError.svelte +11 -8
- package/dist/trajectory/TrajectoryExportPane.svelte +28 -54
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
- package/dist/trajectory/TrajectoryInfoPane.svelte +88 -99
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
- package/dist/trajectory/constants.js +6 -2
- package/dist/trajectory/extract.js +73 -71
- package/dist/trajectory/format-detect.d.ts +0 -1
- package/dist/trajectory/format-detect.js +13 -17
- package/dist/trajectory/frame-reader.d.ts +2 -1
- package/dist/trajectory/frame-reader.js +74 -136
- package/dist/trajectory/helpers.d.ts +12 -2
- package/dist/trajectory/helpers.js +68 -37
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +3 -0
- package/dist/trajectory/parse/ase.d.ts +9 -1
- package/dist/trajectory/parse/ase.js +47 -32
- package/dist/trajectory/parse/diagnostics.d.ts +3 -0
- package/dist/trajectory/parse/diagnostics.js +14 -0
- package/dist/trajectory/parse/h5-utils.d.ts +13 -0
- package/dist/trajectory/parse/h5-utils.js +109 -0
- package/dist/trajectory/parse/hdf5.d.ts +1 -1
- package/dist/trajectory/parse/hdf5.js +116 -106
- package/dist/trajectory/parse/index.d.ts +3 -4
- package/dist/trajectory/parse/index.js +68 -119
- package/dist/trajectory/parse/lammps.d.ts +0 -2
- package/dist/trajectory/parse/lammps.js +14 -16
- package/dist/trajectory/parse/pymatgen.d.ts +2 -0
- package/dist/trajectory/parse/pymatgen.js +74 -0
- package/dist/trajectory/parse/vasp.js +13 -9
- package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
- package/dist/trajectory/parse/vaspout-electronic.js +207 -0
- package/dist/trajectory/parse/vaspout-h5.d.ts +5 -0
- package/dist/trajectory/parse/vaspout-h5.js +284 -0
- package/dist/trajectory/parse/xyz.d.ts +9 -21
- package/dist/trajectory/parse/xyz.js +38 -39
- package/dist/trajectory/plotting.d.ts +8 -10
- package/dist/trajectory/plotting.js +102 -127
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +8 -1
- package/dist/xrd/XrdPlot.svelte +56 -85
- package/dist/xrd/broadening.d.ts +2 -1
- package/dist/xrd/broadening.js +2 -1
- package/dist/xrd/calc-xrd.js +8 -15
- package/dist/xrd/index.d.ts +2 -2
- package/dist/xrd/parse.d.ts +0 -1
- package/dist/xrd/parse.js +56 -73
- package/package.json +77 -36
- package/dist/api/mp.d.ts +0 -6
- package/dist/api/mp.js +0 -22
- package/dist/element/data.json +0 -11864
- package/dist/fermi-surface/marching-cubes.d.ts +0 -2
- package/dist/fermi-surface/marching-cubes.js +0 -2
- package/dist/plot/core/hover-lock.svelte.d.ts +0 -14
- package/dist/plot/core/hover-lock.svelte.js +0 -45
- package/dist/plot/sunburst/SunburstControls.svelte +0 -200
- package/dist/structure/label-placement.d.ts +0 -14
- package/dist/structure/label-placement.js +0 -72
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PhaseData } from '../convex-hull/types';
|
|
2
|
+
import { type FullscreenToggleProp } from '../layout';
|
|
2
3
|
import type { ChemPotDiagramConfig, ChemPotHoverInfo } from './types';
|
|
3
4
|
type $$ComponentProps = {
|
|
4
5
|
entries: PhaseData[];
|
|
@@ -10,7 +11,12 @@ type $$ComponentProps = {
|
|
|
10
11
|
max_interpolation_gap?: number;
|
|
11
12
|
hover_info?: ChemPotHoverInfo | null;
|
|
12
13
|
render_local_tooltip?: boolean;
|
|
14
|
+
wrapper?: HTMLDivElement;
|
|
15
|
+
fullscreen?: boolean;
|
|
16
|
+
fullscreen_toggle?: FullscreenToggleProp;
|
|
17
|
+
controls_open?: boolean;
|
|
18
|
+
export_pane_open?: boolean;
|
|
13
19
|
};
|
|
14
|
-
declare const ChemPotDiagram3D: import("svelte").Component<$$ComponentProps, {}, "
|
|
20
|
+
declare const ChemPotDiagram3D: import("svelte").Component<$$ComponentProps, {}, "height" | "width" | "fullscreen" | "wrapper" | "controls_open" | "export_pane_open" | "temperature" | "hover_info">;
|
|
15
21
|
type ChemPotDiagram3D = ReturnType<typeof ChemPotDiagram3D>;
|
|
16
22
|
export default ChemPotDiagram3D;
|
|
@@ -68,7 +68,7 @@ export function compute_chempot_async(entries, config = {}) {
|
|
|
68
68
|
pending.set(id, { resolve, reject });
|
|
69
69
|
try {
|
|
70
70
|
// $state.snapshot strips Svelte $state proxies (not structured-cloneable)
|
|
71
|
-
//
|
|
71
|
+
// oxlint-disable-next-line unicorn/require-post-message-target-origin
|
|
72
72
|
wkr.postMessage($state.snapshot({ id, entries, config }));
|
|
73
73
|
}
|
|
74
74
|
catch (err) {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { type D3InterpolateName } from '../colors';
|
|
2
|
-
|
|
3
|
-
export declare function get_chempot_interpolator(name: D3InterpolateName, reverse: boolean): (t: number) => string;
|
|
4
|
-
/** Build sequential color scale from values and D3 interpolator name. */
|
|
2
|
+
import type { Vec2 } from '../math';
|
|
5
3
|
export declare function make_chempot_color_scale(values: number[], interpolator_name: D3InterpolateName, reverse: boolean): ((val: number) => string) | null;
|
|
6
|
-
/** Resolve color bar props for chempot diagrams (interpolator + domain). */
|
|
7
4
|
export declare function get_chempot_color_bar_config(color_scale: D3InterpolateName, reverse: boolean): {
|
|
8
|
-
color_scale_fn: (
|
|
9
|
-
color_scale_domain:
|
|
5
|
+
color_scale_fn: (frac: number) => string;
|
|
6
|
+
color_scale_domain: Vec2;
|
|
10
7
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { get_d3_interpolator } from '../colors';
|
|
2
2
|
import { scaleSequential } from 'd3-scale';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// Resolve D3 interpolator with optional reverse for chempot color scales.
|
|
4
|
+
function get_chempot_interpolator(name, reverse) {
|
|
5
5
|
const raw = get_d3_interpolator(name);
|
|
6
|
-
return reverse ? (
|
|
6
|
+
return reverse ? (frac) => raw(1 - frac) : raw;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
// Build sequential color scale from values and D3 interpolator name.
|
|
9
9
|
export function make_chempot_color_scale(values, interpolator_name, reverse) {
|
|
10
10
|
const finite_values = values.filter(Number.isFinite);
|
|
11
11
|
if (finite_values.length === 0)
|
|
@@ -23,7 +23,7 @@ export function make_chempot_color_scale(values, interpolator_name, reverse) {
|
|
|
23
23
|
max_value,
|
|
24
24
|
]);
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
// Resolve color bar props for chempot diagrams (interpolator + domain).
|
|
27
27
|
export function get_chempot_color_bar_config(color_scale, reverse) {
|
|
28
28
|
return {
|
|
29
29
|
color_scale_fn: get_chempot_interpolator(color_scale, reverse),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PhaseData } from '../convex-hull/types';
|
|
2
|
+
import type { Vec2 } from '../math';
|
|
2
3
|
import { type ChemPotDiagramConfig, type ChemPotDiagramData } from './types';
|
|
3
4
|
export declare function get_energy_per_atom(entry: PhaseData): number;
|
|
4
5
|
export declare function formula_key_from_composition(composition: Record<string, number>): string;
|
|
@@ -6,14 +7,13 @@ export declare function get_min_entries_and_el_refs(entries: PhaseData[]): {
|
|
|
6
7
|
min_entries: PhaseData[];
|
|
7
8
|
el_refs: Record<string, PhaseData>;
|
|
8
9
|
};
|
|
9
|
-
export declare function compute_form_energy_per_atom(entry: PhaseData, el_refs: Record<string, PhaseData>): number;
|
|
10
10
|
export declare function best_form_energy_for_formula(entries: PhaseData[], formula: string, el_refs: Record<string, PhaseData>): number | undefined;
|
|
11
11
|
export declare const renormalize_entries: (entries: PhaseData[], el_refs: Record<string, PhaseData>, elements: string[]) => PhaseData[];
|
|
12
12
|
export declare function build_hyperplanes(min_entries: PhaseData[], el_refs: Record<string, PhaseData>, elements: string[]): {
|
|
13
13
|
hyperplanes: number[][];
|
|
14
14
|
hyperplane_entries: PhaseData[];
|
|
15
15
|
};
|
|
16
|
-
export declare function build_border_hyperplanes(lims: [
|
|
16
|
+
export declare function build_border_hyperplanes(lims: Vec2[]): number[][];
|
|
17
17
|
export declare function compute_domains(hyperplanes: number[][], border_hyperplanes: number[][], hyperplane_entries: PhaseData[], dim: number): Record<string, number[][]>;
|
|
18
18
|
export declare function apply_element_padding(domains: Record<string, number[][]>, elem_indices: number[], padding: number, default_min_limit: number): number[];
|
|
19
19
|
export declare function pad_domain_points(pts: number[][], elem_indices: number[], new_lims: number[], default_min_limit: number, padding: number): number[][];
|
|
@@ -26,7 +26,7 @@ export declare function simple_pca(data: number[][], k?: number): {
|
|
|
26
26
|
scores: number[][];
|
|
27
27
|
eigenvectors: number[][];
|
|
28
28
|
};
|
|
29
|
-
export declare function orthonormal_2d(line_pts: number[][]):
|
|
29
|
+
export declare function orthonormal_2d(line_pts: number[][]): Vec2;
|
|
30
30
|
export declare function dedup_points(pts: number[][], tol?: number): {
|
|
31
31
|
unique: number[][];
|
|
32
32
|
orig_indices: number[];
|
|
@@ -84,7 +84,9 @@ export function get_min_entries_and_el_refs(entries) {
|
|
|
84
84
|
return { min_entries, el_refs };
|
|
85
85
|
}
|
|
86
86
|
// Compute formation energy per atom against elemental references.
|
|
87
|
-
|
|
87
|
+
// NOTE: diverges from convex-hull's compute_e_form_per_atom (which returns null on
|
|
88
|
+
// missing refs); kept module-private so the divergent variant can't leak into public API.
|
|
89
|
+
function compute_form_energy_per_atom(entry, el_refs) {
|
|
88
90
|
const atom_count = count_atoms_in_composition(entry.composition);
|
|
89
91
|
const energy_per_atom = get_energy_per_atom(entry);
|
|
90
92
|
let ref_energy = 0;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ChemPotDiagramConfig } from './types';
|
|
2
|
+
export declare function create_chempot_overrides<Key extends keyof ChemPotDiagramConfig>(config: () => ChemPotDiagramConfig, keys: readonly Key[], custom_defaults?: {
|
|
3
|
+
[P in Key]?: NonNullable<ChemPotDiagramConfig[P]>;
|
|
4
|
+
}): {
|
|
5
|
+
resolve: <P extends Key>(key: P) => NonNullable<ChemPotDiagramConfig[P]>;
|
|
6
|
+
set: <P extends Key>(key: P, value: NonNullable<ChemPotDiagramConfig[P]>) => void;
|
|
7
|
+
reset: () => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const CHEMPOT_COLOR_MODE_OPTIONS: readonly [readonly ["none", "None"], readonly ["energy", "Energy/atom"], readonly ["formation_energy", "Formation energy"], readonly ["arity", "Element count"], readonly ["entries", "Entry count"]];
|
|
10
|
+
export declare const CHEMPOT_COLOR_SCALE_OPTIONS: readonly [readonly ["interpolateViridis", "Viridis"], readonly ["interpolatePlasma", "Plasma"], readonly ["interpolateInferno", "Inferno"], readonly ["interpolateMagma", "Magma"], readonly ["interpolateCividis", "Cividis"], readonly ["interpolateTurbo", "Turbo"], readonly ["interpolateRdYlBu", "RdYlBu"], readonly ["interpolateSpectral", "Spectral"]];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Override state + shared <option> lists for the ChemPotDiagram2D/3D control panes
|
|
2
|
+
import { CHEMPOT_DEFAULTS } from './types';
|
|
3
|
+
// Per-key user overrides with `override ?? config ?? default` resolution; `reset()`
|
|
4
|
+
// clears all overrides (the panes' "Reset defaults" buttons). Defaults come from
|
|
5
|
+
// CHEMPOT_DEFAULTS unless overridden via custom_defaults; keys without either throw upfront.
|
|
6
|
+
export function create_chempot_overrides(config, keys, custom_defaults = {}) {
|
|
7
|
+
const defaults = Object.fromEntries(keys.map((key) => {
|
|
8
|
+
const fallback = custom_defaults[key] ?? CHEMPOT_DEFAULTS[key];
|
|
9
|
+
if (fallback === undefined) {
|
|
10
|
+
throw new Error(`create_chempot_overrides: key '${key}' is missing from both custom_defaults and CHEMPOT_DEFAULTS`);
|
|
11
|
+
}
|
|
12
|
+
return [key, fallback];
|
|
13
|
+
}));
|
|
14
|
+
let overrides = $state({});
|
|
15
|
+
return {
|
|
16
|
+
resolve: (key) => overrides[key] ?? config()[key] ?? defaults[key],
|
|
17
|
+
set: (key, value) => {
|
|
18
|
+
overrides[key] = value;
|
|
19
|
+
},
|
|
20
|
+
reset: () => {
|
|
21
|
+
overrides = {};
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// [value, label] pairs for the color-mode and color-scale <select>s in both panes
|
|
26
|
+
export const CHEMPOT_COLOR_MODE_OPTIONS = [
|
|
27
|
+
[`none`, `None`],
|
|
28
|
+
[`energy`, `Energy/atom`],
|
|
29
|
+
[`formation_energy`, `Formation energy`],
|
|
30
|
+
[`arity`, `Element count`],
|
|
31
|
+
[`entries`, `Entry count`],
|
|
32
|
+
];
|
|
33
|
+
export const CHEMPOT_COLOR_SCALE_OPTIONS = [
|
|
34
|
+
[`interpolateViridis`, `Viridis`],
|
|
35
|
+
[`interpolatePlasma`, `Plasma`],
|
|
36
|
+
[`interpolateInferno`, `Inferno`],
|
|
37
|
+
[`interpolateMagma`, `Magma`],
|
|
38
|
+
[`interpolateCividis`, `Cividis`],
|
|
39
|
+
[`interpolateTurbo`, `Turbo`],
|
|
40
|
+
[`interpolateRdYlBu`, `RdYlBu`],
|
|
41
|
+
[`interpolateSpectral`, `Spectral`],
|
|
42
|
+
];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
export declare const get_json_string: (payload: unknown) => string;
|
|
3
|
+
export declare const export_json_file: (payload: unknown, basename: string) => void;
|
|
4
|
+
interface XYZ {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
z: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function get_view_settings(opts: {
|
|
10
|
+
elements: string[];
|
|
11
|
+
camera_projection: string;
|
|
12
|
+
auto_rotate: number;
|
|
13
|
+
color_mode: string;
|
|
14
|
+
color_scale: string;
|
|
15
|
+
reverse_color_scale: boolean;
|
|
16
|
+
camera_position?: XYZ | null;
|
|
17
|
+
camera_target?: XYZ | null;
|
|
18
|
+
}): Record<string, unknown>;
|
|
19
|
+
export declare const export_view_json_file: (view_settings: Record<string, unknown>, basename: string) => void;
|
|
20
|
+
export interface OverlayTextItem {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
text: string;
|
|
24
|
+
font: string;
|
|
25
|
+
font_size: string;
|
|
26
|
+
font_family: string;
|
|
27
|
+
font_weight: string;
|
|
28
|
+
color: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function get_overlay_text_items(wrapper: HTMLElement, canvas_rect: DOMRect): OverlayTextItem[];
|
|
31
|
+
export declare function export_png_file(wrapper: HTMLElement | undefined, basename: string, png_dpi: number): void;
|
|
32
|
+
export declare function export_svg_file(wrapper: HTMLElement | undefined, basename: string, view_settings: Record<string, unknown>): void;
|
|
33
|
+
export interface ChemPotGlbParts {
|
|
34
|
+
hull_geometry?: THREE.BufferGeometry | null;
|
|
35
|
+
hull_opacity?: number;
|
|
36
|
+
edge_geometry: THREE.BufferGeometry;
|
|
37
|
+
formula_meshes?: {
|
|
38
|
+
geometry: THREE.BufferGeometry;
|
|
39
|
+
color: string;
|
|
40
|
+
}[];
|
|
41
|
+
formula_edges?: {
|
|
42
|
+
geometry: THREE.BufferGeometry;
|
|
43
|
+
color: string;
|
|
44
|
+
}[];
|
|
45
|
+
}
|
|
46
|
+
export declare function export_glb_file(parts: ChemPotGlbParts, basename: string): void;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Export helpers for chemical potential diagrams (shared between 2D and 3D views).
|
|
2
|
+
import { dpi_to_scale } from '../io/export';
|
|
3
|
+
import { download } from '../io/fetch';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js';
|
|
6
|
+
export const get_json_string = (payload) => JSON.stringify(payload, null, 2);
|
|
7
|
+
const download_json = (payload, filename) => download(get_json_string(payload), filename, `application/json`);
|
|
8
|
+
export const export_json_file = (payload, basename) => download_json(payload, `${basename}.json`);
|
|
9
|
+
const xyz_tuple = (point) => point ? [point.x, point.y, point.z] : null;
|
|
10
|
+
const get_gl_canvas = (wrapper) => {
|
|
11
|
+
const canvas = wrapper?.querySelector(`canvas`);
|
|
12
|
+
return canvas instanceof HTMLCanvasElement ? canvas : null;
|
|
13
|
+
};
|
|
14
|
+
// Serializable snapshot of the current 3D view (embedded in SVG/JSON exports)
|
|
15
|
+
export function get_view_settings(opts) {
|
|
16
|
+
const { camera_position, camera_target, ...settings } = opts;
|
|
17
|
+
return {
|
|
18
|
+
...settings,
|
|
19
|
+
camera_position: xyz_tuple(camera_position),
|
|
20
|
+
camera_target: xyz_tuple(camera_target),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export const export_view_json_file = (view_settings, basename) => download_json(view_settings, `${basename}-view.json`);
|
|
24
|
+
// Collect HTML overlay text (tick/axis/domain labels) positioned relative to the canvas
|
|
25
|
+
export function get_overlay_text_items(wrapper, canvas_rect) {
|
|
26
|
+
const text_items = [];
|
|
27
|
+
for (const element of wrapper.querySelectorAll(`.tick-label, .axis-label, .domain-label`)) {
|
|
28
|
+
const html_element = element;
|
|
29
|
+
const style = getComputedStyle(html_element);
|
|
30
|
+
if (style.display === `none` || style.visibility === `hidden`)
|
|
31
|
+
continue;
|
|
32
|
+
const element_rect = html_element.getBoundingClientRect();
|
|
33
|
+
text_items.push({
|
|
34
|
+
x: element_rect.left + element_rect.width / 2 - canvas_rect.left,
|
|
35
|
+
y: element_rect.top + element_rect.height / 2 - canvas_rect.top,
|
|
36
|
+
text: html_element.textContent ?? ``,
|
|
37
|
+
font: style.font || `${style.fontSize} ${style.fontFamily}`,
|
|
38
|
+
font_size: style.fontSize || `11px`,
|
|
39
|
+
font_family: style.fontFamily || `sans-serif`,
|
|
40
|
+
font_weight: style.fontWeight || `400`,
|
|
41
|
+
color: style.color || `#333`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return text_items;
|
|
45
|
+
}
|
|
46
|
+
// Composite the WebGL canvas + HTML overlay labels into a single PNG download
|
|
47
|
+
export function export_png_file(wrapper, basename, png_dpi) {
|
|
48
|
+
const gl_canvas = get_gl_canvas(wrapper);
|
|
49
|
+
if (!gl_canvas || !wrapper)
|
|
50
|
+
return;
|
|
51
|
+
const rect = gl_canvas.getBoundingClientRect();
|
|
52
|
+
// A degenerate rect means the canvas is hidden/unrendered: nothing to capture
|
|
53
|
+
if (!(rect.width > 0) || !(rect.height > 0)) {
|
|
54
|
+
console.error(`Cannot export PNG: canvas has zero size (width=${rect.width}, height=${rect.height})`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const scale = dpi_to_scale(png_dpi);
|
|
58
|
+
const out = document.createElement(`canvas`);
|
|
59
|
+
// Floor at 1px so tiny rect x min-DPI rounding can't yield an invalid 0x0 canvas
|
|
60
|
+
out.width = Math.max(1, Math.round(rect.width * scale));
|
|
61
|
+
out.height = Math.max(1, Math.round(rect.height * scale));
|
|
62
|
+
const ctx = out.getContext(`2d`);
|
|
63
|
+
if (!ctx)
|
|
64
|
+
return;
|
|
65
|
+
ctx.scale(scale, scale);
|
|
66
|
+
ctx.drawImage(gl_canvas, 0, 0, rect.width, rect.height);
|
|
67
|
+
for (const text_item of get_overlay_text_items(wrapper, rect)) {
|
|
68
|
+
ctx.font = text_item.font;
|
|
69
|
+
ctx.fillStyle = text_item.color;
|
|
70
|
+
ctx.textAlign = `center`;
|
|
71
|
+
ctx.textBaseline = `middle`;
|
|
72
|
+
ctx.fillText(text_item.text, text_item.x, text_item.y);
|
|
73
|
+
}
|
|
74
|
+
out.toBlob((blob) => {
|
|
75
|
+
if (!blob)
|
|
76
|
+
return;
|
|
77
|
+
download(blob, `${basename}.png`, `image/png`);
|
|
78
|
+
}, `image/png`);
|
|
79
|
+
}
|
|
80
|
+
const xml_escape = (text) => text
|
|
81
|
+
.replaceAll(`&`, `&`)
|
|
82
|
+
.replaceAll(`<`, `<`)
|
|
83
|
+
.replaceAll(`>`, `>`)
|
|
84
|
+
.replaceAll(`"`, `"`)
|
|
85
|
+
.replaceAll(`'`, `'`);
|
|
86
|
+
// SVG snapshot: rasterized canvas as embedded image + overlay labels as real text nodes
|
|
87
|
+
export function export_svg_file(wrapper, basename, view_settings) {
|
|
88
|
+
const gl_canvas = get_gl_canvas(wrapper);
|
|
89
|
+
if (!gl_canvas || !wrapper)
|
|
90
|
+
return;
|
|
91
|
+
const canvas_rect = gl_canvas.getBoundingClientRect();
|
|
92
|
+
if (canvas_rect.width === 0 || canvas_rect.height === 0)
|
|
93
|
+
return;
|
|
94
|
+
const png_data_url = gl_canvas.toDataURL(`image/png`);
|
|
95
|
+
const text_nodes = get_overlay_text_items(wrapper, canvas_rect).map((text_item) => `<text x="${text_item.x.toFixed(2)}" y="${text_item.y.toFixed(2)}" text-anchor="middle" dominant-baseline="central" fill="${xml_escape(text_item.color)}" font-size="${xml_escape(text_item.font_size)}" font-family="${xml_escape(text_item.font_family)}" font-weight="${xml_escape(text_item.font_weight)}">${xml_escape(text_item.text)}</text>`);
|
|
96
|
+
const metadata = xml_escape(JSON.stringify(view_settings));
|
|
97
|
+
const svg = [
|
|
98
|
+
`<?xml version="1.0" encoding="UTF-8"?>`,
|
|
99
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${canvas_rect.width}" height="${canvas_rect.height}" viewBox="0 0 ${canvas_rect.width} ${canvas_rect.height}">`,
|
|
100
|
+
`<metadata>${metadata}</metadata>`,
|
|
101
|
+
`<image href="${png_data_url}" x="0" y="0" width="${canvas_rect.width}" height="${canvas_rect.height}" />`,
|
|
102
|
+
...text_nodes,
|
|
103
|
+
`</svg>`,
|
|
104
|
+
].join(``);
|
|
105
|
+
download(svg, `${basename}.svg`, `image/svg+xml`);
|
|
106
|
+
}
|
|
107
|
+
// Rebuild the scene from its geometries and export as binary GLTF
|
|
108
|
+
export function export_glb_file(parts, basename) {
|
|
109
|
+
const { hull_geometry, hull_opacity = 0.25, edge_geometry, formula_meshes = [], formula_edges = [], } = parts;
|
|
110
|
+
const gltf_exporter = new GLTFExporter();
|
|
111
|
+
const export_root = new THREE.Group();
|
|
112
|
+
const add_mesh = (geometry, material) => {
|
|
113
|
+
const opts = { transparent: true, side: THREE.DoubleSide, ...material };
|
|
114
|
+
export_root.add(new THREE.Mesh(geometry.clone(), new THREE.MeshBasicMaterial(opts)));
|
|
115
|
+
};
|
|
116
|
+
const add_lines = (geometry, color) => {
|
|
117
|
+
export_root.add(new THREE.LineSegments(geometry.clone(), new THREE.LineBasicMaterial({ color })));
|
|
118
|
+
};
|
|
119
|
+
if (hull_geometry)
|
|
120
|
+
add_mesh(hull_geometry, { vertexColors: true, opacity: hull_opacity });
|
|
121
|
+
add_lines(edge_geometry, 0x333333);
|
|
122
|
+
for (const { geometry, color } of formula_meshes) {
|
|
123
|
+
add_mesh(geometry, { color: new THREE.Color(color), opacity: 0.13 });
|
|
124
|
+
}
|
|
125
|
+
for (const { geometry, color } of formula_edges) {
|
|
126
|
+
add_lines(geometry, new THREE.Color(color));
|
|
127
|
+
}
|
|
128
|
+
gltf_exporter.parse(export_root, (result) => {
|
|
129
|
+
if (!(result instanceof ArrayBuffer))
|
|
130
|
+
return;
|
|
131
|
+
download(result, `${basename}.glb`, `model/gltf-binary`);
|
|
132
|
+
}, (err) => console.error(`Failed to export GLB:`, err), { binary: true, onlyVisible: false });
|
|
133
|
+
}
|
|
@@ -3,4 +3,5 @@ export { default as ChemPotDiagram2D } from './ChemPotDiagram2D.svelte';
|
|
|
3
3
|
export { default as ChemPotDiagram3D } from './ChemPotDiagram3D.svelte';
|
|
4
4
|
export { compute_chempot_async } from './async-compute.svelte';
|
|
5
5
|
export { compute_chempot_diagram, get_ternary_combinations } from './compute';
|
|
6
|
+
export * from './export';
|
|
6
7
|
export * from './types';
|
|
@@ -3,4 +3,5 @@ export { default as ChemPotDiagram2D } from './ChemPotDiagram2D.svelte';
|
|
|
3
3
|
export { default as ChemPotDiagram3D } from './ChemPotDiagram3D.svelte';
|
|
4
4
|
export { compute_chempot_async } from './async-compute.svelte';
|
|
5
5
|
export { compute_chempot_diagram, get_ternary_combinations } from './compute';
|
|
6
|
+
export * from './export';
|
|
6
7
|
export * from './types';
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export declare function get_pointer_coords(raw_event: unknown): {
|
|
2
|
-
clientX: number;
|
|
3
|
-
clientY: number;
|
|
4
|
-
} | null;
|
|
5
|
-
/** Convert pointer event to container-relative coords for tooltip placement. */
|
|
6
|
-
export declare function get_hover_pointer(raw_event: unknown, container_rect: DOMRect | null | undefined): {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
} | null;
|
|
10
|
-
/** Add hover pointer to an info object for tooltip placement. */
|
|
11
1
|
export declare function with_hover_pointer<T extends {
|
|
12
2
|
pointer?: {
|
|
13
3
|
x: number;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Handles DOM events and Threlte/Three.js event wrappers (nativeEvent, srcEvent).
|
|
3
3
|
const is_pointer_like_event = (event_val) => (typeof PointerEvent !== `undefined` && event_val instanceof PointerEvent) ||
|
|
4
4
|
(typeof MouseEvent !== `undefined` && event_val instanceof MouseEvent);
|
|
5
|
-
|
|
5
|
+
function get_pointer_coords(raw_event) {
|
|
6
6
|
if (is_pointer_like_event(raw_event)) {
|
|
7
7
|
return raw_event;
|
|
8
8
|
}
|
|
@@ -22,8 +22,8 @@ export function get_pointer_coords(raw_event) {
|
|
|
22
22
|
}
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
// Convert pointer event to container-relative coords for tooltip placement.
|
|
26
|
+
function get_hover_pointer(raw_event, container_rect) {
|
|
27
27
|
const pointer_event = get_pointer_coords(raw_event);
|
|
28
28
|
if (!pointer_event)
|
|
29
29
|
return null;
|
|
@@ -33,7 +33,7 @@ export function get_hover_pointer(raw_event, container_rect) {
|
|
|
33
33
|
const y = pointer_event.clientY - offset_y + 4;
|
|
34
34
|
return { x, y };
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
// Add hover pointer to an info object for tooltip placement.
|
|
37
37
|
export function with_hover_pointer(info, raw_event, container_rect) {
|
|
38
38
|
const pointer = get_hover_pointer(raw_event, container_rect);
|
|
39
39
|
return { ...info, pointer: pointer ?? undefined };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { D3InterpolateName } from '../colors';
|
|
2
2
|
import type { PhaseData } from '../convex-hull/types';
|
|
3
|
-
import type { Point2D } from '../math';
|
|
4
|
-
export type ChemPotLimits = Partial<Record<string,
|
|
3
|
+
import type { Point2D, Vec2 } from '../math';
|
|
4
|
+
export type ChemPotLimits = Partial<Record<string, Vec2>>;
|
|
5
5
|
export type ChemPotColorMode = `none` | `energy` | `formation_energy` | `arity` | `entries`;
|
|
6
6
|
export type ChemPotProjectionMode = `single` | `grid`;
|
|
7
7
|
export interface ChemPotDiagramConfig {
|
|
@@ -31,7 +31,7 @@ export interface ChemPotDiagramData {
|
|
|
31
31
|
min_entries: PhaseData[];
|
|
32
32
|
hyperplanes: number[][];
|
|
33
33
|
hyperplane_entries: PhaseData[];
|
|
34
|
-
lims: [
|
|
34
|
+
lims: Vec2[];
|
|
35
35
|
}
|
|
36
36
|
export interface ChemPotHoverInfoBase {
|
|
37
37
|
formula: string;
|
package/dist/colors/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as d3_sc from 'd3-scale-chromatic';
|
|
2
|
-
import type { Vec3 } from '../math';
|
|
3
|
-
import type { ELEM_SYMBOLS } from '../labels';
|
|
4
2
|
export type D3InterpolateName = keyof typeof d3_sc & `interpolate${string}`;
|
|
5
3
|
export type D3ColorSchemeName = D3InterpolateName extends `interpolate${infer Name}` ? Name : never;
|
|
6
4
|
export declare const get_d3_interpolator: (name: D3InterpolateName) => ((t: number) => string);
|
|
@@ -9,8 +7,6 @@ export type ColorScaleType = (typeof COLOR_SCALE_TYPES)[number];
|
|
|
9
7
|
export declare const DEFAULT_CATEGORY_COLORS: Record<string, string>;
|
|
10
8
|
export declare const AXIS_COLORS: readonly [readonly ["x", "#d75555", "#e66666"], readonly ["y", "#55b855", "#66c966"], readonly ["z", "#5555d7", "#6666e6"]];
|
|
11
9
|
export declare const NEG_AXIS_COLORS: readonly [readonly ["nx", "#b84444", "#cc5555"], readonly ["ny", "#44a044", "#55b155"], readonly ["nz", "#4444b8", "#5555c9"]];
|
|
12
|
-
export type RGBColor = Vec3;
|
|
13
|
-
export type ElementColorScheme = Record<(typeof ELEM_SYMBOLS)[number], RGBColor>;
|
|
14
10
|
export declare const vesta_hex: Record<string, string>;
|
|
15
11
|
export declare const jmol_hex: Record<string, string>;
|
|
16
12
|
export declare const alloy_hex: Record<string, string>;
|
package/dist/colors/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { color as d3_color, rgb } from 'd3-color';
|
|
2
2
|
import * as d3_sc from 'd3-scale-chromatic';
|
|
3
|
+
import { COLOR_THEMES, get_system_mode, get_theme_preference, is_valid_theme_name, resolve_theme_mode, THEME_STORAGE_KEY, THEME_TYPE, } from '../theme';
|
|
4
|
+
import { clamp01 } from '../utils';
|
|
3
5
|
import alloy_colors from './alloy-colors.json' with { type: 'json' };
|
|
4
6
|
import dark_mode_colors from './dark-mode-colors.json' with { type: 'json' };
|
|
5
7
|
import jmol_colors from './jmol-colors.json' with { type: 'json' };
|
|
@@ -79,19 +81,20 @@ export const PLOT_COLORS = [
|
|
|
79
81
|
];
|
|
80
82
|
// calculate human-perceived brightness from RGB color
|
|
81
83
|
export function luminance(clr) {
|
|
82
|
-
const { r, g, b } = rgb(clr);
|
|
83
|
-
return (0.299 *
|
|
84
|
+
const { r: red, g: green, b: blue } = rgb(clr);
|
|
85
|
+
return (0.299 * red + 0.587 * green + 0.114 * blue) / 255; // https://stackoverflow.com/a/596243
|
|
84
86
|
}
|
|
87
|
+
// CSS color string for a fully transparent background
|
|
88
|
+
const NO_BG = `rgba(0, 0, 0, 0)`;
|
|
85
89
|
// get background color of passed DOM node, or recurse up the DOM tree if current node is transparent
|
|
86
90
|
export function get_bg_color(elem, bg_color = null) {
|
|
87
91
|
if (bg_color)
|
|
88
92
|
return bg_color;
|
|
89
93
|
// recurse up the DOM tree to find the first non-transparent background color
|
|
90
|
-
const transparent = `rgba(0, 0, 0, 0)`;
|
|
91
94
|
if (!elem)
|
|
92
|
-
return
|
|
95
|
+
return NO_BG; // if no DOM node, return transparent
|
|
93
96
|
const bg = getComputedStyle(elem).backgroundColor; // get node background color
|
|
94
|
-
if (bg !==
|
|
97
|
+
if (bg !== NO_BG)
|
|
95
98
|
return bg; // if not transparent, return it
|
|
96
99
|
return get_bg_color(elem.parentElement); // otherwise recurse up the DOM tree
|
|
97
100
|
}
|
|
@@ -104,7 +107,7 @@ export function pick_contrast_color(options = {}) {
|
|
|
104
107
|
export const contrast_color = (options = {}) => (node) => {
|
|
105
108
|
node.style.color = pick_contrast_color({ ...options, bg_color: get_bg_color(node) });
|
|
106
109
|
};
|
|
107
|
-
const is_valid_bg = (bg) => bg !== `` && bg !==
|
|
110
|
+
const is_valid_bg = (bg) => bg !== `` && bg !== NO_BG && bg !== `transparent`;
|
|
108
111
|
// Detect and return the page background color from html/body elements or user preferences
|
|
109
112
|
export function get_page_background(fallback_dark = `#1a1a1a`, fallback_light = `#ffffff`) {
|
|
110
113
|
if (typeof window === `undefined`)
|
|
@@ -119,25 +122,21 @@ export function get_page_background(fallback_dark = `#1a1a1a`, fallback_light =
|
|
|
119
122
|
if (is_valid_bg(html_bg))
|
|
120
123
|
return html_bg;
|
|
121
124
|
// Fall back to prefers-color-scheme
|
|
122
|
-
const prefers_dark = globalThis.matchMedia(`(prefers-color-scheme: dark)`)
|
|
125
|
+
const prefers_dark = globalThis.matchMedia?.(`(prefers-color-scheme: dark)`)?.matches;
|
|
123
126
|
return prefers_dark ? fallback_dark : fallback_light;
|
|
124
127
|
}
|
|
125
|
-
// Detect dark mode: checks data-theme attribute,
|
|
128
|
+
// Detect dark mode: checks data-theme attribute, then the persisted theme
|
|
129
|
+
// preference (resolving `auto` against the OS), then falls back to OS preference.
|
|
126
130
|
export function is_dark_mode() {
|
|
127
131
|
if (typeof document === `undefined`)
|
|
128
132
|
return false;
|
|
133
|
+
// Prefer the resolved theme name on data-theme (light/dark/white/black), else
|
|
134
|
+
// fall back to the persisted preference (resolving `auto` against the OS)
|
|
129
135
|
const data_theme = document.documentElement.dataset.theme;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (stored === `dark` || stored === `light`)
|
|
135
|
-
return stored === `dark`;
|
|
136
|
-
}
|
|
137
|
-
catch {
|
|
138
|
-
/* localStorage throws in private browsing mode */
|
|
139
|
-
}
|
|
140
|
-
return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches ?? false;
|
|
136
|
+
const theme_name = data_theme && is_valid_theme_name(data_theme)
|
|
137
|
+
? data_theme
|
|
138
|
+
: resolve_theme_mode(get_theme_preference(), get_system_mode());
|
|
139
|
+
return THEME_TYPE[theme_name] === COLOR_THEMES.dark;
|
|
141
140
|
}
|
|
142
141
|
// Watch for dark mode changes and call callback on each change. Returns cleanup function.
|
|
143
142
|
export function watch_dark_mode(on_change) {
|
|
@@ -149,8 +148,8 @@ export function watch_dark_mode(on_change) {
|
|
|
149
148
|
attributes: true,
|
|
150
149
|
attributeFilter: [`data-theme`],
|
|
151
150
|
});
|
|
152
|
-
const on_storage = (
|
|
153
|
-
if (
|
|
151
|
+
const on_storage = (event) => {
|
|
152
|
+
if (event.key === THEME_STORAGE_KEY)
|
|
154
153
|
notify();
|
|
155
154
|
};
|
|
156
155
|
globalThis.addEventListener(`storage`, on_storage);
|
|
@@ -178,7 +177,7 @@ export function css_color_to_hex(color, fallback) {
|
|
|
178
177
|
// Returns the color in rgba() format, or the original color if format is unsupported.
|
|
179
178
|
export function add_alpha(color, alpha) {
|
|
180
179
|
// Clamp alpha to valid CSS range [0, 1]
|
|
181
|
-
const clamped_alpha =
|
|
180
|
+
const clamped_alpha = clamp01(alpha);
|
|
182
181
|
// Handle hex colors (#rgb, #rgba, #rrggbb, #rrggbbaa)
|
|
183
182
|
if (color.startsWith(`#`)) {
|
|
184
183
|
const hex = color.slice(1);
|