@tbela99/css-parser 1.4.3 → 1.4.4
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/CHANGELOG.md +192 -2
- package/README.md +69 -1120
- package/dist/config.json.js +43 -2
- package/dist/index-umd-web.js +17226 -15037
- package/dist/index.cjs +16889 -14705
- package/dist/index.d.ts +1804 -1684
- package/dist/lib/ast/clone.js +4 -3
- package/dist/lib/ast/expand.js +2 -2
- package/dist/lib/ast/features/calc.js +59 -54
- package/dist/lib/ast/features/if.js +22 -16
- package/dist/lib/ast/features/inlinecssvariables.js +2 -2
- package/dist/lib/ast/features/prefix.js +343 -6
- package/dist/lib/ast/features/transform.js +7 -4
- package/dist/lib/ast/find.js +5 -5
- package/dist/lib/ast/math/expression.js +12 -8
- package/dist/lib/ast/minify.js +28 -33
- package/dist/lib/ast/transform/minify.js +135 -131
- package/dist/lib/ast/transform/utils.js +3 -2
- package/dist/lib/ast/types.js +69 -8
- package/dist/lib/ast/walk.js +4 -5
- package/dist/lib/fs/resolve.js +71 -57
- package/dist/lib/parser/declaration/list.js +92 -3
- package/dist/lib/parser/declaration/map.js +5 -5
- package/dist/lib/parser/parse.js +528 -466
- package/dist/lib/parser/tokenize.js +110 -4
- package/dist/lib/parser/utils/angle.js +29 -0
- package/dist/lib/parser/utils/at-rule-container.js +2 -2
- package/dist/lib/parser/utils/at-rule-font-feature-values.js +2 -2
- package/dist/lib/parser/utils/at-rule-generic.js +1 -1
- package/dist/lib/parser/utils/at-rule-media.js +2 -2
- package/dist/lib/parser/utils/at-rule-support.js +73 -8
- package/dist/lib/parser/utils/at-rule-when-else.js +2 -2
- package/dist/lib/parser/utils/at-rule.js +2 -8
- package/dist/lib/parser/utils/declaration.js +179 -76
- package/dist/lib/parser/utils/selector.js +53 -11
- package/dist/lib/parser/utils/token.js +13 -11
- package/dist/lib/renderer/render.js +501 -59
- package/dist/lib/syntax/color/alpha.js +64 -0
- package/dist/lib/syntax/color/cmyk.js +2 -2
- package/dist/lib/syntax/color/color-mix.js +283 -220
- package/dist/lib/syntax/color/color.js +37 -28
- package/dist/lib/syntax/color/hex.js +2 -2
- package/dist/lib/syntax/color/hsl.js +3 -3
- package/dist/lib/syntax/color/hwb.js +7 -7
- package/dist/lib/syntax/color/lab.js +5 -5
- package/dist/lib/syntax/color/lch.js +4 -4
- package/dist/lib/syntax/color/oklab.js +3 -3
- package/dist/lib/syntax/color/oklch.js +3 -3
- package/dist/lib/syntax/color/relativecolor.js +97 -12
- package/dist/lib/syntax/color/srgb.js +5 -5
- package/dist/lib/syntax/color/utils/color-type.js +18 -0
- package/dist/lib/syntax/color/utils/colorspace.js +46 -0
- package/dist/lib/syntax/color/utils/components.js +7 -3
- package/dist/lib/syntax/color/utils/distance.js +21 -4
- package/dist/lib/syntax/color/utils/make-color.js +56 -0
- package/dist/lib/syntax/color/xyz.js +2 -2
- package/dist/lib/syntax/constants.js +29 -1
- package/dist/lib/syntax/syntax.js +307 -39
- package/dist/lib/validation/config.js +2 -2
- package/dist/lib/validation/config.json.js +32 -17
- package/dist/lib/validation/match.js +239 -104
- package/dist/lib/validation/parser/parse.js +0 -1
- package/dist/lib/validation/parser/typedef.js +6 -0
- package/dist/node.js +64 -22
- package/dist/web.js +65 -18
- package/package.json +26 -15
- package/.nyc_output/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +0 -1
- package/.nyc_output/6193bc4c-6f5f-4898-8950-c628825e6342.json +0 -1
- package/.nyc_output/processinfo/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +0 -1
- package/.nyc_output/processinfo/6193bc4c-6f5f-4898-8950-c628825e6342.json +0 -1
- package/.repl_history +0 -4
- package/badges/coverage.svg +0 -20
- package/deno.lock +0 -2861
- package/dist/lib/ast/clone.d.ts +0 -10
- package/dist/lib/ast/expand.d.ts +0 -14
- package/dist/lib/ast/features/calc.d.ts +0 -10
- package/dist/lib/ast/features/if.d.ts +0 -10
- package/dist/lib/ast/features/index.d.ts +0 -6
- package/dist/lib/ast/features/inlinecssvariables.d.ts +0 -15
- package/dist/lib/ast/features/prefix.d.ts +0 -8
- package/dist/lib/ast/features/shorthand.d.ts +0 -12
- package/dist/lib/ast/features/transform.d.ts +0 -10
- package/dist/lib/ast/features/type.d.ts +0 -15
- package/dist/lib/ast/find.d.ts +0 -165
- package/dist/lib/ast/math/expression.d.ts +0 -18
- package/dist/lib/ast/math/math.d.ts +0 -6
- package/dist/lib/ast/minify.d.ts +0 -19
- package/dist/lib/ast/transform/compute.d.ts +0 -8
- package/dist/lib/ast/transform/matrix.d.ts +0 -22
- package/dist/lib/ast/transform/minify.d.ts +0 -5
- package/dist/lib/ast/transform/perspective.d.ts +0 -3
- package/dist/lib/ast/transform/rotate.d.ts +0 -12
- package/dist/lib/ast/transform/scale.d.ts +0 -6
- package/dist/lib/ast/transform/skew.d.ts +0 -4
- package/dist/lib/ast/transform/translate.d.ts +0 -6
- package/dist/lib/ast/transform/utils.d.ts +0 -9
- package/dist/lib/ast/types.d.ts +0 -903
- package/dist/lib/ast/walk.d.ts +0 -162
- package/dist/lib/fs/resolve.d.ts +0 -20
- package/dist/lib/parser/declaration/list.d.ts +0 -16
- package/dist/lib/parser/declaration/map.d.ts +0 -15
- package/dist/lib/parser/declaration/set.d.ts +0 -9
- package/dist/lib/parser/node.d.ts +0 -7
- package/dist/lib/parser/parse.d.ts +0 -107
- package/dist/lib/parser/tokenize.d.ts +0 -57
- package/dist/lib/parser/utils/at-rule-container.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-font-feature-values.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-generic.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-import.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-media.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-page.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-page.js +0 -28
- package/dist/lib/parser/utils/at-rule-support.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule-token.d.ts +0 -1
- package/dist/lib/parser/utils/at-rule-when-else.d.ts +0 -5
- package/dist/lib/parser/utils/at-rule.d.ts +0 -13
- package/dist/lib/parser/utils/cache.d.ts +0 -6
- package/dist/lib/parser/utils/config.d.ts +0 -2
- package/dist/lib/parser/utils/declaration-list.d.ts +0 -5
- package/dist/lib/parser/utils/declaration.d.ts +0 -18
- package/dist/lib/parser/utils/eq.d.ts +0 -1
- package/dist/lib/parser/utils/hash.d.ts +0 -21
- package/dist/lib/parser/utils/selector.d.ts +0 -5
- package/dist/lib/parser/utils/text.d.ts +0 -3
- package/dist/lib/parser/utils/token.d.ts +0 -14
- package/dist/lib/parser/utils/type.d.ts +0 -2
- package/dist/lib/renderer/render.d.ts +0 -28
- package/dist/lib/renderer/sourcemap/lib/encode.d.ts +0 -1
- package/dist/lib/renderer/sourcemap/sourcemap.d.ts +0 -26
- package/dist/lib/syntax/color/a98rgb.d.ts +0 -2
- package/dist/lib/syntax/color/cmyk.d.ts +0 -10
- package/dist/lib/syntax/color/color-mix.d.ts +0 -2
- package/dist/lib/syntax/color/color.d.ts +0 -42
- package/dist/lib/syntax/color/hex.d.ts +0 -16
- package/dist/lib/syntax/color/hsl.d.ts +0 -20
- package/dist/lib/syntax/color/hsv.d.ts +0 -2
- package/dist/lib/syntax/color/hwb.d.ts +0 -21
- package/dist/lib/syntax/color/lab.d.ts +0 -25
- package/dist/lib/syntax/color/lch.d.ts +0 -23
- package/dist/lib/syntax/color/oklab.d.ts +0 -22
- package/dist/lib/syntax/color/oklch.d.ts +0 -20
- package/dist/lib/syntax/color/p3.d.ts +0 -6
- package/dist/lib/syntax/color/prophotorgb.d.ts +0 -2
- package/dist/lib/syntax/color/rec2020.d.ts +0 -2
- package/dist/lib/syntax/color/relativecolor.d.ts +0 -13
- package/dist/lib/syntax/color/rgb.d.ts +0 -20
- package/dist/lib/syntax/color/srgb.d.ts +0 -23
- package/dist/lib/syntax/color/utils/components.d.ts +0 -2
- package/dist/lib/syntax/color/utils/distance.d.ts +0 -18
- package/dist/lib/syntax/color/utils/matrix.d.ts +0 -6
- package/dist/lib/syntax/color/xyz.d.ts +0 -5
- package/dist/lib/syntax/color/xyzd50.d.ts +0 -4
- package/dist/lib/syntax/constants.d.ts +0 -67
- package/dist/lib/syntax/syntax.d.ts +0 -38
- package/dist/lib/validation/config.d.ts +0 -14
- package/dist/lib/validation/json.d.ts +0 -2
- package/dist/lib/validation/match.d.ts +0 -38
- package/dist/lib/validation/parser/parse.d.ts +0 -8
- package/dist/lib/validation/parser/typedef.d.ts +0 -95
- package/dist/lib/validation/utils/list.d.ts +0 -4
- package/dist/lib/validation/utils/whitespace.d.ts +0 -2
- package/dist/node.d.ts +0 -207
- package/dist/web.d.ts +0 -169
- package/playground/index.html +0 -1328
- package/playground/sw.js +0 -55
- package/playground/tree.js +0 -176
package/playground/sw.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
function isCacheable(request) {
|
|
2
|
-
|
|
3
|
-
return request.method === 'GET' && (request.mode === 'cors' || new URL(request.url).origin === self.origin)
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
self.addEventListener('install', async (event) => {
|
|
7
|
-
|
|
8
|
-
event.waitUntil(async () => {
|
|
9
|
-
|
|
10
|
-
await clients.claim();
|
|
11
|
-
});
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
self.addEventListener('fetch', async (event) => {
|
|
15
|
-
|
|
16
|
-
event.respondWith(
|
|
17
|
-
(async () => {
|
|
18
|
-
|
|
19
|
-
// console.debug(event.request);
|
|
20
|
-
|
|
21
|
-
const cache = await caches.open('css-parser-playground');
|
|
22
|
-
|
|
23
|
-
if (!isCacheable(event.request)) return fetch(event.request);
|
|
24
|
-
|
|
25
|
-
let response = await cache.match(event.request);
|
|
26
|
-
|
|
27
|
-
console.debug(response);
|
|
28
|
-
|
|
29
|
-
if (response != null) {
|
|
30
|
-
|
|
31
|
-
return response;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
response = await fetch(event.request);
|
|
35
|
-
|
|
36
|
-
console.debug(response);
|
|
37
|
-
|
|
38
|
-
if (response == null || !response.ok) {
|
|
39
|
-
|
|
40
|
-
return fetch(event.request)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.debug(response.headers.get('Content-Type'));
|
|
44
|
-
|
|
45
|
-
if (response.ok && response.headers.get('Content-Type')?.includes('text/css')) {
|
|
46
|
-
|
|
47
|
-
await cache.put(event.request, response.clone());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return response.ok ? response : fetch(event.request);
|
|
51
|
-
|
|
52
|
-
// return fetch(event.request)
|
|
53
|
-
})()
|
|
54
|
-
)
|
|
55
|
-
})
|
package/playground/tree.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
function clickHandler(event) {
|
|
2
|
-
|
|
3
|
-
if (event.target.matches('.e,.property') || event.target.tagName === 'A') {
|
|
4
|
-
|
|
5
|
-
const parentLi = event.target.closest('li');
|
|
6
|
-
|
|
7
|
-
if (parentLi != null) {
|
|
8
|
-
|
|
9
|
-
event.preventDefault();
|
|
10
|
-
parentLi.classList.toggle('tree-collapsed');
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Función para construir el árbol
|
|
17
|
-
|
|
18
|
-
export function buildTree(treeElement, jsonObj, options) {
|
|
19
|
-
|
|
20
|
-
treeElement.innerHTML = "";
|
|
21
|
-
|
|
22
|
-
const isArray = Array.isArray(jsonObj);
|
|
23
|
-
const isObject = typeof jsonObj === 'object' && !isArray;
|
|
24
|
-
|
|
25
|
-
let openKey = '{';
|
|
26
|
-
|
|
27
|
-
let closeKey = '}';
|
|
28
|
-
|
|
29
|
-
if (isArray) {
|
|
30
|
-
|
|
31
|
-
openKey = '[';
|
|
32
|
-
closeKey = ']';
|
|
33
|
-
|
|
34
|
-
} else if (isObject) {
|
|
35
|
-
|
|
36
|
-
openKey = '{';
|
|
37
|
-
closeKey = '}';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
treeElement.removeEventListener('click', clickHandler);
|
|
41
|
-
treeElement.addEventListener('click', clickHandler);
|
|
42
|
-
|
|
43
|
-
treeElement.innerHTML = `<ul><li data-key=''>
|
|
44
|
-
<span class="e"></span>
|
|
45
|
-
${options?.rootName ? `
|
|
46
|
-
<span class="token property">${options.rootName}</span>
|
|
47
|
-
<span class="token operator">: </span>` : ''}
|
|
48
|
-
<span class="token punctuation">${openKey}</span>
|
|
49
|
-
<span class="tree-more-dots"> ... </span>
|
|
50
|
-
<span class="token punctuation">${closeKey}</span>
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
|
-
treeElement.firstElementChild.querySelector('.tree-more-dots').insertAdjacentElement('afterend', createTreeDom(jsonObj, '', options));
|
|
54
|
-
|
|
55
|
-
treeElement.firstElementChild.addEventListener('click', (event) => {
|
|
56
|
-
|
|
57
|
-
const target = event.target.parentElement;
|
|
58
|
-
if (target.matches('li[data-parsed=no]')) {
|
|
59
|
-
|
|
60
|
-
const node = target.querySelector(':scope>.tree-more-dots');
|
|
61
|
-
|
|
62
|
-
if (node == null) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
node.insertAdjacentElement('afterend', createTreeDom(jsonObj, target.dataset.key, options));
|
|
67
|
-
target.removeAttribute('data-parsed');
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Función para crear el DOM del árbol
|
|
73
|
-
|
|
74
|
-
function createTreeDom(obj, key, options) {
|
|
75
|
-
|
|
76
|
-
const path = [];
|
|
77
|
-
|
|
78
|
-
if (key !== '' && key !== null) {
|
|
79
|
-
|
|
80
|
-
path.push(...JSON.parse(key));
|
|
81
|
-
|
|
82
|
-
for (const pathKey of path) {
|
|
83
|
-
|
|
84
|
-
obj = obj[pathKey];
|
|
85
|
-
|
|
86
|
-
if (obj == null) {
|
|
87
|
-
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Obtenemos las claves del objeto en un array
|
|
94
|
-
|
|
95
|
-
const keys = Object.keys(obj);
|
|
96
|
-
const ul = document.createElement("ul");
|
|
97
|
-
|
|
98
|
-
for (let i = 0; i < keys.length; i++) {
|
|
99
|
-
|
|
100
|
-
const key = keys[i];
|
|
101
|
-
|
|
102
|
-
const li = document.createElement("li");
|
|
103
|
-
|
|
104
|
-
li.classList.add("tree-collapsed");
|
|
105
|
-
li.dataset.key = JSON.stringify([...path, key]);
|
|
106
|
-
li.dataset.parsed = 'no';
|
|
107
|
-
|
|
108
|
-
const child = obj[key];
|
|
109
|
-
|
|
110
|
-
const childTypeof = typeof child;
|
|
111
|
-
|
|
112
|
-
const {name, value} = options?.transform(key, child, obj) ?? {name: key, value: child};
|
|
113
|
-
|
|
114
|
-
if (childTypeof === "object" && child != null) {
|
|
115
|
-
|
|
116
|
-
if (Object.keys(child).length === 0) {
|
|
117
|
-
|
|
118
|
-
li.innerHTML = `<span class="token property">${name}</span>
|
|
119
|
-
<span class="token operator">: </span>
|
|
120
|
-
<span class="token punctuation">{</span>
|
|
121
|
-
<span class="tree-more-dots"> ... </span>
|
|
122
|
-
<span class="token punctuation">${i < keys.length - 1 ? "}," : "}"}</span>
|
|
123
|
-
`;
|
|
124
|
-
|
|
125
|
-
} else {
|
|
126
|
-
|
|
127
|
-
const objectIsArray = Array.isArray(obj);
|
|
128
|
-
const childIsArray = Array.isArray(child);
|
|
129
|
-
|
|
130
|
-
const openKey = childIsArray ? '[' : '{';
|
|
131
|
-
const closeKey = childIsArray ? ']' : '}';
|
|
132
|
-
|
|
133
|
-
if (objectIsArray) {
|
|
134
|
-
|
|
135
|
-
li.innerHTML = `<span class="e"></span>
|
|
136
|
-
<span class="token property">${name}</span>
|
|
137
|
-
<span class="token operator">: </span>
|
|
138
|
-
<a href="#" class="token punctuation">${openKey}</a>
|
|
139
|
-
<span class="tree-more-dots"> ... </span>
|
|
140
|
-
`;
|
|
141
|
-
|
|
142
|
-
} else {
|
|
143
|
-
|
|
144
|
-
li.innerHTML = `<span class="e"></span>
|
|
145
|
-
<span class="token property">${key}</span>
|
|
146
|
-
<span class="token operator">: </span>
|
|
147
|
-
<a href="#" class="token punctuation">${openKey}</a>
|
|
148
|
-
<span class="tree-more-dots"> ... </span>
|
|
149
|
-
`;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
li.innerHTML += `<span class="token punctuation">${closeKey}${i < keys.length - 1 ? "," : ''}</span>
|
|
153
|
-
`;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
} else {
|
|
157
|
-
|
|
158
|
-
li.innerHTML = `${name === '' ? '' : `<span class="token property">${name}</span>
|
|
159
|
-
<span class="token operator">: </span>
|
|
160
|
-
`}
|
|
161
|
-
<span class="token childTypeof${child === null ? 'null' : ''}">${value}</span>
|
|
162
|
-
`;
|
|
163
|
-
|
|
164
|
-
// Agregamos la coma solo si no es el último elemento
|
|
165
|
-
|
|
166
|
-
if (i < keys.length - 1) {
|
|
167
|
-
|
|
168
|
-
li.innerHTML += ",";
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
ul.appendChild(li);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return ul;
|
|
176
|
-
}
|