import type { CSSValueAST, BuildVarAst } from './ast-types.ts'; import type { ParseResults } from './value-parser.ts'; export function defineProperty< FORMATS extends string, CLASSIFICATIONS extends string, TOP_COMMA extends boolean = false, >(_config: { name: string; syntax: string; subSyntax?: Record; subProperties?: Record>; topLevelCommaSeparation?: TOP_COMMA; formats?: Record; classifications?: Record< CLASSIFICATIONS, | MatchClassification // ToDo: optional default value / required | (TOP_COMMA extends true ? { match?: MatchClassification; syntax?: string; inTopLevelIndex?: (index: number, total: number) => boolean; cssProperty?: ReturnType; } : { match?: MatchClassification; syntax?: string; cssProperty?: ReturnType; }) >; }): { validate: (ast: CSSValueAST[], options?: ActionParams) => [...errors: string[]]; getFormat: (ast: CSSValueAST[], options?: ActionParams) => FORMATS; classify: ( ast: CSSValueAST[], options?: ActionParams & { deep?: boolean; ignoreComments?: boolean }, ) => TOP_COMMA extends true ? Record[] : Record; } { return {} as any; } defineProperty.errors = { unexpectedType: (node: CSSValueAST, expectedType: string) => `expected to get ${expectedType}, but got ${node.type}`, unexpectedComma: () => `unexpected comma`, }; export interface ActionParams { cssVars?: Record[]>; resolveBuildVar?: (node: BuildVarAst) => CSSValueAST[]; } type MatchClassification = ( node: CSSValueAST, info: { index: number; indexOfType: number; amountOfType: number; }, ) => boolean; type Classification = { value: CSSValueAST[]; resolved: { origin: ParseResults; nodes: CSSValueAST[] }[][]; // ToDo: should probably be more detailed... need to see cases isProperty: boolean; };