aliascss 1.4.4 → 1.4.7

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 (63) hide show
  1. package/aliascss.config.js +32 -32
  2. package/dist/aliascss.js +1 -1
  3. package/lib/compilers/color.js +5 -5
  4. package/lib/compilers/gradient.js +3 -3
  5. package/lib/compilers/stringAndContent.js +2 -1
  6. package/lib/component-elements.d.ts +155 -0
  7. package/lib/component-elements.js +223 -0
  8. package/lib/config.d.ts +1 -0
  9. package/lib/config.js +2 -1
  10. package/lib/css-properties-all.js +337 -202
  11. package/lib/custom-css-compilers.js +54 -54
  12. package/lib/extras-elements.d.ts +87 -0
  13. package/lib/extras-elements.js +184 -0
  14. package/lib/form-elements.d.ts +75 -0
  15. package/lib/form-elements.js +186 -0
  16. package/lib/layout-elements.d.ts +59 -0
  17. package/lib/layout-elements.js +113 -0
  18. package/lib/nav-elements.d.ts +71 -0
  19. package/lib/nav-elements.js +243 -0
  20. package/lib/node/compileFile-bk.d.ts +27 -0
  21. package/lib/node/compileFile-bk.js +379 -0
  22. package/lib/node/compileFile.d.ts +11 -11
  23. package/lib/node/compileFile.js +170 -235
  24. package/lib/prebuild.d.ts +520 -12
  25. package/lib/prebuild.js +9 -852
  26. package/lib/prefix/PseudoPrefixNew.js +301 -16
  27. package/lib/prefix/attribute-selector.js +4 -2
  28. package/lib/prefix/pseudoSelectorNew.js +184 -49
  29. package/lib/prefix/responsive.d.ts +13 -9
  30. package/lib/prefix/responsive.js +131 -9
  31. package/lib/returnPropertyAndValue.js +9 -4
  32. package/lib/returnStatement-bk.d.ts +5 -0
  33. package/lib/returnStatement-bk.js +311 -0
  34. package/lib/returnStatement.js +165 -2
  35. package/lib/static/customStaticClassNames.js +35 -35
  36. package/lib/static/staticClassNamesAlias.js +18 -16
  37. package/lib/table-elements.d.ts +39 -0
  38. package/lib/table-elements.js +90 -0
  39. package/lib/utils/helper.d.ts +6 -0
  40. package/lib/utils/helper.js +52 -0
  41. package/lib/x-classes/x-bundle.d.ts +563 -0
  42. package/lib/x-classes/x-bundle.js +11 -0
  43. package/lib/x-classes/x-comps.d.ts +87 -0
  44. package/lib/x-classes/x-comps.js +189 -0
  45. package/lib/x-classes/x-extras.d.ts +155 -0
  46. package/lib/x-classes/x-extras.js +223 -0
  47. package/lib/x-classes/x-form-components.d.ts +75 -0
  48. package/lib/x-classes/x-form-components.js +186 -0
  49. package/lib/x-classes/x-helper-components.d.ts +63 -0
  50. package/lib/x-classes/x-helper-components.js +91 -0
  51. package/lib/x-classes/x-layout-components.d.ts +59 -0
  52. package/lib/x-classes/x-layout-components.js +113 -0
  53. package/lib/x-classes/x-menu.d.ts +23 -0
  54. package/lib/x-classes/x-menu.js +55 -0
  55. package/lib/x-classes/x-navs.d.ts +71 -0
  56. package/lib/x-classes/x-navs.js +243 -0
  57. package/lib/x-classes/x-table.d.ts +39 -0
  58. package/lib/x-classes/x-table.js +90 -0
  59. package/lib/x-classes/x-theme.d.ts +15 -0
  60. package/lib/x-classes/x-theme.js +32 -0
  61. package/lib/x-imports.d.ts +31 -0
  62. package/lib/x-imports.js +748 -0
  63. package/package.json +1 -1
