diff --git a/badges/coverage.svg b/badges/coverage.svg new file mode 100644 index 00000000..5a07aab9 --- /dev/null +++ b/badges/coverage.svg @@ -0,0 +1,20 @@ + + coverage: 86.32% + + + + + + + + + + + + + diff --git a/benchmark/index.html b/benchmark/index.html new file mode 100644 index 00000000..990182a1 --- /dev/null +++ b/benchmark/index.html @@ -0,0 +1,228 @@ + + + + + + CSS minification benchmark results + + + + +
+
+

CSS Minification Benchmark

+ GitHub +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Fileclean-css - 5.3.3clean-css (level 2) - 5.3.3cssnano - 7.0.7csso - 5.0.5csso (restructure off) - 5.0.5css-tree - 3.1.0esbuild - 0.25.9lightningcss - 1.30.1@tbela99/css-parser - v1.3.1@tbela99/css-parser (nesting) - v1.3.1
960.css - 9989 bytes5772 bytes
8.29 ms
5772 bytes
8.35 ms
5772 bytes
28.31 ms
5768 bytes
11.53 ms
5772 bytes
2.21 ms
5772 bytes
3.67 ms
5773 bytes
59.37 ms
5772 bytes
7.76 ms
5772 bytes
12.97 ms
4522 bytes
5.99 ms
animate.css - 95374 bytes75274 bytes
25.56 ms
74510 bytes
20.3 ms
71723 bytes
67.84 ms
73220 bytes
30.9 ms
74520 bytes
13.4 ms
75731 bytes
11.25 ms
73455 bytes
6.45 ms
68773 bytes
4.65 ms
65661 bytes
72.53 ms
65441 bytes
42.72 ms
blueprint.css - 17422 bytes10794 bytes
8.41 ms
10644 bytes
18.48 ms
10696 bytes
31.43 ms
10677 bytes
10.46 ms
10760 bytes
3.14 ms
10785 bytes
2.99 ms
10775 bytes
1.99 ms
10762 bytes
1.63 ms
10697 bytes
11.25 ms
10682 bytes
9.25 ms
bootstrap-4.css - 200078 bytes161971 bytes
63.28 ms
159896 bytes
78.06 ms
160609 bytes
194.7 ms
160157 bytes
65.41 ms
161962 bytes
23.87 ms
163304 bytes
24.93 ms
160903 bytes
10.14 ms
153591 bytes
7.19 ms
153092 bytes
99.35 ms
144609 bytes
62.22 ms
bootstrap-5.css - 205481 bytes163824 bytes
54.48 ms
161691 bytes
62.06 ms
162318 bytes
204.13 ms
161483 bytes
50.38 ms
163830 bytes
20.89 ms
165613 bytes
14.64 ms
162200 bytes
10.75 ms
159902 bytes
5.18 ms
158693 bytes
62.56 ms
151224 bytes
52.97 ms
font-awesome-all.css - 73117 bytes58568 bytes
9.73 ms
58568 bytes
15.3 ms
58929 bytes
80.54 ms
53128 bytes
19.38 ms
53184 bytes
7.75 ms
53189 bytes
6.17 ms
58980 bytes
4.59 ms
56046 bytes
2.04 ms
52753 bytes
19.01 ms
52744 bytes
22.14 ms
fotorama.css - 17863 bytes15025 bytes
7.39 ms
14845 bytes
5.66 ms
15000 bytes
15.31 ms
15115 bytes
5.51 ms
15125 bytes
2.09 ms
15134 bytes
1.69 ms
14973 bytes
1.39 ms
14459 bytes
0.87 ms
13625 bytes
9.85 ms
12514 bytes
6.67 ms
foundation.css - 168014 bytes132599 bytes
35.19 ms
125182 bytes
48.92 ms
126470 bytes
157.85 ms
124232 bytes
45.25 ms
132554 bytes
17.4 ms
133178 bytes
10.74 ms
128406 bytes
8.95 ms
122738 bytes
3.74 ms
119475 bytes
54.73 ms
107638 bytes
50.55 ms
inuit.css - 53050 bytes18184 bytes
11.05 ms
17635 bytes
11.19 ms
18105 bytes
29.05 ms
17878 bytes
7.41 ms
18216 bytes
3.28 ms
18282 bytes
2.15 ms
18325 bytes
2.59 ms
17839 bytes
0.84 ms
17477 bytes
10.83 ms
17354 bytes
7.93 ms
normalize.css - 6138 bytes1815 bytes
0.82 ms
1742 bytes
1.03 ms
1802 bytes
4.19 ms
1692 bytes
1.06 ms
1816 bytes
0.36 ms
1851 bytes
0.28 ms
1816 bytes
1.21 ms
1751 bytes
0.2 ms
1623 bytes
1.04 ms
1611 bytes
0.89 ms
pure.css - 28843 bytes16797 bytes
3.81 ms
16500 bytes
6.35 ms
16660 bytes
27.8 ms
16733 bytes
5.41 ms
16780 bytes
2.22 ms
17082 bytes
1.4 ms
16762 bytes
1.85 ms
16393 bytes
0.86 ms
14681 bytes
5.76 ms
13651 bytes
5.92 ms
reset.css - 1092 bytes773 bytes
0.29 ms
773 bytes
0.47 ms
773 bytes
4.74 ms
747 bytes
1.06 ms
773 bytes
0.18 ms
773 bytes
0.13 ms
774 bytes
0.56 ms
773 bytes
0.14 ms
747 bytes
0.41 ms
747 bytes
0.31 ms
tailwind.css - 2380419 bytes1941820 bytes
323.25 ms
1941515 bytes
483.99 ms
1925626 bytes
1766.37 ms
1652840 bytes
408.61 ms
1944385 bytes
201.57 ms
1963358 bytes
144.52 ms
1961185 bytes
95.49 ms
1836618 bytes
55.28 ms
1661681 bytes
540.69 ms
1633462 bytes
492.59 ms
Total - 3256880 bytes2603216 bytes
551.55 ms
2589273 bytes
760.16 ms
2574483 bytes
2612.26 ms
2293670 bytes
662.37 ms
2599677 bytes
298.36 ms
2624052 bytes
224.56 ms
2614327 bytes
205.33 ms
2465417 bytes
90.38 ms
2275977 bytes
900.98 ms
2216199 bytes
760.15 ms
+
+
+

