matterviz 0.3.1 → 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 +154 -96
- package/dist/Icon.svelte +20 -14
- package/dist/MillerIndexInput.svelte +27 -21
- package/dist/api/optimade.js +6 -6
- package/dist/app.css +216 -178
- package/dist/brillouin/BrillouinZone.svelte +299 -198
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
- package/dist/brillouin/BrillouinZoneExportPane.svelte +74 -55
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
- package/dist/brillouin/BrillouinZoneScene.svelte +277 -165
- 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 +327 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +847 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +3194 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +11 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- 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.d.ts +10 -0
- package/dist/chempot-diagram/color.js +32 -0
- package/dist/chempot-diagram/compute.d.ts +48 -0
- package/dist/chempot-diagram/compute.js +812 -0
- package/dist/chempot-diagram/index.d.ts +6 -0
- package/dist/chempot-diagram/index.js +6 -0
- package/dist/chempot-diagram/pointer.d.ts +16 -0
- package/dist/chempot-diagram/pointer.js +40 -0
- package/dist/chempot-diagram/temperature.d.ts +15 -0
- package/dist/chempot-diagram/temperature.js +36 -0
- package/dist/chempot-diagram/types.d.ts +86 -0
- package/dist/chempot-diagram/types.js +28 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +9 -3
- package/dist/composition/BarChart.svelte +141 -77
- package/dist/composition/BubbleChart.svelte +107 -52
- package/dist/composition/Composition.svelte +100 -79
- package/dist/composition/Formula.svelte +108 -62
- package/dist/composition/FormulaFilter.svelte +973 -353
- package/dist/composition/FormulaFilter.svelte.d.ts +35 -1
- package/dist/composition/PieChart.svelte +199 -99
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- 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 -38
- package/dist/convex-hull/ConvexHull2D.svelte +551 -393
- package/dist/convex-hull/ConvexHull3D.svelte +1303 -825
- package/dist/convex-hull/ConvexHull4D.svelte +1012 -686
- package/dist/convex-hull/ConvexHullControls.svelte +115 -28
- package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
- package/dist/convex-hull/ConvexHullStats.svelte +821 -249
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +41 -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.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +40 -0
- package/dist/convex-hull/gas-thermodynamics.js +17 -12
- package/dist/convex-hull/helpers.d.ts +10 -1
- package/dist/convex-hull/helpers.js +79 -38
- package/dist/convex-hull/index.d.ts +1 -0
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +163 -69
- package/dist/convex-hull/types.d.ts +12 -12
- package/dist/convex-hull/types.js +0 -12
- package/dist/coordination/CoordinationBarPlot.svelte +232 -176
- package/dist/element/BohrAtom.svelte +56 -13
- 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/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/types.d.ts +1 -0
- 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 +336 -239
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
- package/dist/fermi-surface/FermiSurfaceScene.svelte +536 -343
- 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 +37 -33
- package/dist/fermi-surface/symmetry.js +2 -7
- package/dist/fermi-surface/types.d.ts +3 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1527 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +30 -0
- package/dist/heatmap-matrix/index.d.ts +53 -0
- package/dist/heatmap-matrix/index.js +100 -0
- package/dist/heatmap-matrix/shared.d.ts +2 -0
- package/dist/heatmap-matrix/shared.js +4 -0
- package/dist/icons.d.ts +111 -0
- package/dist/icons.js +158 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.d.ts +3 -0
- package/dist/io/export.js +138 -140
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +43 -0
- package/dist/io/index.d.ts +2 -2
- package/dist/io/index.js +2 -112
- package/dist/io/is-binary.js +2 -3
- package/dist/io/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +117 -0
- package/dist/isosurface/Isosurface.svelte +220 -110
- package/dist/isosurface/IsosurfaceControls.svelte +65 -28
- package/dist/isosurface/parse.js +104 -56
- package/dist/isosurface/slice.d.ts +2 -1
- package/dist/isosurface/slice.js +8 -13
- package/dist/isosurface/types.d.ts +14 -1
- package/dist/isosurface/types.js +152 -5
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +12 -8
- package/dist/layout/FullscreenToggle.svelte +11 -2
- package/dist/layout/InfoCard.svelte +38 -6
- package/dist/layout/InfoTag.svelte +125 -94
- package/dist/layout/PropertyFilter.svelte +82 -37
- package/dist/layout/SettingsSection.svelte +85 -55
- package/dist/layout/SubpageGrid.svelte +82 -0
- package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +266 -223
- package/dist/layout/json-tree/JsonTree.svelte +516 -429
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +281 -173
- package/dist/layout/json-tree/types.d.ts +10 -2
- package/dist/layout/json-tree/utils.d.ts +2 -0
- package/dist/layout/json-tree/utils.js +37 -2
- package/dist/marching-cubes.js +25 -2
- package/dist/math.d.ts +20 -17
- package/dist/math.js +474 -57
- package/dist/overlays/ContextMenu.svelte +66 -40
- package/dist/overlays/DraggablePane.svelte +331 -154
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- 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 +559 -267
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +131 -51
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +160 -110
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +8 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +217 -86
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- 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/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/parse.js +10 -9
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +869 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +8 -4
- package/dist/phase-diagram/utils.js +219 -74
- package/dist/plot/AxisLabel.svelte +51 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +1461 -768
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +33 -6
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +533 -383
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ColorScaleSelect.svelte +28 -7
- package/dist/plot/ElementScatter.svelte +38 -16
- package/dist/plot/FillArea.svelte +152 -92
- package/dist/plot/Histogram.svelte +1162 -709
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +81 -18
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- 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 +221 -96
- 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 -146
- package/dist/plot/ReferenceLine.svelte +77 -22
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferenceLine3D.svelte +132 -107
- package/dist/plot/ReferencePlane.svelte +146 -123
- package/dist/plot/ScatterPlot.svelte +1880 -1156
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte +256 -131
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +300 -297
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot3DScene.svelte +608 -406
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +150 -70
- 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 +96 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +23 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- 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/index.d.ts +6 -2
- package/dist/plot/index.js +6 -2
- package/dist/plot/interactions.d.ts +8 -10
- package/dist/plot/interactions.js +2 -3
- package/dist/plot/layout.d.ts +11 -2
- package/dist/plot/layout.js +44 -17
- package/dist/plot/reference-line.d.ts +5 -22
- package/dist/plot/reference-line.js +12 -84
- package/dist/plot/scales.js +24 -36
- package/dist/plot/types.d.ts +53 -40
- package/dist/plot/types.js +12 -7
- package/dist/plot/utils/label-placement.d.ts +32 -15
- package/dist/plot/utils/label-placement.js +227 -63
- package/dist/plot/utils/series-visibility.js +2 -3
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +173 -132
- 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 +21 -6
- package/dist/settings.js +63 -19
- package/dist/spectral/Bands.svelte +963 -412
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- 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.d.ts +23 -1
- package/dist/spectral/helpers.js +119 -51
- package/dist/spectral/types.d.ts +2 -0
- 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 +231 -129
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +73 -47
- package/dist/structure/CanvasTooltip.svelte +10 -2
- package/dist/structure/CellSelect.svelte +148 -51
- package/dist/structure/Cylinder.svelte +33 -17
- package/dist/structure/Lattice.svelte +88 -33
- package/dist/structure/Structure.svelte +1077 -821
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureControls.svelte +373 -139
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +124 -89
- package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +304 -231
- package/dist/structure/StructureScene.svelte +919 -445
- package/dist/structure/StructureScene.svelte.d.ts +16 -7
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +42 -29
- package/dist/structure/bonding.js +6 -7
- package/dist/structure/export.js +22 -34
- package/dist/structure/ferrox-wasm-types.d.ts +3 -2
- package/dist/structure/ferrox-wasm-types.js +0 -3
- package/dist/structure/ferrox-wasm.d.ts +3 -2
- package/dist/structure/ferrox-wasm.js +2 -3
- package/dist/structure/index.d.ts +16 -0
- package/dist/structure/index.js +88 -6
- package/dist/structure/measure.d.ts +2 -2
- package/dist/structure/measure.js +4 -44
- package/dist/structure/parse.js +130 -155
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +99 -0
- 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 +5 -3
- package/dist/symmetry/SymmetryStats.svelte +94 -37
- package/dist/symmetry/WyckoffTable.svelte +42 -14
- package/dist/symmetry/cell-transform.js +5 -3
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +87 -21
- package/dist/symmetry/spacegroups.js +148 -148
- package/dist/table/HeatmapTable.svelte +1112 -516
- package/dist/table/HeatmapTable.svelte.d.ts +12 -1
- package/dist/table/ToggleMenu.svelte +125 -90
- package/dist/table/index.d.ts +2 -0
- 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 +889 -687
- package/dist/trajectory/TrajectoryError.svelte +14 -3
- package/dist/trajectory/TrajectoryExportPane.svelte +148 -90
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +13 -31
- package/dist/trajectory/format-detect.d.ts +9 -0
- package/dist/trajectory/format-detect.js +76 -0
- package/dist/trajectory/frame-reader.d.ts +17 -0
- package/dist/trajectory/frame-reader.js +332 -0
- package/dist/trajectory/helpers.d.ts +14 -0
- package/dist/trajectory/helpers.js +172 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +23 -14
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +77 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +129 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +299 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +179 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +68 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +110 -0
- package/dist/trajectory/plotting.js +13 -8
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +17 -0
- package/dist/xrd/XrdPlot.svelte +337 -245
- package/dist/xrd/broadening.js +14 -9
- package/dist/xrd/calc-xrd.js +12 -19
- package/dist/xrd/parse.d.ts +1 -1
- package/dist/xrd/parse.js +17 -17
- package/package.json +103 -101
- package/readme.md +4 -4
- package/dist/trajectory/parse.d.ts +0 -42
- package/dist/trajectory/parse.js +0 -1267
- /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
- /package/dist/theme/{themes.js → themes.mjs} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
2
|
import type { JsonTreeProps } from './types';
|
|
3
|
-
type $$ComponentProps = JsonTreeProps & Omit<HTMLAttributes<HTMLDivElement>, `onselect`>;
|
|
3
|
+
type $$ComponentProps = JsonTreeProps & Omit<HTMLAttributes<HTMLDivElement>, `onselect` | `onchange`>;
|
|
4
4
|
declare const JsonTree: import("svelte").Component<$$ComponentProps, {}, "collapsed_paths" | "show_data_types" | "show_array_indices">;
|
|
5
5
|
type JsonTree = ReturnType<typeof JsonTree>;
|
|
6
6
|
export default JsonTree;
|
|
@@ -1,182 +1,282 @@
|
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
44
|
+
just_changed = true
|
|
45
|
+
if (change_timeout) clearTimeout(change_timeout)
|
|
46
|
+
change_timeout = setTimeout(() => {
|
|
47
|
+
just_changed = false
|
|
48
|
+
}, 1000)
|
|
49
|
+
}
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
77
|
+
// When editable, delay copy so double-click can cancel it
|
|
78
|
+
if (ctx.settings.editable && ctx.onchange) {
|
|
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)
|
|
84
|
+
}
|
|
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]`
|
|
50
90
|
if (value_type === `string`) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
return format_preview(value)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
91
|
+
const str = value as string
|
|
92
|
+
return is_long_string && !is_expanded
|
|
93
|
+
? `"${str.slice(0, max_len)}..."`
|
|
94
|
+
: `"${str}"`
|
|
95
|
+
}
|
|
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
|
+
}
|
|
66
107
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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()
|
|
116
|
+
// Cancel pending click-to-copy
|
|
117
|
+
if (click_timer) clearTimeout(click_timer)
|
|
118
|
+
// Pre-fill with raw value (strings without quotes)
|
|
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)
|
|
128
|
+
if (!values_equal(new_value, value)) {
|
|
129
|
+
ctx?.onchange?.(path, new_value, value)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function handle_edit_keydown(event: KeyboardEvent) {
|
|
134
|
+
if (event.key === `Enter`) {
|
|
76
135
|
event.preventDefault()
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
136
|
+
commit_edit()
|
|
137
|
+
} else if (event.key === `Escape`) {
|
|
138
|
+
event.preventDefault()
|
|
139
|
+
editing = false
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
{#if editing}
|
|
145
|
+
<!-- svelte-ignore a11y_autofocus -->
|
|
146
|
+
<input
|
|
147
|
+
bind:this={edit_input}
|
|
148
|
+
type="text"
|
|
149
|
+
class="edit-input {value_type}"
|
|
150
|
+
bind:value={edit_text}
|
|
151
|
+
onkeydown={handle_edit_keydown}
|
|
152
|
+
onblur={commit_edit}
|
|
153
|
+
style:width="{Math.max(edit_text.length + 2, 6)}ch"
|
|
154
|
+
autofocus
|
|
155
|
+
/>
|
|
156
|
+
{:else}
|
|
157
|
+
<span
|
|
158
|
+
class="json-value {value_type}"
|
|
159
|
+
class:changed={just_changed}
|
|
160
|
+
class:editable={ctx?.settings.editable}
|
|
161
|
+
onclick={handle_click}
|
|
162
|
+
ondblclick={start_edit}
|
|
163
|
+
oncontextmenu={(event) => {
|
|
164
|
+
ctx?.show_context_menu(event, path, value, false, false)
|
|
165
|
+
}}
|
|
166
|
+
onkeydown={(event) => {
|
|
167
|
+
if (event.key === `Enter` || event.key === ` `) {
|
|
168
|
+
event.preventDefault()
|
|
169
|
+
ctx?.copy_value(path, value)
|
|
170
|
+
}
|
|
171
|
+
}}
|
|
172
|
+
role="button"
|
|
173
|
+
tabindex="-1"
|
|
174
|
+
title={ctx?.settings.editable ? `Double-click to edit` : undefined}
|
|
175
|
+
>
|
|
176
|
+
{#if color_detected}
|
|
177
|
+
<span class="color-swatch" style:background={color_detected}></span>
|
|
178
|
+
{/if}
|
|
179
|
+
{#if url_detected}
|
|
180
|
+
<a
|
|
181
|
+
href={encodeURI(trimmed_str)}
|
|
182
|
+
class="url-link"
|
|
183
|
+
target="_blank"
|
|
184
|
+
rel="noopener noreferrer"
|
|
185
|
+
onclick={(event) => event.stopPropagation()}
|
|
186
|
+
title="Open URL in new tab"
|
|
187
|
+
>
|
|
188
|
+
{display_value}
|
|
189
|
+
</a>
|
|
190
|
+
{:else}
|
|
96
191
|
{display_value}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
</button>
|
|
119
|
-
{/if}
|
|
120
|
-
{#if ctx?.settings.show_data_types && value_type !== `null` &&
|
|
192
|
+
{/if}
|
|
193
|
+
{#if is_truncated}
|
|
194
|
+
<button
|
|
195
|
+
type="button"
|
|
196
|
+
class="expand-btn"
|
|
197
|
+
onclick={toggle_expand}
|
|
198
|
+
title="Show full string"
|
|
199
|
+
>
|
|
200
|
+
...
|
|
201
|
+
</button>
|
|
202
|
+
{:else if is_long_string && is_expanded}
|
|
203
|
+
<button
|
|
204
|
+
type="button"
|
|
205
|
+
class="expand-btn"
|
|
206
|
+
onclick={toggle_expand}
|
|
207
|
+
title="Collapse string"
|
|
208
|
+
>
|
|
209
|
+
▲
|
|
210
|
+
</button>
|
|
211
|
+
{/if}
|
|
212
|
+
{#if ctx?.settings.show_data_types && value_type !== `null` &&
|
|
121
213
|
value_type !== `undefined`}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
</span>
|
|
214
|
+
<span class="type-annotation">{value_type}</span>
|
|
215
|
+
{/if}
|
|
216
|
+
</span>
|
|
217
|
+
{/if}
|
|
125
218
|
|
|
126
219
|
<style>
|
|
220
|
+
/* Type-specific colors shared between display and edit input */
|
|
221
|
+
:is(.json-value, .edit-input) {
|
|
222
|
+
&.string {
|
|
223
|
+
color: var(--jt-string, light-dark(#a31515, #ce9178));
|
|
224
|
+
}
|
|
225
|
+
&.number {
|
|
226
|
+
color: var(--jt-number, light-dark(#098658, #b5cea8));
|
|
227
|
+
}
|
|
228
|
+
&.boolean {
|
|
229
|
+
color: var(--jt-boolean, light-dark(#0000ff, #569cd6));
|
|
230
|
+
}
|
|
231
|
+
&.null {
|
|
232
|
+
color: var(--jt-null, light-dark(#808080, #808080));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
127
235
|
.json-value {
|
|
128
236
|
cursor: pointer;
|
|
129
237
|
border-radius: 2px;
|
|
130
238
|
transition: background-color 0.15s, color 0.15s;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
.json-value.circular {
|
|
174
|
-
color: var(--jt-circular, light-dark(#808080, #808080));
|
|
175
|
-
font-style: italic;
|
|
176
|
-
}
|
|
177
|
-
/* Change animation */
|
|
178
|
-
.json-value.changed {
|
|
179
|
-
animation: value-change 1s ease-out;
|
|
239
|
+
&:hover {
|
|
240
|
+
background: var(
|
|
241
|
+
--jt-hover-bg,
|
|
242
|
+
light-dark(rgba(0, 0, 0, 0.05), rgba(255, 255, 255, 0.08))
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
&.string {
|
|
246
|
+
word-break: break-word;
|
|
247
|
+
}
|
|
248
|
+
&:is(.null, .undefined) {
|
|
249
|
+
font-style: italic;
|
|
250
|
+
}
|
|
251
|
+
&.date {
|
|
252
|
+
color: var(--jt-date, light-dark(#098658, #dcdcaa));
|
|
253
|
+
}
|
|
254
|
+
&.regexp {
|
|
255
|
+
color: var(--jt-regexp, light-dark(#811f3f, #d16969));
|
|
256
|
+
}
|
|
257
|
+
&.symbol {
|
|
258
|
+
color: var(--jt-symbol, light-dark(#267f99, #4ec9b0));
|
|
259
|
+
}
|
|
260
|
+
&.bigint {
|
|
261
|
+
color: var(--jt-bigint, light-dark(#098658, #b5cea8));
|
|
262
|
+
}
|
|
263
|
+
&.function {
|
|
264
|
+
color: var(--jt-function, light-dark(#795e26, #dcdcaa));
|
|
265
|
+
font-style: italic;
|
|
266
|
+
}
|
|
267
|
+
&.error {
|
|
268
|
+
color: var(--jt-error, light-dark(#a31515, #f48771));
|
|
269
|
+
}
|
|
270
|
+
&.circular {
|
|
271
|
+
color: var(--jt-circular, light-dark(#808080, #808080));
|
|
272
|
+
font-style: italic;
|
|
273
|
+
}
|
|
274
|
+
&.changed {
|
|
275
|
+
animation: value-change 1s ease-out;
|
|
276
|
+
}
|
|
277
|
+
&.editable {
|
|
278
|
+
cursor: default;
|
|
279
|
+
}
|
|
180
280
|
}
|
|
181
281
|
@keyframes value-change {
|
|
182
282
|
0% {
|
|
@@ -186,7 +286,6 @@ function toggle_expand(event) {
|
|
|
186
286
|
background: transparent;
|
|
187
287
|
}
|
|
188
288
|
}
|
|
189
|
-
/* Expand/collapse button for long strings */
|
|
190
289
|
.expand-btn {
|
|
191
290
|
display: inline;
|
|
192
291
|
background: none;
|
|
@@ -196,11 +295,10 @@ function toggle_expand(event) {
|
|
|
196
295
|
font-size: 0.85em;
|
|
197
296
|
padding: 0 2px;
|
|
198
297
|
margin-left: 2px;
|
|
298
|
+
&:hover {
|
|
299
|
+
text-decoration: underline;
|
|
300
|
+
}
|
|
199
301
|
}
|
|
200
|
-
.expand-btn:hover {
|
|
201
|
-
text-decoration: underline;
|
|
202
|
-
}
|
|
203
|
-
/* Type annotation */
|
|
204
302
|
.type-annotation {
|
|
205
303
|
font-size: 0.7em;
|
|
206
304
|
color: var(--jt-type-annotation, light-dark(#808080, #6a6a6a));
|
|
@@ -210,9 +308,19 @@ function toggle_expand(event) {
|
|
|
210
308
|
.url-link {
|
|
211
309
|
color: var(--jt-url, light-dark(#0066cc, #4fc3f7));
|
|
212
310
|
text-decoration: none;
|
|
311
|
+
&:hover {
|
|
312
|
+
text-decoration: underline;
|
|
313
|
+
}
|
|
213
314
|
}
|
|
214
|
-
.
|
|
215
|
-
|
|
315
|
+
.edit-input {
|
|
316
|
+
font: inherit;
|
|
317
|
+
font-family: var(--jt-font-family, 'SF Mono', Monaco, 'Courier New', monospace);
|
|
318
|
+
padding: 0 2px;
|
|
319
|
+
border: 1px solid var(--jt-edit-border, light-dark(#4a90d9, #4a90d9));
|
|
320
|
+
border-radius: 2px;
|
|
321
|
+
background: var(--jt-edit-bg, light-dark(#fff, #1a1a2e));
|
|
322
|
+
outline: none;
|
|
323
|
+
min-width: 4ch;
|
|
216
324
|
}
|
|
217
325
|
.color-swatch {
|
|
218
326
|
display: inline-block;
|
|
@@ -16,6 +16,8 @@ export interface JsonTreeProps {
|
|
|
16
16
|
oncopy?: (path: string, value: string) => void;
|
|
17
17
|
download_filename?: string;
|
|
18
18
|
compare_value?: unknown;
|
|
19
|
+
editable?: boolean;
|
|
20
|
+
onchange?: (path: string, new_value: unknown, old_value: unknown) => void;
|
|
19
21
|
}
|
|
20
22
|
export interface JsonTreeContext {
|
|
21
23
|
settings: {
|
|
@@ -27,6 +29,7 @@ export interface JsonTreeContext {
|
|
|
27
29
|
sort_keys: boolean;
|
|
28
30
|
max_string_length: number;
|
|
29
31
|
highlight_changes: boolean;
|
|
32
|
+
editable: boolean;
|
|
30
33
|
};
|
|
31
34
|
collapsed: Set<string>;
|
|
32
35
|
force_expanded: Set<string>;
|
|
@@ -41,8 +44,8 @@ export interface JsonTreeContext {
|
|
|
41
44
|
collapse_all: () => void;
|
|
42
45
|
collapse_to_level: (level: number) => void;
|
|
43
46
|
set_focused: (path: string | null) => void;
|
|
44
|
-
copy_value: (path: string, value: unknown, event?:
|
|
45
|
-
copy_path: (path: string, event?:
|
|
47
|
+
copy_value: (path: string, value: unknown, event?: CopyEventPosition) => Promise<void>;
|
|
48
|
+
copy_path: (path: string, event?: CopyEventPosition) => Promise<void>;
|
|
46
49
|
register_path: (path: string) => void;
|
|
47
50
|
unregister_path: (path: string) => void;
|
|
48
51
|
show_context_menu: (event: MouseEvent, path: string, value: unknown, expandable: boolean, is_collapsed: boolean) => void;
|
|
@@ -54,7 +57,12 @@ export interface JsonTreeContext {
|
|
|
54
57
|
diff_map: Map<string, DiffEntry> | null;
|
|
55
58
|
ghost_map: Map<string, import('./utils').GhostEntry[]>;
|
|
56
59
|
collapse_children_only: (path: string) => void;
|
|
60
|
+
onchange?: (path: string, new_value: unknown, old_value: unknown) => void;
|
|
57
61
|
}
|
|
62
|
+
export type CopyEventPosition = {
|
|
63
|
+
clientX: number;
|
|
64
|
+
clientY: number;
|
|
65
|
+
};
|
|
58
66
|
export declare const JSON_TREE_CONTEXT_KEY: unique symbol;
|
|
59
67
|
export type DiffStatus = `added` | `removed` | `changed`;
|
|
60
68
|
export interface DiffEntry {
|
|
@@ -14,6 +14,8 @@ export declare function find_matching_paths(value: unknown, query: string, curre
|
|
|
14
14
|
export declare function get_ancestor_paths(path: string): string[];
|
|
15
15
|
export declare function parse_path(path: string): (string | number)[];
|
|
16
16
|
export declare function values_equal(val_a: unknown, val_b: unknown): boolean;
|
|
17
|
+
export declare function parse_edited_value(text: string): unknown;
|
|
18
|
+
export declare function set_at_path(root: unknown, path_str: string, new_value: unknown, root_label?: string): unknown;
|
|
17
19
|
export declare function is_url(str: string): boolean;
|
|
18
20
|
export declare function is_css_color(str: string): boolean;
|
|
19
21
|
export declare function estimate_byte_size(value: unknown, max_depth?: number, current_depth?: number): number;
|
|
@@ -390,6 +390,39 @@ export function values_equal(val_a, val_b) {
|
|
|
390
390
|
}
|
|
391
391
|
return false;
|
|
392
392
|
}
|
|
393
|
+
// Parse a raw edited string into a typed JSON value
|
|
394
|
+
// Numbers, booleans, and null are auto-detected; everything else stays as string
|
|
395
|
+
export function parse_edited_value(text) {
|
|
396
|
+
const trimmed = text.trim();
|
|
397
|
+
if (trimmed === `null`)
|
|
398
|
+
return null;
|
|
399
|
+
if (trimmed === `true`)
|
|
400
|
+
return true;
|
|
401
|
+
if (trimmed === `false`)
|
|
402
|
+
return false;
|
|
403
|
+
const num = Number(trimmed);
|
|
404
|
+
if (trimmed !== `` && Number.isFinite(num))
|
|
405
|
+
return num;
|
|
406
|
+
return text;
|
|
407
|
+
}
|
|
408
|
+
// Set a value at a dot/bracket path in a deep-cloned copy of root
|
|
409
|
+
// root_label is stripped from the path prefix if present
|
|
410
|
+
export function set_at_path(root, path_str, new_value, root_label) {
|
|
411
|
+
const segments = parse_path(path_str);
|
|
412
|
+
const start = root_label && segments[0] === root_label ? 1 : 0;
|
|
413
|
+
if (start >= segments.length)
|
|
414
|
+
return new_value;
|
|
415
|
+
const cloned = JSON.parse(JSON.stringify(root));
|
|
416
|
+
let current = cloned;
|
|
417
|
+
for (let idx = start; idx < segments.length - 1; idx++) {
|
|
418
|
+
const next = current[segments[idx]];
|
|
419
|
+
if (next === undefined || next === null)
|
|
420
|
+
return root; // bail — path no longer valid
|
|
421
|
+
current = next;
|
|
422
|
+
}
|
|
423
|
+
current[segments[segments.length - 1]] = new_value;
|
|
424
|
+
return cloned;
|
|
425
|
+
}
|
|
393
426
|
// URL regex for auto-detection in string values
|
|
394
427
|
const URL_RE = /^https?:\/\/\S+$/;
|
|
395
428
|
// CSS color patterns for swatch rendering
|
|
@@ -507,8 +540,10 @@ export function compute_diff(old_val, new_val, current_path = ``, result = new M
|
|
|
507
540
|
}
|
|
508
541
|
// Both primitive: compare values (with NaN === NaN special case)
|
|
509
542
|
if (is_primitive_type(old_type)) {
|
|
510
|
-
const both_nan = typeof old_val === `number` &&
|
|
511
|
-
|
|
543
|
+
const both_nan = typeof old_val === `number` &&
|
|
544
|
+
typeof new_val === `number` &&
|
|
545
|
+
Number.isNaN(old_val) &&
|
|
546
|
+
Number.isNaN(new_val);
|
|
512
547
|
if (!both_nan && old_val !== new_val) {
|
|
513
548
|
result.set(current_path, {
|
|
514
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 = [
|