@@ -1,27 +1,27 @@
1
1
  export default function main(config: {
2
- ['input']: string | string[];
3
2
  [key: string]: any;
4
- }): void;
5
- export declare function globalCSSCompiler(): void;
3
+ input: string | string[];
4
+ }): Promise<void>;
5
+ export declare function globalCSSCompiler(): Promise<void>;
6
6
  export declare function compileFile(file: string, config: any, statementMaker: {
7
- ['make']: (a: string) => string;
7
+ make: (a: string, b?: any, c?: any) => string;
8
8
  group: (a: string, b: string) => string;
9
- ['rawCSS']?: string;
10
- ['customGroupStatement']?: string;
9
+ rawCSS?: string;
10
+ customGroupStatement?: string;
11
11
  }, globalClassList: string[]): string[];
12
12
  export declare function groupStatement(name: string, classNames: string, statementMaker: {
13
- ['group']: (a: string, b: string) => string;
13
+ group: (a: string, b: string) => string;
14
14
  }): string;
15
15
  export declare function keyframesStatement(name: string, timeLine: string, statementMaker: {
16
- ['make']: (a: string, b?: string | null, c?: boolean) => string;
16
+ make: (a: string, b?: string | null, c?: boolean) => string;
17
17
  }): string;
18
- export declare function createCSSFileByFile(file: string, bool?: boolean): void;
19
- export declare function postify(file: string, plugin: any[], minify?: boolean, sort?: "mobile-first" | "desktop-first"): void;
18
+ export declare function createCSSFileByFile(file: string, bool?: boolean): Promise<void>;
19
+ export declare function postify(file: string, plugin: any[], minify?: boolean, sort?: "mobile-first" | "desktop-first"): Promise<void>;
20
20
  export declare function writeStatementToFile(file: string, content: string, from?: string): void;
21
21
  export declare function initialize(configFile: {
22
22
  [key: string]: any;
23
23
  }): void;
24
24
  export declare function watch(config: {
25
- ['input']: string | string[];
26
25
  [key: string]: any;
26
+ input: string | string[];
27
27
  }): void;
@@ -1,76 +1,102 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import extractClassNamesFromFile from "./extractClassNamesFromFile.js";
2
11
  import { compiler as statementMaker } from "../returnStatement.js";
3
- import config from '../config.js';
12
+ import config from "../config.js";
4
13
  import fs from "fs";
5
14
  import fg from "fast-glob";
6
- import path from 'path';
7
- import postcss from 'postcss';
8
- import postcssDiscardDuplicates from 'postcss-discard-duplicates';
9
- import cssnano from 'cssnano';
10
- import chokidar from 'chokidar';
11
- import sortMediaQueries from 'postcss-sort-media-queries';
12
- import { splitByCommaOutsideParens } from '../utils/helper.js';
15
+ import path from "path";
16
+ import postcss from "postcss";
17
+ import postcssDiscardDuplicates from "postcss-discard-duplicates";
18
+ import cssnano from "cssnano";
19
+ import chokidar from "chokidar";
20
+ import sortMediaQueries from "postcss-sort-media-queries";
21
+ import { splitByCommaOutsideParens } from "../utils/helper.js";
13
22
  const init = {
14
- classList: [], // hold className for MasterCSS to avoid repeating
23
+ classList: [],
15
24
  groups: [],
16
- input: '', // input glob pattern
17
- output: '', // location off output
18
- '--file': false, // if set true compileFileByFile to [filename].css
25
+ input: "",
26
+ output: "",
27
+ "--file": false,
19
28
  statementMaker,
20
29
  config,
21
- '--module': false,
22
- rawCSS: '',
30
+ "--module": false,
31
+ rawCSS: "",
23
32
  layers: [],
24
- customGroupStatement: '',
33
+ initializedLayer: false,
34
+ customGroupStatement: "",
25
35
  minify: false,
26
- globPattern: '', // Use this to check valid new created file to add to watch during watch.on
36
+ globPattern: "",
27
37
  };
