/** * The code here is based on used-styles npm library: https://github.com/theKashey/used-styles * Some of the code was leaking to browser causing problems, so we copied the code instead of using the library as is. */ export interface StyleSelector { selector: string; postfix: string; pieces: string[]; media: string[]; parents?: string[]; declaration: number; hash: string; } export interface CodeLocation { line: number; column: number; } export interface StyleRule { prop: string; value: string; important: boolean; } export interface StyleBody { id: number; rules: StyleRule[]; start: CodeLocation; end: CodeLocation; } export type StyleBodies = Record; export interface AtRule { kind: string; id: string; css: string; } export interface SingleStyleAst { file: string; selectors: StyleSelector[]; bodies: StyleBodies; atRules: AtRule[]; } export type StyleAst = Record; export type StylesLookupTable = Record; export type StyleDefinition = Readonly<{ isReady: boolean; lookup: Readonly; ast: Readonly; urlPrefix: string; then(resolve?: () => void, reject?: () => void): Promise; }>; export type SelectionFilter = { (selector: string, rule: StyleSelector): boolean; }; export interface StyleChunk { file: string; css: string; } export interface SyncStyleDefinition { isReady: true; lookup: StylesLookupTable; ast: StyleAst; }