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: 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: XastChild[];
|
48 | };
|
49 |
|
50 | export type XastParent = XastRoot | XastElement;
|
51 |
|
52 | export type XastNode = XastRoot | XastChild;
|
53 |
|
54 | export type StringifyOptions = {
|
55 | doctypeStart?: string;
|
56 | doctypeEnd?: string;
|
57 | procInstStart?: string;
|
58 | procInstEnd?: string;
|
59 | tagOpenStart?: string;
|
60 | tagOpenEnd?: string;
|
61 | tagCloseStart?: string;
|
62 | tagCloseEnd?: string;
|
63 | tagShortStart?: string;
|
64 | tagShortEnd?: string;
|
65 | attrStart?: string;
|
66 | attrEnd?: string;
|
67 | commentStart?: string;
|
68 | commentEnd?: string;
|
69 | cdataStart?: string;
|
70 | cdataEnd?: string;
|
71 | textStart?: string;
|
72 | textEnd?: string;
|
73 | indent?: number | string;
|
74 | regEntities?: RegExp;
|
75 | regValEntities?: RegExp;
|
76 | encodeEntity?: (char: string) => string;
|
77 | pretty?: boolean;
|
78 | useShortTags?: boolean;
|
79 | eol?: 'lf' | 'crlf';
|
80 | finalNewline?: boolean;
|
81 | };
|
82 |
|
83 | type VisitorNode<Node> = {
|
84 | enter?: (node: Node, parentNode: XastParent) => void | symbol;
|
85 | exit?: (node: Node, parentNode: XastParent) => void;
|
86 | };
|
87 |
|
88 | type VisitorRoot = {
|
89 | enter?: (node: XastRoot, parentNode: null) => void;
|
90 | exit?: (node: XastRoot, parentNode: null) => void;
|
91 | };
|
92 |
|
93 | export type Visitor = {
|
94 | doctype?: VisitorNode<XastDoctype>;
|
95 | instruction?: VisitorNode<XastInstruction>;
|
96 | comment?: VisitorNode<XastComment>;
|
97 | cdata?: VisitorNode<XastCdata>;
|
98 | text?: VisitorNode<XastText>;
|
99 | element?: VisitorNode<XastElement>;
|
100 | root?: VisitorRoot;
|
101 | };
|
102 |
|
103 | export type PluginInfo = {
|
104 | path?: string;
|
105 | multipassCount: number;
|
106 | };
|
107 |
|
108 | export type Plugin<Params> = (
|
109 | root: XastRoot,
|
110 | params: Params,
|
111 | info: PluginInfo,
|
112 | ) => null | Visitor;
|
113 |
|
114 | export type Specificity = [number, number, number];
|
115 |
|
116 | export type StylesheetDeclaration = {
|
117 | name: string;
|
118 | value: string;
|
119 | important: boolean;
|
120 | };
|
121 |
|
122 | export type StylesheetRule = {
|
123 | dynamic: boolean;
|
124 | selector: string;
|
125 | specificity: Specificity;
|
126 | declarations: StylesheetDeclaration[];
|
127 | };
|
128 |
|
129 | export type Stylesheet = {
|
130 | rules: StylesheetRule[];
|
131 | parents: Map<XastElement, XastParent>;
|
132 | };
|
133 |
|
134 | type StaticStyle = {
|
135 | type: 'static';
|
136 | inherited: boolean;
|
137 | value: string;
|
138 | };
|
139 |
|
140 | type DynamicStyle = {
|
141 | type: 'dynamic';
|
142 | inherited: boolean;
|
143 | };
|
144 |
|
145 | export type ComputedStyles = Record<string, StaticStyle | DynamicStyle>;
|
146 |
|
147 | export type PathDataCommand =
|
148 | | 'M'
|
149 | | 'm'
|
150 | | 'Z'
|
151 | | 'z'
|
152 | | 'L'
|
153 | | 'l'
|
154 | | 'H'
|
155 | | 'h'
|
156 | | 'V'
|
157 | | 'v'
|
158 | | 'C'
|
159 | | 'c'
|
160 | | 'S'
|
161 | | 's'
|
162 | | 'Q'
|
163 | | 'q'
|
164 | | 'T'
|
165 | | 't'
|
166 | | 'A'
|
167 | | 'a';
|
168 |
|
169 | export type PathDataItem = {
|
170 | command: PathDataCommand;
|
171 | args: number[];
|
172 | };
|
173 |
|
174 | export type DataUri = 'base64' | 'enc' | 'unenc';
|