28
38
  export default function main(config) {
29
- // initialize
30
- initialize(config);
31
- if (init.config.prefix)
32
- init.statementMaker.prefix = init.config.prefix;
33
- if (init.input && (init.output || init['--file'])) {
34
- const input = fg.sync(init.input, { dot: true });
35
- // console.log(input);
36
- input.forEach((file) => {
37
- createCSSFileByFile(file);
38
- });
39
- postify(init.output, [postcssDiscardDuplicates], init.minify);
40
- }
41
- else {
42
- console.error("Please Provide input, output or set '--file' to true");
43
- }
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ initialize(config);
41
+ if (init.config.prefix)
42
+ init.statementMaker.prefix = init.config.prefix;
43
+ if (init.input && (init.output || init["--file"])) {
44
+ const input = fg.sync(init.input, { dot: true });
45
+ input.forEach((file) => {
46
+ createCSSFileByFile(file, true);
47
+ });
48
+ if (init.output) {
49
+ yield globalCSSCompiler();
50
+ }
51
+ }
52
+ else {
53
+ console.error("Please Provide input, output or set '--file' to true");
54
+ }
55
+ });
44
56
  }
45
57
  export function globalCSSCompiler() {
46
- const classList = [];
47
- if (init.globPattern && init.output) {
48
- fs.truncateSync(init.output);
49
- const input = fg.sync(init.globPattern, { dot: true });
50
- // console.log(input);
51
- input.forEach((file) => {
52
- const [gbContent,] = compileFile(file, config, statementMaker, classList);
53
- try {
54
- fs.writeFileSync(init.output, `@layer ${init.layers.join(', ')};
55
- \n/* Start :-----------ACSS ${path.relative('.', file)}------------------------*/\n${gbContent}
56
- \n/* End :-----------ACSS ${path.relative('.', file)}----------------------------*/\n
57
- `, { flag: 'a+' });
58
- console.log('AliasCSS compiled', path.relative('.', file), 'to main css file :' + init.output);
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const classList = [];
60
+ if (init.globPattern && init.output) {
61
+ fs.truncateSync(init.output);
62
+ let basePreamble = "";
63
+ // 1. Layer declaration
64
+ if (Array.isArray(init.layers) && init.layers.length > 0) {
65
+ basePreamble += `@layer ${init.layers.join(", ")};\n\n`;
66
+ init.initializedLayer = true;
59
67
  }
60
- catch (error) {
61
- console.log('\x1b[31m', "Couldn't able to append/create to main css file :" + init.output);
62
- console.log(error);
68
+ // 2. Custom CSS statements & group statements
69
+ if (init.rawCSS) {
70
+ basePreamble += `/* Start :-----------ACSS:From aliasCSSConfig.statement------------------------*/\n${init.rawCSS}\n/* End :-----------ACSS aliasCSSConfig.statement----------------------------*/\n\n`;
63
71
  }
64
- });
65
- postify(init.output, [postcssDiscardDuplicates], init.minify);
66
- }
67
- else {
68
- console.error("Please Provide input, output or set '--file' to true");
69
- }
72
+ if (init.customGroupStatement) {
73
+ basePreamble += `/* Start :-----------ACSS:From aliasCSSConfig.group------------------------*/\n${init.customGroupStatement}\n/* End :-----------ACSS aliasCSSConfig.group----------------------------*/\n\n`;
74
+ }
75
+ if (basePreamble) {
76
+ fs.writeFileSync(init.output, basePreamble, { flag: "a+" });
77
+ }
78
+ // 3. Process matched files
79
+ const input = fg.sync(init.globPattern, { dot: true });
80
+ input.forEach((file) => {
81
+ const [gbContent] = compileFile(file, config, statementMaker, classList);
82
+ try {
83
+ fs.writeFileSync(init.output, `/* Start :-----------ACSS ${path.relative(".", file)}------------------------*/\n${gbContent}\n/* End :-----------ACSS ${path.relative(".", file)}----------------------------*/\n\n`, { flag: "a+" });
84
+ console.log("AliasCSS compiled", path.relative(".", file), "to main css file :" + init.output);
85
+ }
86
+ catch (error) {
87
+ console.log('\x1b[31m', "Couldn't able to append/create to main css file :" + init.output);
88
+ console.log(error);
89
+ }
90
+ });
91
+ yield postify(init.output, [postcssDiscardDuplicates], init.minify);
92
+ }
93
+ else {
94
+ console.error("Please Provide input, output or set '--file' to true");
95
+ }
96
+ });
70
97
  }
