aliascss 1.5.1 → 1.5.3

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.
@@ -7,6 +7,7 @@ export let classPrinter = {
7
7
  invalidLists: new Set(), // was arrays + indexOf: O(n) per lookup
8
8
  classLists: new Set(),
9
9
  doneGroups: new Set(), // class:name="…" groups already emitted
10
+ doneKeyframes: new Set(), // add this
10
11
  buffer: [], // CSS waiting to be written
11
12
  flushQueued: false,
12
13
  styleTagExists: false,
@@ -84,6 +85,7 @@ export let classPrinter = {
84
85
  [...el.attributes].map((each) => {
85
86
  // ------------
86
87
  // Raw-CSS Statement
88
+ var _a;
87
89
  // class-group
88
90
  if (testRegExp.test(each.name)) {
89
91
  let value = each.value;
@@ -110,22 +112,29 @@ export let classPrinter = {
110
112
  // }
111
113
  // }
112
114
  if (testRegExpKF.test(each.name)) {
113
- const key = each.name.replace(testRegExpKF, '');
114
- let kfStatement = '@keyframes ' + this.kfNames[key] + "{\n";
115
- const returnPnV = (e) => e.map((i) => statementMaker.make(i, undefined, true)).join(";");
116
- const split = each.value.trim().split(/\s+/);
117
- split.forEach((each) => {
118
- try {
119
- const [at, pNv] = each.replace(/\]\[/, ']-[').replace("-", "=").split("=");
120
- // const result=returnPnV(pNv.replace(/^\[|\]$/g,'').split(','));
121
- const result = returnPnV(splitByCommaOutsideParens(pNv.replace(/^\[|\]$/g, '')));
122
- kfStatement += ` ${at.replace('@', '').replace(/:/g, ',').replace(/,/g, "%,").replace(/[\[|\]]/g, '')}% {${result ? result : ''}}`;
123
- }
124
- catch (error) {
125
- console.log('invalid Entry for AliasCSS keyframes processor : ' + each, error);
126
- }
127
- });
128
- this.appendToStyleTag(kfStatement + "\n}");
115
+ const key = each.name.replace(testRegExpKF, ''); // already lower-case (HTML does that)
116
+ const name = (_a = this.kfNames[key]) !== null && _a !== void 0 ? _a : key;
117
+ const doneKey = name + '\u0000' + each.value;
118
+ if (!this.doneKeyframes.has(doneKey)) { // add once, like doneGroups
119
+ this.doneKeyframes.add(doneKey);
120
+ const returnPnV = (e) => e.map((i) => statementMaker.make(i, undefined, true)).join(';');
121
+ let steps = '';
122
+ each.value.trim().split(/\s+/).forEach((step) => {
123
+ try {
124
+ // @0[…] @0-[…] @50%[…] @[0,25,50][…] @[0,25,50]-[…]
125
+ const m = step.match(/^@(\[[\d.,%]+\]|[\d.]+%?)-?(\[.*\])$/);
126
+ if (!m)
127
+ throw new Error('expected @50[...] or @[0,50][...]');
128
+ const at = m[1].replace(/[\[\]%]/g, ''); // "0,25,50"
129
+ steps += ` ${at.split(',').map((s) => s + '%').join(',')} {${returnPnV(splitByCommaOutsideParens(m[2].replace(/^\[|\]$/g, '')))}}`;
130
+ }
131
+ catch (error) {
132
+ console.log('invalid Entry for AliasCSS keyframes processor : ' + step, error);
133
+ }
134
+ });
135
+ if (steps)
136
+ this.appendToStyleTag('@keyframes ' + name + '{\n' + steps + '\n}');
137
+ }
129
138
  }
130
139
  });
131
140
  // if has value to process
@@ -18,6 +18,13 @@ const width = config.widths; // ['medium:m','thin:t','thick:th:t2'];
18
18
  const mode = config.modes; // ['normal:ml','multiply:m','screen:s','overlay:o','darken:d','lighten:l','color-dodge:cd','color-burn:cb','hard-light:hl','soft-light:sl','difference:di:d2','exclusion:e','hue:h','saturation:sa:s2','color:c','luminosity:lu:l2'];
19
19
  const remUnits = config.remUnits; // [`${1/4}rem:1`,`${2/4}rem:2`,`${3/4}rem:3`,`${4/4}rem:4`,`${5/4}rem:5`,`${6/4}rem:6`,`${7/4}rem:7`,`${8/4}rem:8`,`${9/4}rem:9`,`${10/4}rem:10`,];
20
20
  const remUnitsNegative = config.remUnitsNegative; // [`-${1/4}rem:-1`, `-${2/4}rem:-2`, `-${3/4}rem:-3`, `-${4/4}rem:-4`, `-${5/4}rem:-5`, `-${6/4}rem:-6`, `-${7/4}rem:-7`, `-${8/4}rem:-8`, `-${9/4}rem:-9`, `-${10/4}rem:-10`];
21
+ const gridBy = (value) => value
22
+ .replace(/--([\d])/g, '-Minus$1')
23
+ .replace(/\/-([\d])/g, '/Minus$1') // "/-1" is always negative: "/" is not a dash separator
24
+ .replace(/^-/, '')
25
+ .replace(/-by-/g, " / ")
26
+ .replace(/[-]?(span|[-]?[\d]+)[-]?/g, ' $1 ')
27
+ .replace(/[-]?Minus[\s]*/g, '-');
21
28
  const cssProps = {
22
29
  // type:s=static,d=dynamic
23
30
  // -----------------xc----------------
@@ -946,7 +953,7 @@ const cssProps = {
946
953
  alias: 'cur',
947
954
  type: '',
948
955
  // compiler:'',
949
- values: ['alias:al', 'all-scroll:as', 'auto:a', 'cell:c', 'col-resize:cr', 'context-menu:cm', 'copy:cp',
956
+ values: ['grab:gr:g', 'alias:al', 'all-scroll:as', 'auto:a', 'cell:c', 'col-resize:cr', 'context-menu:cm', 'copy:cp',
950
957
  'crosshair:ch', 'default:d', 'e-resize:er', 'ew-resize:ewr', 'help:h', 'move:mo', 'n-resize:nr', 'ne-resize:ner', 'nesw-resize:neswr',
951
958
  'no-drop:nd', 'none:n', 'not-allowed:na', 'ns-resize:nsr', 'nw-resize:nwr', 'nwse-resize:nwser',
952
959
  'pointer:p', 'progress:pr', 'row-resize:rr', 's-resize:sr', 'se-resize:ser', 'sw-resize:swr',
@@ -963,7 +970,7 @@ const cssProps = {
963
970
  alias: 'd',
964
971
  type: 's',
965
972
  // compiler:'',
966
- values: ['block:b', 'compact:cp', 'container:c', 'contents:cont', 'flex:f', 'grid:g', 'inline:i', 'inline-block:ib',
973
+ values: ['-webkit-box:webkit-box:wb:box', 'block:b', 'compact:cp', 'container:c', 'contents:cont', 'flex:f', 'grid:g', 'inline:i', 'inline-block:ib',
967
974
  'inline-flex:if', 'inline-grid:ig', 'inline-table:it',
968
975
  'list-item:li', 'none:n', 'run-in:ri', 'table:t', 'table-caption:tcap', 'table-cell:tcl', 'table-column:tc',
969
976
  'table-column-group:tcg', 'table-footer-group:tfg', 'table-header-group:thg', 'table-row:tr', 'table-row-group:trg'],
@@ -1188,7 +1195,7 @@ const cssProps = {
1188
1195
  alias: 'ga',
1189
1196
  type: 'd',
1190
1197
  // compiler:lenByNumPer,
1191
- compiler: (value) => value.replace(/--([\d])/g, '-Minus$1').replace(/^-/, '').replace(/-by-/g, " / ").replace(/[-]?(span|[-]?[\d]+)[-]?/g, ' $1 ').replace(/[-]?Minus[\s]*/g, '-'),
1198
+ compiler: gridBy,
1192
1199
  values: [''],
1193
1200
  },
1194
1201
  'grid-auto-columns': {
@@ -1201,6 +1208,7 @@ const cssProps = {
1201
1208
  // }
1202
1209
  // if(/^minmax-/.text(value:string)){
1203
1210
  return value.replace(/[-]?(minmax)-(min-content|max-content|auto|\w+)-(min-content|max-content|auto|\w+)/g, " $1($2 , $3 ) ")
1211
+ .replace(/(\d)\.(\d)/g, '$1d$2').replace(/%/g, 'p')
1204
1212
  .replace(/[-]?(fit-content)[-]([\w]+)/g, "$1( $2 ) ")
1205
1213
  .replace(/-([\d|a|a|f|m])/g, ' $1')
1206
1214
  .replace(/([\d])d([\d])/g, '$1.$2')
@@ -1225,7 +1233,7 @@ const cssProps = {
1225
1233
  // }
1226
1234
  // if(/^minmax-/.text(value:string)){
1227
1235
  return value.replace(/[-]?(minmax)-(min-content|max-content|auto|\w+)-(min-content|max-content|auto|\w+)/g, " $1($2 , $3 ) ")
1228
- .replace(/[-]?(fit-content)[-]([\w]+)/g, "$1( $2 ) ")
1236
+ .replace(/(\d)\.(\d)/g, '$1d$2').replace(/%/g, 'p').replace(/[-]?(fit-content)[-]([\w]+)/g, "$1( $2 ) ")
1229
1237
  .replace(/-([\d|a|a|f|m])/g, ' $1')
1230
1238
  .replace(/([\d])d([\d])/g, '$1.$2')
1231
1239
  .replace(/([\d])p([\s])/g, "$1% ").replace(/p$/, "%");
@@ -1237,14 +1245,14 @@ const cssProps = {
1237
1245
  alias: 'gc',
1238
1246
  type: 'd',
1239
1247
  // compiler:lenByNumPer,
1240
- compiler: (value) => value.replace(/--([\d])/g, '-Minus$1').replace(/^-/, '').replace(/-by-/g, " / ").replace(/[-]?(span|[-]?[\d]+)[-]?/g, ' $1 ').replace(/[-]?Minus[\s]*/g, '-'),
1248
+ compiler: gridBy,
1241
1249
  values: [],
1242
1250
  },
1243
1251
  'grid-column-end': {
1244
1252
  alias: 'gce',
1245
1253
  type: 'd',
1246
1254
  // compiler:lenByNumPer,
1247
- compiler: (value) => value.replace(/--([\d])/g, '-Minus$1').replace(/^-/, '').replace(/-by-/g, " / ").replace(/[-]?(span|[-]?[\d]+)[-]?/g, ' $1 ').replace(/[-]?Minus[\s]*/g, '-'),
1255
+ compiler: gridBy,
1248
1256
  values: ['auto'],
1249
1257
  },
1250
1258
  'grid-column-gap': {
@@ -1257,7 +1265,7 @@ const cssProps = {
1257
1265
  alias: 'gcs',
1258
1266
  type: 'd',
1259
1267
  // compiler:length,
1260
- compiler: (value) => value.replace(/--([\d])/g, '-Minus$1').replace(/^-/, '').replace(/-by-/g, " / ").replace(/[-]?(span|[-]?[\d]+)[-]?/g, ' $1 ').replace(/[-]?Minus[\s]*/g, '-'),
1268
+ compiler: gridBy,
1261
1269
  values: ['auto:a'],
1262
1270
  },
1263
1271
  'grid-gap': {
@@ -1270,14 +1278,14 @@ const cssProps = {
1270
1278
  alias: 'gr',
1271
1279
  type: 'd',
1272
1280
  // compiler:lenByNumPer,
1273
- compiler: (value) => value.replace(/--([\d])/g, '-Minus$1').replace(/^-/, '').replace(/-by-/g, " / ").replace(/[-]?(span|[-]?[\d]+)[-]?/g, ' $1 ').replace(/[-]?Minus[\s]*/g, '-'),
1281
+ compiler: gridBy,
1274
1282
  values: ['auto:a', 'auto / auto:auto-auto'],
1275
1283
  },
1276
1284
  'grid-row-end': {
1277
1285
  alias: 'gre',
1278
1286
  type: 'd',
1279
1287
  // compiler:lenByNumPer,
1280
- compiler: (value) => value.replace(/--([\d])/g, '-Minus$1').replace(/^-/, '').replace(/-by-/g, " / ").replace(/[-]?(span|[-]?[\d]+)[-]?/g, ' $1 ').replace(/[-]?Minus[\s]*/g, '-'),
1288
+ compiler: gridBy,
1281
1289
  values: ['auto:a'],
1282
1290
  },
1283
1291
  'grid-row-gap': {
@@ -1290,7 +1298,7 @@ const cssProps = {
1290
1298
  alias: 'grs',
1291
1299
  type: 'd',
1292
1300
  // compiler:lenByNumPer,
1293
- compiler: (value) => value.replace(/--([\d])/g, '-Minus$1').replace(/^-/, '').replace(/-by-/g, " / ").replace(/[-]?(span|[-]?[\d]+)[-]?/g, ' $1 ').replace(/[-]?Minus[\s]*/g, '-'),
1301
+ compiler: gridBy,
1294
1302
  values: ['auto:a'],
1295
1303
  },
1296
1304
  'grid-template': {
@@ -3085,5 +3093,30 @@ const cssProps = {
3085
3093
  compiler: (value) => url(value),
3086
3094
  values: ['none:n'],
3087
3095
  },
3096
+ // ---------------some Custom Aliases compiler----------------
3097
+ 'max-h': {
3098
+ property: 'max-height',
3099
+ type: 'd',
3100
+ compiler: length,
3101
+ values: ['max-content:xc', 'min-content:mc', 'none:n', 'fit-content:fc'],
3102
+ },
3103
+ 'min-h': {
3104
+ property: 'min-height',
3105
+ type: 'd',
3106
+ compiler: length,
3107
+ values: ['max-content:xc', 'min-content:mc', 'none:n', 'fit-content:fc'],
3108
+ },
3109
+ 'max-w': {
3110
+ property: 'max-width',
3111
+ type: 'd',
3112
+ compiler: length,
3113
+ values: ['max-content:xc', 'min-content:mc', 'none:n', 'fit-content:fc'],
3114
+ },
3115
+ 'min-w': {
3116
+ property: 'min-width',
3117
+ type: 'd',
3118
+ compiler: length,
3119
+ values: ['max-content:xc', 'min-content:mc', 'none:n', 'fit-content:fc'],
3120
+ },
3088
3121
  };
3089
3122
  export default cssProps;
@@ -144,14 +144,34 @@ export function compileFile(file, config, statementMaker, globalClassList) {
144
144
  export function groupStatement(name, classNames, statementMaker) {
145
145
  return statementMaker.group(classNames, name) + "\n";
146
146
  }
147
+ // export function keyframesStatement(name: string, timeLine: string, statementMaker: { make: (a: string, b?: string | null, c?: boolean) => string }) {
148
+ // let kfStatement = "@keyframes " + name + "{\n";
149
+ // const returnPnV = (e: string[]) => e.map((i) => statementMaker.make(i, null, true)).join(";");
150
+ // const split = timeLine.split(/\s+/);
151
+ // split.forEach((each: string) => {
152
+ // try {
153
+ // const [at, pNv] = each.replace(/\]\[/, "]-[").replace("-", "=").split("=");
154
+ // kfStatement += ` ${at.replace("@", "").replace(/:/g, ",").replace(/,/g, "%,").replace(/[\[|\]]/g, "")}% {${returnPnV(
155
+ // splitByCommaOutsideParens(pNv.replace(/^\[|\]$/g, ""))
156
+ // )}}`;
157
+ // } catch (error) {
158
+ // console.error("Not a valid entry for AliasCSS keyframes processor : " + each, error);
159
+ // }
160
+ // });
161
+ // return kfStatement + "\n}\n";
162
+ // }
147
163
  export function keyframesStatement(name, timeLine, statementMaker) {
148
164
  let kfStatement = "@keyframes " + name + "{\n";
149
165
  const returnPnV = (e) => e.map((i) => statementMaker.make(i, null, true)).join(";");
150
- const split = timeLine.split(/\s+/);
166
+ const split = timeLine.trim().split(/\s+/);
151
167
  split.forEach((each) => {
152
168
  try {
153
- const [at, pNv] = each.replace(/\]\[/, "]-[").replace("-", "=").split("=");
154
- kfStatement += ` ${at.replace("@", "").replace(/:/g, ",").replace(/,/g, "%,").replace(/[\[|\]]/g, "")}% {${returnPnV(splitByCommaOutsideParens(pNv.replace(/^\[|\]$/g, "")))}}`;
169
+ // @0[…] @0-[…] @[0,25,50][…] @[0,25,50]-[…]
170
+ const m = each.match(/^@(\[[\d,\s%]+\]|[\d.]+)-?(\[.*\])$/);
171
+ if (!m)
172
+ throw new Error("expected @50[...] or @[0,50][...]");
173
+ const at = m[1].replace(/[\[\]\s%]/g, ""); // "0,25,50"
174
+ kfStatement += ` ${at.split(",").map((s) => s + "%").join(",")} {${returnPnV(splitByCommaOutsideParens(m[2].replace(/^\[|\]$/g, "")))}}`;
155
175
  }
156
176
  catch (error) {
157
177
  console.error("Not a valid entry for AliasCSS keyframes processor : " + each, error);
@@ -187,14 +207,21 @@ export function createCSSFileByFile(file_1) {
187
207
  }
188
208
  export function postify(file_1, plugin_1) {
189
209
  return __awaiter(this, arguments, void 0, function* (file, plugin, minify = false, sort = "mobile-first") {
210
+ // Ensure the file exists before attempting to read/write
190
211
  if (!fs.existsSync(file))
191
212
  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);
213
+ try {
214
+ const data = fs.readFileSync(file, "utf-8");
215
+ const plugins = [...plugin, sortMediaQueries({ sort })];
216
+ if (minify) {
217
+ plugins.push(cssnano);
218
+ }
219
+ const result = yield postcss(plugins).process(data, { from: undefined });
220
+ fs.writeFileSync(file, result.css);
221
+ }
222
+ catch (error) {
223
+ console.error(`Failed to process CSS for ${file}:`, error);
224
+ }
198
225
  });
199
226
  }
200
227
  export function writeStatementToFile(file, content, from) {
@@ -5,6 +5,7 @@
5
5
  * ":--8px" is accepted as negative too.
6
6
  */
7
7
  const asClassValue = (value) => '-' + value.replace(/^--(?=[\d.])/, '-');
8
+ const calcValue = (value) => value.replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2').replace(/_/g, ' ');
8
9
  /** Value clean-up used when no compiler handles the value (same rules as before, sign-safe). */
9
10
  const fallbackValue = (value) => asClassValue(value)
10
11
  .replace(/[-]([-]?[\w])/g, ' $1')
@@ -29,6 +30,9 @@ bool = false) {
29
30
  if (staticClassNames.hasOwnProperty(className)) {
30
31
  return staticClassNames[className];
31
32
  }
33
+ // Leading-dot decimals: ".5" → "0.5" (o-.5, m-.5rem, --x-o:.5, scale(.5)). 0.5 is the documented form.
34
+ // Only a dot after a non-word character changes, so "1.5", "0d5", "x.5" and "_.5" stay as written.
35
+ className = className.replace(/(^|[^\w.])\.(\d)/g, '$10.$2');
32
36
  // case 2 defining css-variable as className
33
37
  if (className.startsWith('--') && className.includes(':')) {
34
38
  let value = className.slice(className.indexOf(':')).replace(':', '');
@@ -68,7 +72,8 @@ bool = false) {
68
72
  //
69
73
  // case 1: CSS Variable inside css variable
70
74
  if (/^calc/.test(value)) {
71
- return bool ? [property, value.replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2')] : property + ":" + value.replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2');
75
+ const v = calcValue(value);
76
+ return bool ? [property, v] : property + ":" + v;
72
77
  }
73
78
  // case 2: CSS variable in side css variable
74
79
  if (/^--[a-zA-Z]/.test(value)) {
@@ -120,7 +125,7 @@ bool = false) {
120
125
  let value = splits[1].slice(splits[1].indexOf(':')).replace(':', '');
121
126
  const cssVar = splits[1].replace(value, '').replace(':', '');
122
127
  if (/^calc\(/.test(value)) {
123
- return bool ? [prop, "var(--" + cssVar + ',' + value.replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2') + ')'] : prop + ": var(--" + cssVar + ',' + value.replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2') + ')';
128
+ return bool ? [prop, "var(--" + cssVar + ',' + calcValue(value) + ')'] : prop + ": var(--" + cssVar + ',' + calcValue(value) + ')';
124
129
  }
125
130
  if (property.hasOwnProperty('compiler') && typeof property.compiler === 'function') {
126
131
  const val = property.compiler(asClassValue(value), custom);
@@ -151,11 +156,17 @@ bool = false) {
151
156
  return bool ? [prop, val] : prop + ":" + val;
152
157
  }
153
158
  }
154
- // case 3: calc function
159
+ // case 3: rew var function
160
+ if (/^-var\(/.test(valuePortion)) {
161
+ return bool ? [prop, valuePortion.replace(/^-/, '')] : prop + ":" + valuePortion.replace(/^-/, '');
162
+ }
163
+ // case 4: calc function
155
164
  if (/^-calc\(/.test(valuePortion)) {
156
- return bool ? [prop, valuePortion.replace(/^-/, '').replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2')] : prop + ":" + valuePortion.replace(/^-/, '').replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2');
165
+ const v = calcValue(valuePortion.replace(/^-/, ''));
166
+ return bool ? [prop, v] : prop + ":" + v;
167
+ // return bool?[prop,valuePortion.replace(/^-/,'').replace(/([-+/*])([\d]|var\(|calc\()/g,' $1 $2')]:prop+":"+valuePortion.replace(/^-/,'').replace(/([-+/*])([\d]|var\(|calc\()/g,' $1 $2');
157
168
  }
158
- // case 4: CSS variable without --var keyword
169
+ // case 5: CSS variable without --var keyword
159
170
  if (/^--[a-zA-Z]/.test(valuePortion)) {
160
171
  if (valuePortion.includes(':')) {
161
172
  let value = valuePortion.slice(valuePortion.indexOf(':')).replace(':', '');
@@ -178,7 +189,7 @@ bool = false) {
178
189
  }
179
190
  //
180
191
  if (/^calc\(/.test(value)) {
181
- return bool ? [prop, "var(" + cssVar + ',' + value.replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2') + ')'] : prop + ": var(" + cssVar + ',' + value.replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2') + ')';
192
+ return bool ? [prop, "var(" + cssVar + ',' + calcValue(value) + ')'] : prop + ": var(" + cssVar + ',' + calcValue(value) + ')';
182
193
  }
183
194
  if (property.hasOwnProperty('compiler') && typeof property.compiler === 'function') {
184
195
  const val = property.compiler(asClassValue(value), custom);
@@ -14,6 +14,7 @@ import { staticClassNamesAlias } from "./static/staticClassNamesAlias.js";
14
14
  import { splitByCommaOutsideParens, matchTrailingGroup, splitTopLevel, joinGroupItem } from "./utils/helper.js";
15
15
  import cssCustomCompilers from "./custom-css-compilers.js";
16
16
  // import customGroups from './prebuild.js';
17
+ import postcss from "postcss";
17
18
  const [staticClassNamesWithAlias, cssPropsWithAlias] = createCompilerObj(cssProps, config.globalValues);
18
19
  const NAME = '[a-zA-Z_][\\w-]*(?:\\/[a-zA-Z_][\\w-]*)*';
19
20
  const AS_EXPORT = new RegExp(`--as-(?<names>${NAME}|\\[${NAME}(?:,${NAME})*\\])$`);
@@ -268,9 +269,15 @@ export const compiler = {
268
269
  else {
269
270
  stm = `${beforeClassNameSelector}.${className}${elementAndPseudo}{${result}${important}}`;
270
271
  }
271
- if (isSafeCss(stm))
272
+ try {
273
+ postcss.parse(stm);
272
274
  return stm;
273
- console.warn(`AliasCSS: "${as ? as : className}" produced invalid CSS:`, stm);
275
+ }
276
+ catch (error) {
277
+ console.log('Not a Valid CSS Statement, PostCSS Parse:', className, " => ", stm);
278
+ }
279
+ // if (isSafeCss(stm)) return stm;
280
+ // console.warn(`AliasCSS: "${as ? as : className}" produced invalid CSS:`, stm);
274
281
  }
275
282
  else {
276
283
  // extractProperty returns [property, key] even when nothing matched, so test the property itself
@@ -412,9 +419,16 @@ export const compiler = {
412
419
  else {
413
420
  stm = `${beforeClassNameSelector}.${className}${elementAndPseudo}{${result}${important}}`;
414
421
  }
415
- if (isSafeCss(stm))
422
+ // Check if the generated statement is valid CSS using PostCSS parser
423
+ try {
424
+ postcss.parse(stm);
416
425
  return stm;
417
- console.log('Not a Valid CSS Statement:', stm);
426
+ }
427
+ catch (error) {
428
+ console.log('Not a Valid CSS Statement, PostCSS Parse:', stm);
429
+ }
430
+ // if (isSafeCss(stm)) return stm;
431
+ // console.log('Not a Valid CSS Statement:', stm);
418
432
  }
419
433
  else {
420
434
  console.log(`Unable to process ${className} [media:${mediaEX},pseudoSelector:${elementAndPseudo},imp:${important}]`);
@@ -4,6 +4,8 @@ export function repeat(data) {
4
4
  if (data.match(/-repeat[(]/)) {
5
5
  return data.replace(/^-/, '');
6
6
  }
7
+ // "." works like "d" and "%" like "p" (same rule as length/gradient)
8
+ data = data.replace(/(\d)\.(\d)/g, '$1d$2').replace(/%/g, 'p');
7
9
  data = data.replace(/repeat/g, '===');
8
10
  const matchRegex = /===-([\d]+|auto-fill|auto-fit)-([a-z0-9-]+)/;
9
11
  while (data.match(matchRegex)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aliascss",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "AliasCSS is a CSS post processor.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",