@@ -2,32 +2,31 @@ import React from "react";
22import Typography from "@mui/material/Typography" ;
33import type { SxProps , Theme } from "@mui/material/styles" ;
44
5- // Neither version is importable at runtime -- smiles-drawer's package.json is blocked
6- // by its own "exports" field, and RDKit drawings are produced server-side (see
7- // gui/src/server/routes/rules.py). Both are kept in sync by hand with the resolved
8- // version in package-lock.json and pyproject.toml's `rdkit==` pin, respectively.
9- const RDKIT_VERSION = "2025.9.1" ;
5+ // smiles-drawer's package.json is blocked from import by its own "exports" field, so
6+ // this is kept in sync by hand with the resolved version in package-lock.json --
7+ // scripts/checkSmilesDrawerVersion.js fails CI/lint if the two drift apart.
108const SMILES_DRAWER_VERSION = "2.4.1" ;
119
12- type DrawingLibrary = "smiles-drawer" | "rdkit" ;
13-
14- const LIBRARY_LABEL : Record < DrawingLibrary , string > = {
15- "smiles-drawer" : `SmilesDrawer v ${ SMILES_DRAWER_VERSION } ` ,
16- rdkit : `RDKit v ${ RDKIT_VERSION } ` ,
17- } ;
10+ type DrawingAttributionProps =
11+ | { library : "smiles-drawer" ; sx ?: SxProps < Theme > }
12+ // RDKit drawings are produced server-side (see gui/src/server/routes/rules.py), so
13+ // there's no local constant to hardcode -- the version is only known once the
14+ // caller has actually fetched a drawing and the server reported what rendered it.
15+ | { library : "rdkit" ; version : string ; sx ?: SxProps < Theme > } ;
1816
1917// A single caption attributing one or more structure/reaction drawings above it to the
2018// library that rendered them. Place once per diagram -- if a diagram contains multiple
2119// drawings from the same library (e.g. a compound plus its reconstructions), attribute
2220// the whole group once rather than repeating this per drawing.
23- export const DrawingAttribution : React . FC < { library : DrawingLibrary ; sx ?: SxProps < Theme > } > = ( { library, sx } ) => {
21+ export const DrawingAttribution : React . FC < DrawingAttributionProps > = ( props ) => {
22+ const label = props . library === "smiles-drawer" ? `SmilesDrawer v${ SMILES_DRAWER_VERSION } ` : `RDKit v${ props . version } ` ;
2423 return (
2524 < Typography
2625 variant = "caption"
2726 color = "text.secondary"
28- sx = { { display : "block" , fontStyle : "italic" , ...sx } }
27+ sx = { { display : "block" , fontStyle : "italic" , ...props . sx } }
2928 >
30- Drawn with { LIBRARY_LABEL [ library ] }
29+ Drawn with { label }
3130 </ Typography >
3231 ) ;
3332} ;
0 commit comments