71
98
  export function compileFile(file, config, statementMaker, globalClassList) {
72
- let [globalStatement, compiledStatement, moduleStatement] = ['', '', ''];
73
- // inject config.group and config.statement
99
+ let [globalStatement, compiledStatement, moduleStatement] = ["", "", ""];
74
100
  if (statementMaker.rawCSS) {
75
101
  compiledStatement += `/* From:aliacss.config.statement */\n${statementMaker.rawCSS}\n/* -----End:aliacss.config.statement----- */\n\n`;
76
102
  moduleStatement += `/* From:aliacss.config.statement */\n${statementMaker.rawCSS}\n/* ------End:aliacss.config.statement----- */\n\n`;
@@ -80,291 +106,200 @@ export function compileFile(file, config, statementMaker, globalClassList) {
80
106
  moduleStatement += `/* From:aliacss.config.group */\n${statementMaker.customGroupStatement}\n/* -----End:aliacss.config.group----- */\n\n`;
81
107
  }
82
108
  const [classList, groups, keyframe, rawCSSStatement] = extractClassNamesFromFile(file, config);
83
- // 1. raw-css
84
109
  if (rawCSSStatement) {
85
- globalStatement += rawCSSStatement + '\n';
86
- compiledStatement += rawCSSStatement + '\n';
110
+ globalStatement += rawCSSStatement + "\n";
111
+ compiledStatement += rawCSSStatement + "\n";
87
112
  }
88
- // 2. group
89
113
  for (const key in groups) {
90
- if (groups.hasOwnProperty(key)) {
91
- // --------------ModuleStatement
114
+ if (Object.prototype.hasOwnProperty.call(groups, key)) {
92
115
  if (/^module=/.test(key)) {
93
- const mdStatement = statementMaker.group(groups[key], key.replace(/module=/, ''));
94
- moduleStatement += mdStatement + '\n';
116
+ moduleStatement += statementMaker.group(groups[key], key.replace(/module=/, "")) + "\n";
95
117
  }
96
- // -------------EndOfModule
97
118
  else {
98
119
  const gpStatement = statementMaker.group(groups[key], key);
99
- globalStatement += gpStatement + '\n';
100
- compiledStatement += gpStatement + '\n';
120
+ globalStatement += gpStatement + "\n";
121
+ compiledStatement += gpStatement + "\n";
101
122
  }
102
123
  }
103
124
  }
104
- // 2. ClassList
105
125
  classList.forEach((e) => {
106
126
  const statement = statementMaker.make(e);
107
127
  if (statement) {
108
- console.log('\x1b[32m', statement);
109
128
  if (globalClassList.indexOf(e) === -1) {
110
- globalStatement += statement + '\n';
129
+ globalStatement += statement + "\n";
111
130
  globalClassList.push(e);
112
- // console.log(e);
113
131
  }
114
- compiledStatement += statement + '\n';
132
+ compiledStatement += statement + "\n";
115
133
  }
116
134
  });
117
- // 3. Keyframe
118
135
  for (const key in keyframe) {
119
- if (keyframe.hasOwnProperty(key)) {
136
+ if (Object.prototype.hasOwnProperty.call(keyframe, key)) {
120
137
  const kfStatement = keyframesStatement(key, keyframe[key], statementMaker);
121
- globalStatement += kfStatement + '\n';
122
- compiledStatement += kfStatement + '\n';
138
+ globalStatement += kfStatement + "\n";
139
+ compiledStatement += kfStatement + "\n";
123
140
  }
124
141
  }
125
142
  return [globalStatement, compiledStatement, moduleStatement];
126
143
  }
127
144
  export function groupStatement(name, classNames, statementMaker) {
128
- return statementMaker.group(classNames, name) + '\n';
145
+ return statementMaker.group(classNames, name) + "\n";
129
146
  }
130
147
  export function keyframesStatement(name, timeLine, statementMaker) {
131
- let kfStatement = '@keyframes ' + name + "{\n";
148
+ let kfStatement = "@keyframes " + name + "{\n";
132
149
  const returnPnV = (e) => e.map((i) => statementMaker.make(i, null, true)).join(";");
133
150
  const split = timeLine.split(/\s+/);
134
151
  split.forEach((each) => {
135
152
  try {
136
- const [at, pNv] = each.replace(/\]\[/, ']-[').replace("-", "=").split("=");
137
- // kfStatement+=` ${at.replace('@','').replace(/:/g,',').replace(/,/g,"%,").replace(/[\[|\]]/g,'')}% {${returnPnV(pNv.replace(/^\[|\]$/g,'').split(','))}}`
138
- kfStatement += ` ${at.replace('@', '').replace(/:/g, ',').replace(/,/g, "%,").replace(/[\[|\]]/g, '')}% {${returnPnV(splitByCommaOutsideParens(pNv.replace(/^\[|\]$/g, '')))}}`;
153
+ const [at, pNv] = each.replace(/\]\[/, "]-[").replace("-", "=").split("=");
154
+ kfStatement += ` ${at.replace("@", "").replace(/:/g, ",").replace(/,/g, "%,").replace(/[\[|\]]/g, "")}% {${returnPnV(splitByCommaOutsideParens(pNv.replace(/^\[|\]$/g, "")))}}`;
139
155
  }
140
156
  catch (error) {
141
- console.error('Not a valid entry for AliasCSS keyframes processor : ' + each, error);
157
+ console.error("Not a valid entry for AliasCSS keyframes processor : " + each, error);
142
158
  }
143
159
  });
144
160
  return kfStatement + "\n}\n";
145
161
  }
146
- export function createCSSFileByFile(file, bool = false) {
147
- const [gbContent, content, module] = compileFile(file, config, statementMaker, init.classList);
148
- // console.log(init.classList);
149
- // If its fileByFile
150
- if (init["--module"] && module.trim()) {
151
- try {
152
- fs.writeFileSync(file + '.module.css', module);
153
- // console.log(content);
154
- console.log('AliasCSS compiled', path.relative('.', file), 'module Locally ');
155
- }
156
- catch (error) {
157
- console.log('\x1b[31m', "Couldn't able to append/create locally from " + file);
158
- console.log(error);
159
- }
160
- }
161
- if (init["--file"]) {
162
- try {
163
- fs.writeFileSync(file + '.css', content);
164
- postify(file + '.css', [postcssDiscardDuplicates], init.minify);
165
- // console.log(content);
166
- console.log('AliasCSS compiled', path.relative('.', file), 'Locally');
167
- }
168
- catch (error) {
169
- console.log('\x1b[31m', "Couldn't able to append/create locally from " + file);
170
- console.log(error);
171
- }
172
- }
173
- // Check for Global
174
- if (!bool && init.output) {
175
- try {
176
- fs.writeFileSync(init.output, `\n/* Start :-----------ACSS ${path.relative('.', file)}------------------------*/\n${postcss([postcssDiscardDuplicates]).process(gbContent)}
177
- \n/* End :-----------ACSS ${path.relative('.', file)}----------------------------*/\n
178
- `, { flag: 'a+' });
179
- console.log('AliasCSS compiled', path.relative('.', file), 'to main css file :' + init.output);
162
+ export function createCSSFileByFile(file_1) {
163
+ return __awaiter(this, arguments, void 0, function* (file, bool = false) {
164
+ const [gbContent, content, module] = compileFile(file, config, statementMaker, init.classList);
165
+ if (init["--module"] && module.trim()) {
166
+ try {
167
+ fs.writeFileSync(file + ".module.css", module);
168
+ console.log("AliasCSS compiled", path.relative(".", file), "module Locally ");
169
+ }
170
+ catch (error) {
171
+ console.log('\x1b[31m', "Couldn't able to append/create locally from " + file);
172
+ console.log(error);
173
+ }
180
174
  }
181
- catch (error) {
182
- console.log('\x1b[31m', "Couldn't able to append/create to main css file :" + init.output);
183
- console.log(error);
175
+ if (init["--file"]) {
176
+ try {
177
+ fs.writeFileSync(file + ".css", content);
178
+ yield postify(file + ".css", [postcssDiscardDuplicates], init.minify);
179
+ console.log("AliasCSS compiled", path.relative(".", file), "Locally");
180
+ }
181
+ catch (error) {
182
+ console.log('\x1b[31m', "Couldn't able to append/create locally from " + file);
183
+ console.log(error);
184
+ }
184
185
  }
185
- }
186
+ });
186
187
  }
187
- export function postify(file, plugin, minify = false, sort = "mobile-first") {
188
- const data = fs.readFileSync(file, 'utf-8');
189
- plugin.push(sortMediaQueries({
190
- sort
191
- }));
192
- if (fs.existsSync(file)) {
193
- if (minify === true)
194
- plugin.push(cssnano);
195
- postcss(plugin).process(data, { from: undefined }).then(result => {
196
- fs.truncateSync(file);
197
- fs.writeFileSync(file, result.css);
198
- });
199
- }
200
- // fs.readFile(file, (err, css) => {
201
- // postcss(plugin)
202
- // .process(css, { from: file, to: file+"post.css" })
203
- // .then(result => {
204
- // fs.writeFile(file+"post.css", result.css, () => true)
205
- // // if ( result.map ) {
206
- // // fs.writeFile(file+'.map', result.map.toString(), () => true)
207
- // // }
208
- // })
209
- // })
188
+ export function postify(file_1, plugin_1) {
189
+ return __awaiter(this, arguments, void 0, function* (file, plugin, minify = false, sort = "mobile-first") {
190
+ if (!fs.existsSync(file))
191
+ return;
192
+ const data = fs.readFileSync(file, "utf-8");
193
+ const plugins = [...plugin, sortMediaQueries({ sort })];
194
+ if (minify)
195
+ plugins.push(cssnano);
196
+ const result = yield postcss(plugins).process(data, { from: undefined });
197
+ fs.writeFileSync(file, result.css);
198
+ });
210
199
  }
211
200
  export function writeStatementToFile(file, content, from) {
212
- // Check for Global
213
201
  if (init.output) {
214
202
  try {
215
- fs.writeFileSync(init.output, `\n/* Start :-----------ACSS:From aliasCSSConfig.${from}------------------------*/\n${content}
216
- \n/* End :-----------ACSS aliasCSSConfig.${from}----------------------------*/\n
217
- `, { flag: 'a+' });
218
- console.log('AliasCSS compiled', '[aliasCSSConfig.statement]', 'aliascss.config.js');
203
+ fs.writeFileSync(init.output, `\n/* Start :-----------ACSS:From aliasCSSConfig.${from}------------------------*/\n${content}\n/* End :-----------ACSS aliasCSSConfig.${from}----------------------------*/\n`, { flag: "a+" });
204
+ console.log("AliasCSS compiled", `[aliasCSSConfig.${from}]`, "aliascss.config.js");
219
205
  }
220
206
  catch (error) {
221
- console.log('\x1b[31m', "Couldn't able to append/create [key:statement] from alias.config.js ");
207
+ console.log('\x1b[31m', `Couldn't able to append/create [key:${from}] from alias.config.js`);
222
208
  console.log(error);
223
209
  }
224
210
  }
225
211
  }
226
- // Initialize
227
212
  export function initialize(configFile) {
228
- // ----------------input-------------------
229
- if (configFile.hasOwnProperty('input')) {
213
+ if (configFile.hasOwnProperty("input")) {
230
214
  init.input = configFile.input;
231
215
  init.globPattern = configFile.input;
232
216
  }
233
- // ----------------input-------------------
234
- if (configFile.hasOwnProperty('layers') && Array.isArray(configFile.layers)) {
217
+ if (configFile.hasOwnProperty("layers") && Array.isArray(configFile.layers)) {
235
218
  init.layers = configFile.layers;
236
219
  }
237
220
  else {
238
221
  init.layers = config.layers;
239
222
  }
240
- // ----------------Prefix-------------------
241
- if (configFile.hasOwnProperty('prefix')) {
223
+ if (configFile.hasOwnProperty("prefix")) {
242
224
  init.config.prefix = configFile.prefix;
243
225
  }
244
- // ----------------output-------------------
245
- if (configFile.hasOwnProperty('output')) {
226
+ if (configFile.hasOwnProperty("output")) {
246
227
  const op = configFile.output;
247
- if (op.hasOwnProperty('location')) {
228
+ if (op.hasOwnProperty("location"))
248
229
  init.output = op.location;
249
- }
250
- if (op.hasOwnProperty('--file') && op['--file'] === true) {
230
+ if (op.hasOwnProperty("--file") && op["--file"] === true)
251
231
  init["--file"] = true;
252
- }
253
232
  }
254
- // Adding Custom color, length etc
255
- if (configFile.hasOwnProperty('custom') && typeof configFile.custom === 'object') {
233
+ if (configFile.hasOwnProperty("custom") && typeof configFile.custom === "object") {
256
234
  Object.keys(configFile.custom).forEach((key) => {
257
235
  init.statementMaker.addCustom(key, configFile.custom[key]);
258
236
  });
259
237
  }
260
- // Extend custom class name define {'border-color-native":'border-color: skyBlue',}
261
- if (configFile.hasOwnProperty('prebuild')) {
238
+ if (configFile.hasOwnProperty("prebuild")) {
262
239
  init.statementMaker.prebuild(configFile.prebuild);
263
240
  }
264
- // Ignore these class name
265
- if (configFile.hasOwnProperty('ignore')) {
266
- if (Array.isArray(configFile.ignore)) {
267
- configFile.ignore.forEach((each) => init.config.ignore.push(each.trim()));
268
- }
241
+ if (configFile.hasOwnProperty("ignore") && Array.isArray(configFile.ignore)) {
242
+ configFile.ignore.forEach((each) => init.config.ignore.push(each.trim()));
269
243
  }
270
- // --module
271
- if (configFile.hasOwnProperty('--module') && configFile.hasOwnProperty('importModuleAs')) {
244
+ if (configFile.hasOwnProperty("--module") && configFile.hasOwnProperty("importModuleAs")) {
272
245
  init["--module"] = true;
273
- init.config.useCSSModule = init["--module"] ? true : false;
274
- if (init.config.useCSSModule)
275
- init.config.matchCSSModuleFunction = init.config.createCSSModuleRegex(configFile.importModuleAs);
246
+ init.config.useCSSModule = true;
247
+ init.config.matchCSSModuleFunction = init.config.createCSSModuleRegex(configFile.importModuleAs);
276
248
  }
277
- // ---------output Minify
278
- if (configFile.hasOwnProperty('minify')) {
249
+ if (configFile.hasOwnProperty("minify")) {
279
250
  init.minify = configFile.minify;
280
251
  }
281
- // ------------Extractor function-------
282
- if (configFile.hasOwnProperty('extractorFunction')) {
252
+ if (configFile.hasOwnProperty("extractorFunction")) {
283
253
  init.config.useExtractorFunction = configFile.extractorFunction.trim() ? true : false;
284
254
  if (init.config.useExtractorFunction)
285
255
  init.config.matchExtractorFunction = init.config.createExtractorRegex(configFile.extractorFunction);
286
256
  }
287
257
  else {
288
258
  init.config.useExtractorFunction = true;
289
- init.config.matchExtractorFunction = init.config.createExtractorRegex('String');
259
+ init.config.matchExtractorFunction = init.config.createExtractorRegex("String");
290
260
  }
291
- // ---------Extend----------------
292
- if (configFile.hasOwnProperty('extend') && typeof configFile.extend === 'object') {
293
- const filteredObj = {};
294
- Object.keys(configFile.extend).map((key) => {
295
- // if (configFile.extend[key].hasOwnProperty('compiler') && (typeof configFile.extend[key].compiler === 'function')){
296
- filteredObj[key] = configFile.extend[key];
297
- // }
298
- });
299
- init.statementMaker.extend(filteredObj);
261
+ if (configFile.hasOwnProperty("extend") && typeof configFile.extend === "object") {
262
+ init.statementMaker.extend(configFile.extend);
300
263
  }
301
- // -----------------useColon----------------------------
302
- if (configFile.hasOwnProperty('useColon')) {
264
+ if (configFile.hasOwnProperty("useColon")) {
303
265
  init.config.useColon = configFile.useColon;
304
266
  }
305
- // ---------------addMedia----------------
306
- if (configFile.hasOwnProperty('media') && typeof configFile.media === 'object') {
267
+ if (configFile.hasOwnProperty("media") && typeof configFile.media === "object") {
307
268
  init.statementMaker.addMedia(configFile.media);
308
269
  }
309
- // /Truncate File every time we bundle
310
- if (configFile.hasOwnProperty('truncate') && configFile.truncate === false) {
311
- // do nothing
312
- }
313
- else {
314
- if (fs.existsSync(init.output))
315
- fs.truncateSync(path.resolve(init.output));
316
- writeStatementToFile(init.output, `@layer ${init.layers.join(', ')};`, 'Initializating @layer,');
317
- }
318
- // Custom CSS statement
319
- if (configFile.hasOwnProperty('statement')) {
270
+ if (configFile.hasOwnProperty("statement")) {
320
271
  init.rawCSS = configFile.statement;
321
272
  init.statementMaker.rawCSS = configFile.statement;
322
- writeStatementToFile(init.output, configFile.statement, 'config.statement');
323
273
  }
324
- // Custom Groups bundling acss classnames in single class name
325
- if (configFile.hasOwnProperty('group')) {
274
+ if (configFile.hasOwnProperty("group")) {
326
275
  init.customGroupStatement = init.statementMaker.groupObj(configFile.group);
327
276
  init.statementMaker.customGroupStatement = init.statementMaker.groupObj(configFile.group);
328
- if (init.customGroupStatement)
329
- writeStatementToFile(init.output, init.customGroupStatement, 'config.group');
330
277
  }
331
278
  }
332
- // ----------------WATCH-------------------------------
333
279
  export function watch(config) {
334
280
  main(config);
335
281
  const watcher = chokidar.watch(init.input, {
336
- ignored: '*.css', // ignore dot-files
337
- persistent: true
282
+ ignored: "*.css",
283
+ persistent: true,
338
284
  });
339
- const compileFile = (file) => {
285
+ const compileFile = (file) => __awaiter(this, void 0, void 0, function* () {
340
286
  console.log(`--processing file : ${file}`);
341
- createCSSFileByFile(file, true);
342
- globalCSSCompiler();
343
- postify(init.output, [postcssDiscardDuplicates], init.minify);
344
- console.log('Done! ');
345
- };
346
- // Something to use when events are received.
287
+ yield createCSSFileByFile(file, true);
288
+ yield globalCSSCompiler();
289
+ console.log("Done! ");
290
+ });
347
291
  const log = console.log.bind(console);
348
- // Add event listeners.
349
292
  watcher
350
- .on('add', path => log(`File ${path} has been added to watch`))
351
- .on('change', path => compileFile(path));
352
- // .on('unlink', path => log(`File ${path} has been removed`));
353
- // More possible events.
354
- watcher
355
- .on('addDir', path => log(`Directory ${path} has been added`))
356
- .on('unlinkDir', path => log(`Directory ${path} has been removed`))
357
- // .on('error', error => log(`Watcher error: ${error}`))
358
- // .on('ready', () => log('Initial scan complete. Ready for changes'))
359
- .on('raw', (event, path, details) => {
360
- // log('Raw event info:', event, path, details);
361
- if (event === 'created' && details.type === 'file') {
293
+ .on("add", (path) => log(`File ${path} has been added to watch`))
294
+ .on("change", (path) => compileFile(path))
295
+ .on("addDir", (path) => log(`Directory ${path} has been added`))
296
+ .on("unlinkDir", (path) => log(`Directory ${path} has been removed`))
297
+ .on("raw", (event, path, details) => {
298
+ if (event === "created" && details.type === "file") {
362
299
  if (init.globPattern) {
363
300
  const files = fg.sync(init.globPattern, { absolute: true });
364
- if (files.indexOf(path) !== -1) {
301
+ if (files.indexOf(path) !== -1)
365
302
  watcher.add(path);
366
- // console.log(path,123123);
367
- }
368
303
  }
369
304
  else {
370
305
  watcher.add(path);