matterviz 0.3.2 → 0.3.3
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 -2
- package/dist/FilePicker.svelte +123 -82
- package/dist/Icon.svelte +18 -12
- package/dist/MillerIndexInput.svelte +27 -21
- package/dist/api/optimade.js +6 -6
- package/dist/app.css +216 -207
- package/dist/brillouin/BrillouinZone.svelte +292 -149
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
- package/dist/brillouin/BrillouinZoneExportPane.svelte +69 -42
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
- package/dist/brillouin/BrillouinZoneScene.svelte +275 -163
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneTooltip.svelte +17 -7
- package/dist/brillouin/compute.js +11 -6
- package/dist/chempot-diagram/ChemPotDiagram.svelte +162 -27
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +451 -281
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +2148 -1642
- package/dist/chempot-diagram/ChemPotScene3D.svelte +8 -5
- package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
- package/dist/chempot-diagram/async-compute.svelte.js +77 -0
- package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
- package/dist/chempot-diagram/chempot-worker.js +11 -0
- package/dist/chempot-diagram/color.js +1 -2
- package/dist/chempot-diagram/compute.d.ts +10 -0
- package/dist/chempot-diagram/compute.js +250 -88
- package/dist/chempot-diagram/index.d.ts +2 -1
- package/dist/chempot-diagram/index.js +2 -1
- package/dist/chempot-diagram/temperature.js +8 -9
- package/dist/chempot-diagram/types.d.ts +3 -0
- package/dist/chempot-diagram/types.js +1 -0
- package/dist/colors/index.d.ts +1 -1
- package/dist/colors/index.js +5 -3
- package/dist/composition/BarChart.svelte +128 -55
- package/dist/composition/BubbleChart.svelte +102 -49
- package/dist/composition/Composition.svelte +100 -79
- package/dist/composition/Formula.svelte +108 -62
- package/dist/composition/FormulaFilter.svelte +665 -537
- package/dist/composition/PieChart.svelte +183 -108
- package/dist/composition/format.d.ts +5 -0
- package/dist/composition/format.js +20 -3
- package/dist/composition/parse.js +14 -9
- package/dist/convex-hull/ConvexHull.svelte +93 -40
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +549 -360
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +1296 -827
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +1004 -688
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullControls.svelte +115 -28
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
- package/dist/convex-hull/ConvexHullStats.svelte +425 -328
- package/dist/convex-hull/ConvexHullTooltip.svelte +40 -16
- package/dist/convex-hull/GasPressureControls.svelte +104 -61
- package/dist/convex-hull/StructurePopup.svelte +25 -4
- package/dist/convex-hull/TemperatureSlider.svelte +45 -25
- package/dist/convex-hull/barycentric-coords.js +13 -7
- package/dist/convex-hull/demo-temperature.js +8 -4
- package/dist/convex-hull/gas-thermodynamics.js +17 -12
- package/dist/convex-hull/helpers.d.ts +9 -0
- package/dist/convex-hull/helpers.js +77 -34
- package/dist/convex-hull/thermodynamics.js +61 -56
- package/dist/convex-hull/types.d.ts +9 -14
- package/dist/convex-hull/types.js +0 -17
- package/dist/coordination/CoordinationBarPlot.svelte +227 -154
- package/dist/element/BohrAtom.svelte +55 -12
- package/dist/element/ElementHeading.svelte +7 -2
- package/dist/element/ElementPhoto.svelte +15 -9
- package/dist/element/ElementStats.svelte +10 -4
- package/dist/element/ElementTile.svelte +137 -73
- package/dist/element/Nucleus.svelte +39 -11
- package/dist/feedback/ClickFeedback.svelte +16 -5
- package/dist/feedback/DragOverlay.svelte +10 -2
- package/dist/feedback/Spinner.svelte +4 -2
- package/dist/feedback/StatusMessage.svelte +8 -2
- package/dist/fermi-surface/FermiSlice.svelte +118 -88
- package/dist/fermi-surface/FermiSurface.svelte +328 -187
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +535 -342
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
- package/dist/fermi-surface/compute.js +16 -20
- package/dist/fermi-surface/parse.js +24 -14
- package/dist/fermi-surface/symmetry.js +2 -7
- package/dist/fermi-surface/types.d.ts +3 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1019 -765
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +1 -1
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +76 -22
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +2 -3
- package/dist/icons.js +47 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.d.ts +3 -0
- package/dist/io/export.js +129 -143
- package/dist/io/is-binary.js +2 -3
- package/dist/io/url-drop.js +1 -2
- package/dist/isosurface/Isosurface.svelte +202 -148
- package/dist/isosurface/IsosurfaceControls.svelte +46 -28
- package/dist/isosurface/parse.js +34 -29
- package/dist/isosurface/slice.js +5 -10
- package/dist/isosurface/types.d.ts +2 -1
- package/dist/isosurface/types.js +61 -12
- package/dist/labels.js +11 -8
- package/dist/layout/FullscreenToggle.svelte +11 -2
- package/dist/layout/InfoCard.svelte +38 -6
- package/dist/layout/InfoTag.svelte +63 -32
- package/dist/layout/PropertyFilter.svelte +82 -37
- package/dist/layout/SettingsSection.svelte +85 -55
- package/dist/layout/SubpageGrid.svelte +10 -2
- package/dist/layout/json-tree/JsonNode.svelte +183 -138
- package/dist/layout/json-tree/JsonTree.svelte +499 -413
- package/dist/layout/json-tree/JsonValue.svelte +127 -99
- package/dist/layout/json-tree/utils.js +4 -2
- package/dist/marching-cubes.js +25 -2
- package/dist/math.d.ts +13 -17
- package/dist/math.js +133 -67
- package/dist/overlays/ContextMenu.svelte +65 -40
- package/dist/overlays/DraggablePane.svelte +211 -139
- package/dist/periodic-table/PeriodicTable.svelte +278 -145
- package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
- package/dist/periodic-table/PropertySelect.svelte +25 -7
- package/dist/periodic-table/TableInset.svelte +8 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +446 -309
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramControls.svelte +102 -43
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +63 -40
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +71 -28
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +158 -101
- package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
- package/dist/phase-diagram/build-diagram.js +9 -9
- package/dist/phase-diagram/colors.js +1 -3
- package/dist/phase-diagram/parse.js +10 -9
- package/dist/phase-diagram/svg-to-diagram.js +53 -49
- package/dist/phase-diagram/utils.d.ts +1 -0
- package/dist/phase-diagram/utils.js +80 -25
- package/dist/plot/AxisLabel.svelte +28 -3
- package/dist/plot/BarPlot.svelte +1182 -734
- package/dist/plot/BarPlot.svelte.d.ts +2 -2
- package/dist/plot/BarPlotControls.svelte +31 -5
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +479 -329
- package/dist/plot/ColorScaleSelect.svelte +27 -6
- package/dist/plot/ElementScatter.svelte +36 -15
- package/dist/plot/FillArea.svelte +152 -95
- package/dist/plot/Histogram.svelte +934 -571
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +53 -9
- package/dist/plot/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/InteractiveAxisLabel.svelte +34 -11
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/Line.svelte +63 -28
- package/dist/plot/PlotControls.svelte +157 -114
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +174 -91
- package/dist/plot/PlotTooltip.svelte +45 -6
- package/dist/plot/PortalSelect.svelte +175 -147
- package/dist/plot/ReferenceLine.svelte +76 -22
- package/dist/plot/ReferenceLine3D.svelte +132 -107
- package/dist/plot/ReferencePlane.svelte +146 -121
- package/dist/plot/ScatterPlot.svelte +1681 -1091
- package/dist/plot/ScatterPlot.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3D.svelte +256 -131
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +113 -63
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot3DScene.svelte +608 -403
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +65 -25
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ScatterPoint.svelte +98 -26
- package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
- package/dist/plot/SpacegroupBarPlot.svelte +142 -85
- package/dist/plot/Surface3D.svelte +159 -108
- package/dist/plot/ZeroLines.svelte +55 -3
- package/dist/plot/ZoomRect.svelte +4 -2
- package/dist/plot/axis-utils.js +1 -3
- package/dist/plot/data-cleaning.js +12 -28
- package/dist/plot/data-transform.js +2 -1
- package/dist/plot/fill-utils.js +2 -0
- package/dist/plot/layout.d.ts +4 -1
- package/dist/plot/layout.js +33 -14
- package/dist/plot/reference-line.d.ts +2 -2
- package/dist/plot/reference-line.js +7 -5
- package/dist/plot/scales.js +24 -36
- package/dist/plot/types.d.ts +11 -23
- package/dist/plot/types.js +6 -11
- package/dist/plot/utils/label-placement.d.ts +32 -15
- package/dist/plot/utils/label-placement.js +227 -66
- package/dist/plot/utils/series-visibility.js +2 -3
- package/dist/rdf/RdfPlot.svelte +143 -91
- package/dist/rdf/calc-rdf.js +4 -5
- package/dist/sanitize.d.ts +4 -0
- package/dist/sanitize.js +107 -0
- package/dist/settings.d.ts +18 -6
- package/dist/settings.js +46 -16
- package/dist/spectral/Bands.svelte +632 -453
- package/dist/spectral/BandsAndDos.svelte +90 -49
- package/dist/spectral/BrillouinBandsDos.svelte +151 -93
- package/dist/spectral/Dos.svelte +389 -258
- package/dist/spectral/helpers.js +55 -43
- package/dist/state.svelte.d.ts +1 -1
- package/dist/state.svelte.js +3 -2
- package/dist/structure/Arrow.svelte +59 -20
- package/dist/structure/AtomLegend.svelte +215 -134
- package/dist/structure/Bond.svelte +73 -47
- package/dist/structure/CanvasTooltip.svelte +10 -2
- package/dist/structure/CellSelect.svelte +72 -45
- package/dist/structure/Cylinder.svelte +33 -17
- package/dist/structure/Lattice.svelte +88 -33
- package/dist/structure/Structure.svelte +1063 -797
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureControls.svelte +349 -118
- package/dist/structure/StructureExportPane.svelte +124 -89
- package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +304 -237
- package/dist/structure/StructureScene.svelte +879 -443
- package/dist/structure/StructureScene.svelte.d.ts +15 -7
- package/dist/structure/atom-properties.js +8 -8
- package/dist/structure/bonding.js +6 -7
- package/dist/structure/export.js +14 -29
- package/dist/structure/ferrox-wasm.js +1 -1
- package/dist/structure/index.d.ts +13 -3
- package/dist/structure/index.js +83 -23
- package/dist/structure/measure.d.ts +2 -2
- package/dist/structure/measure.js +4 -44
- package/dist/structure/parse.js +113 -141
- package/dist/structure/partial-occupancy.js +7 -10
- package/dist/structure/pbc.d.ts +1 -0
- package/dist/structure/pbc.js +16 -6
- package/dist/structure/supercell.d.ts +2 -2
- package/dist/structure/supercell.js +12 -22
- package/dist/structure/validation.js +1 -2
- package/dist/symmetry/SymmetryStats.svelte +84 -41
- package/dist/symmetry/WyckoffTable.svelte +26 -6
- package/dist/symmetry/cell-transform.js +5 -3
- package/dist/symmetry/index.js +8 -7
- package/dist/symmetry/spacegroups.js +148 -148
- package/dist/table/HeatmapTable.svelte +790 -554
- package/dist/table/HeatmapTable.svelte.d.ts +1 -1
- package/dist/table/ToggleMenu.svelte +125 -92
- package/dist/table/index.js +2 -4
- package/dist/theme/ThemeControl.svelte +21 -12
- package/dist/time.js +4 -1
- package/dist/tooltip/TooltipContent.svelte +33 -8
- package/dist/trajectory/Trajectory.svelte +758 -558
- package/dist/trajectory/TrajectoryError.svelte +14 -3
- package/dist/trajectory/TrajectoryExportPane.svelte +137 -83
- package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
- package/dist/trajectory/extract.js +10 -26
- package/dist/trajectory/format-detect.js +5 -5
- package/dist/trajectory/frame-reader.d.ts +1 -1
- package/dist/trajectory/frame-reader.js +5 -12
- package/dist/trajectory/helpers.d.ts +0 -1
- package/dist/trajectory/helpers.js +2 -17
- package/dist/trajectory/index.js +14 -12
- package/dist/trajectory/parse/ase.js +5 -4
- package/dist/trajectory/parse/hdf5.js +26 -18
- package/dist/trajectory/parse/index.js +13 -18
- package/dist/trajectory/parse/lammps.js +17 -7
- package/dist/trajectory/parse/vasp.js +5 -2
- package/dist/trajectory/parse/xyz.js +8 -7
- package/dist/trajectory/plotting.js +13 -8
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +13 -0
- package/dist/xrd/XrdPlot.svelte +337 -247
- package/dist/xrd/broadening.js +14 -9
- package/dist/xrd/calc-xrd.js +12 -18
- package/dist/xrd/parse.d.ts +1 -1
- package/dist/xrd/parse.js +17 -17
- package/package.json +99 -103
- package/readme.md +1 -1
- /package/dist/theme/{themes.js → themes.mjs} +0 -0
|
@@ -1,116 +1,144 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, tick } from 'svelte'
|
|
3
|
+
import type { JsonTreeContext, JsonValueType } from './types'
|
|
4
|
+
import { JSON_TREE_CONTEXT_KEY } from './types'
|
|
5
|
+
import {
|
|
6
|
+
format_preview,
|
|
7
|
+
is_css_color,
|
|
8
|
+
is_url,
|
|
9
|
+
parse_edited_value,
|
|
10
|
+
values_equal,
|
|
11
|
+
} from './utils'
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
value,
|
|
15
|
+
value_type,
|
|
16
|
+
path,
|
|
17
|
+
}: {
|
|
18
|
+
value: unknown
|
|
19
|
+
value_type: JsonValueType
|
|
20
|
+
path: string
|
|
21
|
+
} = $props()
|
|
22
|
+
|
|
23
|
+
const ctx = getContext<JsonTreeContext>(JSON_TREE_CONTEXT_KEY)
|
|
24
|
+
|
|
25
|
+
// Track if value just changed for animation
|
|
26
|
+
let just_changed = $state(false)
|
|
27
|
+
let change_timeout: ReturnType<typeof setTimeout> | undefined
|
|
28
|
+
|
|
29
|
+
// Expanded state for long strings
|
|
30
|
+
let is_expanded = $state(false)
|
|
31
|
+
|
|
32
|
+
// Extract max_string_length threshold for reuse
|
|
33
|
+
let max_len = $derived(ctx?.settings.max_string_length ?? 200)
|
|
34
|
+
let is_long_string = $derived(
|
|
35
|
+
value_type === `string` && (value as string).length > max_len,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
// Check for changes on mount and when value changes
|
|
39
|
+
$effect(() => {
|
|
40
|
+
if (!ctx?.settings.highlight_changes) return
|
|
41
|
+
|
|
42
|
+
const prev = ctx.previous_values.get(path)
|
|
19
43
|
if (prev !== undefined && !values_equal(prev, value)) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, 1000);
|
|
44
|
+
just_changed = true
|
|
45
|
+
if (change_timeout) clearTimeout(change_timeout)
|
|
46
|
+
change_timeout = setTimeout(() => {
|
|
47
|
+
just_changed = false
|
|
48
|
+
}, 1000)
|
|
26
49
|
}
|
|
27
|
-
ctx.previous_values.set(path, value)
|
|
50
|
+
ctx.previous_values.set(path, value)
|
|
51
|
+
|
|
28
52
|
return () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// Trimmed string for URL/color detection (avoids using raw whitespace in href/style)
|
|
34
|
-
let trimmed_str = $derived(value_type === `string` ? value.trim() : ``)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
53
|
+
if (change_timeout) clearTimeout(change_timeout)
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
// Trimmed string for URL/color detection (avoids using raw whitespace in href/style)
|
|
58
|
+
let trimmed_str = $derived(value_type === `string` ? (value as string).trim() : ``)
|
|
59
|
+
|
|
60
|
+
// Auto-detect URLs in string values
|
|
61
|
+
let url_detected = $derived(value_type === `string` && is_url(trimmed_str))
|
|
62
|
+
|
|
63
|
+
// Auto-detect CSS colors in string values
|
|
64
|
+
let color_detected = $derived(
|
|
65
|
+
value_type === `string` && is_css_color(trimmed_str) ? trimmed_str : null,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
// Handle click to copy (delayed to avoid firing on double-click-to-edit)
|
|
69
|
+
let click_timer: ReturnType<typeof setTimeout> | undefined
|
|
70
|
+
$effect(() => () => {
|
|
71
|
+
if (click_timer) clearTimeout(click_timer)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
async function handle_click(event: MouseEvent) {
|
|
75
|
+
event.stopPropagation()
|
|
76
|
+
if (!ctx) return
|
|
49
77
|
// When editable, delay copy so double-click can cancel it
|
|
50
78
|
if (ctx.settings.editable && ctx.onchange) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
79
|
+
if (click_timer) clearTimeout(click_timer)
|
|
80
|
+
const copy_pos = { clientX: event.clientX, clientY: event.clientY }
|
|
81
|
+
click_timer = setTimeout(() => ctx.copy_value(path, value, copy_pos), 250)
|
|
82
|
+
} else {
|
|
83
|
+
await ctx.copy_value(path, value, event)
|
|
55
84
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
let display_value = $derived.by(() => {
|
|
62
|
-
if (value_type === `circular`)
|
|
63
|
-
return `[Circular]`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Format display value - strings use custom truncation, others use format_preview
|
|
88
|
+
let display_value = $derived.by(() => {
|
|
89
|
+
if (value_type === `circular`) return `[Circular]`
|
|
64
90
|
if (value_type === `string`) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
91
|
+
const str = value as string
|
|
92
|
+
return is_long_string && !is_expanded
|
|
93
|
+
? `"${str.slice(0, max_len)}..."`
|
|
94
|
+
: `"${str}"`
|
|
69
95
|
}
|
|
70
|
-
return format_preview(value)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
96
|
+
return format_preview(value)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
// Check if string is truncated
|
|
100
|
+
let is_truncated = $derived(is_long_string && !is_expanded)
|
|
101
|
+
|
|
102
|
+
// Toggle string expansion
|
|
103
|
+
function toggle_expand(event: MouseEvent) {
|
|
104
|
+
event.stopPropagation()
|
|
105
|
+
is_expanded = !is_expanded
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// === Inline Editing ===
|
|
109
|
+
let editing = $state(false)
|
|
110
|
+
let edit_text = $state(``)
|
|
111
|
+
let edit_input = $state<HTMLInputElement | null>(null)
|
|
112
|
+
|
|
113
|
+
function start_edit(event: MouseEvent) {
|
|
114
|
+
if (!ctx?.settings.editable || !ctx.onchange) return
|
|
115
|
+
event.stopPropagation()
|
|
87
116
|
// Cancel pending click-to-copy
|
|
88
|
-
if (click_timer)
|
|
89
|
-
clearTimeout(click_timer);
|
|
117
|
+
if (click_timer) clearTimeout(click_timer)
|
|
90
118
|
// Pre-fill with raw value (strings without quotes)
|
|
91
|
-
edit_text = value_type === `string` ? value : String(value)
|
|
92
|
-
editing = true
|
|
93
|
-
tick().then(() => edit_input?.select())
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
editing = false
|
|
99
|
-
const new_value = parse_edited_value(edit_text)
|
|
119
|
+
edit_text = value_type === `string` ? (value as string) : String(value)
|
|
120
|
+
editing = true
|
|
121
|
+
tick().then(() => edit_input?.select())
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function commit_edit() {
|
|
125
|
+
if (!editing) return
|
|
126
|
+
editing = false
|
|
127
|
+
const new_value = parse_edited_value(edit_text)
|
|
100
128
|
if (!values_equal(new_value, value)) {
|
|
101
|
-
|
|
129
|
+
ctx?.onchange?.(path, new_value, value)
|
|
102
130
|
}
|
|
103
|
-
}
|
|
104
|
-
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function handle_edit_keydown(event: KeyboardEvent) {
|
|
105
134
|
if (event.key === `Enter`) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
editing = false;
|
|
135
|
+
event.preventDefault()
|
|
136
|
+
commit_edit()
|
|
137
|
+
} else if (event.key === `Escape`) {
|
|
138
|
+
event.preventDefault()
|
|
139
|
+
editing = false
|
|
112
140
|
}
|
|
113
|
-
}
|
|
141
|
+
}
|
|
114
142
|
</script>
|
|
115
143
|
|
|
116
144
|
{#if editing}
|
|
@@ -540,8 +540,10 @@ export function compute_diff(old_val, new_val, current_path = ``, result = new M
|
|
|
540
540
|
}
|
|
541
541
|
// Both primitive: compare values (with NaN === NaN special case)
|
|
542
542
|
if (is_primitive_type(old_type)) {
|
|
543
|
-
const both_nan = typeof old_val === `number` &&
|
|
544
|
-
|
|
543
|
+
const both_nan = typeof old_val === `number` &&
|
|
544
|
+
typeof new_val === `number` &&
|
|
545
|
+
Number.isNaN(old_val) &&
|
|
546
|
+
Number.isNaN(new_val);
|
|
545
547
|
if (!both_nan && old_val !== new_val) {
|
|
546
548
|
result.set(current_path, {
|
|
547
549
|
status: `changed`,
|
package/dist/marching-cubes.js
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
// Edge table: for each cube configuration (256 cases), which edges are intersected
|
|
2
2
|
// Each bit indicates whether that edge has an intersection
|
|
3
|
-
//
|
|
4
|
-
const EDGE_TABLE = [
|
|
3
|
+
// oxfmt-ignore
|
|
4
|
+
const EDGE_TABLE = [
|
|
5
|
+
0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a,
|
|
6
|
+
0xd03, 0xe09, 0xf00, 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c,
|
|
7
|
+
0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, 0x230, 0x339, 0x33, 0x13a, 0x636,
|
|
8
|
+
0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, 0x3a0,
|
|
9
|
+
0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa,
|
|
10
|
+
0xea3, 0xda9, 0xca0, 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c, 0xc6c,
|
|
11
|
+
0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6,
|
|
12
|
+
0xff, 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, 0x650,
|
|
13
|
+
0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a,
|
|
14
|
+
0xb53, 0x859, 0x950, 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc, 0xfcc,
|
|
15
|
+
0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6,
|
|
16
|
+
0xdcf, 0xec5, 0xfcc, 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, 0x950,
|
|
17
|
+
0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55, 0x35f, 0x256, 0x55a,
|
|
18
|
+
0x453, 0x759, 0x650, 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc,
|
|
19
|
+
0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, 0xb60, 0xa69, 0x963, 0x86a, 0xf66,
|
|
20
|
+
0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460, 0xca0,
|
|
21
|
+
0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa,
|
|
22
|
+
0x1a3, 0x2a9, 0x3a0, 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c,
|
|
23
|
+
0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230, 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96,
|
|
24
|
+
0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190, 0xf00,
|
|
25
|
+
0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a,
|
|
26
|
+
0x203, 0x109, 0x0,
|
|
27
|
+
];
|
|
5
28
|
// Triangle table: for each cube configuration, list of edge triplets forming triangles
|
|
6
29
|
// -1 marks the end of the triangle list for that configuration
|
|
7
30
|
const TRI_TABLE = [
|
package/dist/math.d.ts
CHANGED
|
@@ -2,17 +2,7 @@ import type { LatticeParams, Pbc } from './structure/index';
|
|
|
2
2
|
export type Vec2 = [number, number];
|
|
3
3
|
export type Vec3 = [number, number, number];
|
|
4
4
|
export type Vec4 = [number, number, number, number];
|
|
5
|
-
export type Vec9 = [
|
|
6
|
-
number,
|
|
7
|
-
number,
|
|
8
|
-
number,
|
|
9
|
-
number,
|
|
10
|
-
number,
|
|
11
|
-
number,
|
|
12
|
-
number,
|
|
13
|
-
number,
|
|
14
|
-
number
|
|
15
|
-
];
|
|
5
|
+
export type Vec9 = [number, number, number, number, number, number, number, number, number];
|
|
16
6
|
export type Matrix3x3 = [Vec3, Vec3, Vec3];
|
|
17
7
|
export type Matrix4x4 = [Vec4, Vec4, Vec4, Vec4];
|
|
18
8
|
export type NdVector = number[];
|
|
@@ -46,23 +36,29 @@ export declare function calc_lattice_params(matrix: Matrix3x3): LatticeParams &
|
|
|
46
36
|
};
|
|
47
37
|
export declare const scale: <T extends NdVector>(vec: T, factor: number) => T;
|
|
48
38
|
export declare const euclidean_dist: (vec1: NdVector, vec2: NdVector) => number;
|
|
49
|
-
export declare function
|
|
50
|
-
pos2: Vec3,
|
|
51
|
-
lattice_matrix: Matrix3x3, // 3x3 lattice matrix where each row is a lattice vector
|
|
52
|
-
lattice_inv?: Matrix3x3, // Optional pre-computed inverse matrix for optimization (since lattice is usually constant and repeatedly inverting matrix is expensive)
|
|
53
|
-
pbc?: Pbc): number;
|
|
39
|
+
export declare function min_image_displacement(from: Vec3, to: Vec3, lattice_matrix: Matrix3x3, converters?: LatticeConverters, pbc?: Pbc): Vec3;
|
|
40
|
+
export declare function pbc_dist(pos1: Vec3, pos2: Vec3, lattice_matrix: Matrix3x3, converters?: LatticeConverters, pbc?: Pbc): number;
|
|
54
41
|
export declare function matrix_inverse_3x3(matrix: Matrix3x3): Matrix3x3;
|
|
55
42
|
export declare function mat3x3_vec3_multiply(matrix: Matrix3x3, vector: Vec3): Vec3;
|
|
56
43
|
export declare function add<T extends NdVector>(...vecs: T[]): T;
|
|
57
44
|
export declare function subtract<T extends NdVector>(vec1: T, vec2: T): T;
|
|
58
|
-
export declare function dot(vec1: NdVector
|
|
45
|
+
export declare function dot(vec1: NdVector, vec2: NdVector): number;
|
|
46
|
+
export declare function dot(vec1: NdVector[], vec2: NdVector): number[];
|
|
47
|
+
export declare function dot(vec1: NdVector[], vec2: NdVector[]): number[][];
|
|
59
48
|
export declare function to_voigt(tensor: number[][]): number[];
|
|
60
49
|
export declare function from_voigt(voigt: number[]): number[][];
|
|
61
50
|
export declare function vec9_to_mat3x3(flat_array: number[]): number[][];
|
|
62
51
|
export declare function tensor_to_flat_array(tensor: number[][]): number[];
|
|
63
52
|
export declare const transpose_3x3_matrix: (matrix: Matrix3x3) => Matrix3x3;
|
|
53
|
+
export declare function scale_lattice_matrix(orig_matrix: Matrix3x3, scaling_factors: Vec3): Matrix3x3;
|
|
64
54
|
export declare const create_frac_to_cart: (lattice: Matrix3x3) => (frac: Vec3) => Vec3;
|
|
65
55
|
export declare const create_cart_to_frac: (lattice: Matrix3x3) => (cart: Vec3) => Vec3;
|
|
56
|
+
export type LatticeConverters = {
|
|
57
|
+
cart_to_frac: (v: Vec3) => Vec3;
|
|
58
|
+
frac_to_cart: (v: Vec3) => Vec3;
|
|
59
|
+
reciprocal_axis_norms: Vec3;
|
|
60
|
+
};
|
|
61
|
+
export declare const create_lattice_converters: (lattice: Matrix3x3) => LatticeConverters;
|
|
66
62
|
export declare function cell_to_lattice_matrix(a: number, b: number, c: number, alpha: number, beta: number, gamma: number): Matrix3x3;
|
|
67
63
|
export declare function det_3x3(matrix: Matrix3x3): number;
|
|
68
64
|
export declare function get_coefficient_of_variation(values: number[]): number;
|