/** * `@civitai/theme` token GENERATOR. * * Feeds the vendored civitai `createTheme` override (`theme.source.ts`) through * Mantine's PUBLIC theme resolver — the same primitives civitai/civitai uses in * `mantine-css-variables.ts`: * `mergeMantineTheme(DEFAULT_THEME, override)` -> `defaultCssVariablesResolver` * (yields the `{ variables, light, dark }` map of `--mantine-*` values). * From there this generator does its OWN thing (it does NOT call Mantine's * `convertCssVariables`): a hand-rolled transitive `var()` resolver reduces each * selected Mantine variable to a concrete literal, which is then re-namespaced * and emitted as the `--civitai-*` CSS / typed-JS / DTCG artifacts. * * The output is a re-namespaced `--civitai-*` token contract. We deliberately * do NOT expose `--mantine-*` as the public surface: every `--civitai-*` value * is fully resolved down to a concrete literal (hex / rem), so consumers need * only this package's tokens, never Mantine's variables. * * `buildArtifacts()` is PURE (no fs) so both the build writer * (`scripts/build-tokens.ts`) and the generation-parity test consume it. */ import { type MantineThemeOverride } from '@mantine/core'; /** * A light/dark pair, for the tokens whose two sides come from different places — * something a single Mantine variable cannot express. */ type SchemePair = { light: string; dark: string; }; /** A single public token, mapped to the Mantine variable it derives from. */ interface TokenSpec { /** Public name WITHOUT the `--civitai-` prefix, e.g. `color-primary`. */ name: string; /** * Source Mantine variable name (with `--mantine-` prefix), or one per scheme. * Mutually exclusive with `literal` — exactly one of the two must be set. */ source?: string | SchemePair; /** * Concrete literal value for a token that deliberately does NOT derive from * Mantine. The breakpoint scale uses this, and the reason is load-bearing: * civitai's px breakpoints are NOT part of its Mantine theme, and Mantine's own * stock EM scale disagrees with them on four of five keys (see * `breakpoints.source.ts`). Routing them through `mergeMantineTheme` would * silently resolve any un-overridden key to the wrong number, so they bypass * the Mantine pipeline entirely. A single string is scheme-independent by * construction. */ literal?: string | SchemePair; /** Typed-syntax category — drives `@property` registration + DTCG `$type`. */ type: 'color' | 'length' | 'font'; description: string; /** * Force this token into the `[data-theme='dark']` block even when its resolved * dark value is IDENTICAL to light (the generator otherwise emits a dark * override only when it differs). Used for symmetry: the primary group * (`color-primary`/`-hover`/`-light`) all shift shade in dark, so the * contrast/foreground token belongs alongside them in the dark block even * though its value (white) happens to be scheme-independent — keeping the dark * block self-contained rather than silently inheriting from `:root`/light. */ alwaysDark?: boolean; } export interface ResolvedTokens { /** Base + light-scheme value keyed by the FULL `--civitai-*` var name. */ root: Record; /** Dark-scheme overrides (only tokens whose value differs from light). */ dark: Record; /** Per-token metadata in spec order. */ meta: { varName: string; camel: string; type: TokenSpec['type']; description: string; }[]; } /** Resolve the token spec against the vendored theme into concrete values. */ export declare function resolveTokens(themeOverride?: MantineThemeOverride): ResolvedTokens; export interface Artifacts { 'tokens.css': string; 'tokens.dtcg.json': string; /** Generated TS module (compiled by tsc into dist/tokens.generated.js/.d.ts). */ 'tokens.generated.ts': string; } /** Build every artifact string. PURE — no fs. */ export declare function buildArtifacts(themeOverride?: MantineThemeOverride): Artifacts; export {}; //# sourceMappingURL=generate.d.ts.map