matterviz 0.3.5 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/dist/MillerIndexInput.svelte +5 -5
  2. package/dist/api/optimade.js +3 -3
  3. package/dist/brillouin/BrillouinZone.svelte +5 -2
  4. package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
  5. package/dist/brillouin/BrillouinZoneExportPane.svelte +1 -3
  6. package/dist/brillouin/BrillouinZoneInfoPane.svelte +1 -1
  7. package/dist/brillouin/BrillouinZoneScene.svelte +5 -5
  8. package/dist/brillouin/compute.js +21 -21
  9. package/dist/brillouin/index.d.ts +1 -1
  10. package/dist/brillouin/index.js +0 -1
  11. package/dist/brillouin/types.d.ts +8 -13
  12. package/dist/chempot-diagram/ChemPotDiagram.svelte +3 -3
  13. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +3 -4
  14. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +33 -34
  15. package/dist/chempot-diagram/compute.js +1 -7
  16. package/dist/chempot-diagram/temperature.d.ts +1 -1
  17. package/dist/chempot-diagram/temperature.js +1 -3
  18. package/dist/chempot-diagram/types.d.ts +4 -9
  19. package/dist/colors/index.js +5 -5
  20. package/dist/composition/Composition.svelte +2 -1
  21. package/dist/composition/Formula.svelte +7 -4
  22. package/dist/composition/FormulaFilter.svelte +1 -3
  23. package/dist/composition/format.js +4 -4
  24. package/dist/composition/parse.d.ts +2 -1
  25. package/dist/composition/parse.js +61 -46
  26. package/dist/convex-hull/ConvexHull2D.svelte +62 -51
  27. package/dist/convex-hull/ConvexHull3D.svelte +101 -90
  28. package/dist/convex-hull/ConvexHull4D.svelte +70 -58
  29. package/dist/convex-hull/ConvexHullControls.svelte +24 -35
  30. package/dist/convex-hull/ConvexHullInfoPane.svelte +8 -5
  31. package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +2 -0
  32. package/dist/convex-hull/ConvexHullStats.svelte +9 -2
  33. package/dist/convex-hull/ConvexHullStats.svelte.d.ts +2 -0
  34. package/dist/convex-hull/GasPressureControls.svelte +7 -7
  35. package/dist/convex-hull/StructurePopup.svelte +65 -30
  36. package/dist/convex-hull/StructurePopup.svelte.d.ts +6 -6
  37. package/dist/convex-hull/TemperatureSlider.svelte +8 -5
  38. package/dist/convex-hull/barycentric-coords.d.ts +2 -2
  39. package/dist/convex-hull/barycentric-coords.js +2 -2
  40. package/dist/convex-hull/gas-thermodynamics.js +2 -4
  41. package/dist/convex-hull/helpers.d.ts +13 -2
  42. package/dist/convex-hull/helpers.js +37 -16
  43. package/dist/convex-hull/index.d.ts +1 -0
  44. package/dist/convex-hull/index.js +1 -0
  45. package/dist/convex-hull/thermodynamics.d.ts +2 -1
  46. package/dist/convex-hull/thermodynamics.js +7 -7
  47. package/dist/convex-hull/types.d.ts +15 -15
  48. package/dist/effects.svelte.d.ts +12 -0
  49. package/dist/effects.svelte.js +37 -0
  50. package/dist/element/BohrAtom.svelte +4 -4
  51. package/dist/element/data.json.gz.d.ts +3 -1
  52. package/dist/element/index.d.ts +1 -1
  53. package/dist/element/index.js +0 -1
  54. package/dist/fermi-surface/FermiSurface.svelte +4 -4
  55. package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
  56. package/dist/fermi-surface/FermiSurfaceControls.svelte +15 -19
  57. package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
  58. package/dist/fermi-surface/FermiSurfaceScene.svelte +8 -6
  59. package/dist/fermi-surface/compute.js +2 -2
  60. package/dist/fermi-surface/export.js +13 -26
  61. package/dist/fermi-surface/parse.js +8 -12
  62. package/dist/fermi-surface/types.d.ts +2 -5
  63. package/dist/heatmap-matrix/HeatmapMatrix.svelte +21 -3
  64. package/dist/heatmap-matrix/index.js +6 -6
  65. package/dist/io/decompress.d.ts +2 -1
  66. package/dist/io/decompress.js +1 -1
  67. package/dist/io/export.js +1 -1
  68. package/dist/io/index.d.ts +1 -1
  69. package/dist/io/index.js +0 -1
  70. package/dist/io/url-drop.js +7 -1
  71. package/dist/isosurface/IsosurfaceControls.svelte +11 -25
  72. package/dist/isosurface/slice.js +1 -1
  73. package/dist/isosurface/types.js +12 -12
  74. package/dist/labels.d.ts +1 -1
  75. package/dist/labels.js +14 -11
  76. package/dist/layout/InfoTag.svelte +6 -4
  77. package/dist/layout/PropertyFilter.svelte +4 -2
  78. package/dist/layout/json-tree/JsonTree.svelte +22 -14
  79. package/dist/layout/json-tree/JsonValue.svelte +2 -2
  80. package/dist/layout/json-tree/types.d.ts +3 -2
  81. package/dist/layout/json-tree/types.js +0 -1
  82. package/dist/layout/json-tree/utils.d.ts +4 -4
  83. package/dist/layout/json-tree/utils.js +12 -20
  84. package/dist/marching-cubes.js +13 -15
  85. package/dist/math.d.ts +11 -1
  86. package/dist/math.js +15 -6
  87. package/dist/overlays/DragControlTab.svelte +98 -0
  88. package/dist/overlays/DragControlTab.svelte.d.ts +8 -0
  89. package/dist/overlays/DraggablePane.svelte +7 -84
  90. package/dist/overlays/index.d.ts +1 -0
  91. package/dist/overlays/index.js +1 -0
  92. package/dist/periodic-table/PeriodicTable.svelte +11 -11
  93. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +4 -2
  94. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
  95. package/dist/phase-diagram/PhaseDiagramControls.svelte +4 -9
  96. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
  97. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +2 -10
  98. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +2 -3
  99. package/dist/phase-diagram/TdbInfoPanel.svelte +3 -3
  100. package/dist/phase-diagram/build-diagram.js +11 -18
  101. package/dist/phase-diagram/diagram-input.d.ts +5 -9
  102. package/dist/phase-diagram/index.d.ts +2 -2
  103. package/dist/phase-diagram/index.js +0 -2
  104. package/dist/phase-diagram/parse.d.ts +2 -2
  105. package/dist/phase-diagram/parse.js +6 -10
  106. package/dist/phase-diagram/svg-to-diagram.js +15 -15
  107. package/dist/phase-diagram/types.d.ts +5 -11
  108. package/dist/phase-diagram/utils.d.ts +2 -2
  109. package/dist/phase-diagram/utils.js +9 -11
  110. package/dist/plot/BarPlot.svelte +162 -314
  111. package/dist/plot/BarPlot.svelte.d.ts +5 -4
  112. package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
  113. package/dist/plot/BinnedScatterPlot.svelte +1114 -0
  114. package/dist/plot/BinnedScatterPlot.svelte.d.ts +66 -0
  115. package/dist/plot/ColorBar.svelte +19 -17
  116. package/dist/plot/ColorBar.svelte.d.ts +1 -1
  117. package/dist/plot/FillArea.svelte +2 -4
  118. package/dist/plot/FillArea.svelte.d.ts +1 -1
  119. package/dist/plot/Histogram.svelte +167 -281
  120. package/dist/plot/Histogram.svelte.d.ts +1 -1
  121. package/dist/plot/HistogramControls.svelte.d.ts +1 -1
  122. package/dist/plot/InteractiveAxisLabel.svelte +5 -3
  123. package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
  124. package/dist/plot/PlotAxis.svelte +169 -0
  125. package/dist/plot/PlotAxis.svelte.d.ts +24 -0
  126. package/dist/plot/PlotControls.svelte.d.ts +1 -1
  127. package/dist/plot/ReferenceLine3D.svelte +53 -51
  128. package/dist/plot/ReferencePlane.svelte +39 -42
  129. package/dist/plot/ScatterPlot.svelte +300 -367
  130. package/dist/plot/ScatterPlot.svelte.d.ts +8 -5
  131. package/dist/plot/ScatterPlot3D.svelte +33 -6
  132. package/dist/plot/ScatterPlot3D.svelte.d.ts +3 -2
  133. package/dist/plot/ScatterPlot3DControls.svelte +9 -9
  134. package/dist/plot/ScatterPlotControls.svelte +3 -4
  135. package/dist/plot/ScatterPoint.svelte +18 -27
  136. package/dist/plot/ScatterPoint.svelte.d.ts +4 -3
  137. package/dist/plot/Surface3D.svelte +4 -7
  138. package/dist/plot/ZeroLines.svelte +2 -1
  139. package/dist/plot/ZeroLines.svelte.d.ts +2 -1
  140. package/dist/plot/ZoomRect.svelte +2 -2
  141. package/dist/plot/ZoomRect.svelte.d.ts +3 -3
  142. package/dist/plot/adaptive-density.d.ts +69 -0
  143. package/dist/plot/adaptive-density.js +191 -0
  144. package/dist/plot/auto-place.d.ts +43 -0
  145. package/dist/plot/auto-place.js +122 -0
  146. package/dist/plot/axis-utils.js +3 -5
  147. package/dist/plot/binned-scatter-types.d.ts +59 -0
  148. package/dist/plot/binned-scatter-types.js +1 -0
  149. package/dist/plot/data-cleaning.js +1 -1
  150. package/dist/plot/data-transform.js +1 -1
  151. package/dist/plot/fill-utils.d.ts +4 -9
  152. package/dist/plot/fill-utils.js +29 -44
  153. package/dist/plot/index.d.ts +4 -0
  154. package/dist/plot/index.js +2 -0
  155. package/dist/plot/interactions.d.ts +4 -4
  156. package/dist/plot/interactions.js +4 -3
  157. package/dist/plot/layout.d.ts +20 -2
  158. package/dist/plot/layout.js +59 -16
  159. package/dist/plot/reference-line.d.ts +1 -1
  160. package/dist/plot/reference-line.js +9 -11
  161. package/dist/plot/scales.d.ts +1 -1
  162. package/dist/plot/scales.js +20 -23
  163. package/dist/plot/types.d.ts +30 -58
  164. package/dist/plot/types.js +2 -6
  165. package/dist/plot/utils/label-placement.d.ts +24 -3
  166. package/dist/plot/utils/label-placement.js +82 -12
  167. package/dist/plot/utils/series-visibility.d.ts +8 -2
  168. package/dist/plot/utils/series-visibility.js +23 -5
  169. package/dist/rdf/RdfPlot.svelte +5 -5
  170. package/dist/rdf/calc-rdf.js +3 -3
  171. package/dist/sanitize.d.ts +2 -0
  172. package/dist/sanitize.js +2 -0
  173. package/dist/spectral/Bands.svelte +1 -1
  174. package/dist/spectral/BandsAndDos.svelte +22 -16
  175. package/dist/spectral/BrillouinBandsDos.svelte +20 -16
  176. package/dist/spectral/Dos.svelte +1 -1
  177. package/dist/spectral/helpers.d.ts +4 -2
  178. package/dist/spectral/helpers.js +44 -35
  179. package/dist/spectral/index.d.ts +1 -1
  180. package/dist/spectral/index.js +0 -1
  181. package/dist/structure/AtomLegend.svelte +23 -6
  182. package/dist/structure/AtomLegend.svelte.d.ts +1 -0
  183. package/dist/structure/CanvasTooltip.svelte +9 -9
  184. package/dist/structure/CanvasTooltip.svelte.d.ts +1 -1
  185. package/dist/structure/CellSelect.svelte +14 -16
  186. package/dist/structure/Structure.svelte +317 -68
  187. package/dist/structure/Structure.svelte.d.ts +4 -2
  188. package/dist/structure/StructureControls.svelte +20 -45
  189. package/dist/structure/StructureExportPane.svelte +2 -1
  190. package/dist/structure/StructureInfoPane.svelte +10 -8
  191. package/dist/structure/StructureScene.svelte +527 -177
  192. package/dist/structure/StructureScene.svelte.d.ts +5 -2
  193. package/dist/structure/atom-properties.js +4 -4
  194. package/dist/structure/bond-order-perception.js +115 -98
  195. package/dist/structure/bonding.d.ts +27 -1
  196. package/dist/structure/bonding.js +187 -16
  197. package/dist/structure/export.js +1 -1
  198. package/dist/structure/index.d.ts +3 -2
  199. package/dist/structure/index.js +0 -2
  200. package/dist/structure/parse.js +88 -59
  201. package/dist/symmetry/WyckoffTable.svelte +7 -0
  202. package/dist/symmetry/index.js +13 -14
  203. package/dist/table/HeatmapTable.svelte +45 -66
  204. package/dist/table/HeatmapTable.svelte.d.ts +1 -1
  205. package/dist/table/ToggleMenu.svelte +19 -10
  206. package/dist/theme/themes.mjs +12 -0
  207. package/dist/tooltip/index.d.ts +1 -1
  208. package/dist/tooltip/index.js +0 -1
  209. package/dist/trajectory/Trajectory.svelte +43 -15
  210. package/dist/trajectory/TrajectoryInfoPane.svelte +2 -2
  211. package/dist/trajectory/extract.js +1 -1
  212. package/dist/trajectory/frame-reader.js +4 -4
  213. package/dist/trajectory/helpers.d.ts +5 -4
  214. package/dist/trajectory/helpers.js +9 -17
  215. package/dist/trajectory/index.d.ts +2 -2
  216. package/dist/trajectory/index.js +2 -2
  217. package/dist/trajectory/parse/ase.js +4 -4
  218. package/dist/trajectory/parse/hdf5.js +1 -1
  219. package/dist/trajectory/parse/index.js +2 -3
  220. package/dist/trajectory/parse/lammps.js +1 -1
  221. package/dist/trajectory/parse/vasp.js +1 -1
  222. package/dist/trajectory/plotting.d.ts +1 -1
  223. package/dist/trajectory/plotting.js +38 -38
  224. package/dist/trajectory/types.d.ts +1 -1
  225. package/dist/utils.d.ts +1 -0
  226. package/dist/utils.js +9 -0
  227. package/dist/xrd/calc-xrd.js +3 -4
  228. package/dist/xrd/parse.js +1 -1
  229. package/package.json +42 -22
