//#region src/condition.d.ts /** * The `@` condition axis — the spine of the v0 language. * * In TeaCSS, `@` unifies every "selector / condition relative to `&` (the classed * element)": pseudo-classes, pseudo-elements, target combinators, relations, media, * and arbitrary selectors are all the same axis. A token may carry many `@cond` * segments; they are always AND (there is no OR), and the rightmost element is the * one styled. See teacss-rs `docs/proposals/v12-teacss.md` for the current language contract. * * This module is the **core parsing primitive**, consistent with `parseClassToken`: * it classifies each condition by first-character dispatch, resolves the * purely-structural kinds (self-class/id, pseudo-element, target combinator) itself, * and routes everything it cannot resolve — named conditions (`hover`, `md`, * `group-hover`, `media(...)`) and arbitrary selectors (`[…]`) — through a * **resolver hook** so presets can register named and arbitrary-selector * vocabulary without moving that vocabulary into core. * * Core owns the mechanism (classification, the hook registry, canonical assembly); * presets own the vocabulary. */ /** How an `@cond` segment is classified by its first character (after a NOT `!`). */ export type ConditionKind = /** `@.cls` / `@#id` — a class/id on the subject itself. */ "self" | /** `@::after` — a pseudo-element on the subject. */ "pseudo-element" | /** `@>li` `@_p` `@+span` `@~span` `@>*` — a combinator + target; the target is styled. */ "target" | /** `@[…]` — an arbitrary selector (`&` implicit). Resolved by a hook. */ "arbitrary" | /** Letter-first: a named condition (pseudo-class / media / relation / breakpoint / at-rule). Resolved by hooks. */ "named"; /** A single `@cond` segment parsed into structured form (no CSS resolved yet). */ export interface ParsedCondition { /** The segment without its leading `@`, exactly as written (e.g. `hover`, `.is-dragging`, `>li:hover`, `!disabled`). */ raw: string; kind: ConditionKind; /** True when the segment began with `!` (NOT). The `!` is stripped from `value`. */ negate: boolean; /** The classification payload, after stripping a leading `!` (e.g. `hover`, `.is-dragging`, `>li:hover`, `[…]`). */ value: string; } /** * Classify a single condition segment (without its leading `@`). * * Pure and total. A leading `!` sets `negate` and is stripped before dispatch. * First-character dispatch follows the current condition grammar: * `::` → pseudo-element · `.`/`#` → self · `> _ + ~` → target · `[` → arbitrary · else → named. * CSS comments may separate the two pseudo-element colons. */ export declare function parseCondition(raw: string): ParsedCondition; /** Classify a list of condition segments (e.g. `ParsedClassToken.conditions`). */ export declare function parseConditions(conditions: string[]): ParsedCondition[]; /** * The contribution of one resolved condition to the final rule, split by role so * assembly can place each part canonically (selector-first), independent of the * order conditions were written in. */ export interface ResolvedCondition { /** Ancestor prepended before the subject, e.g. `.group:hover `. */ prefix?: string; /** Combinator + target appended after the subject, shifting the styled element, e.g. ` > li`. */ combinator?: string; /** Appended directly to the subject, e.g. `:hover`, `.is-dragging`, `[data-open]`. */ suffix?: string; /** Pseudo-element on the styled element, e.g. `::after`. At most one per token. */ pseudoElement?: string; /** At-rule wrapping the whole rule, e.g. `@media (min-width: 48rem)`. */ parent?: string; } /** Context handed to resolver hooks. */ export interface ConditionResolveContext { /** The full parsed condition list, for hooks that need siblings (e.g. named container). */ conditions: ParsedCondition[]; /** The resolved theme, for hooks whose vocabulary is theme-driven (e.g. breakpoints). */ theme?: object; } /** * A resolver hook. Returns a {@link ResolvedCondition} when it handles `cond`, * or `undefined` to defer to the next hook. Presets register hooks for named * and arbitrary conditions. */ export type ConditionResolver = (cond: ParsedCondition, ctx: ConditionResolveContext) => ResolvedCondition | undefined; export interface ResolveConditionsResult { /** Conditions resolved to structured contributions (by core or a hook). */ resolved: ResolvedCondition[]; /** Conditions no hook handled — surfaced so callers/tests can detect missing vocabulary. */ unresolved: ParsedCondition[]; } /** * Resolve a list of parsed conditions. Core resolves the structural kinds; the * arbitrary and named kinds are offered to `resolvers` in order (first match wins). * Anything left over is returned in `unresolved` (it stays unresolved until a * feature registers a hook for it). * * Enforces at most one pseudo-element per token. */ export declare function resolveConditions(conditions: ParsedCondition[], resolvers?: ConditionResolver[], theme?: object): ResolveConditionsResult; export interface BuiltConditionSelector { /** The assembled selector, e.g. `.group:hover .bg\:red:hover > li`. */ selector: string; /** At-rule parents wrapping the rule, outermost-last (e.g. `["@media (min-width: 48rem)"]`). */ parents: string[]; } /** * Assemble resolved conditions onto a subject selector, canonically (selector-first): * * ``, wrapped by ``. * * Assembly canonicalizes conditions that contribute different roles, so * `a@_svg@group-hover@md` and `a@md@group-hover@_svg` produce the same selector * + parents. Conditions within the same role retain their authored order. */ export declare function buildConditionSelector(subject: string, resolved: ResolvedCondition[]): BuiltConditionSelector; //#endregion //#region src/condition-pseudo-elements.d.ts /** Whether a selector may end with these pseudo-elements, written one after another. */ export declare function isPseudoElementChain(value: string): boolean; //#endregion //#region src/utils/basic.d.ts type ToArrayResult> = [Value] extends [never] ? [] : Value extends any[] ? Value[number][] : Value extends readonly (infer U)[] ? readonly U[] : Value[]; export declare function toArray(): T[]; export declare function toArray(value: undefined): []; export declare function toArray(value: T): ToArrayResult; export declare function uniq(value: T[]): T[]; export declare function uniqueBy(array: readonly T[], equalFn: (a: T, b: T) => boolean): T[]; export declare function isString(s: any): s is string; //#endregion //#region src/utils/countable-set.d.ts export declare class CountableSet extends Set { _map: Map; constructor(values?: Iterable); add(key: K): this; delete(key: K): boolean; clear(): void; getCount(key: K): number; setCount(key: K, count: number): this; } export declare function isCountableSet(value: any): value is CountableSet; //#endregion //#region src/utils/css-identifier.d.ts export declare function isCssWhitespace(character: string | undefined): boolean; export declare function isCssNameStartCharacter(character: string | undefined): boolean; export declare function isCssNameCharacter(character: string | undefined): boolean; export declare function consumeCssEscape(value: string, start: number): number | undefined; export declare function consumeCssName(value: string, start: number): number; export declare function consumeCssIdentifier(value: string, index?: number): number | undefined; export declare function isCssIdentifier(value: string): boolean; /** Decode CSS identifier escapes so equivalent spellings share one identity. */ export declare function decodeCssIdentifier(value: string): string; //#endregion //#region src/utils/css-syntax.d.ts export interface CssTokenSpan { end: number; start: number; value: string; } export declare function splitTopLevelDelimiter(value: string, delimiter: string): string[]; export declare function splitTopLevelCommas(value: string): string[]; export declare function splitTopLevelWhitespace(value: string): string[]; export declare function topLevelWhitespaceSpans(value: string): CssTokenSpan[]; export declare function findLastTopLevelDelimiter(value: string, delimiter: string): number; export declare function findFirstTopLevelDelimiter(value: string, delimiter: string): number; export declare function hasTopLevelDelimiter(value: string, delimiter: string): boolean; export declare function findClosingParenthesis(value: string, openIndex: number): number | undefined; //#endregion //#region src/utils/escape.d.ts export declare function escapeRegExp(string: string): string; /** * CSS Selector Escape */ export declare function escapeSelector(str: string): string; export declare const e: typeof escapeSelector; //#endregion //#region src/utils/events.d.ts type EventsMap = Record; interface DefaultEvents extends EventsMap { [event: string]: (...args: any) => void; } /** Unbind listeners; calls after a successful unsubscribe are no-ops. */ export type Unsubscribe = () => void; export interface Emitter { /** * Event names in keys and arrays with listeners in values. * * ```js * emitter1.events = emitter2.events * emitter2.events = { } * ``` */ events: Partial<{ [E in keyof Events]: Events[E][]; }>; /** * Add a listener for a given event. * * ```js * const unbind = ee.on('tick', (tickType, tickDuration) => { * count += 1 * }) * * disable () { * unbind() * } * ``` * * @param event The event name. * @param cb The listener function. * @returns Unbind listener from event. */ on(this: this, event: K, cb: Events[K]): Unsubscribe; /** * Calls each of the listeners registered for a given event. * * ```js * ee.emit('tick', tickType, tickDuration) * ``` * * @param event The event name. * @param args The arguments for listeners. */ emit(this: this, event: K, ...args: Parameters): void; } /** * Create event emitter. * * ```js * import { createNanoEvents } from 'nanoevents' * * class Ticker { * constructor() { * this.emitter = createNanoEvents() * } * on(...args) { * return this.emitter.on(...args) * } * tick() { * this.emitter.emit('tick') * } * } * ``` */ export declare function createNanoEvents(): Emitter; //#endregion //#region src/utils/helpers.d.ts export declare const attributifyRE: RegExp; export declare const cssIdRE: RegExp; export declare const validateFilterRE: RegExp; export declare function isAttributifySelector(selector: string): RegExpMatchArray | null; export declare function isValidSelector(selector?: string): selector is string; export declare function normalizeVariant(variant: Variant): VariantObject; export declare function isRawUtil(util: ParsedUtil | RawUtil | StringifiedUtil): util is RawUtil; export declare function notNull(value: T | null | undefined): value is T; /** * Checks for a callable `then` on an object or function, without invoking it. * Primitive values are never thenables. Object getter errors propagate. */ export declare function isThenable(value: T | PromiseLike): value is PromiseLike; export declare function noop(): void; //#endregion //#region src/utils/layer.d.ts export declare function withLayer(layer: string, rules: Rule[]): Rule[]; //#endregion //#region src/utils/map.d.ts export declare class TwoKeyMap { _map: Map>; get(key1: K1, key2: K2): V | undefined; getFallback(key1: K1, key2: K2, fallback: V): V; set(key1: K1, key2: K2, value: V): this; has(key1: K1, key2: K2): boolean; delete(key1: K1, key2: K2): boolean; deleteTop(key1: K1): boolean; map(fn: (v: V, k1: K1, k2: K2) => T): T[]; } export declare class BetterMap extends Map { getFallback(key: K, fallback: V): V; map(mapFn: (value: V, key: K) => R): R[]; flatMap(mapFn: (value: V, key: K) => R): R[number][]; } //#endregion //#region src/utils/object.d.ts export declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntriesInput; export declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntriesInput)[]; export declare function clearIdenticalEntries(entry: CSSEntriesInput): CSSEntries; export declare const VirtualKey = "__virtual_key__"; export declare function entriesToCss(arr?: CSSEntriesInput): string; export declare function isObject(item: any): item is Record; /** * Marker key on a patch object that forces a full replacement of the * corresponding original value instead of a deep merge. An explicit * `{ $reset: true, … }` replaces an entire category. * The marker is stripped from output. */ export declare const RESET_KEY = "$reset"; /** * Deep merge two objects. * * A patch object whose own `$reset` is truthy is treated as a *replacement*: the * original value at that position is discarded and the patch (minus the `$reset` * marker) is used as-is. This applies recursively, so a single theme category can * opt out of deep-merging (`theme.colors = { $reset: true, ... }`). */ export declare function mergeDeep(original: T, patch: DeepPartial, mergeArray?: boolean): T; export declare function clone(val: T): T; export declare function isStaticRule(rule: Rule): rule is StaticRule; export declare function isStaticShortcut(sc: Shortcut): sc is StaticShortcut; //#endregion //#region src/utils/selector-syntax.d.ts export declare function isWithinSelectorNestingBudget(value: string): boolean; export declare function isValidNthArgument(name: string, argument: string): boolean; export declare function isValidCssSelector(value: string, allowList?: boolean): boolean; //#endregion //#region src/utils/selector-target.d.ts /** True when `target` is one complex selector that can begin a compound. */ export declare function isValidTargetSelector(target: string): boolean; //#endregion //#region src/utils/source.d.ts export declare function getPath(id: string): string; export declare function isCssId(id: string): boolean; export declare function hash(str: string): string; export declare function transformSkipCode(code: string, map: Map, SKIP_RULES_RE: RegExp, keyFlag: string): string; export declare function restoreSkipCode(code: string, map: Map): string; export declare function replaceAsync(string: string, searchValue: RegExp, replacer: (substring: string, ...args: any[]) => Promise): Promise; //#endregion //#region src/utils/unmatched-diagnostics.d.ts /** The structural slice of a resolved config the suggestion index reads. */ interface SuggestionSource { rulesStaticMap: Record; rulesDynamic: readonly (readonly [RegExp, ...unknown[]])[]; } /** * Strip trailing conditions using the shared token grammar, retaining `!`. */ export declare function tokenConditionBase(token: string): string; /** * Extracted source text is mostly not TeaCSS. Only candidates that read as a * `prefix:value` token (optionally behind a condition chain) are diagnosed — * plain words, framework class names, import specifiers, and URLs never are. */ export declare function isTokenShaped(token: string): boolean; /** CSS property → the prefixes that set it (`display` → `d`). */ type PropertyPrefixes = ReadonlyMap>; /** * The diagnostic for an unmatched candidate: at most three ranked suggestions * that `compiles` accepts. A known or near-known prefix is reported even when * none of its suggestions compiles. */ export declare function diagnoseUnmatchedToken(token: string, config: SuggestionSource, options?: { compiles?: (suggestion: string) => boolean; confirmedIntent?: boolean; propertyPrefixes?: PropertyPrefixes; }): string[] | undefined; //#endregion //#region src/utils/warn.d.ts export declare function warnOnce(msg: string): void; //#endregion //#region src/generator.d.ts export declare const symbols: ControlSymbols; type ExpansionEntry = Shortcut; type ExpansionResult = [(string | ExpansionInlineValue)[], RuleMeta | undefined]; type ExpansionPrefixes = readonly (string | undefined)[]; export interface PreparedGeneratorConfig { readonly config: ResolvedConfig; readonly defaults: UserConfigDefaults; /** Isolated generator for validating work against `config` before commit. */ readonly generator: TeacssGenerator; readonly userConfig: UserConfig; readonly version: number; } /** A width reduced to the scale it can be compared on. @see {@link comparableWidth} */ export interface ComparableWidth { /** `"px"` for every unit with a fixed pixel ratio, else the unit as authored. */ unit: string; /** The width on that scale. Negative reverses the direction within it. */ value: number; } /** * A CSS width reduced to a comparable scale, or `null` when it cannot be represented * as a finite number — including conversion overflow, `calc()`, `var()`, unknown * units, and malformed values such as `..`. A * non-length must never yield a number: `NaN` compares equal to everything, which marks * two unequal parents equal and skips the tiebreak {@link compareParentAtRules} relies * on. * * Widths only compare within one scale. Everything with a fixed pixel ratio shares the * `px` scale; a viewport- or font-relative unit gets its own, because nothing here * knows the viewport or the font it would resolve against. Exported so a consumer that * has to order the same widths — the `@screen` range resolver reads them straight from * `theme.breakpoint` — asks generation rather than keeping a copy that drifts. */ export declare function comparableWidth(size: string): ComparableWidth | null; /** * Order two parent (at-rule) selectors for the emitted sheet: an explicit * `parentOrders` delta wins; otherwise width `@container` and `@media` queries * cascade numerically (`min-width` ascending, `max-width` descending, via * {@link widthSortKey}), each against the widths sharing its query kind and scale, * container widths before media widths, and everything else, ordered * lexicographically, before both. * * Exported so tooling that re-serializes parsed utilities outside `generate()` — * `@apply` in `@teacss/directives` does — orders parent blocks * exactly as generation does, instead of keeping a copy that drifts. */ export declare function compareParentAtRules(parentOrders: ReadonlyMap, a: string, b: string): number; declare class TeacssGeneratorInternal { userConfig: UserConfig; defaults: UserConfigDefaults; readonly version: string; readonly events: Emitter<{ config: (config: ResolvedConfig) => void; }>; config: ResolvedConfig; cache: Map[] | null>; blocked: Set; /** Unmatched tokens already warned about; per generator, reset with runtime caches. */ private _warnedUnmatched; parentOrders: Map; activatedRules: Set>; /** Property-prefix dispatch index for `config.rulesDynamic`, rebuilt when the config changes. */ private _dynamicIndex?; private _expansionIndex?; private _contextConfigs; private _expansionPrefixes; /** Only engine-produced, unchanged leaves may complete a stripped declaration prefix. */ private _expansionOwnership; private _generationContexts; private _matchedStaticContexts; /** Tagged empty cache payloads retain match evidence without retaining contexts or raw token keys. */ private _emptyStaticPayloads; private _propertyPrefixes; private _configVersion; private _collectionGeneration; private _preparedConfigs; private _indexedRules?; private _indexedRuleSnapshot?; private _ruleObservation?; private _indexedShortcuts?; private _indexedShortcutSnapshot?; private _preparedCacheSnapshot?; private _preparedConfigMutable; private _authorityShortcutSnapshot?; private _preparedCacheReliable; private _startingGenerationParse; private _startingInputCheck; private _contextInputChecks; private _runtimeRevision; private _variantCacheOwner; private _constructedCSSResults; private _constructedCSSSequence; private _parsedOutputOrders; private _rawUtilMetadata; private _stringifiedCurrentSelectors; private _stringifiedOutputOrders; private _stringifiedParentOrders; private _shortcutMergeOrders; private _utilParentOrders; private reportConfigObserverErrors; private dispatchConfig; private clearRuntimeCaches; /** * Snapshot the shortcut list an expansion is about to read. Each expansion * used to capture the whole list; reusing the last snapshot once it still * validates as current is equivalent, because a complete current snapshot * describes exactly the state a fresh capture would record. An incomplete * snapshot (accessors, Proxies, unreadable observations) can validate while * a fresh capture would record more, so it is never reused. */ private currentShortcutSnapshot; private ensureRuleIndexesCurrent; private collectValidatedParentOrders; private transferOutputOrder; private recordStringifiedContext; private copyStringifiedUtil; private transferStringifiedMetadata; private copyValidatedStringifiedUtils; /** * Index one expansion-entry list so a lookup replaces the per-token scan: * static names — with each configured prefix folded into the key — resolve * through one map read, and only regex entries still walk in order. Bodies * and metas are read from the live tuples at match time. Only config-owned * lists participate in cache invalidation; external lists must be reindexed * on every lookup and must not replace the cached config index. Cached lists * are also revalidated slot by slot, because registration flows such as * compile-class splice entries into the live array between parses. */ private getExpansionIndex; private getDynamicIndex; private constructor(); static create(userConfig?: UserConfig, defaults?: UserConfigDefaults): Promise>; setConfig(userConfig?: UserConfig, defaults?: UserConfigDefaults): Promise; /** Resolve a candidate configuration without mutating this live generator. */ prepareConfig(userConfig: UserConfig, defaults?: UserConfigDefaults): Promise>; /** Commit a prepared configuration if no newer configuration request superseded it. */ commitConfig(prepared: PreparedGeneratorConfig): boolean; applyExtractors(code: string, id: string | undefined, extracted: CountableSet): Promise>; applyExtractors(code: string, id?: string, extracted?: Set): Promise>; private applyExtractorsCurrent; private applyExtractorsForConfig; private makeContextForConfig; makeContext(raw: string, applied: VariantMatchedResult): RuleContext; private getContextConfig; /** * The prefixes that set a CSS property written under its own name. A prefix * whose `inherit` value compiles to one declaration sets that declaration's property. */ private collectPropertyPrefixes; /** * Utilities of one layer and parent in the order the stylesheet writes them: a * flattened shortcut whose components the sort keeps together stays whole, * otherwise its components take their own places. */ sheetOrder(utilities: readonly StringifiedUtil[]): StringifiedUtil[]; parseToken(raw: string, alias?: string): Promise[] | undefined | null>; private parseTokenInternal; private parseTokenForGeneration; /** * Returns cached token names that currently emit the same declaration bodies as * `raw`. Tooling uses this after generation has populated the parse cache, so * references can include aliases without reading the cache's tuple shape. */ getCachedEquivalentTokens(raw: string): string[]; generate(input: string | Set | CountableSet | string[], options?: GenerateOptions): Promise>>; generate(input: string | Set | CountableSet | string[], options: GenerateOptions & { extendedInfo: true; }): Promise>>>; generate(input: string | Set | CountableSet | string[], options?: GenerateOptions): Promise | Map>>>; private generateInternal; matchVariants(raw: string, current?: string): Promise[]>; private matchVariantsCurrent; /** A token with too many pseudo-elements is unmatched, so the other tokens and shortcut members still apply. */ private matchVariantsForConfig; private applyVariants; constructCustomCSS(context: Readonly>, body: CSSObjectInput | CSSEntriesInput, overrideSelector?: string): string; private constructNormalizedCSS; parseUtil(input: string | VariantMatchedResult, context: RuleContext, internal?: boolean, shortcutPrefix?: string | string[] | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>; private parseUtilWithOwnership; private resolveCSSResult; stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext): StringifiedUtil[] | undefined; expandShortcut(input: string, context: RuleContext, depth?: number): Promise; private expandMatchedShortcut; private withExpansionBudget; expandConfiguredExpansions(input: string, context: RuleContext, depth: number, entries: ExpansionEntry[], label: "shortcut", fallback?: (input: string, context: RuleContext, depth: number) => Promise, inheritedPrefix?: string): Promise; private expandConfiguredExpansionsForInput; stringifyShortcuts(parent: VariantMatchedResult, context: RuleContext, expanded: (string | ExpansionInlineValue)[], meta?: RuleMeta, _matchedPrefixes?: ExpansionPrefixes): Promise[] | undefined>; isBlocked(raw: string): boolean; getBlocked(raw: string): [BlocklistValue, BlocklistMeta | undefined] | undefined; private matchesBlocklist; } /** Generator instance type; create instances with `await createGenerator()`. */ export type TeacssGenerator = TeacssGeneratorInternal; export declare function createGenerator(config?: UserConfig, defaults?: UserConfigDefaults): Promise>; export declare const regexScopePlaceholder: RegExp; export declare function hasScopePlaceholder(css: string): boolean; export declare function toEscapedSelector(raw: string): string; //#endregion //#region src/types.d.ts /** * The subset of `magic-string`'s API that the transformer contract and variant-group * expansion actually use. Typing against this keeps `magic-string` out of * `@teacss/core`'s public types — a real `MagicString` satisfies it structurally, * so the integration layer (which constructs one) still passes it directly, but * consumers of `@teacss/core` don't inherit a dependency on `magic-string`. */ export interface MagicStringLike { readonly original: string; slice(start?: number, end?: number): string; toString(): string; overwrite(start: number, end: number, content: string): MagicStringLike; update(start: number, end: number, content: string): MagicStringLike; remove(start: number, end: number): MagicStringLike; appendLeft(index: number, content: string): MagicStringLike; appendRight(index: number, content: string): MagicStringLike; } /** The result of resolving config from the CSS entry: the config + its source file(s). */ export interface LoadConfigResult { config: Config; sources: string[]; } export type Awaitable = T | Promise; export type Arrayable = T | T[]; export type ToArray = T extends any[] ? T[number][] : T extends readonly (infer U)[] ? readonly U[] : T[]; export type ArgumentType = T extends ((...args: infer A) => any) ? A : never; export type Shift = T extends [_: any, ...args: infer A] ? A : never; export type RestArgs = Shift>; export type DeepPartial = { [P in keyof T]?: DeepPartial; }; export type FlatObjectTuple = { [K in keyof T]: T[K]; }; export type PartialByKeys = FlatObjectTuple>> & Omit>; export type RequiredByKey = FlatObjectTuple>> & Omit>; export type CSSObject = Record; /** * [property, value, operators?] * * The optional third slot is retained as entry data for custom processors. * Core does not execute operators; CSS serialization uses only property and value. */ export type CSSEntry = [string, string | number | undefined, Arrayable?]; export type CSSEntries = CSSEntry[]; export type CSSObjectInput = CSSObject | Partial; export type CSSEntriesInput = (CSSEntry | ControlSymbolsEntry)[]; export type CSSValueInput = CSSObjectInput | CSSEntriesInput | CSSValue; export interface PresetOptions { [key: string]: any; } export interface RuleContext { /** * Unprocessed selector from user input. * Useful for generating CSS rule. */ rawSelector: string; /** * Current selector for rule matching * In shortcut leaf rule callbacks, this is the leaf after variant matching; * rawSelector remains the outer token being styled. */ currentSelector: string; /** * Generator instance */ generator: TeacssGenerator; /** * Symbols for special handling */ symbols: ControlSymbols; /** * The theme object */ theme: Theme; /** * Matched variants handlers for this rule. */ variantHandlers: VariantHandler[]; /** * The result of variant matching for the current parse branch. */ variantMatch: VariantMatchedResult; /** * Construct a custom CSS rule. * Variants and selector escaping will be handled automatically. */ constructCSS: (body: CSSEntriesInput | CSSObjectInput, overrideSelector?: string) => string; /** * Available only when `details` option is enabled. */ rules?: Rule[]; /** * Available only when `details` option is enabled. */ shortcuts?: Shortcut[]; /** * Available only when `details` option is enabled. */ variants?: Variant[]; } declare const SymbolShortcutsNoMerge: unique symbol; declare const SymbolNoMerge: unique symbol; declare const SymbolNoScope: unique symbol; declare const SymbolVariants: unique symbol; declare const SymbolParent: unique symbol; declare const SymbolSelector: unique symbol; declare const SymbolLayer: unique symbol; declare const SymbolSort: unique symbol; declare const SymbolBody: unique symbol; export interface ControlSymbols { /** * Prevent merging in shortcuts */ readonly shortcutsNoMerge: typeof SymbolShortcutsNoMerge; /** * Prevent merging in rules */ readonly noMerge: typeof SymbolNoMerge; /** * Prevent applying the `scope` option to this rule/selector */ readonly noScope: typeof SymbolNoScope; /** * Additional variants applied to this rule output. Functional values receive * a private handler list; inserting or removing handlers leaves siblings intact. */ readonly variants: typeof SymbolVariants; /** * Parent selector (`@media`, `@supports`, etc.) */ readonly parent: typeof SymbolParent; /** * Selector modifier */ readonly selector: typeof SymbolSelector; /** * Layer modifier */ readonly layer: typeof SymbolLayer; /** * Sort modifier */ readonly sort: typeof SymbolSort; /** * Custom css body modifier */ readonly body: typeof SymbolBody; } export interface ControlSymbolsValue { [SymbolShortcutsNoMerge]: boolean; [SymbolNoMerge]: boolean; [SymbolNoScope]: boolean; [SymbolVariants]: VariantHandler[] | ((handlers: VariantHandler[]) => VariantHandler[]); [SymbolParent]: string; [SymbolSelector]: (selector: string) => string; [SymbolLayer]: string; [SymbolSort]: number; [SymbolBody]: string; } export type ObjectToEntry = { [K in keyof T]: [K, T[K]]; }[keyof T]; export type ControlSymbolsEntry = ObjectToEntry; export interface VariantContext { /** * Unprocessed selector from user input. */ rawSelector: string; /** * Generator instance */ generator: TeacssGenerator; /** * The theme object */ theme: Theme; } export interface ExtractorContext { readonly original: string; code: string; id?: string; extracted: Set | CountableSet; envMode?: "dev" | "build"; } export interface BaseContext { /** * Generator instance */ generator: TeacssGenerator; /** * The theme object */ theme: Theme; } export interface PreflightContext extends BaseContext { /** Utilities produced for this generate() call after postprocessing, including cache hits and excluding preflights. */ generated?: readonly StringifiedUtil[]; /** Safelist entries starting with `--`, trimmed and in safelist order; empty when the call passes `safelist: false`. They name variables to keep and generate no utility. */ safelistVariables?: readonly string[]; } export interface SafeListContext extends BaseContext {} export interface Extractor { name: string; order?: number; /** * Extract the code and return a list of selectors. * * Return `undefined` to skip this extractor. */ extract?: (ctx: ExtractorContext) => Awaitable | CountableSet | string[] | undefined | void>; } export interface RuleMeta { /** * The layer name of this rule. * @default 'default' */ layer?: string; /** * Option to not merge this selector even if the body are the same. * @default false */ noMerge?: boolean; /** * Option to not apply scope to this selector. * @default false */ noScope?: boolean; /** * Fine tune sort */ sort?: number; /** * Templates to provide autocomplete suggestions */ autocomplete?: Arrayable; /** * Matching prefix before this util */ prefix?: string | string[]; /** * Internal rules will only be matched from expansions but not the user code. * @default false */ internal?: boolean; /** * Store the hash of the rule boy * * @internal * @private */ __hash?: string; /** * Internal index of the rulelist * @internal * @private */ __index?: number; /** * Rank of the rule in sheet order when it differs from its index in the * merged rule list (Rust ranks each preset's rules within that preset) * @internal * @private */ __order?: number; /** * Custom metadata */ custom?: Record; } export type CSSValue = CSSObject | CSSEntries; export type CSSValues = CSSValue | CSSValue[]; export type DynamicMatcher = (match: RegExpMatchArray, context: Readonly>) => Awaitable | Generator | AsyncGenerator; export type DynamicRule = [RegExp, DynamicMatcher, RuleMeta?]; export type StaticRule = [string, CSSObjectInput | CSSEntriesInput | (CSSValueInput | string)[], RuleMeta?]; export type Rule = DynamicRule | StaticRule; export type ExpansionValue = string | CSSValue; export interface ExpansionInlineValue { handles: VariantHandler[]; value: ExpansionValue; } export type DynamicExpansionMatcher = (match: RegExpMatchArray, context: Readonly>) => string | ExpansionValue[] | undefined; export type DynamicShortcutMatcher = DynamicExpansionMatcher; export type StaticShortcut = [string, string | ExpansionValue[], RuleMeta?]; export type StaticShortcutMap = Record; export type DynamicShortcut = [RegExp, DynamicShortcutMatcher, RuleMeta?]; export type UserShortcuts = StaticShortcutMap | (StaticShortcut | DynamicShortcut | StaticShortcutMap)[]; export type Shortcut = StaticShortcut | DynamicShortcut; export type ShortcutInlineValue = ExpansionInlineValue; export type ShortcutValue = ExpansionValue; export type FilterPattern = ReadonlyArray | string | RegExp | null; export interface Preflight { getCSS: (context: PreflightContext) => Promise | string | undefined; layer?: string; } export interface BlocklistMeta { /** * Custom message to show why this selector is blocked. */ message?: string | ((selector: string) => string); } export type BlocklistValue = string | RegExp | ((selector: string) => boolean | null | undefined); export type BlocklistRule = BlocklistValue | [BlocklistValue, BlocklistMeta]; export interface VariantHandlerContext { /** * Rewrite the output selector. Often be used to append parents. */ prefix: string; /** * Rewrite the output selector. Often be used to append pseudo classes. */ selector: string; /** * Rewrite the output selector. Often be used to append pseudo elements. */ pseudo: string; /** * Rewrite the output css body. The input come in [key,value][] pairs. */ entries: CSSEntriesInput; /** * Provide a parent selector(e.g. media query) to the output css. */ parent?: string; /** * Provide order to the `parent` parent selector within layer. */ parentOrder?: number; /** * Override layer to the output css. */ layer?: string; /** * Order in which the variant is sorted within single rule. */ sort?: number; /** * Option to not merge the resulting entries even if the body are the same. * @default false */ noMerge?: boolean; } export interface VariantHandler { /** * Callback to process the handler. */ handle?: (input: VariantHandlerContext, next: (input: VariantHandlerContext) => VariantHandlerContext) => VariantHandlerContext; /** * The result rewritten selector for the next round of matching */ matcher?: string; /** * Order in which the variant is applied to selector. */ order?: number; /** * Rewrite the output selector. Often be used to append pseudo classes or parents. */ selector?: (input: string, body: CSSEntriesInput) => string | undefined; /** * Rewrite the output css body. The input come in [key,value][] pairs. */ body?: (body: CSSEntriesInput) => CSSEntriesInput | undefined; /** * Provide a parent selector(e.g. media query) to the output css. */ parent?: string | [string, number] | undefined; /** * Order in which the variant is sorted within single rule. */ sort?: number; /** * Override layer to the output css. */ layer?: string | undefined; } export type VariantFunction = (matcher: string, context: Readonly>) => Awaitable; export interface VariantObject { /** * The name of the variant. */ name?: string; /** * The entry function to match and rewrite the selector for further processing. */ match: VariantFunction; /** * Sort for when the match is applied. */ order?: number; /** * Allows this variant to be used more than once in matching a single rule * * @default false */ multiPass?: boolean; /** * Custom function for auto complete */ autocomplete?: Arrayable; } export type Variant = VariantFunction | VariantObject; export type Preprocessor = (matcher: string) => string | undefined; export type Postprocessor = (util: UtilObject) => void | UtilObject | (UtilObject | null | undefined)[]; export type ThemeExtender = (theme: Theme, config: Readonly>) => Theme | void; export interface ConfigBase { /** * Rules to generate CSS utilities. * * Later entries have higher priority. */ rules?: Rule[]; /** * Variants that preprocess the selectors, * having the ability to rewrite the CSS object. */ variants?: Variant[]; /** * Similar to Windi CSS's shortcuts, * allows you have create new utilities by combining existing ones. * * Later entries have higher priority. */ shortcuts?: UserShortcuts; /** * Rules to exclude the selectors for your design system (to narrow down the possibilities). * Combining `warnExcluded` options it can also help you identify wrong usages. */ blocklist?: BlocklistRule[]; /** * Utilities always included in generation, unless `safelist: false` is passed. * Static entries and callback results support `{a;b}@condition` groups. * An entry starting with `--` is a variable entry: it generates no utility and * reaches preflights as `PreflightContext.safelistVariables`. */ safelist?: (string | ((context: SafeListContext) => Arrayable))[]; /** * Extractors to handle the source file and outputs possible classes/selectors * Can be language-aware. */ extractors?: Extractor[]; /** * Default extractor that are always applied. * By default it split the source code by whitespace and quotes. * * It maybe be replaced by preset or user config, * only one default extractor can be presented, * later one will override the previous one. * * Pass `null` or `false` to disable the default extractor. * */ extractorDefault?: Extractor | null | false; /** * Raw CSS injections. */ preflights?: Preflight[]; /** * Theme object for shared configuration between rules */ theme?: Theme; /** * Layer orders. Default to 0. */ layers?: Record; /** * Output the internal layers as CSS Cascade Layers. */ outputToCssLayers?: boolean | OutputCssLayersOptions; /** * Custom function to sort layers. */ sortLayers?: (layers: string[]) => string[]; /** * Preprocess the incoming utilities, return falsy value to exclude */ preprocess?: Arrayable; /** * Postprocess the generate utils object */ postprocess?: Arrayable; /** * Custom functions mutate the theme object. * * It's also possible to return a new theme object to completely replace the original one. */ extendTheme?: Arrayable>; /** * Presets */ presets?: (PresetOrFactoryAwaitable | PresetOrFactoryAwaitable[])[]; /** * Additional options for auto complete */ autocomplete?: { /** * Custom functions / templates to provide autocomplete suggestions */ templates?: Arrayable; /** * Custom extractors to pickup possible classes and * transform class-name style suggestions to the correct format */ extractors?: Arrayable; /** * Custom shorthands to provide autocomplete suggestions. * if values is an array, it will be joined with `|` and wrapped with `()` */ shorthands?: Record; }; /** * Hook to modify the resolved config. * * Hooks run sequentially in resolved preset order, then the user hook. * Returned promises are awaited; a throw or rejection aborts resolution. * Rule indexes are rebuilt after all hooks finish. Return values are ignored. * The void callback type accepts async functions while preserving existing * synchronous callbacks that return an ignored value. */ configResolved?: (config: ResolvedConfig) => void; /** * Expose internal details for debugging / inspecting * * Added `rules`, `shortcuts`, `variants` to the context and expose the context object in `StringifiedUtil` * * You don't usually need to set this. * * @default `true` when `envMode` is `dev`, otherwise `false` */ details?: boolean; /** * Options for sources to be extracted as utilities usages. * */ content?: ContentOptions; /** * Custom transformers to the source code. */ transformers?: SourceCodeTransformer[]; } export interface OutputCssLayersOptions { /** * Specify the css layer that the internal layer should be output to. * * Return `null` to specify that the layer should not be output to any css layer. */ cssLayerName?: (internalLayer: string) => string | undefined | null; /** * Force output all css layers, even if they are not used. * * @example `@layer theme, preflights, [unused-layer], utilities;` */ allLayers?: boolean; } export type AutoCompleteTemplate = string; export type AutoCompleteFunction = (input: string) => Awaitable; export interface AutoCompleteExtractorContext { content: string; cursor: number; } export interface Replacement { /** * The range of the original text */ start: number; end: number; /** * The text used to replace */ replacement: string; } export interface SuggestResult { /** * The generated suggestions * * `[original, formatted]` */ suggestions: [string, string][]; /** * The function to convert the selected suggestion back. * Needs to pass in the original one. */ resolveReplacement: (suggestion: string) => Replacement; } export interface AutoCompleteExtractorResult { /** * The extracted string */ extracted: string; /** * The function to convert the selected suggestion back */ resolveReplacement: (suggestion: string) => Replacement; /** * The function to format suggestions */ transformSuggestions?: (suggestions: string[]) => string[]; } export interface AutoCompleteExtractor { name: string; extract: (context: AutoCompleteExtractorContext) => Awaitable; order?: number; } export interface Preset extends ConfigBase { name: string; /** * Enforce the preset to be applied before or after other presets */ enforce?: "pre" | "post"; /** * Preset options for other tools like IDE to consume */ options?: PresetOptions; /** * Apply prefix to all utilities and shortcuts */ prefix?: string | string[]; /** * Apply layer to all utilities and shortcuts */ layer?: string; /** * Custom API endpoint for cross-preset communication */ api?: any; /** * Custom metadata for the preset */ meta?: Record; } export type PresetFactory = (options?: PresetOptions) => Preset; export type PresetFactoryAwaitable = (options?: PresetOptions) => Awaitable>; export type PresetOrFactory = Preset | PresetFactory; export type PresetOrFactoryAwaitable = PresetOrFactory | Promise> | PresetFactoryAwaitable; export interface GeneratorOptions { /** * Merge utilities with the exact same body to save the file size * * @default true */ mergeSelectors?: boolean; /** * Emit warning when matched selectors are presented in blocklist * * @default true */ warn?: boolean; } export interface UserOnlyOptions { /** * Opt-in reporting for token-shaped candidates that match no rule. With the * default `"off"`, unmatched tokens stay silent, nothing is collected, and * generation pays no diagnostic cost. `"warn"` logs each once with * near-miss suggestions (respecting `warn: false`); `"error"` throws after * the full list is collected. `GenerateResult.diagnostics` is populated * only when this option is enabled. * * @default "off" */ unmatched?: "warn" | "error" | "off"; /** * Plain theme objects are deep-merged with preset themes. Non-plain themes * are atomic; use `$reset` to replace one with a plain object or * `extendTheme` for class-aware composition. */ theme?: Theme; /** * Layer name for shortcuts * * @default 'shortcuts' */ shortcutsLayer?: string; /** * Environment mode * * @default 'build' */ envMode?: "dev" | "build"; } /** * For cli config */ export interface CliOptions { cli?: { entry?: Arrayable; }; } export interface TeacssPluginContext { /** * Singleton promise for config loading */ ready: Promise>; /** * The generator instance. Should be used after `ready` resolved. */ generator: TeacssGenerator; /** * All tokens scanned */ tokens: Set; /** * Current transformed or extracted content keyed by module ID */ modules: BetterMap; /** * Module IDs */ affectedModules: Set; /** * Pending promises */ tasks: Promise[]; /** * Await all pending tasks */ flushTasks: () => Promise; filter: (code: string, id: string) => boolean; extract: (code: string, id?: string) => Promise; reloadConfig: () => Promise>; getConfig: () => Promise; /** Subscribe to config reloads. Async failures are reported without delaying publication. Returns a disposer. */ onReload: (fn: () => void) => () => void; invalidate: () => void; /** Subscribe to generated-output invalidations. Async failures are reported without delaying notification. Returns a disposer. */ onInvalidate: (fn: () => void) => () => void; root: string; updateRoot: (root: string) => Promise>; getConfigFileList: () => string[]; /** * Get regexes to match virtual module ids * Full matches include directory prefixes; layer/query captures are preserved. * Virtual names in query or fragment suffixes are not matched as filenames. */ getVMPRegexes: () => Promise<{ prefix: string; RESOLVED_ID_WITH_QUERY_RE: RegExp; RESOLVED_ID_RE: RegExp; }>; } export interface SourceMap { file?: string; mappings?: string; names?: string[]; sources?: string[]; sourcesContent?: string[]; version?: number; } export interface HighlightAnnotation { offset: number; length: number; className: string; } export type SourceCodeTransformerEnforce = "pre" | "post" | "default"; export interface SourceCodeTransformer { name: string; /** * The order of transformer */ enforce?: SourceCodeTransformerEnforce; /** * Custom id filter, if not provided, the extraction filter will be applied */ idFilter?: (id: string) => boolean; /** * The transform function */ transform: (code: MagicStringLike, id: string, ctx: TeacssPluginContext) => Awaitable<{ highlightAnnotations?: HighlightAnnotation[]; } | void>; /** * Release state owned by a module after the integration removes it. */ onModuleRemoved?: (id: string, ctx: TeacssPluginContext) => Awaitable; } export interface ContentOptions { /** * Glob patterns to extract from the file system, in addition to other content sources. * * In dev mode, the files will be watched and trigger HMR. * * @default [] */ filesystem?: string[]; /** * Inline text to be extracted */ inline?: (string | { code: string; id?: string; } | (() => Awaitable))[]; /** * Filters to determine whether to extract certain modules from the build tools' transformation pipeline. * * Used by integrations that receive source modules from a build pipeline. * * Set `false` to disable. */ pipeline?: false | { /** * Patterns that filter the files being extracted. * Supports regular expressions and `picomatch` glob patterns. * * By default, `.ts` and `.js` files are NOT extracted. * * @see https://www.npmjs.com/package/picomatch * @default [/\.(vue|svelte|[jt]sx|vine\.ts|mdx?|astro|elm|php|phtml|marko|html)($|\?)/] */ include?: FilterPattern; /** * Patterns that filter the files NOT being extracted. * Supports regular expressions and `picomatch` glob patterns. * * By default, `node_modules` and `dist` are also extracted. * * @see https://www.npmjs.com/package/picomatch * @default [/\.(css|postcss|sass|scss|less|stylus|styl)($|\?)/] */ exclude?: FilterPattern; }; } /** * For other modules to aggregate the options */ export interface PluginOptions { /** * Custom transformers to the source code */ transformers?: SourceCodeTransformer[]; /** * Options for sources to be extracted as utilities usages * * Supported sources: * - `filesystem` - extract from file system * - `inline` - extract from plain inline text * - `pipeline` - extract from a build tool's transformation pipeline * * The usage extracted from each source will be **merged** together. */ content?: ContentOptions; } export interface UserConfig extends ConfigBase, UserOnlyOptions, GeneratorOptions, PluginOptions, CliOptions {} export interface UserConfigDefaults extends ConfigBase, UserOnlyOptions {} export interface ResolvedConfig extends Omit, "mergeSelectors" | "theme" | "rules" | "variants" | "layers" | "extractors" | "blocklist" | "safelist" | "preflights" | "sortLayers">, "rules" | "shortcuts" | "autocomplete" | "presets"> { presets: Preset[]; shortcuts: Shortcut[]; variants: VariantObject[]; preprocess: Preprocessor[]; postprocess: Postprocessor[]; rulesSize: number; rules: readonly Rule[]; rulesDynamic: readonly DynamicRule[]; rulesStaticMap: Record; autocomplete: { templates: (AutoCompleteFunction | AutoCompleteTemplate)[]; extractors: AutoCompleteExtractor[]; shorthands: Record; }; } export interface UnmatchedTokenDiagnostic { token: string; suggestions: string[]; } export interface GenerateDiagnostics { unmatched: UnmatchedTokenDiagnostic[]; } export interface GenerateResult> { css: string; layers: string[]; getLayer: (name?: string) => string | undefined; getLayers: (includes?: string[], excludes?: string[]) => string; setLayer: (layer: string, callback: (content: string) => Awaitable) => Promise; matched: T; /** Token-shaped candidates that matched no rule; populated only when the opt-in `unmatched` option is enabled, suggestions compute lazily on first read. */ diagnostics: GenerateDiagnostics; } export type VariantMatchedResult = [raw: string, current: string, variantHandlers: VariantHandler[], variants: Set>]; export type ParsedUtil = readonly [index: number, raw: string, entries: CSSEntriesInput, meta: RuleMeta | undefined, variantHandlers: VariantHandler[]]; export type RawUtil = readonly [index: number, rawCSS: string, meta: RuleMeta | undefined]; export type StringifiedUtil = readonly [index: number, selector: string | undefined, body: string, parent: string | undefined, meta: RuleMeta | undefined, context: RuleContext | undefined, noMerge: boolean | undefined]; export type PreparedRule = readonly [selector: [string, number][], body: string, noMerge: boolean]; export interface CliEntryItem { patterns: string[]; outFile: string; /** * Whether to rewrite the transformed utilities. * * - For css: if rewrite is true, it will not generate a new file, but directly modify the original file content. * - For other files: if rewrite is true, it replaces the original file with the transformed content. * * @default false */ rewrite?: boolean; /** * Whether to output CSS files scanned from patterns to outFile * * - false: Do not output CSS files * - true: Transform and output scanned CSS file contents to outFile * - 'multi': Output each CSS file separately with filename format `${originFile}-[hash]` * - 'single': Merge multiple CSS files into one output file named `outFile-merged.css` * * @default true */ splitCss?: boolean | "multi" | "single"; } export interface UtilObject { selector: string; entries: CSSEntriesInput; parent: string | undefined; layer: string | undefined; sort: number | undefined; noMerge: boolean | undefined; } /** * Returned from `tea.generate()` when `extendedInfo` option is enabled. */ export interface ExtendedTokenInfo { /** * Stringified util data */ data: StringifiedUtil[]; /** * Return -1 if the data structure is not countable */ count: number; } export interface GenerateOptions { /** * Filepath of the file being processed. */ id?: string; /** * Generate preflights (if defined) * * @default true */ preflights?: boolean; /** * Includes safelist entries, variable entries included */ safelist?: boolean; /** * Generate minified CSS * @default false */ minify?: boolean; /** * Maximum number of tokens parsed concurrently. Omit to preserve unbounded * scheduling; set a positive integer to cap peak work for large inputs. */ tokenConcurrency?: number; /** * Synchronous, side-effect-free check for externally extracted input. * Called repeatedly across generation boundaries and before diagnostics. * Returning false rejects generation; thrown errors propagate. Omit to * preserve normal config retries. This does not cancel running hooks or * undo previously published diagnostics. */ isInputCurrent?: () => boolean; /** * Scope generated selectors to a CSS selector or selector list. Each scope * arm is applied independently, preserving its own specificity. * An empty string disables scoping; empty or comment-only list arms reject * generation rather than emitting unscoped selectors. * @experimental */ scope?: string; /** * If return extended "matched" with payload and count */ extendedInfo?: T; } //#endregion //#region src/condition-variant.d.ts export interface ConditionVariantOptions { /** * Variant name (for debugging / `details`). * @default "at-condition" */ name?: string; } /** * Build the `@` condition-axis variant from a vocabulary of {@link ConditionResolver}s. * * When a token carries trailing `@cond` segments, the variant: * - parses + resolves them with the supplied `resolvers`, * - strips the `@cond` from the `matcher` so the remaining declaration (plus an * optional `!`) still matches a rule, and * - in `handle`, appends the resolved selector parts around the styled element. * * If any condition is unrecognized by the resolvers, the token is left unclaimed * (`undefined`), preserving the generator's behavior for unknown tokens. */ export declare function createConditionVariant(resolvers: ConditionResolver[], options?: ConditionVariantOptions): VariantObject; //#endregion //#region src/config.d.ts export declare function resolveShortcuts(shortcuts: UserShortcuts): Shortcut[]; /** * Resolve a single preset, nested presets are ignored */ export declare function resolvePreset(presetInput: PresetOrFactoryAwaitable): Promise>; /** * Resolve presets with nested presets */ export declare function resolvePresets(preset: PresetOrFactoryAwaitable): Promise[]>; /** * Merges content options in source order: pipeline include and exclude lists and filesystem and * inline sources concatenate, and `pipeline: false` anywhere disables the pipeline. * @internal Shared with @teacss/config, which merges host defaults with a loaded config the same way. */ export declare function mergeContentOptions(optionsArray: ContentOptions[]): ContentOptions; export declare function resolveConfig(userConfig?: UserConfig, defaults?: UserConfigDefaults): Promise>; export declare function mergeConfigs(configs: UserConfig[]): UserConfig; export declare function definePreset(preset: PresetFactory): PresetFactory; export declare function definePreset(preset: PresetFactoryAwaitable): PresetFactoryAwaitable; export declare function definePreset(preset: Preset): Preset; export declare const PRESET_OPTIONS_KEYS: Readonly<{ standard: symbol; icons: symbol; official: symbol; }>; /** Attach the factory options to a preset so an engine facade can translate it without executing rule code. Non-enumerable: survives `mergeConfigs` and never leaks into config clones. */ export declare function tagPresetOptions

