-
Notifications
You must be signed in to change notification settings - Fork 0
/
api-type-definitions.js
174 lines (147 loc) · 4.26 KB
/
api-type-definitions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/**
* @file Type definitions for the API and reusable functions/objects
* @author TheJaredWilcurt
*/
/**
* OPTIONAL: console.error is called by default if verbose: true.
*
* Your own custom logging function called with helpful warning/error
* messages from the internal validators. Only used if verbose: true.
*
* @callback {Function} CUSTOMLOGGER
* @param {string} message The human readable warning/error message
* @param {object} [error] Sometimes an error or options object is passed
* @return {void}
*/
/**
* @typedef {object} OPTIONS
* @property {boolean} [verbose=true] Logs out helpful warnings/errors using `customLogger` or console.error.
* @property {CUSTOMLOGGER} [customLogger] Called (if verbose: true) with helpful warning/error messages from internal validators.
* @property {boolean} [uglify=false] If `false` atomized classes are long (`.rp__padding__--COLOR12px`). If `true` they are short (`.rp__b5p`).
* @property {string} [input=''] A string of any valid CSS to be atomized
*/
/**
* @typedef {object} CLASSMAP
* @property {{[key: string]: string[]}} classMapEntry The key is the original classname, the value is an array of strings of atomized classes
*/
/**
* @typedef {object} SELECTORCHUNK
* @property {string} type The type of selector ('tag', 'attribute', 'pseudo')
* @property {string} name Selector name ('class', 'hover')
* @property {string} [action] Action ('element')
* @property {string} [value] Actual selector value ('cow')
* @property {boolean} [ignoreCase] If casing should be ignored (false)
* @property {string} [namespace] Not sure what this is (null)
* @property {string} [data] Not sure what this is (null)
* @property {string} [original] The original value for this selector ('.cow')
*/
/**
* @typedef {SELECTORCHUNK[]} SELECTOR
*/
/**
* @typedef {SELECTOR[]} SELECTORS
*/
/**
* @typedef {object} DECLARATION
* @property {string} type The type of AST ('declaration')
* @property {string} property The CSS property name ('background', 'width')
* @property {string} value The CSS value ('#F00', '100px')
*/
/**
* @typedef {DECLARATION[]} DECLARATIONS
*/
/**
* @typedef {object} RULE
* @property {string} type The type of the AST ('rule')
* @property {SELECTORS} selectors Array of arrays containing AST objects for each part of the CSS Selector
* @property {DECLARATIONS} declarations Array of declaration objects for each property/value pair
*/
/**
* @typedef {object} STYLESHEET
* @property {string} [source] Not sure what this is (undefined)
* @property {RULE[]} rules Array of all rules in the the stylesheet
* @property {Array} parsingErrors Not sure what this is (empty array)
*/
/**
* @typedef {object} STYLESHEETAST
* @property {string} type The type of the AST ('stylesheet')
* @property {STYLESHEET} stylesheet Object containing the Rules AST
*/
/**
* @typedef {object} UGLIFYRESULT
* @property {string} name An uglified class name ('.rp__b5z2')
* @property {number} index The index number used (520958)
*/
/**
* @typedef {object} OUTPUT
* @property {CLASSMAP} classMap Example: { '.cow': ['.rp__0', '.rp__1'], '.moo': ['.rp__2', '.rp__1'] }
* @property {string} atomizedCss A string of atomized CSS styles
* @property {string[]} styleErrors Array of strings of errors that occurred, or empty array if no errors occurred
*/
/**
* @type {CUSTOMLOGGER}
*/
let CUSTOMLOGGER;
/**
* @type {OPTIONS}
*/
let OPTIONS;
/**
* @type {CLASSMAP}
*/
let CLASSMAP;
/**
* @type {SELECTORCHUNK}
*/
let SELECTORCHUNK;
/**
* @type {SELECTOR}
*/
let SELECTOR;
/**
* @type {SELECTORS}
*/
let SELECTORS;
/**
* @type {DECLARATION}
*/
let DECLARATION;
/**
* @type {DECLARATIONS}
*/
let DECLARATIONS;
/**
* @type {RULE}
*/
let RULE;
/**
* @type {STYLESHEET}
*/
let STYLESHEET;
/**
* @type {STYLESHEETAST}
*/
let STYLESHEETAST;
/**
* @type {UGLIFYRESULT}
*/
let UGLIFYRESULT;
/**
* @type {OUTPUT}
*/
let OUTPUT;
module.exports = {
CUSTOMLOGGER,
OPTIONS,
CLASSMAP,
SELECTORCHUNK,
SELECTOR,
SELECTORS,
DECLARATION,
DECLARATIONS,
RULE,
STYLESHEET,
STYLESHEETAST,
UGLIFYRESULT,
OUTPUT
};