@ingcrea/aumic-tailwind-killer 3.1.6 → 3.1.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/dist/index.js +45 -4
- package/dist/worker.js +1 -1
- package/package.json +48 -48
- package/patch.js +80 -0
package/dist/index.js
CHANGED
|
@@ -1154,6 +1154,34 @@ async function run() {
|
|
|
1154
1154
|
return;
|
|
1155
1155
|
}
|
|
1156
1156
|
spinner.succeed(`Se extrajeron ${globalExtracted.size} bloques únicos de Tailwind.`);
|
|
1157
|
+
// --- NUEVO: JIT VALIDATOR PASS (Zero-Bloat Seguro) ---
|
|
1158
|
+
spinner.start('Verificando clases nativas de Tailwind vs Custom CSS (JIT Validator)...');
|
|
1159
|
+
const allUniqueTokens = new Set();
|
|
1160
|
+
for (const orig of globalExtracted.keys()) {
|
|
1161
|
+
orig.split(' ').forEach(t => { if (t.trim() && !t.includes('aumic-'))
|
|
1162
|
+
allUniqueTokens.add(t.trim()); });
|
|
1163
|
+
}
|
|
1164
|
+
const testHtml = Array.from(allUniqueTokens).map(t => `<div class="${t}"></div>`).join('\n');
|
|
1165
|
+
let testPlugin;
|
|
1166
|
+
try {
|
|
1167
|
+
testPlugin = require('tailwindcss')({ content: [{ raw: testHtml, extension: 'html' }], corePlugins: { preflight: false } });
|
|
1168
|
+
}
|
|
1169
|
+
catch (e) {
|
|
1170
|
+
testPlugin = require('tailwindcss');
|
|
1171
|
+
}
|
|
1172
|
+
const testJit = await (0, postcss_1.default)([testPlugin]).process(`@tailwind utilities;`, { from: undefined });
|
|
1173
|
+
const testRoot = postcss_1.default.parse(testJit.css);
|
|
1174
|
+
const validTwClasses = new Set();
|
|
1175
|
+
testRoot.walkRules((rule) => {
|
|
1176
|
+
const allTokensArr = Array.from(allUniqueTokens);
|
|
1177
|
+
for (const token of allTokensArr) {
|
|
1178
|
+
const escaped = '.' + escapeCssSelector(token);
|
|
1179
|
+
if (rule.selector.includes(escaped)) {
|
|
1180
|
+
validTwClasses.add(token);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
spinner.succeed(`Filtro JIT completado: ${validTwClasses.size} utilidades nativas reconocidas.`);
|
|
1157
1185
|
const classMapping = new Map();
|
|
1158
1186
|
let customRules = '';
|
|
1159
1187
|
const rcPath = path_1.default.join(TARGET_DIR, '.aumicrc.json');
|
|
@@ -1193,7 +1221,13 @@ async function run() {
|
|
|
1193
1221
|
await fs_extra_1.default.writeJson(memoryPath, finalMapping, { spaces: 2 });
|
|
1194
1222
|
for (const [orig, { category, component, occurrences }] of globalExtracted) {
|
|
1195
1223
|
const cleanAumic = finalMapping[orig] || `aumic-ai-${component}-${getHash(orig)}`;
|
|
1196
|
-
|
|
1224
|
+
const fullArray = orig.split(' ');
|
|
1225
|
+
const twArray = fullArray.filter(c => validTwClasses.has(c));
|
|
1226
|
+
const customArray = fullArray.filter(c => !validTwClasses.has(c));
|
|
1227
|
+
const repString = customArray.length > 0 ? (twArray.length > 0 ? cleanAumic + ' ' + customArray.join(' ') : customArray.join(' ')) : cleanAumic;
|
|
1228
|
+
if (twArray.length > 0) {
|
|
1229
|
+
classMapping.set(orig, { original: orig, array: fullArray, tailwindOnlyArray: twArray, customArray, aumicClass: cleanAumic, replacementString: repString, category, component, occurrences });
|
|
1230
|
+
}
|
|
1197
1231
|
}
|
|
1198
1232
|
}
|
|
1199
1233
|
else {
|
|
@@ -1207,7 +1241,14 @@ async function run() {
|
|
|
1207
1241
|
};
|
|
1208
1242
|
for (const [orig, { category, component, occurrences }] of globalExtracted) {
|
|
1209
1243
|
const prefix = levelPrefix[category] || 'molecule';
|
|
1210
|
-
|
|
1244
|
+
const fullArray = orig.split(' ');
|
|
1245
|
+
const twArray = fullArray.filter(c => validTwClasses.has(c));
|
|
1246
|
+
const customArray = fullArray.filter(c => !validTwClasses.has(c));
|
|
1247
|
+
const hashAumic = `aumic-${prefix}-${component}-${getHash(orig)}`;
|
|
1248
|
+
const repString = customArray.length > 0 ? (twArray.length > 0 ? hashAumic + ' ' + customArray.join(' ') : customArray.join(' ')) : hashAumic;
|
|
1249
|
+
if (twArray.length > 0) {
|
|
1250
|
+
classMapping.set(orig, { original: orig, array: fullArray, tailwindOnlyArray: twArray, customArray, aumicClass: hashAumic, replacementString: repString, category, component, occurrences });
|
|
1251
|
+
}
|
|
1211
1252
|
}
|
|
1212
1253
|
spinner.succeed('Hashes generados.');
|
|
1213
1254
|
}
|
|
@@ -1280,7 +1321,7 @@ async function run() {
|
|
|
1280
1321
|
const utilityToAumic = new Map();
|
|
1281
1322
|
for (const [_, mapping] of classMapping) {
|
|
1282
1323
|
const cat = mapping.category || 'molecules';
|
|
1283
|
-
for (const util of mapping.
|
|
1324
|
+
for (const util of mapping.tailwindOnlyArray) {
|
|
1284
1325
|
const escaped = '.' + escapeCssSelector(util);
|
|
1285
1326
|
const list = utilityToAumic.get(escaped) || [];
|
|
1286
1327
|
list.push({ aumicClass: mapping.aumicClass, category: cat });
|
|
@@ -1328,7 +1369,7 @@ async function run() {
|
|
|
1328
1369
|
}
|
|
1329
1370
|
else {
|
|
1330
1371
|
spinner.start(`Fase 4: Forzando JIT de Tailwind (v${twVersion})...`);
|
|
1331
|
-
const virtualHtml = Array.from(classMapping.values()).map(map => `<div class="${map.
|
|
1372
|
+
const virtualHtml = Array.from(classMapping.values()).map(map => `<div class="${map.tailwindOnlyArray.join(' ')}"></div>`).join('\n');
|
|
1332
1373
|
let twPlugin;
|
|
1333
1374
|
twPlugin = require('tailwindcss')({ content: [{ raw: virtualHtml, extension: 'html' }], corePlugins: { preflight: false } });
|
|
1334
1375
|
await piscinaPool.destroy();
|
package/dist/worker.js
CHANGED
|
@@ -16,7 +16,7 @@ async function processFile(data) {
|
|
|
16
16
|
else if (data.mode === 'mutate') {
|
|
17
17
|
const { newCode } = astEngine.processFrameworkFile(data.content, data.filePath, (twClass) => {
|
|
18
18
|
if (data.map && data.map[twClass]) {
|
|
19
|
-
return data.map[twClass].aumicClass;
|
|
19
|
+
return data.map[twClass].replacementString || data.map[twClass].aumicClass;
|
|
20
20
|
}
|
|
21
21
|
return twClass;
|
|
22
22
|
});
|
package/package.json
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@ingcrea/aumic-tailwind-killer",
|
|
3
|
+
"version": "3.1.7",
|
|
4
|
+
"description": "Transpilador de Tailwind a CSS3 puro bajo estándar AUM-IC",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"aumic-tailwind-killer": "bin/aumic-killer.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"bump": "node scripts/bump.js",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"publish-public": "npm publish --access public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@babel/generator": "^8.0.6",
|
|
17
|
+
"@babel/parser": "^8.0.6",
|
|
18
|
+
"@babel/traverse": "^8.0.6",
|
|
19
|
+
"@tailwindcss/postcss": "^4.0.0",
|
|
20
|
+
"dotenv": "^16.6.1",
|
|
21
|
+
"fs-extra": "^11.2.0",
|
|
22
|
+
"inquirer": "^9.3.8",
|
|
23
|
+
"tailwindcss": "^3.4.1",
|
|
24
|
+
"picocolors": "^1.0.0",
|
|
25
|
+
"ora": "^5.4.1",
|
|
26
|
+
"commander": "^11.0.0",
|
|
27
|
+
"glob": "^10.3.10",
|
|
28
|
+
"piscina": "^4.4.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/fs-extra": "^11.0.4",
|
|
32
|
+
"@types/node": "^20.11.20",
|
|
33
|
+
"typescript": "^5.3.3"
|
|
34
|
+
},
|
|
35
|
+
"author": "IngenierÃa Creativa \u003csoporte@ingcrea.com\u003e (https://ingcrea.com)",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/ingcrea/aumic-tailwind-killer.git"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"tailwind",
|
|
42
|
+
"css",
|
|
43
|
+
"aum-ic",
|
|
44
|
+
"transpiler",
|
|
45
|
+
"ast",
|
|
46
|
+
"cli"
|
|
47
|
+
]
|
|
48
|
+
}
|
package/patch.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
let content = fs.readFileSync('src-typescript/index.ts', 'utf8');
|
|
3
|
+
|
|
4
|
+
const classMapRegex = /const classMapping = new Map<string, \{ original: string, array: string\[\], aumicClass: string, category: string, component: string, occurrences: number \}>\(\);/;
|
|
5
|
+
const classMapReplacement = 'const classMapping = new Map<string, { original: string, array: string[], tailwindOnlyArray: string[], customArray: string[], aumicClass: string, replacementString: string, category: string, component: string, occurrences: number }>();';
|
|
6
|
+
content = content.replace(classMapRegex, classMapReplacement);
|
|
7
|
+
|
|
8
|
+
const memoryInjectRegex = /classMapping\.set\(orig, \{ original: orig, array: orig\.split\(' '\), aumicClass: cleanAumic, category, component, occurrences \}\);/g;
|
|
9
|
+
const memoryInjectReplacement = `
|
|
10
|
+
const fullArray = orig.split(' ');
|
|
11
|
+
const twArray = fullArray.filter(c => validTwClasses.has(c));
|
|
12
|
+
const customArray = fullArray.filter(c => !validTwClasses.has(c));
|
|
13
|
+
const repString = customArray.length > 0 ? (twArray.length > 0 ? cleanAumic + ' ' + customArray.join(' ') : customArray.join(' ')) : cleanAumic;
|
|
14
|
+
if (twArray.length > 0) {
|
|
15
|
+
classMapping.set(orig, { original: orig, array: fullArray, tailwindOnlyArray: twArray, customArray, aumicClass: cleanAumic, replacementString: repString, category, component, occurrences });
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
content = content.replace(memoryInjectRegex, memoryInjectReplacement);
|
|
19
|
+
|
|
20
|
+
const hashInjectRegex = /classMapping\.set\(orig, \{ original: orig, array: orig\.split\(' '\), aumicClass: `aumic-\${prefix}-\${component}-\${getHash\(orig\)}`, category, component, occurrences \}\);/g;
|
|
21
|
+
const hashInjectReplacement = `
|
|
22
|
+
const fullArray = orig.split(' ');
|
|
23
|
+
const twArray = fullArray.filter(c => validTwClasses.has(c));
|
|
24
|
+
const customArray = fullArray.filter(c => !validTwClasses.has(c));
|
|
25
|
+
const hashAumic = \`aumic-\${prefix}-\${component}-\${getHash(orig)}\`;
|
|
26
|
+
const repString = customArray.length > 0 ? (twArray.length > 0 ? hashAumic + ' ' + customArray.join(' ') : customArray.join(' ')) : hashAumic;
|
|
27
|
+
if (twArray.length > 0) {
|
|
28
|
+
classMapping.set(orig, { original: orig, array: fullArray, tailwindOnlyArray: twArray, customArray, aumicClass: hashAumic, replacementString: repString, category, component, occurrences });
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
content = content.replace(hashInjectRegex, hashInjectReplacement);
|
|
32
|
+
|
|
33
|
+
const extractSuccessSplit = content.split("globalExtracted.size} bloques");
|
|
34
|
+
if(extractSuccessSplit.length > 1) {
|
|
35
|
+
const after = extractSuccessSplit[1];
|
|
36
|
+
const rest = after.substring(after.indexOf(");") + 2);
|
|
37
|
+
const before = extractSuccessSplit[0] + "globalExtracted.size} bloques" + after.substring(0, after.indexOf(");") + 2);
|
|
38
|
+
|
|
39
|
+
const jitValidationBlock = `
|
|
40
|
+
// --- NUEVO: JIT VALIDATOR PASS (Zero-Bloat Seguro) ---
|
|
41
|
+
spinner.start('Verificando clases nativas de Tailwind vs Custom CSS (JIT Validator)...');
|
|
42
|
+
const allUniqueTokens = new Set<string>();
|
|
43
|
+
for (const orig of globalExtracted.keys()) {
|
|
44
|
+
orig.split(' ').forEach(t => { if (t.trim() && !t.includes('aumic-')) allUniqueTokens.add(t.trim()); });
|
|
45
|
+
}
|
|
46
|
+
const testHtml = Array.from(allUniqueTokens).map(t => \`<div class="\${t}"></div>\`).join('\\n');
|
|
47
|
+
let testPlugin;
|
|
48
|
+
try {
|
|
49
|
+
testPlugin = require('tailwindcss')({ content: [{ raw: testHtml, extension: 'html' }], corePlugins: { preflight: false } });
|
|
50
|
+
} catch(e) {
|
|
51
|
+
testPlugin = require('tailwindcss');
|
|
52
|
+
}
|
|
53
|
+
const testJit = await postcss([testPlugin]).process(\`@tailwind utilities;\`, { from: undefined });
|
|
54
|
+
const testRoot = postcss.parse(testJit.css);
|
|
55
|
+
const validTwClasses = new Set<string>();
|
|
56
|
+
testRoot.walkRules((rule) => {
|
|
57
|
+
const allTokensArr = Array.from(allUniqueTokens);
|
|
58
|
+
for (const token of allTokensArr) {
|
|
59
|
+
const escaped = '.' + escapeCssSelector(token);
|
|
60
|
+
if (rule.selector.includes(escaped)) {
|
|
61
|
+
validTwClasses.add(token);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
spinner.succeed(\`Filtro JIT completado: \${validTwClasses.size} utilidades nativas reconocidas.\`);
|
|
66
|
+
`;
|
|
67
|
+
content = before + "\n" + jitValidationBlock + "\n" + rest;
|
|
68
|
+
} else {
|
|
69
|
+
console.log("Could not find globalExtracted block!");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const virtualHtmlReplacement = "const virtualHtml = Array.from(classMapping.values()).map(map => `<div class=\"${map.tailwindOnlyArray.join(' ')}\"></div>`).join('\\n');";
|
|
73
|
+
content = content.replace("const virtualHtml = Array.from(classMapping.values()).map(map => `<div class=\"${map.original}\"></div>`).join('\\n');", virtualHtmlReplacement);
|
|
74
|
+
|
|
75
|
+
const mapArrayRegex = /for \(const util of mapping\.array\) \{/g;
|
|
76
|
+
const mapArrayReplacement = 'for (const util of mapping.tailwindOnlyArray) {';
|
|
77
|
+
content = content.replace(mapArrayRegex, mapArrayReplacement);
|
|
78
|
+
|
|
79
|
+
fs.writeFileSync('src-typescript/index.ts', content, 'utf8');
|
|
80
|
+
console.log("Patched successfully!");
|