@usesource/adapter-shadcn
v0.1.0
Published
shadcn/ui ↔ canonical SOURCE mapping pack. Maps shadcn component names and CSS variable tokens to source.* canonical IDs so cross-library translate tools (in @usesource/mcp / @usesource/scan) can pivot through SOURCE without library-specific mapping code.
Downloads
49
Maintainers
Readme
@usesource/adapter-shadcn
shadcn/ui ↔ canonical SOURCE mapping pack. Maps shadcn component names
and CSS variable tokens to source.* canonical IDs so cross-library
translate tools (in @usesource/mcp and @usesource/scan) can pivot through
SOURCE without library-specific mapping code.
Install
npm install @usesource/adapter-shadcnUse
import {
lookupByIdentifier,
lookupByCanonical,
listMappings,
ADAPTER_INFO,
} from "@usesource/adapter-shadcn";
// shadcn → canonical
const buttonMapping = lookupByIdentifier("Button", "component");
// → { canonical: "source.element.button", confidence: 1, ... }
const primaryToken = lookupByIdentifier("primary", "token");
// → { canonical: "source.core.color.primary.500", confidence: 0.85, ... }
// canonical → shadcn (reverse)
const matches = lookupByCanonical("source.element.button");
// → [{ identifier: "Button", confidence: 1, ... }]
// Bulk listing for codegen / inspection
for (const m of listMappings()) console.log(m.identifier, "→", m.canonical);
console.log(ADAPTER_INFO);
// → { library: "shadcn", version: "0.1.0", mappingCount: 46 }What's mapped (v0.1.0)
| Type | Count | Examples |
|---|---:|---|
| component | 29 | Button, Card, Dialog, Input, Tabs, Sheet, … |
| token | 17 | primary, background, foreground, muted, ring, radius, … |
shadcn's tokens are the CSS variables exposed in globals.css
(--primary, --background, --radius, etc.). Components are the
exported React components from @/components/ui/*.
What's NOT mapped (yet)
- Variant props (
variant="destructive",size="lg"). These are configuration on top of the canonical component, not separate identifiers. Codemods that translate variants will rely on a separate variant-mapping pack — out of scope for this adapter pack. - Tailwind utility classes used inside shadcn components. Those are
Tailwind-native and would map through a
@usesource/adapter-tailwindpack (planned). - Component composition patterns (e.g.
<Card><CardHeader>...). The adapter maps the top-level component identifier; sub-component composition is a translator concern, not an adapter concern.
Stability
- Adapter version is independent of
@usesource/registrysnapshot version. - The contract is stable:
lookupByIdentifier,lookupByCanonical, andlistMappingswill not change signature without a major bump. - All mappings validate against
LibraryMappingSchemafrom@usesource/schemaon import. A bad mapping throws — refusing to serve incorrect translations is preferable to silently serving them.
License
Apache-2.0. See LICENSE at the repository root.
