@assemblcorp/shared (1.0.9)
Installation
@assemblcorp:registry=npm install @assemblcorp/shared@1.0.9"@assemblcorp/shared": "1.0.9"About this package
@assemblcorp/shared
Cross-domain utilities, types, and color operations - zero-dependency foundation for theme system, build tooling, and components.
Semantic Entry Points
This package uses multi-entry bundling for optimal tree-shaking and minimal bundle bloat. Choose the import path that matches your use case:
Main Export (Types + Utilities)
import type { OKLCHColor, PrimitiveColorToken, PrimitiveSpacingToken } from '@assemblcorp/shared'
import { hexToOKLCH, getWCAGContrast } from '@assemblcorp/shared'
Use when: You need types and utilities from multiple domains. ~8 KB gzipped.
Color-Specific Export
import { hexToOKLCH, oklchToHex, parseOKLCH, formatOKLCH, isValidOKLCH, isValidHex, reduceToGamut, isInSRGBGamut, getPerceivedBrightness, isColorDark, getHueDistance, getComplementaryHue, classifyHarmony } from '@assemblcorp/shared/color'
Use when: Only working with OKLCH conversions and color utilities. ~3 KB gzipped (62% smaller).
Validation Export
import { validateTokenPath, validateSemanticCoverage, validateWCAGCompliance } from '@assemblcorp/shared/validation'
Use when: Validating design tokens or component variants. ~2 KB gzipped (75% smaller).
Codecs Export
import { encodeTokenValue, decodeTokenValue } from '@assemblcorp/shared/codecs'
Use when: Serializing/deserializing design tokens. ~1 KB gzipped (87% smaller).
Key Features
| Feature | Details |
|---|---|
| OKLCH Conversions | Perceptually-uniform color space for theme generation |
| Contrast Validation | WCAG AAA & APCA contrast checking |
| Branded Types | Type-safe token categorization (colors ≠ spacing) |
| Color Perception | Brightness detection, hue harmonies, gamut management |
Dependencies
None - pure TypeScript, zero runtime dependencies.
Quick Start
import { hexToOKLCH, getWCAGContrast } from '@assemblcorp/shared'
// Color conversion
const oklch = hexToOKLCH('#3B82F6') // { l: 0.75, c: 0.14, h: 250 }
// Contrast checking
const contrast = getWCAGContrast('#000000', '#FFFFFF') // ratio: 21, AAA compliant
Build
pnpm -C packages/shared build
pnpm -C packages/shared typecheck
Architecture
Leaf Package: No internal @assemblcorp dependencies - provides foundation for all other packages.
Type Safety: Branded token types prevent mixing colors/spacing/typography (compile-time guarantees).
Used By: Kernel, UI, Themes, Tooling, Terrazzo plugins.
License
MIT
Dependencies
Dependencies
| ID | Version |
|---|---|
| neverthrow | ^8.2.0 |
| radashi | ^12.7.2 |
| zod | ^4.3.6 |
Development Dependencies
| ID | Version |
|---|---|
| @typescript/native-preview | 7.0.0-dev.20260225.1 |
| type-fest | ^5.4.4 |
| typescript | npm:@typescript/native-preview@7.0.0-dev.20260225.1 |
| vitest | ^4.0.18 |