@@ -1,6 +1,7 @@
1
- import type { CompUnit, PseudoBinaryMetadata, SpecialPointType, TempUnit } from './types';
2
- export type DiagramPoint = [number, number];
3
- export type TempRange = [number, number];
1
+ import type { Vec2 } from '../math';
2
+ import type { CompUnit, PseudoBinaryMetadata, SpecialPoint, TempUnit } from './types';
3
+ export type DiagramPoint = Vec2;
4
+ export type TempRange = Vec2;
4
5
  export type BoundElement = string | DiagramPoint;
5
6
  export interface DiagramInputMeta {
6
7
  components: [string, string];
@@ -19,12 +20,7 @@ export interface RegionInput {
19
20
  bounds: BoundElement[];
20
21
  label_position?: DiagramPoint;
21
22
  }
22
- export interface SpecialPointInput {
23
- id: string;
24
- type: SpecialPointType;
25
- position: DiagramPoint;
26
- label?: string;
27
- }
23
+ export type SpecialPointInput = SpecialPoint;
28
24
  export interface DiagramInput {
29
25
  meta: DiagramInputMeta;
30
26
  curves: Record<string, DiagramPoint[]>;
@@ -1,6 +1,6 @@
1
1
  export { build_diagram } from './build-diagram';
2
2
  export * from './colors';
3
- export * from './diagram-input';
3
+ export type * from './diagram-input';
4
4
  export { default as IsobaricBinaryPhaseDiagram } from './IsobaricBinaryPhaseDiagram.svelte';
5
5
  export * from './parse';
6
6
  export { default as PhaseDiagramControls } from './PhaseDiagramControls.svelte';
@@ -9,5 +9,5 @@ export { default as PhaseDiagramExportPane } from './PhaseDiagramExportPane.svel
9
9
  export { default as PhaseDiagramTooltip } from './PhaseDiagramTooltip.svelte';
10
10
  export { parse_phase_diagram_svg } from './svg-to-diagram';
11
11
  export { default as TdbInfoPanel } from './TdbInfoPanel.svelte';
12
- export * from './types';
12
+ export type * from './types';
13
13
  export * from './utils';
@@ -1,6 +1,5 @@
1
1
  export { build_diagram } from './build-diagram';
2
2
  export * from './colors';
3
- export * from './diagram-input';
4
3
  export { default as IsobaricBinaryPhaseDiagram } from './IsobaricBinaryPhaseDiagram.svelte';
5
4
  export * from './parse';
6
5
  export { default as PhaseDiagramControls } from './PhaseDiagramControls.svelte';
@@ -9,5 +8,4 @@ export { default as PhaseDiagramExportPane } from './PhaseDiagramExportPane.svel
9
8
  export { default as PhaseDiagramTooltip } from './PhaseDiagramTooltip.svelte';
10
9
  export { parse_phase_diagram_svg } from './svg-to-diagram';
11
10
  export { default as TdbInfoPanel } from './TdbInfoPanel.svelte';
12
- export * from './types';
13
11
  export * from './utils';
@@ -50,6 +50,6 @@ export interface TdbParseResult {
50
50
  temperature_range?: [number, number];
51
51
  }
52
52
  export declare function parse_tdb(content: string): TdbParseResult;
53
- export declare function get_system_name(elements: string[]): string;
54
- export declare function is_binary_system(tdb_data: TdbData): boolean;
53
+ export declare const get_system_name: (elements: string[]) => string;
54
+ export declare const is_binary_system: (tdb_data: TdbData) => boolean;
55
55
  export declare function normalize_system_name(input: string): string;
@@ -207,17 +207,13 @@ function parse_tdb_line(line, data) {
207
207
  // TYPE_DEFINITION, DEFINE_SYSTEM_DEFAULT, etc. are ignored
208
208
  }
209
209
  // Get a normalized system name from elements (e.g., "AL-ZN" always alphabetically sorted)
210
- export function get_system_name(elements) {
211
- return elements
212
- .filter(is_real_element)
213
- .map((el) => el.toUpperCase())
214
- .sort()
215
- .join(`-`);
216
- }
210
+ export const get_system_name = (elements) => elements
211
+ .filter(is_real_element)
212
+ .map((el) => el.toUpperCase())
213
+ .sort()
214
+ .join(`-`);
217
215
  // Check if a TDB file represents a binary system
218
- export function is_binary_system(tdb_data) {
219
- return tdb_data.elements.map((el) => el.symbol).filter(is_real_element).length === 2;
220
- }
216
+ export const is_binary_system = (tdb_data) => tdb_data.elements.map((el) => el.symbol).filter(is_real_element).length === 2;
221
217
  // Predicate to filter out non-real elements (VA = vacancy, /- = electron)
222
218
  const is_real_element = (sym) => sym !== `VA` && sym !== `/-`;
223
219
  // Known element symbols for parsing concatenated system names (e.g., "CuMg" -> ["CU", "MG"])
@@ -124,10 +124,10 @@ function extract_mpds_scales(doc) {
124
124
  // Note: value 100 appears in both filters (valid as 100 at% and 100°C).
125
125
  // This is intentional — only endpoints are used for scale mapping.
126
126
  const comp_vals = [
127
- ...new Set(numbers.filter((v) => v >= 0 && v <= 100 && v % 10 === 0)),
127
+ ...new Set(numbers.filter((value) => value >= 0 && value <= 100 && value % 10 === 0)),
128
128
  ].toSorted((a, b) => a - b);
129
129
  const temp_vals = [
130
- ...new Set(numbers.filter((v) => v >= 100 && v % 100 === 0 && v <= 3000)),
130
+ ...new Set(numbers.filter((value) => value >= 100 && value % 100 === 0 && value <= 3000)),
131
131
  ].toSorted((a, b) => a - b);
132
132
  if (comp_vals.length < 2 || temp_vals.length < 2) {
133
133
  throw new Error(`MPDS SVG: could not infer axis ranges (found ${comp_vals.length} composition, ${temp_vals.length} temperature values)`);
@@ -164,10 +164,10 @@ function extract_mpds_scales(doc) {
164
164
  }
165
165
  // Deduplicate and sort
166
166
  const x_ticks_sorted = [
167
- ...new Set(x_major_ticks.map((v) => Math.round(v * 10) / 10)),
167
+ ...new Set(x_major_ticks.map((value) => Math.round(value * 10) / 10)),
168
168
  ].toSorted((a, b) => a - b);
169
169
  const y_ticks_sorted = [
170
- ...new Set(y_major_ticks.map((v) => Math.round(v * 10) / 10)),
170
+ ...new Set(y_major_ticks.map((value) => Math.round(value * 10) / 10)),
171
171
  ].toSorted((a, b) => a - b);
172
172
  if (x_ticks_sorted.length < 2 || y_ticks_sorted.length < 2) {
173
173
  throw new Error(`MPDS SVG: could not find tick marks (found ${x_ticks_sorted.length} x-ticks, ${y_ticks_sorted.length} y-ticks)`);
@@ -432,45 +432,45 @@ function extract_simple_labels(doc, labels) {
432
432
  }
433
433
  }
434
434
  // === Component Inference ===
435
+ const split_phase_label = (label) => label.text.split(/\s*\+\s*/);
435
436
  // Infer binary components from region labels
436
437
  function infer_components(labels) {
437
438
  // Sort labels by x position, split each into phases
438
439
  const sorted = labels.toSorted((a, b) => a.px_x - b.px_x);
439
440
  if (sorted.length < 2)
440
441
  return [`A`, `B`];
441
- const split = (label) => label.text.split(/\s*\+\s*/);
442
- const leftmost = split(sorted[0]);
443
- const rightmost = split(sorted[sorted.length - 1]);
442
+ const leftmost = split_phase_label(sorted[0]);
443
+ const rightmost = split_phase_label(sorted[sorted.length - 1]);
444
444
  // Component A: the unique phase in the leftmost region that doesn't appear on the right
445
445
  // For "La2NiO4 + La2O3", La2O3 is the pure A endpoint
446
446
  let comp_a = `A`;
447
447
  if (leftmost.length === 2) {
448
- const right_phases = new Set(sorted.slice(-3).flatMap(split));
449
- comp_a = leftmost.find((p) => !right_phases.has(p)) ?? leftmost[1] ?? `A`;
448
+ const right_phases = new Set(sorted.slice(-3).flatMap(split_phase_label));
449
+ comp_a = leftmost.find((phase) => !right_phases.has(phase)) ?? leftmost[1] ?? `A`;
450
450
  }
451
451
  // Component B: the unique phase in the rightmost region that doesn't appear on the left
452
452
  let comp_b = `B`;
453
453
  if (rightmost.length === 2) {
454
- const left_phases = new Set(sorted.slice(0, 3).flatMap(split));
455
- comp_b = rightmost.find((p) => !left_phases.has(p)) ?? rightmost[1] ?? `B`;
454
+ const left_phases = new Set(sorted.slice(0, 3).flatMap(split_phase_label));
455
+ comp_b = rightmost.find((phase) => !left_phases.has(phase)) ?? rightmost[1] ?? `B`;
456
456
  }
457
457
  return [comp_a, comp_b];
458
458
  }
459
459
  // === Region Inference ===
460
460
  // Infer phase regions from orthogonal boundaries using flood-fill on a cell grid
461
461
  function infer_regions(boundaries, labels, x_scale, y_scale) {
462
- const verticals = boundaries.filter((b) => b.orientation === `vertical`);
463
- const horizontals = boundaries.filter((b) => b.orientation === `horizontal`);
462
+ const verticals = boundaries.filter((boundary) => boundary.orientation === `vertical`);
463
+ const horizontals = boundaries.filter((boundary) => boundary.orientation === `horizontal`);
464
464
  // Collect all unique x and y coordinates (boundaries + domain edges)
465
465
  const x_coords = collect_unique_sorted([
466
466
  x_scale.domain[0],
467
467
  x_scale.domain[1],
468
- ...verticals.map((b) => b.x1), // x1 === x2 for vertical
468
+ ...verticals.map((boundary) => boundary.x1), // x1 === x2 for vertical
469
469
  ]);
470
470
  const y_coords = collect_unique_sorted([
471
471
  y_scale.domain[0],
472
472
  y_scale.domain[1],
473
- ...horizontals.map((b) => b.y1), // y1 === y2 for horizontal
473
+ ...horizontals.map((boundary) => boundary.y1), // y1 === y2 for horizontal
474
474
  ]);
475
475
  // Build cell grid: cells[col][row]
476
476
  const n_cols = x_coords.length - 1;
@@ -1,6 +1,7 @@
1
- import type { Sides } from '../plot';
1
+ import type { Point2D, Vec2 } from '../math';
2
+ import type { LineStyle } from '../plot';
3
+ import type { Sides } from '../plot/layout';
2
4
  import type { TooltipConfig, TooltipProp } from '../tooltip';
3
- import type { Vec2 } from '../math.ts';
4
5
  export type TempUnit = `K` | `°C` | `°F`;
5
6
  export type CompUnit = `at%` | `wt%` | `mol%` | `fraction`;
6
7
  export interface PhaseRegion {
@@ -15,11 +16,7 @@ export interface PhaseBoundary {
15
16
  id: string;
16
17
  type: BoundaryType;
17
18
  points: Vec2[];
18
- style?: {
19
- color?: string;
20
- width?: number;
21
- dash?: string;
22
- };
19
+ style?: LineStyle;
23
20
  label?: string;
24
21
  }
25
22
  export type SpecialPointType = `eutectic` | `peritectic` | `eutectoid` | `peritectoid` | `congruent` | `melting_point` | `custom`;
@@ -87,10 +84,7 @@ export interface PhaseHoverInfo {
87
84
  region: PhaseRegion;
88
85
  composition: number;
89
86
  temperature: number;
90
- position: {
91
- x: number;
92
- y: number;
93
- };
87
+ position: Point2D;
94
88
  lever_rule?: LeverRuleResult;
95
89
  vertical_lever_rule?: VerticalLeverRuleResult;
96
90
  special_point?: SpecialPoint;
@@ -1,5 +1,5 @@
1
1
  import { type Vec2 } from '../math';
2
- import type { Sides } from '../plot';
2
+ import type { Sides } from '../plot/layout';
3
3
  import type { CompUnit, LeverRuleMode, LeverRuleResult, PhaseDiagramConfig, PhaseDiagramData, PhaseHoverInfo, PhaseRegion, TempUnit, VerticalLeverRuleResult } from './types';
4
4
  export declare function convert_temp(value: number, from: TempUnit, to: TempUnit): number;
5
5
  export declare const PHASE_DIAGRAM_DEFAULTS: Readonly<{
@@ -89,7 +89,7 @@ export declare function compute_label_properties(label: string, bounds: {
89
89
  lines: string[];
90
90
  scale: number;
91
91
  };
92
- export declare function transform_vertices(vertices: Vec2[], x_scale: (val: number) => number, y_scale: (val: number) => number): Vec2[];
92
+ export declare const transform_vertices: (vertices: Vec2[], x_scale: (val: number) => number, y_scale: (val: number) => number) => Vec2[];
93
93
  export declare function format_composition(value: number, unit?: CompUnit, include_unit?: boolean): string;
94
94
  export declare function format_temperature(value: number, unit?: TempUnit): string;
95
95
  export declare function calculate_lever_rule(region: PhaseRegion, composition: number, temperature: number): LeverRuleResult | null;
@@ -76,10 +76,10 @@ export const PHASE_COLOR_HEX = {
76
76
  };
77
77
  // Derive RGB string format (e.g. "135, 206, 250") for custom alpha usage
78
78
  export const PHASE_COLOR_RGB = Object.freeze(Object.fromEntries(Object.entries(PHASE_COLOR_HEX).map(([key, hex]) => {
79
- const r = parseInt(hex.slice(1, 3), 16);
80
- const g = parseInt(hex.slice(3, 5), 16);
81
- const b = parseInt(hex.slice(5, 7), 16);
82
- return [key, `${r}, ${g}, ${b}`];
79
+ const red = parseInt(hex.slice(1, 3), 16);
80
+ const green = parseInt(hex.slice(3, 5), 16);
81
+ const blue = parseInt(hex.slice(5, 7), 16);
82
+ return [key, `${red}, ${green}, ${blue}`];
83
83
  })));
84
84
  // Derive rgba() format with default alpha using add_alpha
85
85
  const PHASE_ALPHA = { two_phase: 0.5, default: 0.5, tie_line: 1 };
@@ -109,7 +109,7 @@ export function get_phase_color_key(name) {
109
109
  if (lower === `l`)
110
110
  return `liquid`; // exact match for shorthand "L"
111
111
  for (const [patterns, key, prefix] of PHASE_PATTERNS) {
112
- if (patterns.some((p) => lower.includes(p)))
112
+ if (patterns.some((pattern) => lower.includes(pattern)))
113
113
  return key;
114
114
  if (prefix && lower.startsWith(prefix))
115
115
  return key;
@@ -129,7 +129,7 @@ export function get_multi_phase_gradient(name) {
129
129
  return null;
130
130
  const phases = name
131
131
  .split(`+`)
132
- .map((s) => s.trim())
132
+ .map((phase) => phase.trim())
133
133
  .filter(Boolean);
134
134
  if (phases.length < 2)
135
135
  return null;
@@ -152,8 +152,8 @@ export function find_phase_at_point(composition, temperature, data) {
152
152
  }
153
153
  // SVG path generator using d3-shape
154
154
  const path_line = line()
155
- .x((d) => d[0])
156
- .y((d) => d[1]);
155
+ .x((point) => point[0])
156
+ .y((point) => point[1]);
157
157
  // Generate closed SVG path for polygon regions (min 3 points)
158
158
  export const generate_region_path = (vertices) => vertices.length < 3 ? `` : `${path_line(vertices)} Z`;
159
159
  // Generate open SVG path for boundary curves (min 2 points)
@@ -222,9 +222,7 @@ function wrap_text(text, max_chars) {
222
222
  return lines;
223
223
  }
224
224
  // Transform data coordinates to SVG coordinates using scale functions
225
- export function transform_vertices(vertices, x_scale, y_scale) {
226
- return vertices.map(([comp, temp]) => [x_scale(comp), y_scale(temp)]);
227
- }
225
+ export const transform_vertices = (vertices, x_scale, y_scale) => vertices.map(([comp, temp]) => [x_scale(comp), y_scale(temp)]);
228
226
  // Format composition value for display
229
227
  export function format_composition(value, unit = `at%`, include_unit = true) {
230
228
  if (unit === `fraction`)