Make scale-reference stateless: settings per call, no global config - #2
Merged
Merged
Conversation
Remove the shared settings object (configure/getConfig/resetConfig). Settings are passed per call: fromEllipse(ellipse, diameterMm, options), explain(reason, messages). Defaults are frozen constants; an unknown or non-positive option throws. A test fails on any module-level let/var. Version 0.2.0 (breaking; nothing published yet). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The package kept one shared, changeable settings object:
configure()changed it for every caller in the app, andresetConfig()put it back. This PR removes that. Every setting is now passed with the call, and the package keeps no state at all.What changes
configure({maxTiltDegrees, minReferencePixels, references})changed module state for everyonefromEllipse(ellipse, diameterMm, options?). The options apply to that call only.getConfig()/resetConfig()DEFAULT_OPTIONSis a frozen constant.REFERENCES,MAX_TILT_DEGREES,MIN_REFERENCE_PIXELSwere getters over the shared objectmaxTilt) was silently ignoredTypeError.explain(reason)had fixed English textexplain(reason, messages?)accepts your own text or translation, withdefaultas a fallback.The reference table (
DEFAULT_REFERENCES) stays as a frozen, published-size constant. Nothing reads it for you;fromEllipsetakes any diameter, so apps keep their own references.The version goes to 0.2.0 because the removed
configure,getConfigandresetConfigbreak the old API. Nothing is published yet. The MoleCare app never calls them: its adapter only re-exports them, and it will be updated when the pin is bumped. The app's ownScaleReferencetest (17 cases) passes unchanged against this code.How it was checked
letorvar, so state cannot creep back in.🤖 Generated with Claude Code