A reasonable solution to this might be to determine when the number of pixels that'd match dark v light is near the midpoint, adding a text-shadow (for text) or box-shadow (everything else) of 1px with the more dominant of the two colors.
Edit: Looked closer at the library, if he just added dark-mid or light-mid styles when close, the user can implement the appropriate visual differentiator. Should be good.
Edit: Looked closer at the library, if he just added dark-mid or light-mid styles when close, the user can implement the appropriate visual differentiator. Should be good.