aliascss 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/.prettierrc +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +544 -0
  4. package/READMEEdititng.md +615 -0
  5. package/aliascss.config.js +201 -0
  6. package/bin/aliascss.js +101 -0
  7. package/dist/aliascss.js +1 -0
  8. package/jestconfig.json +10 -0
  9. package/lib/build/index.d.ts +1 -0
  10. package/lib/build/index.js +63 -0
  11. package/lib/classPrinter.d.ts +6 -0
  12. package/lib/classPrinter.js +233 -0
  13. package/lib/compilers/border.d.ts +5 -0
  14. package/lib/compilers/border.js +50 -0
  15. package/lib/compilers/clipPath.d.ts +5 -0
  16. package/lib/compilers/clipPath.js +57 -0
  17. package/lib/compilers/color.d.ts +5 -0
  18. package/lib/compilers/color.js +61 -0
  19. package/lib/compilers/filter.d.ts +7 -0
  20. package/lib/compilers/filter.js +54 -0
  21. package/lib/compilers/font.d.ts +5 -0
  22. package/lib/compilers/font.js +19 -0
  23. package/lib/compilers/gradient.d.ts +5 -0
  24. package/lib/compilers/gradient.js +138 -0
  25. package/lib/compilers/length.d.ts +2 -0
  26. package/lib/compilers/length.js +10 -0
  27. package/lib/compilers/shadow.d.ts +5 -0
  28. package/lib/compilers/shadow.js +55 -0
  29. package/lib/compilers/stringAndContent.d.ts +6 -0
  30. package/lib/compilers/stringAndContent.js +23 -0
  31. package/lib/compilers/timingFunction.d.ts +5 -0
  32. package/lib/compilers/timingFunction.js +35 -0
  33. package/lib/compilers/transform.d.ts +2 -0
  34. package/lib/compilers/transform.js +117 -0
  35. package/lib/compilers/transition.d.ts +1 -0
  36. package/lib/compilers/transition.js +35 -0
  37. package/lib/compilers/url.d.ts +1 -0
  38. package/lib/compilers/url.js +33 -0
  39. package/lib/config.d.ts +20 -0
  40. package/lib/config.js +21 -0
  41. package/lib/css-properties-all.d.ts +16 -0
  42. package/lib/css-properties-all.js +2642 -0
  43. package/lib/index.d.ts +8 -0
  44. package/lib/index.js +7 -0
  45. package/lib/node/compileFile.d.ts +25 -0
  46. package/lib/node/compileFile.js +337 -0
  47. package/lib/node/extractClassNamesFromFile.d.ts +18 -0
  48. package/lib/node/extractClassNamesFromFile.js +105 -0
  49. package/lib/prefix/PseudoPrefix.d.ts +7 -0
  50. package/lib/prefix/PseudoPrefix.js +145 -0
  51. package/lib/prefix/attribute-selector.d.ts +5 -0
  52. package/lib/prefix/attribute-selector.js +14 -0
  53. package/lib/prefix/colonToDefaultConversion.d.ts +1 -0
  54. package/lib/prefix/colonToDefaultConversion.js +3 -0
  55. package/lib/prefix/element-selector.d.ts +5 -0
  56. package/lib/prefix/element-selector.js +25 -0
  57. package/lib/prefix/extractMediaPrefix.d.ts +3 -0
  58. package/lib/prefix/extractMediaPrefix.js +12 -0
  59. package/lib/prefix/extractPrefix.d.ts +1 -0
  60. package/lib/prefix/extractPrefix.js +66 -0
  61. package/lib/prefix/pseudoSelector.d.ts +1 -0
  62. package/lib/prefix/pseudoSelector.js +48 -0
  63. package/lib/prefix/pseudoSelectorNew.d.ts +1 -0
  64. package/lib/prefix/pseudoSelectorNew.js +78 -0
  65. package/lib/prefix/responsive.d.ts +10 -0
  66. package/lib/prefix/responsive.js +26 -0
  67. package/lib/returnPropertyAndValue.d.ts +8 -0
  68. package/lib/returnPropertyAndValue.js +42 -0
  69. package/lib/returnStatement.d.ts +5 -0
  70. package/lib/returnStatement.js +189 -0
  71. package/lib/static/customColors.d.ts +3 -0
  72. package/lib/static/customColors.js +376 -0
  73. package/lib/static/customStaticClassNames.d.ts +3 -0
  74. package/lib/static/customStaticClassNames.js +132 -0
  75. package/lib/static/staticClassNamesAlias.d.ts +3 -0
  76. package/lib/static/staticClassNamesAlias.js +1300 -0
  77. package/lib/utils/createCompilerObj.d.ts +35 -0
  78. package/lib/utils/createCompilerObj.js +97 -0
  79. package/lib/utils/cssFunc.d.ts +1 -0
  80. package/lib/utils/cssFunc.js +27 -0
  81. package/package.json +64 -0
  82. package/ts.js +5 -0
  83. package/tsconfig.json +14 -0
  84. package/tslint.json +9 -0
  85. package/webpack.config.js +11 -0
