aliascss 1.1.10 → 1.1.11
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 +20 -3
- package/custom-compilers.js +32 -134
- package/dist/aliascss.js +1 -1
- package/lib/compilers/length.js +1 -1
- package/lib/node/compileFile.d.ts +3 -1
- package/lib/node/compileFile.js +16 -5
- package/lib/returnStatement.js +28 -2
- package/old-custom-compilers.js +149 -0
- package/package.json +3 -2
- package/ts.js +21 -1
package/lib/compilers/length.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default function length(data) {
|
|
2
2
|
return data.replace(/[-]?fit-content-([-]?\w+)/g, ' fit-content( $1 )')
|
|
3
|
-
.replace(/[-]([-]?[0-9])/g, ' $1').replace(/([\d])d([\d])
|
|
3
|
+
.replace(/[-]([-]?[0-9])/g, ' $1').replace(/([\d])d([\d])/g, '$1.$2').replace(/-auto/g, ' auto')
|
|
4
4
|
.replace(/([\d])p[\s]/g, "$1% ").replace(/([\d])p$/, "$1%").replace(/-(f|m)/g, '$1');
|
|
5
5
|
}
|
|
6
6
|
export const lenByNumPer = (value) => value.replace(/[-]([-]?[\w])/g, ' $1').replace(/([\d])d([\d])/g, '$1.$2').replace(/([\d])p[\s]/g, "$1% ").replace(/([\d])p$/, "$1%").replace(/[\s]by[\s]/g, ' / ').replace(/auto flow/g, 'auto-flow');
|
|
@@ -6,6 +6,8 @@ export declare function globalCSSCompiler(): void;
|
|
|
6
6
|
export declare function compileFile(file: string, config: any, statementMaker: {
|
|
7
7
|
['make']: (a: string) => string;
|
|
8
8
|
group: (a: string, b: string) => string;
|
|
9
|
+
['rawCSS']?: string;
|
|
10
|
+
['customGroupStatement']?: string;
|
|
9
11
|
}, globalClassList: string[]): string[];
|
|
10
12
|
export declare function groupStatement(name: string, classNames: string, statementMaker: {
|
|
11
13
|
['group']: (a: string, b: string) => string;
|
|
@@ -15,7 +17,7 @@ export declare function keyframesStatement(name: string, timeLine: string, state
|
|
|
15
17
|
}): string;
|
|
16
18
|
export declare function createCSSFileByFile(file: string, bool?: boolean): void;
|
|
17
19
|
export declare function postify(file: string, plugin: any[], minify?: boolean): void;
|
|
18
|
-
export declare function writeStatementToFile(file: string, content: string): void;
|
|
20
|
+
export declare function writeStatementToFile(file: string, content: string, from?: string): void;
|
|
19
21
|
export declare function initialize(configFile: {
|
|
20
22
|
[key: string]: any;
|
|
21
23
|
}): void;
|
package/lib/node/compileFile.js
CHANGED
|
@@ -66,6 +66,15 @@ export function globalCSSCompiler() {
|
|
|
66
66
|
}
|
|
67
67
|
export function compileFile(file, config, statementMaker, globalClassList) {
|
|
68
68
|
let [globalStatement, compiledStatement, moduleStatement] = ['', '', ''];
|
|
69
|
+
// inject config.group and config.statement
|
|
70
|
+
if (statementMaker.rawCSS) {
|
|
71
|
+
compiledStatement += `/* From:aliacss.config.statement */\n${statementMaker.rawCSS}\n/* -----End:aliacss.config.statement----- */\n\n`;
|
|
72
|
+
moduleStatement += `/* From:aliacss.config.statement */\n${statementMaker.rawCSS}\n/* ------End:aliacss.config.statement----- */\n\n`;
|
|
73
|
+
}
|
|
74
|
+
if (statementMaker.customGroupStatement) {
|
|
75
|
+
compiledStatement += `/* From:aliacss.config.group */\n${statementMaker.customGroupStatement}\n/* -----End:aliacss.config.group----- */\n\n`;
|
|
76
|
+
moduleStatement += `/* From:aliacss.config.group */\n${statementMaker.customGroupStatement}\n/* -----End:aliacss.config.group----- */\n\n`;
|
|
77
|
+
}
|
|
69
78
|
const [classList, groups, keyframe] = extractClassNamesFromFile(file, config);
|
|
70
79
|
// 2. group
|
|
71
80
|
for (const key in groups) {
|
|
@@ -184,12 +193,12 @@ export function postify(file, plugin, minify = false) {
|
|
|
184
193
|
// })
|
|
185
194
|
// })
|
|
186
195
|
}
|
|
187
|
-
export function writeStatementToFile(file, content) {
|
|
196
|
+
export function writeStatementToFile(file, content, from) {
|
|
188
197
|
// Check for Global
|
|
189
198
|
if (init.output) {
|
|
190
199
|
try {
|
|
191
|
-
fs.writeFileSync(init.output, `\n/* Start :-----------ACSS:From aliasCSSConfig
|
|
192
|
-
\n/* End :-----------ACSS aliasCSSConfig
|
|
200
|
+
fs.writeFileSync(init.output, `\n/* Start :-----------ACSS:From aliasCSSConfig.${from}------------------------*/\n${content}
|
|
201
|
+
\n/* End :-----------ACSS aliasCSSConfig.${from}----------------------------*/\n
|
|
193
202
|
`, { flag: 'a+' });
|
|
194
203
|
console.log('AliasCSS compiled', '[aliasCSSConfig.statement]', 'aliascss.config.js');
|
|
195
204
|
}
|
|
@@ -266,13 +275,15 @@ export function initialize(configFile) {
|
|
|
266
275
|
// Custom CSS statement
|
|
267
276
|
if (configFile.hasOwnProperty('statement')) {
|
|
268
277
|
init.rawCSS = configFile.statement;
|
|
269
|
-
|
|
278
|
+
init.statementMaker.rawCSS = configFile.statement;
|
|
279
|
+
writeStatementToFile(init.output, configFile.statement, 'config.statement');
|
|
270
280
|
}
|
|
271
281
|
// Custom Groups bundling acss classnames in single class name
|
|
272
282
|
if (configFile.hasOwnProperty('group')) {
|
|
273
283
|
init.customGroupStatement = init.statementMaker.groupObj(configFile.group);
|
|
284
|
+
init.statementMaker.customGroupStatement = init.statementMaker.groupObj(configFile.group);
|
|
274
285
|
if (init.customGroupStatement)
|
|
275
|
-
writeStatementToFile(init.output, init.customGroupStatement);
|
|
286
|
+
writeStatementToFile(init.output, init.customGroupStatement, 'config.group');
|
|
276
287
|
}
|
|
277
288
|
// Adding Custom color, length etc
|
|
278
289
|
if (configFile.hasOwnProperty('custom') && typeof configFile.custom === 'object') {
|
package/lib/returnStatement.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createCompilerObj, extractProperty } from "./utils/createCompilerObj.js
|
|
|
8
8
|
import config from "./config.js";
|
|
9
9
|
import cssProps from "./css-properties-all.js";
|
|
10
10
|
import { staticClassNamesAlias } from "./static/staticClassNamesAlias.js";
|
|
11
|
+
import postcss from "postcss";
|
|
11
12
|
const [staticClassNamesWithAlias, cssPropsWithAlias] = createCompilerObj(cssProps, config.globalValues);
|
|
12
13
|
export const compiler = {
|
|
13
14
|
// cache will cache propertyAndValue
|
|
@@ -18,6 +19,8 @@ export const compiler = {
|
|
|
18
19
|
staticClassNames: Object.assign(Object.assign({}, staticClassNamesAlias), staticClassNamesWithAlias),
|
|
19
20
|
cssProps: Object.assign({}, cssPropsWithAlias),
|
|
20
21
|
prefix: null,
|
|
22
|
+
rawCSS: null,
|
|
23
|
+
customGroupStatement: null,
|
|
21
24
|
extend(data) {
|
|
22
25
|
Object.keys(data).forEach((key) => {
|
|
23
26
|
if (data[key].hasOwnProperty('extend')) {
|
|
@@ -97,16 +100,39 @@ export const compiler = {
|
|
|
97
100
|
console.log(error);
|
|
98
101
|
}
|
|
99
102
|
}
|
|
103
|
+
// if(result){
|
|
104
|
+
// className=className.replace(/([$.&%=\]\[@~:*#+\(\)\/^])/g,'\\$1');
|
|
105
|
+
// if(bool===true) return result;
|
|
106
|
+
// this.cache.propertyAndValue[pnv]=result;
|
|
107
|
+
// if(media){
|
|
108
|
+
// return `${media}{${
|
|
109
|
+
// beforeClassNameSelector+'.'+(as?as:className)+ elementAndPseudo
|
|
110
|
+
// }{${result}${important}}}`;
|
|
111
|
+
// }else{
|
|
112
|
+
// return `${beforeClassNameSelector}.${(as?as:className)}${elementAndPseudo}{${result}${important}}`;
|
|
113
|
+
// }
|
|
114
|
+
// }else{
|
|
115
|
+
// console.log(`Unable to process ${className} [media:${media},pseudoSelector:${elementAndPseudo},imp:${important}]`)
|
|
116
|
+
// }
|
|
117
|
+
// ------------PostCSSParse
|
|
100
118
|
if (result) {
|
|
119
|
+
let stm = '';
|
|
101
120
|
className = className.replace(/([$.&%=\]\[@~:*#+\(\)\/^])/g, '\\$1');
|
|
102
121
|
if (bool === true)
|
|
103
122
|
return result;
|
|
104
123
|
this.cache.propertyAndValue[pnv] = result;
|
|
105
124
|
if (media) {
|
|
106
|
-
|
|
125
|
+
stm = `${media}{${beforeClassNameSelector + '.' + (as ? as : className) + elementAndPseudo}{${result}${important}}}`;
|
|
107
126
|
}
|
|
108
127
|
else {
|
|
109
|
-
|
|
128
|
+
stm = `${beforeClassNameSelector}.${(as ? as : className)}${elementAndPseudo}{${result}${important}}`;
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
postcss.parse(stm);
|
|
132
|
+
return stm;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.log('Not a Valid CSS Statement, PostCSS Parse:', stm);
|
|
110
136
|
}
|
|
111
137
|
}
|
|
112
138
|
else {
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {getCompiler} from './lib/index.js'
|
|
2
|
+
export const compilers={
|
|
3
|
+
'import-var':{
|
|
4
|
+
type:'group',
|
|
5
|
+
groups:{
|
|
6
|
+
'spacing':`
|
|
7
|
+
--space-1:4px;
|
|
8
|
+
--space-2:8px;
|
|
9
|
+
--space-3:12px;
|
|
10
|
+
--space-4:16px;
|
|
11
|
+
--space-5:24px;
|
|
12
|
+
--space-6:32px;
|
|
13
|
+
--space-7:40px;
|
|
14
|
+
--space-8:48px;
|
|
15
|
+
--space-9:64px;
|
|
16
|
+
`,
|
|
17
|
+
theme:`
|
|
18
|
+
|
|
19
|
+
`
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
},
|
|
23
|
+
'Text':{
|
|
24
|
+
|
|
25
|
+
compiler:(value)=>{
|
|
26
|
+
let result='';
|
|
27
|
+
const match=/-([-]?[\w\.]+)/;
|
|
28
|
+
const property=['font-size','line-height','letter-spacing','font-weight'];
|
|
29
|
+
value.match(new RegExp(match,'g')).forEach((e,i)=>{
|
|
30
|
+
if(i<property.length){
|
|
31
|
+
result+=`${property[i]}:${e.replace(match,'$1').replace(/(\d)d(\d)/,'$1.$2').replace(/([\d])p([\s]|$)/,'$1%$2')};`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
})
|
|
35
|
+
return result;
|
|
36
|
+
|
|
37
|
+
},
|
|
38
|
+
groups:{
|
|
39
|
+
xs:'font-size:12px;line-height:18px;letter-spacing:0.0025em',
|
|
40
|
+
'1':'font-size:12px;letter-spacing:0.0025em;line-height:16px;',
|
|
41
|
+
'2':'font-size:14px;letter-spacing:0em;line-height:20px;',
|
|
42
|
+
'3':'font-size:16px;letter-spacing:0em;line-height:24px;',
|
|
43
|
+
'4':'font-size:18px;letter-spacing:-0.0025em;line-height:26px;',
|
|
44
|
+
'5':'font-size:20px;letter-spacing:-0.005em;line-height:28px;',
|
|
45
|
+
'6':'font-size:24px;letter-spacing:-0.00625em;line-height:30px;',
|
|
46
|
+
'7':'font-size:28px;letter-spacing:-0.0075em;line-height:36px;',
|
|
47
|
+
'8':'font-size:35px;letter-spacing:-0.01em;line-height:40px;',
|
|
48
|
+
'9':'font-size:60px;letter-spacing:-0.025em;line-height:60px;',
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
},
|
|
53
|
+
Box:{
|
|
54
|
+
compiler:(value)=>{
|
|
55
|
+
let result='';
|
|
56
|
+
const match=/-([-]?[\w\.]+)/;
|
|
57
|
+
const property=['width','height','padding'];
|
|
58
|
+
value.match(new RegExp(match,'g')).forEach((e,i)=>{
|
|
59
|
+
if(i<property.length){
|
|
60
|
+
result+=`${property[i]}:${e.replace(match,'$1').replace(/(\d)d(\d)/,'$1.$2').replace(/([\d])p([\s]|$)/,'$1%$2')};`;
|
|
61
|
+
}else{
|
|
62
|
+
|
|
63
|
+
result=result.replace(/;$/,` ${e.replace(match,'$1').replace(/(\d)d(\d)/,'$1.$2').replace(/([\d])p([\s]|$)/,'$1%$2')};`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
})
|
|
67
|
+
return result;
|
|
68
|
+
|
|
69
|
+
},
|
|
70
|
+
type:'group',
|
|
71
|
+
groups:{
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
Position:{
|
|
76
|
+
'alias':'pos',
|
|
77
|
+
compiler:(value)=>{
|
|
78
|
+
let result='';
|
|
79
|
+
const match=/-([-]?[\w\.]+)/;
|
|
80
|
+
const property=['position','top','right','bottom','left'];
|
|
81
|
+
value.match(new RegExp(match,'g')).forEach((e,i)=>{
|
|
82
|
+
if(i<property.length){
|
|
83
|
+
result+=`${property[i]}:${e.replace(match,'$1').replace(/(\d)d(\d)/,'$1.$2').replace(/([\d])p([\s]|$)/,'$1%$2')};`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
})
|
|
87
|
+
return result;
|
|
88
|
+
|
|
89
|
+
},
|
|
90
|
+
type:'group',
|
|
91
|
+
groups:{
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
Colorize:{
|
|
96
|
+
'alias':'pos',
|
|
97
|
+
compiler:(value,custom)=>{
|
|
98
|
+
let result='';
|
|
99
|
+
const match=/-([-]?[\w\.]+)/;
|
|
100
|
+
const property=['background-color','border-color','color',];
|
|
101
|
+
value.match(new RegExp(match,'g')).forEach((e,i)=>{
|
|
102
|
+
|
|
103
|
+
if(i<property.length){
|
|
104
|
+
if(e.match(/^--[a-zA-Z]/)){
|
|
105
|
+
result+=`${property[i]}:var(${e});`
|
|
106
|
+
}else{
|
|
107
|
+
result+=`${property[i]}:${getCompiler('color').compiler(e,custom)};`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
})
|
|
112
|
+
return result;
|
|
113
|
+
|
|
114
|
+
},
|
|
115
|
+
type:'group',
|
|
116
|
+
groups:{
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
Container:{
|
|
121
|
+
type:"group",
|
|
122
|
+
compiler:(value)=>value,
|
|
123
|
+
groups:{
|
|
124
|
+
'1':'display:block;margin:auto;width:var(--container-1,448px)',
|
|
125
|
+
'2':'display:block;margin:auto;width:var(--container-2,688px)',
|
|
126
|
+
'3':'display:block;margin:auto;width:var(--container-3,880px)',
|
|
127
|
+
'4':'display:block;margin:auto;width:var(--container-4,1136px)',
|
|
128
|
+
'xs':'display:block;margin:auto;width:var(--container-xs,448px)',
|
|
129
|
+
'sm':'display:block;margin:auto;width:var(--container-sm,688px)',
|
|
130
|
+
'md':'display:block;margin:auto;width:var(--container-md,880px)',
|
|
131
|
+
'lg':'display:block;margin:auto;width:var(--container-lg,1136px)',
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
Section:{
|
|
135
|
+
type:"group",
|
|
136
|
+
compiler:(value)=>value,
|
|
137
|
+
groups:{
|
|
138
|
+
'1':'display:block;padding:var(--section-padding-1,24px) auto',
|
|
139
|
+
'2':'display:block;padding:var(--section-padding-2,40px) auto',
|
|
140
|
+
'3':'display:block;padding:var(--section-padding-3,64px) auto',
|
|
141
|
+
'4':'display:block;padding:var(--section-padding-4,80px) auto',
|
|
142
|
+
'xs':'display:block;padding:var(--section-padding-xs,24px) auto',
|
|
143
|
+
'sm':'display:block;padding:var(--section-padding-sm,40px) auto',
|
|
144
|
+
'md':'display:block;padding:var(--section-padding-md,64px) auto',
|
|
145
|
+
'lg':'display:block;padding:var(--section-padding-lg,80px) auto',
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aliascss",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "AliasCSS is a CSS post processor.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -56,7 +56,8 @@
|
|
|
56
56
|
"cssnano": "^7.0.4",
|
|
57
57
|
"fast-glob": "^3.3.1",
|
|
58
58
|
"postcss": "^8.4.39",
|
|
59
|
-
"postcss-discard-duplicates": "^7.0.0"
|
|
59
|
+
"postcss-discard-duplicates": "^7.0.0",
|
|
60
|
+
"postcss-safe-parser": "^7.0.0"
|
|
60
61
|
},
|
|
61
62
|
"homepage": "https://github.com/Rodolopho/acss-lite#readme"
|
|
62
63
|
}
|
package/ts.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import main ,{ watch} from './lib/node/compileFile.js'
|
|
2
|
+
import postcss from 'postcss';
|
|
3
|
+
|
|
2
4
|
import path from 'path'
|
|
5
|
+
import safeParse from 'postcss-safe-parser';
|
|
3
6
|
let config=await import(path.resolve('aliascss.config.js'))
|
|
4
7
|
console.log(config.default.input);
|
|
5
|
-
// watch({input:['./demo/**/*.html'],output:{location:'./demo/acss.css','--file':true}});
|
|
8
|
+
// watch({input:['./demo/**/*.html'],output:{location:'./demo/acss.css','--file':true}});
|
|
9
|
+
//const safe = require('postcss-safe-parser')
|
|
10
|
+
|
|
11
|
+
const badCss = 'a {'
|
|
12
|
+
|
|
13
|
+
// postcss().process('.border{color:::red', { parser: safeParse }).then(result => {
|
|
14
|
+
// postcss().process('.border::hover{##transform:srrrr}', { }).then(result => {
|
|
15
|
+
// //result.css //= 'a {}'
|
|
16
|
+
// console.log(result.css);
|
|
17
|
+
// }).catch((e)=>{
|
|
18
|
+
// console.log('Error')
|
|
19
|
+
// })
|
|
20
|
+
|
|
21
|
+
console.log(postcss.parse(`@media (max-width : 576px){
|
|
22
|
+
.xs-bgc-red{background-color:red}
|
|
23
|
+
}`));
|
|
24
|
+
console.log(postcss.parse('.button{color:red}'));
|
|
25
|
+
console.log(postcss([]).process('.button{color:::red').css);
|