Benchmark info:

+
Date: Mon, 25 Aug 2025 04:07:20 GMT
+CPU: Apple M2
+OS: Darwin arm64 24.6.0
+node: v24.5.0
+
+
+ + diff --git a/playground/index.html b/playground/index.html new file mode 100644 index 00000000..20144e79 --- /dev/null +++ b/playground/index.html @@ -0,0 +1,1264 @@ + + + + + @tbela99/css-parser Playground + + + + + + + + + + + + + +
+
+
+

@tbela99/css-parser Playground

+
+
+
+
+
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+ +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + + + + +
+
+
+ + + +
+
+
+
+
+
+ +
+
+
+
+
+
+ + + + diff --git a/playground/sw.js b/playground/sw.js new file mode 100644 index 00000000..a54c2c21 --- /dev/null +++ b/playground/sw.js @@ -0,0 +1,55 @@ +function isCacheable(request) { + + return request.method === 'GET' && (request.mode === 'cors' || new URL(request.url).origin === self.origin) +} + +self.addEventListener('install', async (event) => { + + event.waitUntil(async () => { + + await clients.claim(); + }); +}) + +self.addEventListener('fetch', async (event) => { + + event.respondWith( + (async () => { + + // console.debug(event.request); + + const cache = await caches.open('css-parser-playground'); + + if (!isCacheable(event.request)) return fetch(event.request); + + let response = await cache.match(event.request); + + console.debug(response); + + if (response != null) { + + return response; + } + + response = await fetch(event.request); + + console.debug(response); + + if (response == null || !response.ok) { + + return fetch(event.request) + } + + console.debug(response.headers.get('Content-Type')); + + if (response.ok && response.headers.get('Content-Type')?.includes('text/css')) { + + await cache.put(event.request, response.clone()); + } + + return response.ok ? response : fetch(event.request); + + // return fetch(event.request) + })() + ) +}) \ No newline at end of file diff --git a/playground/tree.js b/playground/tree.js new file mode 100644 index 00000000..3b8b625a --- /dev/null +++ b/playground/tree.js @@ -0,0 +1,176 @@ +function clickHandler(event) { + + if (event.target.matches('.e,.property') || event.target.tagName === 'A') { + + const parentLi = event.target.closest('li'); + + if (parentLi != null) { + + event.preventDefault(); + parentLi.classList.toggle('tree-collapsed'); + + } + } +} + +// Función para construir el árbol + +export function buildTree(treeElement, jsonObj, options) { + + treeElement.innerHTML = ""; + + const isArray = Array.isArray(jsonObj); + const isObject = typeof jsonObj === 'object' && !isArray; + + let openKey = '{'; + + let closeKey = '}'; + + if (isArray) { + + openKey = '['; + closeKey = ']'; + + } else if (isObject) { + + openKey = '{'; + closeKey = '}'; + } + + treeElement.removeEventListener('click', clickHandler); + treeElement.addEventListener('click', clickHandler); + + treeElement.innerHTML = `