import type { Debugger } from "debug"; import type { MediaFeatureNameFor_MediaFeatureId, TokenOrValue } from "lightningcss"; import { VAR_SYMBOL } from "../native/reactivity"; export interface CompilerOptions { filename?: string; projectRoot?: string; inlineRem?: number | false; inlineVariables?: false | InlineVariableOptions; selectorPrefix?: string; stylesheetOrder?: number; features?: FeatureFlagRecord; logger?: (message: string) => void | Debugger; hexColors?: boolean; colorPrecision?: number; } export interface InlineVariableOptions { exclude?: `--${string}`[]; } /** * A `react-native-css` StyleSheet */ export interface ReactNativeCssStyleSheet { /** Feature flags */ f?: FeatureFlagRecord; /** rem */ r?: number; /** StyleRuleSets */ s?: (readonly [string, StyleRuleSet])[]; /** KeyFrames */ k?: Animation[]; /** Root Variables */ vr?: RootVariables; /** Universal Variables */ vu?: RootVariables; } /******************************** Styles ********************************/ /** * The JS representation of a style object * * This CSS rule is a single StyleRuleSet, made up of multiple StyleRules * * ```css * .my-class { * color: red; * } * ``` * Properties are split into normal and important properties, and then split * into different StyleRules depending on their specificity, conditions, etc */ export type StyleRuleSet = StyleRule[]; export interface StyleRule { /** Specificity */ s: SpecificityArray; /** Declarations */ d?: StyleDeclaration[]; /** Variables */ v?: VariableDescriptor[]; /** Named Containers */ c?: string[]; /** Declarations use variables */ dv?: number; target?: string | string[] | false; /** * Conditionals */ /** MediaQuery */ m?: MediaCondition[]; /** PseudoClassesQuery */ p?: PseudoClassesQuery; /** Container Query */ cq?: ContainerQuery[]; /** Attribute Conditions */ aq?: AttributeQuery[]; /** * Animations and Transitions */ /** Animations */ a?: boolean; } export type StyleDeclaration = /** This is a static style object */ Record /** A style that needs to be set */ | [StyleDescriptor, string | string[]] /** A value that can only be computed at runtime, and only after styles have been calculated */ | [StyleDescriptor, string | string[], 1]; export type StyleDescriptor = string | number | boolean | undefined | StyleFunction | StyleDescriptor[]; export type StyleFunction = [ Record, string ] | readonly [ Record, string ] | [ Record, string, StyleDescriptor ] | readonly [ Record, string, StyleDescriptor ] | [ Record, string, StyleDescriptor, 1 ] | readonly [ Record, string, StyleDescriptor, 1 ]; /****************************** Variables *******************************/ export type VariableDescriptor = [string, StyleDescriptor]; export type VariableRecord = Record; export type VariableValue = [StyleDescriptor] | [StyleDescriptor, MediaCondition[]]; export type RootVariables = [string, VariableValue[]][]; export type InlineVariable = { [VAR_SYMBOL]: "inline"; [key: string]: unknown | undefined; }; export type UniqueVarInfo = { count: number; value: TokenOrValue[] | undefined; flat?: true; }; /****************************** Animations ******************************/ export type Animation = [string, AnimationKeyframes[]]; export type AnimationRecord = Record; export type AnimationKeyframes = [string | number, StyleDeclaration[]]; /****************************** Conditions ******************************/ export type MediaCondition = ["!!", MediaFeatureNameFor_MediaFeatureId] | ["!", MediaCondition] | ["&", MediaCondition[]] | ["|", MediaCondition[]] | [ MediaFeatureComparison, MediaFeatureNameFor_MediaFeatureId | "dir", StyleDescriptor ] | [ "[]", MediaFeatureNameFor_MediaFeatureId, StyleDescriptor, MediaFeatureComparison, StyleDescriptor, MediaFeatureComparison ]; export type MediaFeatureComparison = "=" | ">" | ">=" | "<" | "<="; export interface PseudoClassesQuery { /** Hover */ h?: 1; /** Active */ a?: 1; /** Focus */ f?: 1; } type AttributeQueryType = "a" | "d"; export type AttributeQuery = [AttributeQueryType, string] | [AttributeQueryType, string, "!"] | [AttributeQueryType, string, AttrSelectorOperator, string] | [AttributeQueryType, string, AttrSelectorOperator, string, "i" | "s"]; export type AttrSelectorOperator = "=" | "~=" | "|=" | "^=" | "$=" | "*="; /****************************** Containers *****************************/ export interface ContainerQuery { /** Name */ n?: string | null; m?: MediaCondition; p?: PseudoClassesQuery; a?: AttributeQuery[]; } /****************************** Specificity *****************************/ /** * https://drafts.csswg.org/selectors/#specificity-rules * * This array is sorted by most common values when parsing a StyleSheet */ export type SpecificityArray = SpecificityValue[]; export type SpecificityValue = number | undefined; /****************************** Compiler ********************************/ type FeatureFlags = never; export type FeatureFlagRecord = Partial>; /** @internal */ export type PathTokens = string | string[]; /** @internal */ export type StyleRuleMapping = Record; /** * @internal */ export type LoggerOptions = { logger: (message: string) => void; }; /** * @internal */ export interface CompilerCollection extends CompilerOptions { features: FeatureFlagRecord; rules: Map; keyframes: Map; darkMode?: string | null; rootVariables: VariableRecord; universalVariables: VariableRecord; selectorPrefix?: string; appearanceOrder: number; rem?: number | boolean; varUsageCount: Map; } export {}; //# sourceMappingURL=compiler.types.d.ts.map