A pure, zero-dependency TypeScript color engine built on OKLCH. Publishes to npm
as oklch-engine.
What ships today: the color-space core and the token contract. Hand-rolled
sRGB ⇄ OKLab ⇄ OKLCH conversions plus OKLCH → linear-light Display-P3, on the
Ottosson and CSS Color 4 reference matrices; a never-throwing parseColor;
oklch()/hex/rgb() serializers with defended degradation on hostile input;
and the typed semantic
token contract — ramp primitives, generative rules, and the binding-provenance
model — that the solver builds on. The solver itself (seed color in,
contrast-solved token system out, light and dark derived independently, every
readable token bound to the smallest ramp step that clears its APCA/WCAG
target, with a receipt naming how each token was derived) lands module by
module on this contract.
pnpm install
pnpm gate # the full local gate — the same chain CI runsThe gate is format:check → lint → typecheck → test → build. The test suite
runs twice — once under node, once under jsdom — because the engine's
isomorphism is a tested claim, not a stated one.
TypeScript is pinned to the 6.x line: TypeScript 7 ships without a compiler API, so tools that need programmatic compiler access — typescript-eslint here — run against 6.x until the 7.1 API lands.