import type { lengthValidUnits, angleValidUnits, frequencyValidUnits, resolutionValidUnits, timeValidUnits, } from './units.ts'; export interface CSSValueAST { type: TYPE; start: number; end: number; value: string; } export type BaseAstNode = | Literal | CssWideKeyword | Space | Comment | Invalid | CustomIdent | DashedIdent | Call | String | Number | Integer | Length | Angle | Time | Percentage | Frequency | Resolution | Flex | UnknownUnit | Color; /* types */ // custom export type BuildVarAst = CSSValueAST<`build-var`> & { subType: string; id: string; }; export type Literal = CSSValueAST<`literal`> & { before: string; after: string; }; export type CssWideKeyword = CSSValueAST<`css-wide-keyword`> & { value: AnyCase<`inherit` | `unset` | `initial`>; }; export type Space = CSSValueAST<`space`> & { before: string; after: string; }; export type Comment = CSSValueAST<`comment`> & { before: string; after: string; }; export type Call = CSSValueAST & { args: CSSValueAST[]; before: string; after: string; }; type Unit = CSSValueAST & { unit: UNIT; integer: boolean; }; export type Invalid = CSSValueAST<`invalid`>; export type UnknownUnit = Unit<`unknown-unit`, string>; // textual export type CustomIdent = CSSValueAST<``>; export type DashedIdent = CSSValueAST<``>; export type String = CSSValueAST<``>; export type Url = CSSValueAST<``>; // numeric export type Integer = CSSValueAST<``>; export type Number = CSSValueAST<``>; export type Percentage = Unit<``, `%`>; export type Ratio = CSSValueAST<``>; // distance export type Length = Unit<``, AnyCase<(typeof lengthValidUnits)[number]>>; // other quantities export type Flex = Unit<``, AnyCase<`fr`>>; export type Angle = Unit<``, AnyCase<(typeof angleValidUnits)[number]>>; export type Time = Unit<`