import { TokenType } from "@power-plant/dtcg-schema"; import { CreateTamaguiProps } from "tamagui"; import { Fonts, Schema, Tokens } from "@razorwind/core/schema"; import { formatTokenValue, resolveTokenSets, toCssVar } from "@razorwind/core/utils"; import { GeneratorFunctionResult } from "@power-plant/core"; //#region src/types.d.ts /** * Animation driver entry imported from `@tamagui/config/v5-*`. * * @see https://tamagui.dev/docs/core/config-v5 */ type TamaguiAnimationDriver = "css" | "rn" | "reanimated" | "motion" | false; /** * Tamagui `createTokens` category keys we emit from DTCG tokens. * * `color` is palettes / primitives only. Semantic theme / `$theme` colors * (including computed state siblings) go to `createThemes` extras. */ type TamaguiTokenCategory = "color" | "space" | "size" | "radius" | "zIndex" | "blur" | "fontSize" | "shadow" | "insetShadow" | "dropShadow" | "textShadow" | "fontWeight" | "boxShadow"; /** * Options for the Razorwind Tamagui config generator. */ interface TamaguiPluginOptions { /** * Output path written relative to the execution cwd. * * Light and dark schemes are always written to this single file — Tamagui * `createThemes` encodes both as `light` / `dark` plus nested children. * * @defaultValue `"tamagui.config.ts"` */ outputPath?: string; /** * Animation driver import from `@tamagui/config/v5-*`. * Set to `false` to omit animations (v5 base config includes none). * * @defaultValue `"css"` */ animations?: TamaguiAnimationDriver; /** * Shorthands to include in the generated config. * * @defaultValue `{}` */ shorthands?: Record; /** * Media queries to include in the generated config. * * @defaultValue `{}` */ media?: CreateTamaguiProps["media"]; /** * Default font family to include in the generated config. */ defaultFont?: string; /** * A module to import config from to include in the generated config. */ importConfig?: string; /** * When true, spread `defaultConfig` from `@tamagui/config/v5` and merge * generated tokens/themes on top. When false, emit a minimal config from * Razorwind tokens only. * * @defaultValue `false` */ useDefaultConfig?: boolean; /** * Restrict generated token rows to these DTCG `$type` values. * When omitted, all supported types are included. */ includeTypes?: TokenType[]; /** * Include a TypeScript module augmentation so `$` token autocomplete * picks up generated tokens. * * @defaultValue `true` */ includeTypeAugmentation?: boolean; /** * Override body for generated `INSTALL.md`. When omitted, Tamagui wiring * steps are generated for the output config file. */ installGuide?: string; } /** * A flattened design token ready for Tamagui config emission. */ interface FlatToken { /** Dot-separated token path (e.g. `color.primary`). */ path: string; /** DTCG `$type`, when known. */ type?: TokenType | string; /** Raw `$value` from the token document. */ value: unknown; /** CSS-friendly string form of {@link value}. */ cssValue: string; /** Value suitable for Tamagui `createTokens` (number or string). */ tamaguiValue: string | number; /** Mapped Tamagui token category, when known. */ category?: TamaguiTokenCategory; /** Leaf key used inside the Tamagui token category object. */ tokenKey?: string; /** Optional DTCG `$description`. */ description?: string; /** Theme / set id when tokens are a `Record`. */ theme?: string; /** * Semantic children theme from the token's `theme` / `$theme` property * (`danger`, `accent`, …). Distinct from {@link theme} (token-set id). */ childTheme?: string; /** * True when an ancestor group is marked as a primitive (`primitive: true` or `$type: "primitive"` or `$type: "palette"`). Those scales feed `createTokens({ color })` and `createThemes` palettes. Semantic colors (theme / `$theme`, including computed state siblings) are not primitives and go to extras only. */ primitive?: boolean; } //#endregion //#region src/flatten.d.ts /** * True when a DTCG group is explicitly a color palette. * * Accepts `palette: true`, `$palette: true`, or `$type: "palette"`. */ declare function isPaletteGroup(node: Record): boolean; /** * Map a DTCG token path + type onto a Tamagui `createTokens` category. */ declare function resolveTokenCategory(path: string, type?: string): TamaguiTokenCategory | undefined; /** * Join path/kebab segments into a camelCase Tamagui token key. * * `background` + `accent-subtle` → `backgroundAccentSubtle`. * Numeric steps stay attached (`blue` + `1` → `blue1`). */ declare function toCamelCaseKey(parts: string[]): string; /** * Derive the Tamagui token key from a DTCG path (strip category prefix). * * `radius.DEFAULT` → `true` (Tamagui default token convention). * `color.blue.1` → `blue1`. * `color.background.accent-subtle` → `backgroundAccentSubtle`. */ declare function toTokenKey(path: string): string; /** * Flatten DTCG token trees into Tamagui config rows. */ declare function flattenTokens(tokens: Tokens | Record, options?: Pick): FlatToken[]; //#endregion //#region src/fonts.d.ts /** * A Tamagui `createFont` definition assembled from DTCG typography tokens, * font-family tokens, and `spec.fonts`. * * @see https://tamagui.dev/docs/core/font-language#font-tokens */ interface TamaguiFontDef { /** Tamagui `fonts` object key (`body`, `heading`, `body_cn`, …). */ key: string; /** CSS font-family stack used when `isWeb` is true. */ webFamily: string; /** Family name used on native. */ nativeFamily: string; size: Record; lineHeight: Record; weight: Record; letterSpacing: Record; /** Rendered `face` object literal for local fonts, when present. */ face?: string; } /** * Map a font role / family token name onto a Tamagui `fonts` object key. * * Family aliases (`sans` / `serif` → `body`, `monospace` → `mono`) stay * collapsed so Tamagui's default font names resolve. Distinct type roles * (`heading`, `title`, `display`, `caption`, `code`) keep their own keys. */ declare function tamaguiFontKeyFromRole(name: string): string; /** * Tamagui `fonts` object key for a typography token. The DTCG token name is * kept as-is (`display-lg`, `heading-2xl`) so `fontFamily="$display-lg"` * matches the design tokens. Nested language segments use the `_` separator * FontLanguage expects (`typography.body.cn` → `body_cn`). * * @see https://tamagui.dev/docs/core/font-language */ declare function typographyFontKey(path: string): string; /** * Build Tamagui font definitions from typography tokens, font-family tokens, * and `spec.fonts`. Each resulting entry is emitted via `createFont`. * * @see https://tamagui.dev/docs/core/font-language#font-tokens */ declare function collectTamaguiFonts(tokens: FlatToken[], fonts?: Fonts): TamaguiFontDef[]; /** * Valid JS identifier used for the `const = createFont(...)` binding. * Hyphenated token names (`display-lg`) become camelCase (`displayLgFont`); * FontLanguage keys (`body_cn`) keep the underscore. */ declare function fontVarName(key: string, index: number): string; //#endregion //#region src/format.d.ts /** * Convert a DTCG `$value` into a Tamagui token primitive. * * Colors stay CSS strings. Dimensions with `px` (or unitless numbers) become * numbers — Tamagui `space` / `size` / `radius` / `zIndex` expect numbers. */ declare function toTamaguiValue(value: unknown, type?: string): string | number; //#endregion //#region src/install.d.ts /** * Build Tamagui INSTALL.md for generated config file. * * @see https://tamagui.dev/docs/core/configuration */ declare function renderInstallMd(options: { outputPath: string; }): string; //#endregion //#region src/generate.d.ts /** * Render a Tamagui config module from flattened design tokens. * * `createTokens({ color })` holds palette / primitive scales. Light and dark * semantic colors become `createThemes` extra maps (tagged `$theme` names as * `light_` / `dark_`, with the theme name stripped from the token * key). Each typography token is emitted as its own `createFont` entry with * that token's size, line height, and weight (not a shared type scale). * * @see https://tamagui.dev/docs/core/configuration * @see https://tamagui.dev/docs/intro/themes * @see https://tamagui.dev/docs/core/font-language#font-tokens */ declare function renderTamaguiConfig(spec: Schema, tokens: FlatToken[], options?: TamaguiPluginOptions): string; /** * Generate a Tamagui config file from a Razorwind schema. */ declare function generateTamaguiConfig(spec: Schema, options?: TamaguiPluginOptions): GeneratorFunctionResult; //#endregion //#region src/index.d.ts /** * Razorwind plugin that turns design tokens into a Tamagui config * (`createTamagui` + `createTokens` + `createThemes` + `createFont`). * * Light and dark token sets are emitted as a single config. * `createTokens({ color })` is palettes / primitives only. Semantic theme / * `$theme` colors (including computed state siblings such as hover / pressed / * disabled) go to `createThemes` extras — never to `tokens.color.*`. Tagged * semantics become nested Tamagui themes via `createThemes` from * `@tamagui/theme-builder` (`light_primary`, `dark_danger`, …), with the theme * name stripped from the token key (`backgroundPrimarySubtle` + `theme: "primary"` * → `backgroundSubtle`; `backgroundDangerHover` → `backgroundHover` on `danger`; * `ringPrimarySubtle` → `ringSubtle` on `primary`). Untagged semantic colors * (overlay, link, …) land on `base.extra`. Primitive palettes feed * `base.palette` / `accent.palette`. * * Typography tokens (`$type: "typography"`) each emit their own Tamagui * `createFont` entry with that token's size, line height, and weight. Font * keys keep the DTCG token name (`display-lg`). Names with a `_` suffix (or a * nested language segment) become FontLanguage variants (`body_cn`). * * @see https://tamagui.dev/docs/core/configuration * @see https://tamagui.dev/docs/intro/themes * @see https://tamagui.dev/docs/guides/theme-builder * @see https://tamagui.dev/docs/core/font-language#font-tokens * * @example * ```ts * import { defineConfig } from "@razorwind/core"; * import tamagui from "@razorwind/tamagui"; * * export default defineConfig({ * plugins: [tamagui()] * }); * ``` */ declare const _default: (options?: TamaguiPluginOptions | undefined) => import("@razorwind/core/plugin").Plugin; //#endregion export { type FlatToken, type TamaguiAnimationDriver, type TamaguiFontDef, type TamaguiPluginOptions, type TamaguiTokenCategory, collectTamaguiFonts, _default as default, flattenTokens, fontVarName, formatTokenValue, generateTamaguiConfig, isPaletteGroup, renderInstallMd, renderTamaguiConfig, resolveTokenCategory, resolveTokenSets, tamaguiFontKeyFromRole, toCamelCaseKey, toCssVar, toTamaguiValue, toTokenKey, typographyFontKey }; //# sourceMappingURL=index.d.cts.map