/** 样式单位 */ export enum StyleUnitEnum { percentage = '%', px = 'px', em = 'em', rem = 'rem', vw = 'vw', vh = 'vh', vmax = 'vmax', vmin = 'vmin', } /** 样式属性通用值 */ export enum StyleBaseValueEnum { inherit = 'inherit', initial = 'initial', unset = 'unset' } export enum TypeEnum { ID = 'ID', Number = 'NUMBER', Percentage = 'PERCENTAGE', String = 'STRING', Dimension = 'DIMENSION', Hash = 'HASH', Url = 'URL', Sequence = 'SEQUENCE', Expression = 'EXPRESSION', Function = 'FUNCTION', Declaration = 'DECLARATION' } export interface PrimitiveVal { type: T, value: V; } export interface UnitVal extends PrimitiveVal { unit: string; } export interface IdentVal extends PrimitiveVal { type: TypeEnum.ID; value: string; vendorPrefix?: string; } export type NumberValue = PrimitiveVal; export interface PercentageVal extends PrimitiveVal { unit: StyleUnitEnum.percentage; } export type StringValue = PrimitiveVal; export interface DimensionValue extends PrimitiveVal { unit: string } export type HashValue = PrimitiveVal; export interface UrlValue extends PrimitiveVal { name: IdentVal; } export type SequenceValue = PrimitiveVal; export interface Expression { type: TypeEnum.Expression, operator: string; lhs: NumberValue | PercentageVal | DimensionValue; rhs: NumberValue | PercentageVal | DimensionValue; } export interface FunctionValue extends PrimitiveVal { name: string | IdentVal; parameters: DeclarationValue; } export type DeclarationValue = IdentVal | NumberValue | PercentageVal | StringValue | DimensionValue | UrlValue | FunctionValue | SequenceValue; export interface Declaration { type: TypeEnum.Declaration, property: PrimitiveVal, value: DeclarationValue }