1 | export type XastDoctype = {
|
---|
2 | type: 'doctype';
|
---|
3 | name: string;
|
---|
4 | data: {
|
---|
5 | doctype: string;
|
---|
6 | };
|
---|
7 | };
|
---|
8 |
|
---|
9 | export type XastInstruction = {
|
---|
10 | type: 'instruction';
|
---|
11 | name: string;
|
---|
12 | value: string;
|
---|
13 | };
|
---|
14 |
|
---|
15 | export type XastComment = {
|
---|
16 | type: 'comment';
|
---|
17 | value: string;
|
---|
18 | };
|
---|
19 |
|
---|
20 | export type XastCdata = {
|
---|
21 | type: 'cdata';
|
---|
22 | value: string;
|
---|
23 | };
|
---|
24 |
|
---|
25 | export type XastText = {
|
---|
26 | type: 'text';
|
---|
27 | value: string;
|
---|
28 | };
|
---|
29 |
|
---|
30 | export type XastElement = {
|
---|
31 | type: 'element';
|
---|
32 | name: string;
|
---|
33 | attributes: Record<string, string>;
|
---|
34 | children: Array<XastChild>;
|
---|
35 | };
|
---|
36 |
|
---|
37 | export type XastChild =
|
---|
38 | | XastDoctype
|
---|
39 | | XastInstruction
|
---|
40 | | XastComment
|
---|
41 | | XastCdata
|
---|
42 | | XastText
|
---|
43 | | XastElement;
|
---|
44 |
|
---|
45 | export type XastRoot = {
|
---|
46 | type: 'root';
|
---|
47 | children: Array<XastChild>;
|
---|
48 | };
|
---|
49 |
|
---|
50 | export type XastParent = XastRoot | XastElement;
|
---|
51 |
|
---|
52 | export type XastNode = XastRoot | XastChild;
|
---|
53 |
|
---|
54 | type VisitorNode<Node> = {
|
---|
55 | enter?: (node: Node, parentNode: XastParent) => void | symbol;
|
---|
56 | exit?: (node: Node, parentNode: XastParent) => void;
|
---|
57 | };
|
---|
58 |
|
---|
59 | type VisitorRoot = {
|
---|
60 | enter?: (node: XastRoot, parentNode: null) => void;
|
---|
61 | exit?: (node: XastRoot, parentNode: null) => void;
|
---|
62 | };
|
---|
63 |
|
---|
64 | export type Visitor = {
|
---|
65 | doctype?: VisitorNode<XastDoctype>;
|
---|
66 | instruction?: VisitorNode<XastInstruction>;
|
---|
67 | comment?: VisitorNode<XastComment>;
|
---|
68 | cdata?: VisitorNode<XastCdata>;
|
---|
69 | text?: VisitorNode<XastText>;
|
---|
70 | element?: VisitorNode<XastElement>;
|
---|
71 | root?: VisitorRoot;
|
---|
72 | };
|
---|
73 |
|
---|
74 | export type PluginInfo = {
|
---|
75 | path?: string;
|
---|
76 | multipassCount: number;
|
---|
77 | };
|
---|
78 |
|
---|
79 | export type Plugin<Params> = (
|
---|
80 | root: XastRoot,
|
---|
81 | params: Params,
|
---|
82 | info: PluginInfo
|
---|
83 | ) => null | Visitor;
|
---|
84 |
|
---|
85 | export type Specificity = [number, number, number, number];
|
---|
86 |
|
---|
87 | export type StylesheetDeclaration = {
|
---|
88 | name: string;
|
---|
89 | value: string;
|
---|
90 | important: boolean;
|
---|
91 | };
|
---|
92 |
|
---|
93 | export type StylesheetRule = {
|
---|
94 | dynamic: boolean;
|
---|
95 | selectors: string;
|
---|
96 | specificity: Specificity;
|
---|
97 | declarations: Array<StylesheetDeclaration>;
|
---|
98 | };
|
---|
99 |
|
---|
100 | export type Stylesheet = {
|
---|
101 | rules: Array<StylesheetRule>;
|
---|
102 | parents: Map<XastElement, XastParent>;
|
---|
103 | };
|
---|
104 |
|
---|
105 | type StaticStyle = {
|
---|
106 | type: 'static';
|
---|
107 | inherited: boolean;
|
---|
108 | value: string;
|
---|
109 | };
|
---|
110 |
|
---|
111 | type DynamicStyle = {
|
---|
112 | type: 'dynamic';
|
---|
113 | inherited: boolean;
|
---|
114 | };
|
---|
115 |
|
---|
116 | export type ComputedStyles = Record<string, StaticStyle | DynamicStyle>;
|
---|
117 |
|
---|
118 | export type PathDataCommand =
|
---|
119 | | 'M'
|
---|
120 | | 'm'
|
---|
121 | | 'Z'
|
---|
122 | | 'z'
|
---|
123 | | 'L'
|
---|
124 | | 'l'
|
---|
125 | | 'H'
|
---|
126 | | 'h'
|
---|
127 | | 'V'
|
---|
128 | | 'v'
|
---|
129 | | 'C'
|
---|
130 | | 'c'
|
---|
131 | | 'S'
|
---|
132 | | 's'
|
---|
133 | | 'Q'
|
---|
134 | | 'q'
|
---|
135 | | 'T'
|
---|
136 | | 't'
|
---|
137 | | 'A'
|
---|
138 | | 'a';
|
---|
139 |
|
---|
140 | export type PathDataItem = {
|
---|
141 | command: PathDataCommand;
|
---|
142 | args: Array<number>;
|
---|
143 | };
|
---|