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.
- package/aliascss.config.js +32 -32
- package/dist/aliascss.js +1 -1
- package/lib/compilers/color.js +5 -5
- package/lib/compilers/gradient.js +3 -3
- package/lib/compilers/stringAndContent.js +2 -1
- package/lib/component-elements.d.ts +155 -0
- package/lib/component-elements.js +223 -0
- package/lib/config.d.ts +1 -0
- package/lib/config.js +2 -1
- package/lib/css-properties-all.js +337 -202
- package/lib/custom-css-compilers.js +54 -54
- package/lib/extras-elements.d.ts +87 -0
- package/lib/extras-elements.js +184 -0
- package/lib/form-elements.d.ts +75 -0
- package/lib/form-elements.js +186 -0
- package/lib/layout-elements.d.ts +59 -0
- package/lib/layout-elements.js +113 -0
- package/lib/nav-elements.d.ts +71 -0
- package/lib/nav-elements.js +243 -0
- package/lib/node/compileFile-bk.d.ts +27 -0
- package/lib/node/compileFile-bk.js +379 -0
- package/lib/node/compileFile.d.ts +11 -11
- package/lib/node/compileFile.js +170 -235
- package/lib/prebuild.d.ts +520 -12
- package/lib/prebuild.js +9 -852
- package/lib/prefix/PseudoPrefixNew.js +301 -16
- package/lib/prefix/attribute-selector.js +4 -2
- package/lib/prefix/pseudoSelectorNew.js +184 -49
- package/lib/prefix/responsive.d.ts +13 -9
- package/lib/prefix/responsive.js +131 -9
- package/lib/returnPropertyAndValue.js +9 -4
- package/lib/returnStatement-bk.d.ts +5 -0
- package/lib/returnStatement-bk.js +311 -0
- package/lib/returnStatement.js +165 -2
- package/lib/static/customStaticClassNames.js +35 -35
- package/lib/static/staticClassNamesAlias.js +18 -16
- package/lib/table-elements.d.ts +39 -0
- package/lib/table-elements.js +90 -0
- package/lib/utils/helper.d.ts +6 -0
- package/lib/utils/helper.js +52 -0
- package/lib/x-classes/x-bundle.d.ts +563 -0
- package/lib/x-classes/x-bundle.js +11 -0
- package/lib/x-classes/x-comps.d.ts +87 -0
- package/lib/x-classes/x-comps.js +189 -0
- package/lib/x-classes/x-extras.d.ts +155 -0
- package/lib/x-classes/x-extras.js +223 -0
- package/lib/x-classes/x-form-components.d.ts +75 -0
- package/lib/x-classes/x-form-components.js +186 -0
- package/lib/x-classes/x-helper-components.d.ts +63 -0
- package/lib/x-classes/x-helper-components.js +91 -0
- package/lib/x-classes/x-layout-components.d.ts +59 -0
- package/lib/x-classes/x-layout-components.js +113 -0
- package/lib/x-classes/x-menu.d.ts +23 -0
- package/lib/x-classes/x-menu.js +55 -0
- package/lib/x-classes/x-navs.d.ts +71 -0
- package/lib/x-classes/x-navs.js +243 -0
- package/lib/x-classes/x-table.d.ts +39 -0
- package/lib/x-classes/x-table.js +90 -0
- package/lib/x-classes/x-theme.d.ts +15 -0
- package/lib/x-classes/x-theme.js +32 -0
- package/lib/x-imports.d.ts +31 -0
- package/lib/x-imports.js +748 -0
- 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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
7
|
+
make: (a: string, b?: any, c?: any) => string;
|
|
8
8
|
group: (a: string, b: string) => string;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
rawCSS?: string;
|
|
10
|
+
customGroupStatement?: string;
|
|
11
11
|
}, globalClassList: string[]): string[];
|
|
12
12
|
export declare function groupStatement(name: string, classNames: string, statementMaker: {
|
|
13
|
-
|
|
13
|
+
group: (a: string, b: string) => string;
|
|
14
14
|
}): string;
|
|
15
15
|
export declare function keyframesStatement(name: string, timeLine: string, statementMaker: {
|
|
16
|
-
|
|
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;
|
package/lib/node/compileFile.js
CHANGED
|
@@ -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
|
|
12
|
+
import config from "../config.js";
|
|
4
13
|
import fs from "fs";
|
|
5
14
|
import fg from "fast-glob";
|
|
6
|
-
import path from
|
|
7
|
-
import postcss from
|
|
8
|
-
import postcssDiscardDuplicates from
|
|
9
|
-
import cssnano from
|
|
10
|
-
import chokidar from
|
|
11
|
-
import sortMediaQueries from
|
|
12
|
-
import { splitByCommaOutsideParens } from
|
|
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: [],
|
|
23
|
+
classList: [],
|
|
15
24
|
groups: [],
|
|
16
|
-
input:
|
|
17
|
-
output:
|
|
18
|
-
|
|
25
|
+
input: "",
|
|
26
|
+
output: "",
|
|
27
|
+
"--file": false,
|
|
19
28
|
statementMaker,
|
|
20
29
|
config,
|
|
21
|
-
|
|
22
|
-
rawCSS:
|
|
30
|
+
"--module": false,
|
|
31
|
+
rawCSS: "",
|
|
23
32
|
layers: [],
|
|
24
|
-
|
|
33
|
+
initializedLayer: false,
|
|
34
|
+
customGroupStatement: "",
|
|
25
35
|
minify: false,
|
|
26
|
-
globPattern:
|
|
36
|
+
globPattern: "",
|
|
27
37
|
};
|
|
28
38
|
export default function main(config) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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 +
|
|
86
|
-
compiledStatement += rawCSSStatement +
|
|
110
|
+
globalStatement += rawCSSStatement + "\n";
|
|
111
|
+
compiledStatement += rawCSSStatement + "\n";
|
|
87
112
|
}
|
|
88
|
-
// 2. group
|
|
89
113
|
for (const key in groups) {
|
|
90
|
-
if (
|
|
91
|
-
// --------------ModuleStatement
|
|
114
|
+
if (Object.prototype.hasOwnProperty.call(groups, key)) {
|
|
92
115
|
if (/^module=/.test(key)) {
|
|
93
|
-
|
|
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 +
|
|
100
|
-
compiledStatement += gpStatement +
|
|
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 +
|
|
129
|
+
globalStatement += statement + "\n";
|
|
111
130
|
globalClassList.push(e);
|
|
112
|
-
// console.log(e);
|
|
113
131
|
}
|
|
114
|
-
compiledStatement += statement +
|
|
132
|
+
compiledStatement += statement + "\n";
|
|
115
133
|
}
|
|
116
134
|
});
|
|
117
|
-
// 3. Keyframe
|
|
118
135
|
for (const key in keyframe) {
|
|
119
|
-
if (
|
|
136
|
+
if (Object.prototype.hasOwnProperty.call(keyframe, key)) {
|
|
120
137
|
const kfStatement = keyframesStatement(key, keyframe[key], statementMaker);
|
|
121
|
-
globalStatement += kfStatement +
|
|
122
|
-
compiledStatement += kfStatement +
|
|
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) +
|
|
145
|
+
return statementMaker.group(classNames, name) + "\n";
|
|
129
146
|
}
|
|
130
147
|
export function keyframesStatement(name, timeLine, statementMaker) {
|
|
131
|
-
let kfStatement =
|
|
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(/\]\[/,
|
|
137
|
-
|
|
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(
|
|
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(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (minify
|
|
194
|
-
|
|
195
|
-
postcss(
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
241
|
-
if (configFile.hasOwnProperty('prefix')) {
|
|
223
|
+
if (configFile.hasOwnProperty("prefix")) {
|
|
242
224
|
init.config.prefix = configFile.prefix;
|
|
243
225
|
}
|
|
244
|
-
|
|
245
|
-
if (configFile.hasOwnProperty('output')) {
|
|
226
|
+
if (configFile.hasOwnProperty("output")) {
|
|
246
227
|
const op = configFile.output;
|
|
247
|
-
if (op.hasOwnProperty(
|
|
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
|
-
|
|
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
|
-
|
|
261
|
-
if (configFile.hasOwnProperty('prebuild')) {
|
|
238
|
+
if (configFile.hasOwnProperty("prebuild")) {
|
|
262
239
|
init.statementMaker.prebuild(configFile.prebuild);
|
|
263
240
|
}
|
|
264
|
-
|
|
265
|
-
|
|
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
|
-
|
|
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 =
|
|
274
|
-
|
|
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
|
-
|
|
278
|
-
if (configFile.hasOwnProperty('minify')) {
|
|
249
|
+
if (configFile.hasOwnProperty("minify")) {
|
|
279
250
|
init.minify = configFile.minify;
|
|
280
251
|
}
|
|
281
|
-
|
|
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(
|
|
259
|
+
init.config.matchExtractorFunction = init.config.createExtractorRegex("String");
|
|
290
260
|
}
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
|
|
302
|
-
if (configFile.hasOwnProperty('useColon')) {
|
|
264
|
+
if (configFile.hasOwnProperty("useColon")) {
|
|
303
265
|
init.config.useColon = configFile.useColon;
|
|
304
266
|
}
|
|
305
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
344
|
-
|
|
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(
|
|
351
|
-
.on(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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);
|