import { CSSValue } from './syntax/parser'; import { CSSTypes } from './types'; import { Context } from '../core/context'; export declare const enum PropertyDescriptorParsingType { VALUE = 0, LIST = 1, IDENT_VALUE = 2, TYPE_VALUE = 3, TOKEN_VALUE = 4 } export interface IPropertyDescriptor { name: string; type: PropertyDescriptorParsingType; initialValue: string; prefix: boolean; /** * When true, the parse result is never stored in parseCache. * Set this for descriptors whose parse() has side effects (e.g., * calling context.cache.addImage) that must run on every render pass. * * parse() purity contract: for every descriptor without skipCache, parse() * MUST be a pure function of (raw computed string) — its result is * memoised in a process-wide cache shared across renders and contexts. * Any new side effect (resource loading, context capture) requires * skipCache: true, or the effect silently stops running. */ skipCache?: boolean; } export interface IPropertyIdentValueDescriptor extends IPropertyDescriptor { type: PropertyDescriptorParsingType.IDENT_VALUE; parse: (context: Context, token: string) => T; } export interface IPropertyTypeValueDescriptor extends IPropertyDescriptor { type: PropertyDescriptorParsingType.TYPE_VALUE; format: CSSTypes; } export interface IPropertyValueDescriptor extends IPropertyDescriptor { type: PropertyDescriptorParsingType.VALUE; parse: (context: Context, token: CSSValue) => T; } export interface IPropertyListDescriptor extends IPropertyDescriptor { type: PropertyDescriptorParsingType.LIST; parse: (context: Context, tokens: CSSValue[]) => T; } export interface IPropertyTokenValueDescriptor extends IPropertyDescriptor { type: PropertyDescriptorParsingType.TOKEN_VALUE; } export type CSSPropertyDescriptor = IPropertyValueDescriptor | IPropertyListDescriptor | IPropertyIdentValueDescriptor | IPropertyTypeValueDescriptor | IPropertyTokenValueDescriptor;