package/lib/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export declare const main: {
2
+ [key: string]: any;
3
+ make: (a: string, b?: string | undefined, c?: boolean | undefined) => string;
4
+ group: (a: string, b: string) => string;
5
+ };
6
+ export declare const styleJSX: (str: string, bool?: boolean) => any;
7
+ export declare const staticClassNames: any;
8
+ export declare const extend: (object: {}) => any;
package/lib/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import { compiler } from "./returnStatement.js";
2
+ // import { customStaticClassNames } from "./static/customStaticClassNames.js";
3
+ export const main = compiler;
4
+ export const styleJSX = (str, bool) => compiler.groupForJs(str, bool);
5
+ // export const style=()=>{};
6
+ export const staticClassNames = compiler.staticClassNames;
7
+ export const extend = (object) => compiler.extend(object);
@@ -0,0 +1,25 @@
1
+ export default function main(config: {
2
+ ['input']: string | string[];
3
+ [key: string]: any;
4
+ }): void;
5
+ export declare function globalCSSCompiler(): void;
6
+ export declare function compileFile(file: string, config: any, statementMaker: {
7
+ ['make']: (a: string) => string;
8
+ group: (a: string, b: string) => string;
9
+ }, globalClassList: string[]): string[];
10
+ export declare function groupStatement(name: string, classNames: string, statementMaker: {
11
+ ['group']: (a: string, b: string) => string;
12
+ }): string;
13
+ export declare function keyframesStatement(name: string, timeLine: string, statementMaker: {
14
+ ['make']: (a: string, b?: string | null, c?: boolean) => string;
15
+ }): string;
16
+ export declare function createCSSFileByFile(file: string, bool?: boolean): void;
17
+ export declare function postify(file: string, plugin: any[], minify?: boolean): void;
18
+ export declare function writeStatementToFile(file: string, content: string): void;
19
+ export declare function initialize(configFile: {
20
+ [key: string]: any;
21
+ }): void;
22
+ export declare function watch(config: {
23
+ ['input']: string | string[];
24
+ [key: string]: any;
25
+ }): void;
@@ -0,0 +1,337 @@
1
+ import extractClassNamesFromFile from "./extractClassNamesFromFile.js";
2
+ import { compiler as statementMaker } from "../returnStatement.js";
3
+ import config from '../config.js';
4
+ import fs from "fs";
5
+ import fg from "fast-glob";
6
+ import path from 'path';
7
+ import postcss from 'postcss';
8
+ import postcssDiscardDuplicates from 'postcss-discard-duplicates';
9
+ // import postcssSort from 'postcss-sort-media-queries';
10
+ import cssnano from 'cssnano';
11
+ import chokidar from 'chokidar';
12
+ const init = {
13
+ classList: [], // hold className for MasterCSS to avoid repeating
14
+ groups: [],
15
+ input: '', // input glob pattern
16
+ output: '', // location off output
17
+ '--file': false, // if set true compileFileByFile to [filename].css
18
+ statementMaker,
19
+ config,
20
+ '--module': false,
21
+ rawCSS: '',
22
+ customGroupStatement: '',
23
+ minify: false,
24
+ globPattern: '', // Use this to check valid new created file to add to watch during watch.on
25
+ };
26
+ export default function main(config) {
27
+ // initialize
28
+ initialize(config);
29
+ if (init.config.prefix)
30
+ init.statementMaker.prefix = init.config.prefix;
31
+ if (init.input && (init.output || init['--file'])) {
32
+ const input = fg.sync(init.input, { dot: true });
33
+ // console.log(input);
34
+ input.forEach((file) => {
35
+ createCSSFileByFile(file);
36
+ });
37
+ postify(init.output, [postcssDiscardDuplicates], init.minify);
38
+ }
39
+ else {
40
+ console.error("Please Provide input, output or set '--file' to true");
41
+ }
42
+ }
43
+ export function globalCSSCompiler() {
44
+ const classList = [];
45
+ if (init.globPattern && init.output) {
46
+ fs.truncateSync(init.output);
47
+ const input = fg.sync(init.globPattern, { dot: true });
48
+ // console.log(input);
49
+ input.forEach((file) => {
50
+ const [gbContent,] = compileFile(file, config, statementMaker, classList);
51
+ try {
52
+ fs.writeFileSync(init.output, `\n/* Start :-----------ACSS ${path.basename(file)}------------------------*/\n${gbContent}
53
+ \n/* End :-----------ACSS ${path.basename(file)}----------------------------*/\n
54
+ `, { flag: 'a+' });
55
+ console.log('AliasCSS compiled', path.basename(file), 'to main css file :' + init.output);
56
+ }
57
+ catch (error) {
58
+ console.log('\x1b[31m', "Couldn't able to append/create to main css file :" + init.output);
59
+ console.log(error);
60
+ }
61
+ });
62
+ postify(init.output, [postcssDiscardDuplicates], init.minify);
63
+ }
64
+ else {
65
+ console.error("Please Provide input, output or set '--file' to true");
66
+ }
67
+ }
68
+ export function compileFile(file, config, statementMaker, globalClassList) {
69
+ let [globalStatement, compiledStatement, moduleStatement] = ['', '', ''];
70
+ const [classList, groups, keyframe] = extractClassNamesFromFile(file, config);
71
+ // 2. group
72
+ for (const key in groups) {
73
+ if (groups.hasOwnProperty(key)) {
74
+ // --------------ModuleStatement
75
+ if (/^module=/.test(key)) {
76
+ const mdStatement = statementMaker.group(groups[key], key.replace(/module=/, ''));
77
+ moduleStatement += mdStatement + '\n';
78
+ }
79
+ // -------------EndOfModule
80
+ else {
81
+ const gpStatement = statementMaker.group(groups[key], key);
82
+ globalStatement += gpStatement + '\n';
83
+ compiledStatement += gpStatement + '\n';
84
+ }
85
+ }
86
+ }
87
+ // 2. ClassList
88
+ classList.forEach((e) => {
89
+ const statement = statementMaker.make(e);
90
+ if (statement) {
91
+ console.log('\x1b[32m', statement);
92
+ if (globalClassList.indexOf(e) === -1) {
93
+ globalStatement += statement + '\n';
94
+ globalClassList.push(e);
95
+ // console.log(e);
96
+ }
97
+ compiledStatement += statement + '\n';
98
+ }
99
+ });
100
+ // 3. Keyframe
101
+ for (const key in keyframe) {
102
+ if (keyframe.hasOwnProperty(key)) {
103
+ const kfStatement = keyframesStatement(key, keyframe[key], statementMaker);
104
+ globalStatement += kfStatement + '\n';
105
+ compiledStatement += kfStatement + '\n';
106
+ }
107
+ }
108
+ return [globalStatement, compiledStatement, moduleStatement];
109
+ }
110
+ export function groupStatement(name, classNames, statementMaker) {
111
+ return statementMaker.group(classNames, name) + '\n';
112
+ }
113
+ export function keyframesStatement(name, timeLine, statementMaker) {
114
+ let kfStatement = '@keyframes ' + name + "{\n";
115
+ const split = timeLine.split(/\s+/);
116
+ split.forEach((each) => {
117
+ try {
118
+ const [at, pNv] = each.replace("-", "=").split("=");
119
+ kfStatement += ` ${at.replace('@', '').replace(/:/g, ',').replace(/,/g, "%,").replace(/[\[|\]]/g, '')}% {${statementMaker.make(pNv, null, true)}}`;
120
+ }
121
+ catch (error) {
122
+ console.error('Not a valid entry for AliasCSS keyframes processor : ' + each, error);
123
+ }
124
+ });
125
+ return kfStatement + "\n}\n";
126
+ }
127
+ export function createCSSFileByFile(file, bool = false) {
128
+ const [gbContent, content, module] = compileFile(file, config, statementMaker, init.classList);
129
+ // console.log(init.classList);
130
+ // If its fileByFile
131
+ if (init["--module"] && module.trim()) {
132
+ try {
133
+ fs.writeFileSync(file + '.module.css', module);
134
+ // console.log(content);
135
+ console.log('AliasCSS compiled', path.basename(file), 'module Locally ');
136
+ }
137
+ catch (error) {
138
+ console.log('\x1b[31m', "Couldn't able to append/create locally from " + file);
139
+ console.log(error);
140
+ }
141
+ }
142
+ if (init["--file"]) {
143
+ try {
144
+ fs.writeFileSync(file + '.css', content);
145
+ // console.log(content);
146
+ console.log('AliasCSS compiled', path.basename(file), 'Locally');
147
+ }
148
+ catch (error) {
149
+ console.log('\x1b[31m', "Couldn't able to append/create locally from " + file);
150
+ console.log(error);
151
+ }
152
+ }
153
+ // Check for Global
154
+ if (!bool && init.output) {
155
+ try {
156
+ fs.writeFileSync(init.output, `\n/* Start :-----------ACSS ${path.basename(file)}------------------------*/\n${postcss([postcssDiscardDuplicates]).process(gbContent)}
157
+ \n/* End :-----------ACSS ${path.basename(file)}----------------------------*/\n
158
+ `, { flag: 'a+' });
159
+ console.log('AliasCSS compiled', path.basename(file), 'to main css file :' + init.output);
160
+ }
161
+ catch (error) {
162
+ console.log('\x1b[31m', "Couldn't able to append/create to main css file :" + init.output);
163
+ console.log(error);
164
+ }
165
+ }
166
+ }
167
+ export function postify(file, plugin, minify = false) {
168
+ const data = fs.readFileSync(file, 'utf-8');
169
+ if (fs.existsSync(file)) {
170
+ if (minify === true)
171
+ plugin.push(cssnano);
172
+ postcss(plugin).process(data).then(result => {
173
+ fs.truncateSync(file);
174
+ fs.writeFileSync(file, result.css);
175
+ });
176
+ }
177
+ // fs.readFile(file, (err, css) => {
178
+ // postcss(plugin)
179
+ // .process(css, { from: file, to: file+"post.css" })
180
+ // .then(result => {
181
+ // fs.writeFile(file+"post.css", result.css, () => true)
182
+ // // if ( result.map ) {
183
+ // // fs.writeFile(file+'.map', result.map.toString(), () => true)
184
+ // // }
185
+ // })
186
+ // })
187
+ }
188
+ export function writeStatementToFile(file, content) {
189
+ // Check for Global
190
+ if (init.output) {
191
+ try {
192
+ fs.writeFileSync(init.output, `\n/* Start :-----------ACSS:From aliasCSSConfig.statement------------------------*/\n${content}
193
+ \n/* End :-----------ACSS aliasCSSConfig.statement----------------------------*/\n
194
+ `, { flag: 'a+' });
195
+ console.log('AliasCSS compiled', '[aliasCSSConfig.statement]', 'aliascss.config.js');
196
+ }
197
+ catch (error) {
198
+ console.log('\x1b[31m', "Couldn't able to append/create [key:statement] from alias.config.js ");
199
+ console.log(error);
200
+ }
201
+ }
202
+ }
203
+ // Initialize
204
+ export function initialize(configFile) {
205
+ // ----------------input-------------------
206
+ if (configFile.hasOwnProperty('input')) {
207
+ init.input = configFile.input;
208
+ init.globPattern = configFile.input;
209
+ }
210
+ // ----------------Prefix-------------------
211
+ if (configFile.hasOwnProperty('prefix')) {
212
+ init.config.prefix = configFile.prefix;
213
+ }
214
+ // ----------------output-------------------
215
+ if (configFile.hasOwnProperty('output')) {
216
+ const op = configFile.output;
217
+ if (op.hasOwnProperty('location')) {
218
+ init.output = op.location;
219
+ }
220
+ if (op.hasOwnProperty('--file') && op['--file'] === true) {
221
+ init["--file"] = true;
222
+ }
223
+ }
224
+ // --module
225
+ if (configFile.hasOwnProperty('--module') && configFile.hasOwnProperty('importModuleAs')) {
226
+ init["--module"] = true;
227
+ init.config.useCSSModule = init["--module"] ? true : false;
228
+ if (init.config.useCSSModule)
229
+ init.config.matchCSSModuleFunction = init.config.createCSSModuleRegex(configFile.importModuleAs);
230
+ }
231
+ // ---------output Minify
232
+ if (configFile.hasOwnProperty('minify')) {
233
+ init.minify = configFile.minify;
234
+ }
235
+ // ------------Extractor function-------
236
+ if (configFile.hasOwnProperty('extractorFunction')) {
237
+ init.config.useExtractorFunction = configFile.extractorFunction.trim() ? true : false;
238
+ if (init.config.useExtractorFunction)
239
+ init.config.matchExtractorFunction = init.config.createExtractorRegex(configFile.extractorFunction);
240
+ }
241
+ // ---------Extend----------------
242
+ if (configFile.hasOwnProperty('extend') && typeof configFile.extend === 'object') {
243
+ const filteredObj = {};
244
+ Object.keys(configFile.extend).map((key) => {
245
+ // if (configFile.extend[key].hasOwnProperty('compiler') && (typeof configFile.extend[key].compiler === 'function')){
246
+ filteredObj[key] = configFile.extend[key];
247
+ // }
248
+ });
249
+ init.statementMaker.extend(filteredObj);
250
+ }
251
+ // -----------------useColon----------------------------
252
+ if (configFile.hasOwnProperty('useColon')) {
253
+ init.config.useColon = configFile.useColon;
254
+ }
255
+ // ---------------addMedia----------------
256
+ if (configFile.hasOwnProperty('media') && typeof configFile.media === 'object') {
257
+ init.statementMaker.addMedia(configFile.media);
258
+ }
259
+ // /Truncate File every time we bundle
260
+ if (configFile.hasOwnProperty('truncate') && configFile.truncate === false) {
261
+ // do nothing
262
+ }
263
+ else {
264
+ if (fs.existsSync(init.output))
265
+ fs.truncateSync(path.resolve(init.output));
266
+ }
267
+ // Custom CSS statement
268
+ if (configFile.hasOwnProperty('statement')) {
269
+ init.rawCSS = configFile.statement;
270
+ writeStatementToFile(init.output, configFile.statement);
271
+ }
272
+ // Custom Groups bundling acss classnames in single class name
273
+ if (configFile.hasOwnProperty('group')) {
274
+ init.customGroupStatement = init.statementMaker.groupObj(configFile.group);
275
+ if (init.customGroupStatement)
276
+ writeStatementToFile(init.output, init.customGroupStatement);
277
+ }
278
+ // Adding Custom color, length etc
279
+ if (configFile.hasOwnProperty('custom') && typeof configFile.custom === 'object') {
280
+ Object.keys(configFile.custom).forEach((key) => {
281
+ init.statementMaker.addCustom(key, configFile.custom[key]);
282
+ });
283
+ }
284
+ // Extend custom class name define {'border-color-native":'border-color: skyBlue',}
285
+ if (configFile.hasOwnProperty('prebuild')) {
286
+ init.statementMaker.prebuild(configFile.prebuild);
287
+ }
288
+ // Ignore these class name
289
+ if (configFile.hasOwnProperty('ignore')) {
290
+ if (Array.isArray(configFile.ignore)) {
291
+ configFile.ignore.forEach((each) => init.config.ignore.push(each.trim()));
292
+ }
293
+ }
294
+ }
295
+ // ----------------WATCH-------------------------------
296
+ export function watch(config) {
297
+ main(config);
298
+ const watcher = chokidar.watch(init.input, {
299
+ ignored: '*.css', // ignore dot-files
300
+ persistent: true
301
+ });
302
+ const compileFile = (file) => {
303
+ console.log(`--processing file : ${file}`);
304
+ createCSSFileByFile(file, true);
305
+ globalCSSCompiler();
306
+ postify(init.output, [postcssDiscardDuplicates], init.minify);
307
+ console.log('Done! ');
308
+ };
309
+ // Something to use when events are received.
310
+ const log = console.log.bind(console);
311
+ // Add event listeners.
312
+ watcher
313
+ .on('add', path => log(`File ${path} has been added to watch`))
314
+ .on('change', path => compileFile(path));
315
+ // .on('unlink', path => log(`File ${path} has been removed`));
316
+ // More possible events.
317
+ watcher
318
+ .on('addDir', path => log(`Directory ${path} has been added`))
319
+ .on('unlinkDir', path => log(`Directory ${path} has been removed`))
320
+ // .on('error', error => log(`Watcher error: ${error}`))
321
+ // .on('ready', () => log('Initial scan complete. Ready for changes'))
322
+ .on('raw', (event, path, details) => {
323
+ // log('Raw event info:', event, path, details);
324
+ if (event === 'created' && details.type === 'file') {
325
+ if (init.globPattern) {
326
+ const files = fg.sync(init.globPattern, { absolute: true });
327
+ if (files.indexOf(path) !== -1) {
328
+ watcher.add(path);
329
+ console.log(path, 123123);
330
+ }
331
+ }
332
+ else {
333
+ watcher.add(path);
334
+ }
335
+ }
336
+ });
337
+ }
@@ -0,0 +1,18 @@
1
+ type config = {
2
+ matchExtractorFunction: RegExp | null;
3
+ matchRegExp: RegExp;
4
+ matchRegExpWithColon: RegExp;
5
+ matchRegExpKeyFrame: RegExp;
6
+ matchRegExpWithColonKeyFrame: RegExp;
7
+ useColon: boolean;
8
+ useExtractorFunction: boolean;
9
+ useCSSModule: boolean;
10
+ matchCSSModuleFunction: RegExp | null;
11
+ ignore?: string[];
12
+ };
13
+ export default function extractClassNamesFromFile(file: string, config: config): [string[], {
14
+ [key: string]: string;
15
+ }, {
16
+ [key: string]: string;
17
+ }];
18
+ export {};
@@ -0,0 +1,105 @@
1
+ import fs from 'fs';
2
+ export default function extractClassNamesFromFile(file, config) {
3
+ const data = fs.readFileSync(file, 'utf-8');
4
+ const classList = [];
5
+ const groups = {};
6
+ const keyframes = {};
7
+ const matchExtractorFunction = config.useExtractorFunction ? config.matchExtractorFunction : null;
8
+ const matchCSSModuleFunction = config.useCSSModule ? config.matchCSSModuleFunction : null;
9
+ const matchRegExp = config.useColon ? config.matchRegExpWithColon : config.matchRegExp;
10
+ const matchRegExpKeyFrame = config.useColon ? config.matchRegExpWithColonKeyFrame : config.matchRegExpKeyFrame;
11
+ // 1 - i. Extract from Extractor function
12
+ if (config.useExtractorFunction && matchExtractorFunction) {
13
+ const matchesEF = data.match(new RegExp(matchExtractorFunction, "g"));
14
+ if (matchesEF) {
15
+ matchesEF.forEach((each) => {
16
+ const extraction = each.match(matchExtractorFunction);
17
+ if (extraction && extraction[2]) {
18
+ extraction[2].trim().replace(/[\s]+/, " ").split(/\s+/).forEach((e) => {
19
+ var _a;
20
+ if (((_a = config.ignore) === null || _a === void 0 ? void 0 : _a.indexOf(e)) === -1 && classList.indexOf(e) === -1) {
21
+ classList.push(e);
22
+ }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ }
28
+ // 1 -ii. CSS-Module
29
+ if (config.useCSSModule && matchCSSModuleFunction) {
30
+ const matchesEF = data.match(new RegExp(matchCSSModuleFunction, "g"));
31
+ if (matchesEF) {
32
+ matchesEF.forEach((each) => {
33
+ const extraction = each.match(matchCSSModuleFunction);
34
+ if (extraction && extraction[1]) {
35
+ groups[`module=${extraction[1].replace(/[\s]/g, '\\ ').replace(/([.%=\]\[@~:*#\(\)\/^])/g, '\\$1')}`] = extraction[1].trim().replace(/[\s]+/, " ");
36
+ }
37
+ });
38
+ }
39
+ }
40
+ // 2. Extract KeyFrames
41
+ const matchesKF = data.match(new RegExp(matchRegExpKeyFrame, "g"));
42
+ if (matchesKF) {
43
+ matchesKF.forEach((match) => {
44
+ const extraction = match.match(matchRegExpKeyFrame);
45
+ if (!extraction)
46
+ return;
47
+ // case one if its just keyframes
48
+ if (extraction[1].match(/keyframes[:_-]/)) {
49
+ const name = extraction[1].replace(/keyframes[:_-]/, '');
50
+ if (name) {
51
+ // if name already exists
52
+ // if (names.hasOwnProperty(name) && names[name] === extraction[2]) {
53
+ if (keyframes.hasOwnProperty(name)) {
54
+ keyframes[name] = keyframes[name] + " " + extraction[2].trim().replace(/[\s]+/, " ");
55
+ }
56
+ else {
57
+ // new name
58
+ keyframes[name] = extraction[2].trim().replace(/[\s]+/, " ");
59
+ }
60
+ }
61
+ }
62
+ });
63
+ }
64
+ // 3 .Extract from class|className|group attribute
65
+ const matches = data.match(new RegExp(matchRegExp, "g"));
66
+ if (matches === null || matches === void 0 ? void 0 : matches.length) {
67
+ matches.forEach(toEach => {
68
+ const each = toEach.match(matchRegExp);
69
+ if (!each)
70
+ return;
71
+ if (each[1].match(/^(class|className)$/)) {
72
+ each[2].split(/\s+/).forEach(e => {
73
+ var _a;
74
+ if (((_a = config.ignore) === null || _a === void 0 ? void 0 : _a.indexOf(e)) === -1 && classList.indexOf(e) === -1) {
75
+ classList.push(e);
76
+ }
77
+ });
78
+ }
79
+ else if (each[1].match(/class[:_-]/)) {
80
+ // Group
81
+ let group = each[1].replace(/class[:_-]/, '');
82
+ let classExtracted = each[2];
83
+ const match = group.match(/\[(.)+\]/);
84
+ if (match) {
85
+ group = group.replace(match[0], '');
86
+ classExtracted = classExtracted.trim().split(/\s+/).map(e => match[0].replace(/^\[/, '').replace(/\]$/, '') + (/^[_-]/.test(e) ? '' : '-') + e).join(" ");
87
+ }
88
+ if (group && classExtracted) {
89
+ if (groups.hasOwnProperty(group)) {
90
+ groups[group] = groups[group] + " " + classExtracted;
91
+ }
92
+ else {
93
+ groups[group] = classExtracted.trim().replace(/[\s]+/, " ");
94
+ }
95
+ }
96
+ }
97
+ });
98
+ }
99
+ // ?.join(' ')
100
+ // .replace(/class(Name)?=/g,'')
101
+ // .replace(/["']/g,'')
102
+ // .split(/\s+/)
103
+ // extract from keyframes
104
+ return [classList, groups, keyframes];
105
+ }
@@ -0,0 +1,7 @@
1
+ export declare function createRegexForPseudo(prefix: {
2
+ [key: string]: string;
3
+ }): RegExp;
4
+ declare const prefix: {
5
+ [key: string]: string;
6
+ };
7
+ export default prefix;
@@ -0,0 +1,145 @@
1
+ export function createRegexForPseudo(prefix) {
2
+ const prefixAlias = Object.keys(prefix).reduce((previous, current) => previous + "|" + current);
3
+ return new RegExp("^(" + prefixAlias + ")(?=[-(|_])");
4
+ }
5
+ const prefix = {
6
+ '--active': ':active', // -a
7
+ '-a': ':active',
8
+ '-ac': ':active',
9
+ '--after-hover': '::after:hover',
10
+ '-afh': '::after:hover',
11
+ '--after': '::after', // -af
12
+ '-af': '::after', // -af
13
+ '--autofill': ':-webkit-autofill',
14
+ '-atf': ':-webkit-autofill',
15
+ '--any-link': ':any-link',
16
+ '-al': ':any-link',
17
+ '--backdrop': '::backdrop',
18
+ '-bd': '::backdrop',
19
+ '--blank': ':blank',
20
+ '-bl': ':blank',
21
+ '--before-hover': '::before:hover', // -bfh
22
+ '-bfh': '::before:hover', // -bfh
23
+ '--before': '::before', // -bf
24
+ '-bf': '::before', // -bf
25
+ '--checked': ':checked', // -ck
26
+ '-ch': ':checked', // -ck
27
+ '--current': ':current', // -ck
28
+ '-cur': ':current',
29
+ '--cue': '::cue',
30
+ '-cu': '::cue',
31
+ '--default': ':default', // -df
32
+ '-de': ':default', // -df
33
+ '--disabled': ':disabled', // -ds
34
+ '-di': ':disabled', // -ds
35
+ '--empty': ':empty', // -em
36
+ '-em': ':empty', // -em
37
+ '--enabled': ':enabled', // -en
38
+ '-en': ':enabled', // -en
39
+ '--file-selector-button': '::file-selector-button',
40
+ '-fsb': '::file-selector-button',
41
+ '--first-child': ':first-child', // -fc
42
+ '-fc': ':first-child',
43
+ '--first-letter': '::first-letter', // -f
44
+ '-fl': '::first-letter', // -fl
45
+ '--first-line': '::first-line', // -fln
46
+ '-fln': '::first-line', // -fln
47
+ '--first-of-type': ':first-of-type', // -fot
48
+ '-fot': ':first-of-type',
49
+ '--focus': ':focus', // -fo
50
+ '-fo': ':focus', // -fo
51
+ '-f': ':focus', // -fo
52
+ '--focus-within': ':focus-within', // -fo
53
+ '-fw': ':focus-within', // -fo
54
+ '--focus-visible': ':focus-visible', // -fo
55
+ '-fv': ':focus-visible', // -fo
56
+ '--fullscreen': ':fullscreen',
57
+ '-fs': ':fullscreen',
58
+ '--has': ':has', // --has
59
+ '-hs': ':has', // -hs
60
+ '--hover-after': ':hover::after', // -haf
61
+ '-haf': ':hover::after', // -haf
62
+ '--hover-before': ':hover::before', // -hbf
63
+ '-hbf': ':hover::before', // -hbf
64
+ '--hover-target': ':hover:target', // -htg
65
+ '-htg': ':hover:target', // -htg
66
+ '--hover': ':hover', // -h
67
+ '-h': ':hover', // -h
68
+ '-ho': ':hover', // -h
69
+ '--in-range': ':in-range', // -ir
70
+ '-ir': ':in-range', // -ir
71
+ '--indeterminate': ':indeterminate', // idt
72
+ '-ind': ':indeterminate', // idt
73
+ '--invalid': ':invalid', // -in
74
+ '-inv': ':invalid', // -in
75
+ '--is': ':is',
76
+ '-is': ':is',
77
+ '--lang': ':lang', // -ln
78
+ '-lan': ':lan', // -ln
79
+ '--last-child': ':last-child', // -lc
80
+ '-lc': ':last-child', // -lc
81
+ '--last-of-type': ':last-of-type', // -lot
82
+ '-lot': ':last-of-type', // -lot
83
+ '--link': ':link', // -l
84
+ '-ln': ':link', // -l
85
+ '-l': ':link', // -l
86
+ '--marker': '::marker',
87
+ '-m': '::marker',
88
+ '--not': ':not', // -n-
89
+ '-n': ':not', // -n-
90
+ '--nth-child': ':nth-child', // -nc2n
91
+ '-nc': ':nth-child', // -nc2n
92
+ '--nth-last-child': ':nth-last-child', // -nlc2n
93
+ '-nlc': ':nth-last-child', // -nlc2n
94
+ '--nth-last-of-type': ':nth-last-of-type', // -nlot2n
95
+ '-nlot': ':nth-last-of-type', // -nlot2n
96
+ '--nth-of-type': ':nth-of-type', // -not
97
+ '-not': ':nth-of-type', // -not
98
+ '--only-of-type': ':only-of-type', // -oot
99
+ '-oot': ':only-of-type', // -oot
100
+ '--only-child': ':only-child', // -oc
101
+ '-oc': ':only-child', // -oc
102
+ '--optional': ':optional', // -o
103
+ '-op': ':optional', // -o
104
+ '--out-of-range': ':out-of-range', // -oor
105
+ '-oor': ':out-of-range', // -oor
106
+ '--placeholder': '::placeholder', // -ph
107
+ '-ph': '::placeholder', // -ph
108
+ '--placeholder-shown': ':placeholder-shown', // -phs
109
+ '-phs': ':placeholder-shown', // -phs
110
+ '--popover-open': ':popover-open',
111
+ '-po': ':popover-open',
112
+ '--read-only': ':read-only', // -ro
113
+ '-ro': ':read-only', // -ro
114
+ '--read-write': ':read-write', // -rw
115
+ '-rw': ':read-write', // -rw
116
+ '--required': ':required', // -rq
117
+ '-rq': ':required', // -rq
118
+ '--root': ':root', // -rt
119
+ '-rt': ':root', // -rt
120
+ '--selection': '::selection', // -sl
121
+ '-s': '::selection', // -sl
122
+ '--spelling-error': '::spelling-error',
123
+ '-se': '::spelling-error',
124
+ '--scrollbar': '::-webkit-scrollbar',
125
+ '--webkit-scrollbar': '::-webkit-scrollbar',
126
+ '-sb': '::-webkit-scrollbar',
127
+ '--scrollbar-track': '::-webkit-scrollbar-track',
128
+ '--webkit-scrollbar-track': '::-webkit-scrollbar-track',
129
+ '-st': '::-webkit-scrollbar-track',
130
+ '--scrollbar-thumb': '::-webkit-scrollbar-thumb',
131
+ '--web-kit-scrollbar-thumb': '::-webkit-scrollbar-thumb',
132
+ '-stm': '::-webkit-scrollbar-thumb',
133
+ '--target': ':target', // -tg
134
+ '-tg': ':target', // -tg
135
+ '--user-invalid': ':user-invalid',
136
+ '-ui': ':user-invalid',
137
+ '--valid': ':valid', // -vl
138
+ '-va': ':valid', // -vl
139
+ '--visited': ':visited', // -vi
140
+ '-vi': ':visited', // -vi
141
+ '-v': ':visited', // -vi
142
+ '--where': ':where',
143
+ '-w': ':where'
144
+ };
145
+ export default prefix;
@@ -0,0 +1,5 @@
1
+ declare const attribute: {
2
+ [key: string]: any;
3
+ process: (...args: any[]) => any;
4
+ };
5
+ export default attribute;