>(preset: P, key: symbol, options: object): P; //#endregion //#region src/constants.d.ts export declare const LAYER_IMPORTS = "imports"; export declare const LAYER_PRIMITIVES = "primitives"; export declare const LAYER_PROPERTIES = "properties"; export declare const LAYER_PREFLIGHTS = "preflights"; export declare const LAYER_SHORTCUTS = "shortcuts"; export declare const LAYER_UTILITIES = "utilities"; export declare const DEFAULT_LAYERS: Readonly<{ imports: -200; properties: -150; preflights: -100; shortcuts: -50; primitives: -10; utilities: 0; }>; //#endregion //#region src/env.d.ts export declare function getEnvFlags(): { isNode: boolean; isVSCode: boolean; isESLint: boolean; }; //#endregion //#region src/extractors/split.d.ts export declare const defaultSplitRE: RegExp; export declare const extractorSplit: Extractor; //#endregion //#region src/group.d.ts /** Expand groups in host source, including groups nested in strings/arrays. */ export declare function expandGroups(code: string): string; /** Expand groups in a class list while preserving braces inside attached literals. */ export declare function expandClassGroups(code: string): string; //#endregion //#region src/hash.d.ts export declare function getHash(input: string, length?: number): string; //#endregion //#region src/literal.d.ts /** * Literal regions — `()` and `[]`. * * Inside `()` (a CSS function) and `[]` (an arbitrary value / selector), characters * are taken literally and operators do not participate in symbol parsing — they only * act at depth 0 in the token and condition parsers. This module turns the * *contents* of those regions into their final CSS form: * * - `()` = CSS function: `_` stays literal (`var(--my_var)`), and math-function * operators get surrounding spaces the engine fills in. * - `[]` = arbitrary value / selector: `_` means a space, `\_` means a literal * underscore (`|` is NOT used for spaces). `_` inside a nested `()` stays literal. * * These are pure string utilities, consistent with `parseClassToken` and the * condition parser. They do not resolve rules, theme, or bracket *type hints* * (`[color:red]` etc.) — that interpretation belongs to the rule/preset layer. */ /** * Split a class list on whitespace outside attached `[]` literal regions. * * Unlike the source extractor, this does not treat quotes, semicolons, braces, * or backticks as delimiters. It is for already-isolated class-list surfaces * such as shortcuts, `cn()`, and `@apply`. */ export declare function splitClassTokens(input: string): string[]; /** * Expand `_` to a space inside an arbitrary `[]` region. * * - `\_` → a literal underscore. * - `_` at paren depth 0 → a space. * - `_` inside `(…)` → kept literal (so `var(--my_var)` survives). */ export declare function expandUnderscores(content: string): string; /** The math functions of CSS Values 4 §10, whose binary `+ - * /` need surrounding spaces. */ export declare const mathFunctionNames: ReadonlySet; /** * Add surrounding spaces to `+ - * /` operators inside balanced math functions * (`mathFunctionNames`) without rewriting adjacent values, * quoted text, URLs, custom-property names, or numeric exponent signs. */ export declare function spaceCalcOperators(str: string): string; /** True when `value` is a single `[…]` arbitrary region. */ export declare function isArbitrary(value: string): boolean; export interface NormalizeArbitraryOptions { /** * Apply math-function operator spacing. * @default true */ calc?: boolean; } /** * Normalize a value's literal regions to final CSS. * * - A `[…]` arbitrary value has its brackets stripped and underscores expanded * (`_`→space, `\_`→`_`, `_` inside `()` kept). * - Math-function operators get spacing (in both arbitrary and * raw function values). * - A raw value (no brackets) keeps `_` literal — only `[]` uses `_` for spaces. * * Bracket *type hints* (`[color:red]`, `[length:4px]`) are intentionally not * interpreted here; that is the rule/preset layer's job. * * @example normalizeArbitraryValue("[1px_solid_red]") // "1px solid red" * @example normalizeArbitraryValue("calc(100%-1rem)") // "calc(100% - 1rem)" * @example normalizeArbitraryValue("var(--my_var)") // "var(--my_var)" */ export declare function normalizeArbitraryValue(value: string, options?: NormalizeArbitraryOptions): string; //#endregion //#region src/markers.d.ts export declare const INCLUDE_COMMENT = "@teacss-include"; export declare const IGNORE_COMMENT = "@teacss-ignore"; export declare const INCLUDE_COMMENT_IDE = "@teacss-ide-include"; export declare const CSS_PLACEHOLDER = "@teacss-placeholder"; export declare const SKIP_START_COMMENT = "@teacss-skip-start"; export declare const SKIP_END_COMMENT = "@teacss-skip-end"; export declare const SKIP_COMMENT_RE: RegExp; export declare const VIRTUAL_ENTRY_ALIAS: RegExp[]; export declare const LAYER_MARK_ALL = "__ALL__"; //#endregion //#region src/token.d.ts /** * Token parsing primitives. * * Splits a single TeaCSS class token into its stable structural parts so every * later stage (the `@` condition axis, escaping, rules) can build on one source * of truth. This module is pure structure: it does not resolve rules, variants, * or CSS. The current token shape is documented in * teacss-rs `docs/proposals/v12-teacss.md`. * * Token shape: * * ```txt * (property:value | keyword)[!](@cond)* * ``` * * - A declaration is either `property:value` (split on the first depth-0 `:`) or * a bare keyword (no depth-0 `:`, e.g. `relative`, `sticky`, `text-truncate`). * - `()` and `[]` are literal regions; operators inside them (`:` `!` `@` …) do * not participate in parsing. * - `!` immediately after the value (before any `@`) is `!important`. * - The declaration ends at the first depth-0 `@` or the token's end. Only a * trailing depth-0 `!` is stripped; other bangs remain for later validation. * - Zero or more `@cond` segments follow; each is captured verbatim (without its * leading `@`). Interpreting a condition (pseudo / target / media / NOT `!…` …) * belongs to the condition pipeline. */ export interface ParsedClassToken { /** The full original token, unchanged. */ raw: string; /** Declaration body without the trailing `!` or any `@cond` (e.g. `bg:red`, `d:flex`, `content:[""]`). */ body: string; /** Property side, present only when the declaration has a depth-0 `:`. */ property?: string; /** Value side, present only when the declaration has a depth-0 `:`. */ value?: string; /** True when the declaration is a bare keyword (no depth-0 `:`). */ keyword: boolean; /** True when a depth-0 `!` immediately follows the value (`!important`). */ important: boolean; /** Ordered `@cond` segments, each without its leading `@` (e.g. `["hover"]`, `[">li::after"]`). */ conditions: string[]; } /** * Parse a single class token into its structural parts. * * Pure and total: any non-empty string yields a result. Malformed tokens (e.g. * unbalanced brackets) are parsed leniently rather than throwing — validation is * left to the rule layer. */ export declare function parseClassToken(raw: string): ParsedClassToken; //#endregion export { extractorSplit as extractorDefault };