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
@@ -0,0 +1,35 @@
1
+ type Property = {
2
+ alias?: string;
3
+ property?: string;
4
+ type?: string;
5
+ values?: string[];
6
+ compiler?: (a: string, b: {
7
+ [key: string]: {
8
+ [key: string]: string;
9
+ };
10
+ }) => any;
11
+ };
12
+ declare const _default: (key: string, compiler: Property) => ({
13
+ [key: string]: Property;
14
+ } | {
15
+ [key: string]: string;
16
+ })[];
17
+ export default _default;
18
+ export declare function staticValueCompiler(property: string, alias: string | boolean | undefined, values: string[]): {
19
+ [key: string]: string;
20
+ };
21
+ export declare function extractProperty(className: string, data: {
22
+ [key: string]: Property;
23
+ }): ({} | null)[];
24
+ export declare function generateStaticClassNames(data: {
25
+ [key: string]: Property;
26
+ }, global?: string[]): {
27
+ [key: string]: string;
28
+ };
29
+ export declare function createCompilerObj(obj: {
30
+ [key: string]: Property;
31
+ }, globalValue?: string[]): [{
32
+ [key: string]: string;
33
+ }, {
34
+ [key: string]: Property;
35
+ }];
@@ -0,0 +1,97 @@
1
+ export default (key, compiler) => {
2
+ var _a;
3
+ const dynamicCompilerObj = {};
4
+ let staticCompilerObj = {};
5
+ const property = compiler.property || key;
6
+ const alias = compiler.alias || false;
7
+ // Generate Static ClassNames
8
+ if ((_a = compiler.values) === null || _a === void 0 ? void 0 : _a.length) {
9
+ staticCompilerObj = Object.assign(Object.assign({}, staticValueCompiler(property, alias, compiler.values)), staticCompilerObj);
10
+ }
11
+ // Make Dynamic Class Compiler
12
+ if (compiler.compiler && typeof compiler.compiler === 'function') {
13
+ if (property)
14
+ dynamicCompilerObj[key] = { property, compiler: compiler.compiler };
15
+ if (alias)
16
+ dynamicCompilerObj[alias] = { property, compiler: compiler.compiler };
17
+ }
18
+ return [dynamicCompilerObj, staticCompilerObj];
19
+ };
20
+ export function staticValueCompiler(property, alias = false, values) {
21
+ const result = {};
22
+ if (values.length) {
23
+ values.forEach((value) => {
24
+ const val = value.split(':')[0];
25
+ value.split(':').forEach((each) => {
26
+ result[`${property}-${each}`] = `${property}:${val}`;
27
+ if (alias)
28
+ result[`${alias}-${each}`] = `${property}:${val}`;
29
+ });
30
+ });
31
+ }
32
+ return result;
33
+ }
34
+ export function extractProperty(className, data) {
35
+ // we just need parts before '--' or __ as they can't be in property is any;
36
+ const splittedClassName = className.split('--')[0];
37
+ const extractPossiblePropertyPortion = splittedClassName.match(/^[a-z-]+/);
38
+ // Not a valid Aliascss class name
39
+ if (!extractPossiblePropertyPortion)
40
+ return [null, null];
41
+ let propertyPortion = extractPossiblePropertyPortion[0]
42
+ .replace(/-$/, '') // remove last "-"
43
+ .trim();
44
+ let propertyHolder = null;
45
+ // try to match whole portion with property alias
46
+ // From higher to lower i.e border-right-color.......border-right.....border
47
+ if (data.hasOwnProperty(propertyPortion)) {
48
+ propertyHolder = data[propertyPortion];
49
+ // console.log(className,0);
50
+ }
51
+ else {
52
+ // remove last -[a-z]+ and try again un till ^[a-z]+ means we are at begin ing
53
+ while (/[-][a-z]+$/.test(propertyPortion)) {
54
+ propertyPortion = propertyPortion.replace(/[-][a-z]+$/, '');
55
+ if (data.hasOwnProperty(propertyPortion)) {
56
+ propertyHolder = data[propertyPortion];
57
+ break;
58
+ }
59
+ }
60
+ }
61
+ return [propertyHolder, propertyPortion];
62
+ }
63
+ ;
64
+ export function generateStaticClassNames(data, global = []) {
65
+ let staticClassNames = {};
66
+ Object.keys(data).map((key) => {
67
+ const [property, alias, values] = [(data[key].property || key), (data[key].property ? key : (data[key].alias || false)), [...(data[key].values || []), ...global]
68
+ ];
69
+ staticClassNames = Object.assign(Object.assign({}, staticValueCompiler(property, alias, values)), staticClassNames);
70
+ });
71
+ return staticClassNames;
72
+ }
73
+ ;
74
+ // takes compiler as arguments and return compiler obj with alias and staticClassNames with Alias
75
+ export function createCompilerObj(obj, globalValue = []) {
76
+ const [staticClassNames, compilerObj] = [{}, {}];
77
+ Object.keys(obj).map((key) => {
78
+ var _a, _b;
79
+ // createStaticClassNames from Obj
80
+ const [property, alias, values] = [(obj[key].property || key), (obj[key].property ? key : (obj[key].alias || false)), [...(obj[key].values || []), ...globalValue]
81
+ ];
82
+ for (const [key, value] of Object.entries(staticValueCompiler(property, alias, values))) {
83
+ staticClassNames[key] = value;
84
+ }
85
+ // staticClassNames={...staticValueCompiler(property,alias,values),...staticClassNames}
86
+ // Dynamic compiler generator for css-Props and Alias
87
+ compilerObj[key] = obj[key];
88
+ if ((_a = obj[key].alias) === null || _a === void 0 ? void 0 : _a.trim()) {
89
+ const alias = ((_b = obj[key].alias) === null || _b === void 0 ? void 0 : _b.trim()) || null;
90
+ if (alias) {
91
+ compilerObj[alias] = obj[key];
92
+ compilerObj[alias].property = key;
93
+ }
94
+ }
95
+ });
96
+ return [staticClassNames, compilerObj];
97
+ }
@@ -0,0 +1 @@
1
+ export declare function repeat(data: string): string;
@@ -0,0 +1,27 @@
1
+ // GTC GTR GT left no grid
2
+ export function repeat(data) {
3
+ var _a;
4
+ data = data.replace(/repeat/g, '===');
5
+ const matchRegex = /===-([\d]+|auto-fill|auto-fit)-([a-z0-9-]+)/;
6
+ while (data.match(matchRegex)) {
7
+ const m = (_a = data.match(matchRegex)) === null || _a === void 0 ? void 0 : _a[0].replace(/===/, ' ');
8
+ const match = (m === null || m === void 0 ? void 0 : m.match(/-([\d]+|auto-fill|auto-fit)-([a-z0-9-]+)/)) || ['', '', ''];
9
+ data = data.replace(matchRegex, `repeat(${match[1]}, ${match[2].replace(/[-]?(minmax)-(min-content|max-content|auto|\w+)-(min-content|max-content|auto|\w+)/g, " $1($2 , $3 ) ")
10
+ .replace(/[-]?(fit-content)[-]([\w]+)/g, "$1( $2 ) ")
11
+ .replace(/([\d])d([\d])/g, '$1.$2')
12
+ .replace(/-([\d|a|a])/g, ' $1')
13
+ .replace(/([\d])p([\s])/g, "$1% ").replace(/p$/, "%").replace(/-by[-\s]/g, ' / ')})`);
14
+ }
15
+ // const match=data.match(/-([\d]+|auto-fill|auto-fit)-([a-z0-9-]+)(.*)/)||['','',''];
16
+ // return `repeat(${match[1]}, ${match[2].replace(/[-]?(minmax)-(min-content|max-content|auto|\w+)-(min-content|max-content|auto|\w+)/g," $1($2 , $3 ) ")
17
+ // .replace(/[-]?(fit-content)[-]([\w]+)/g, "$1( $2 ) ")
18
+ // .replace(/([\d])d([\d])/g,'$1.$2')
19
+ // .replace(/-([\d|a|a])/g,' $1')
20
+ // .replace(/([\d])p([\s])/g,"$1% ").replace(/p$/,"%").replace(/-by[-\s]/g,' / ')})`
21
+ // repeat-4-auto-fill-20px-30px-min-max content
22
+ return data.replace(/[-]?(minmax)-(min-content|max-content|auto|\w+)-(min-content|max-content|auto|\w+)/g, " $1($2 , $3 ) ")
23
+ .replace(/[-]?(fit-content)[-]([\w]+)/g, "$1( $2 ) ")
24
+ .replace(/([\d])d([\d])/g, '$1.$2')
25
+ .replace(/-([\d|a|a|m|r])/g, ' $1').replace(/-[)]r/g, ') r')
26
+ .replace(/([\d])p([\s])/g, "$1% ").replace(/p$/, "%").replace(/-by[-\s]/g, ' / ').replace(/_(\d)/g, ' $1');
27
+ }
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "aliascss",
3
+ "version": "1.1.0",
4
+ "description": "AliasCSS is a CSS post processor.",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "bin": "bin/aliascss.js",
8
+ "type": "module",
9
+ "typings": "dist/index.d.ts",
10
+ "scripts": {
11
+ "test": "jest --config jestconfig.json",
12
+ "build": "tsc",
13
+ "wp": "webpack",
14
+ "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
15
+ "lint": "tslint -p tsconfig.json",
16
+ "prepare": "npm run build",
17
+ "prepublishOnly": "npm test && npm run lint",
18
+ "preversion": "npm run lint",
19
+ "version": "npm run format && git add -A src",
20
+ "postversion": "git push && git push --tags"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/Rodolopho/acss-lite.git"
25
+ },
26
+ "devDependencies": {
27
+ "@types/jest": "^29.5.3",
28
+ "@types/postcss-sorting": "^8.0.2",
29
+ "jest": "^29.6.2",
30
+ "jest-ts-webcompat-resolver": "^1.0.0",
31
+ "ts-jest": "^29.1.1",
32
+ "ts-node": "^10.9.2",
33
+ "tslint": "^6.1.3",
34
+ "tslint-config-prettier": "^1.18.0",
35
+ "webpack": "^5.88.2",
36
+ "webpack-cli": "^5.1.4"
37
+ },
38
+ "keywords": [
39
+ "CSS",
40
+ "Post",
41
+ "processor",
42
+ "AliasCSS",
43
+ "ACSS",
44
+ "ACSS-lite",
45
+ "UI",
46
+ "Design",
47
+ "css"
48
+ ],
49
+ "author": "Bikram Thapa",
50
+ "license": "MIT",
51
+ "bugs": {
52
+ "url": "https://github.com/Rodolopho/acss-lite/issues"
53
+ },
54
+ "dependencies": {
55
+ "chokidar": "^3.6.0",
56
+ "cssnano": "^7.0.4",
57
+ "fast-glob": "^3.3.1",
58
+ "postcss": "^8.4.39",
59
+ "postcss-discard-duplicates": "^7.0.0",
60
+ "postcss-sort-media-queries": "^5.2.0",
61
+ "postcss-sorting": "^8.0.2"
62
+ },
63
+ "homepage": "https://github.com/Rodolopho/acss-lite#readme"
64
+ }
package/ts.js ADDED
@@ -0,0 +1,5 @@
1
+ import main ,{ watch} from './lib/node/compileFile.js'
2
+ import path from 'path'
3
+ let config=await import(path.resolve('aliascss.config.js'))
4
+ console.log(config.default.input);
5
+ // watch({input:['./demo/**/*.html'],output:{location:'./demo/acss.css','--file':true}});
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es6",
4
+ "module": "nodenext",
5
+ "declaration": true,
6
+ "outDir": "./lib",
7
+ "esModuleInterop": true,
8
+ "strict": true
9
+ },
10
+ "include": ["src", "test.js", "bin"],
11
+ "exclude": ["node_modules", "**/__tests__/*"],
12
+ "esModuleInterop" : true
13
+ }
14
+
package/tslint.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": ["tslint:recommended", "tslint-config-prettier"],
3
+
4
+ "rules": {
5
+ "no-console": false,
6
+ "no-shadowed-variable":false
7
+ }
8
+
9
+ }
@@ -0,0 +1,11 @@
1
+ // const path = require('path');
2
+ import path from 'path';
3
+
4
+ export default {
5
+ entry: './lib/build/index.js',
6
+ output: {
7
+ filename: 'aliascss.js',
8
+ path: path.resolve('dist'),
9
+ },
10
+ mode:'production',
11
+ };