1 |
|
2 |
|
3 |
|
4 | export type PropertyValue = number | boolean | string | null | undefined;
|
5 |
|
6 |
|
7 |
|
8 | export interface Styles {
|
9 | $unique?: boolean;
|
10 | $global?: boolean;
|
11 | $displayName?: string;
|
12 | [selector: string]: PropertyValue | PropertyValue[] | Styles;
|
13 | }
|
14 | export interface CompiledStyle {
|
15 | selector: string;
|
16 | style: string;
|
17 | isUnique: boolean;
|
18 | }
|
19 | export interface CompiledRule {
|
20 | selector: string;
|
21 | style: string;
|
22 | rules: CompiledRule[];
|
23 | styles: CompiledStyle[];
|
24 | }
|
25 |
|
26 |
|
27 |
|
28 | export interface Compiled {
|
29 | id: string;
|
30 | rules: CompiledRule[];
|
31 | styles: CompiledStyle[];
|
32 | displayName: string | undefined;
|
33 | }
|
34 |
|
35 |
|
36 |
|
37 | export interface Changes {
|
38 | add(style: Container<any>, index: number): void;
|
39 | remove(style: Container<any>, index: number): void;
|
40 | change(style: Container<any>, index: number): void;
|
41 | }
|
42 |
|
43 |
|
44 |
|
45 | export interface Container<T> {
|
46 |
|
47 | cid(): string;
|
48 | clone(): T;
|
49 | getStyles(): string;
|
50 | }
|
51 |
|
52 |
|
53 |
|
54 | export declare class Cache<T extends Container<any>> {
|
55 | changes?: Changes | undefined;
|
56 | changeId: number;
|
57 | protected sheet: string[];
|
58 | protected children: T[];
|
59 | protected counters: Map<string, number>;
|
60 | constructor(changes?: Changes | undefined);
|
61 | add(style: T): void;
|
62 | remove(style: T): void;
|
63 | merge(cache: Cache<any>): this;
|
64 | unmerge(cache: Cache<any>): this;
|
65 | }
|
66 | /**
|
67 | * Selector is a dumb class made to represent nested CSS selectors.
|
68 | */
|
69 | export declare class Selector implements Container<Selector> {
|
70 | selector: string;
|
71 | constructor(selector: string);
|
72 | cid(): string;
|
73 | getStyles(): string;
|
74 | clone(): Selector;
|
75 | }
|
76 | /**
|
77 | * The style container registers a style string with selectors.
|
78 | */
|
79 | export declare class Style extends Cache<Selector> implements Container<Style> {
|
80 | style: string;
|
81 | id: string;
|
82 | constructor(style: string, id: string);
|
83 | cid(): string;
|
84 | getStyles(): string;
|
85 | clone(): Style;
|
86 | }
|
87 | /**
|
88 | * Implement rule logic for style output.
|
89 | */
|
90 | export declare class Rule extends Cache<Rule | Style> implements Container<Rule> {
|
91 | rule: string;
|
92 | style: string;
|
93 | id: string;
|
94 | constructor(rule: string, style: string, id: string);
|
95 | cid(): string;
|
96 | getStyles(): string;
|
97 | clone(): Rule;
|
98 | }
|
99 | /**
|
100 | * The FreeStyle class implements the API for everything else.
|
101 | */
|
102 | export declare class Sheet extends Cache<Rule | Style> {
|
103 | prefix: string;
|
104 | constructor(prefix: string, changes?: Changes);
|
105 | register(compiled: Compiled): string;
|
106 | registerStyle(styles: Styles): string;
|
107 | getStyles(): string;
|
108 | }
|
109 | /**
|
110 | * Exports a simple function to create a new instance.
|
111 | */
|
112 | export declare function create(changes?: Changes, prefix?: string): Sheet;
|
113 | /**
|
114 | * Compile styles into a registerable object.
|
115 | */
|
116 | export declare function compile(styles: Styles): Compiled;
|