@tbela99/css-parser 1.4.1 → 1.4.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.
Files changed (216) hide show
  1. package/.nyc_output/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +1 -0
  2. package/.nyc_output/6193bc4c-6f5f-4898-8950-c628825e6342.json +1 -0
  3. package/.nyc_output/processinfo/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +1 -0
  4. package/.nyc_output/processinfo/6193bc4c-6f5f-4898-8950-c628825e6342.json +1 -0
  5. package/.repl_history +4 -0
  6. package/CHANGELOG.md +168 -4
  7. package/README.md +82 -0
  8. package/badges/coverage.svg +20 -0
  9. package/deno.lock +2861 -0
  10. package/dist/config.json.js +33 -1
  11. package/dist/index-umd-web.js +24393 -18479
  12. package/dist/index.cjs +27430 -21519
  13. package/dist/index.d.ts +1403 -933
  14. package/dist/lib/ast/clone.d.ts +10 -0
  15. package/dist/lib/ast/clone.js +45 -0
  16. package/dist/lib/ast/expand.d.ts +14 -0
  17. package/dist/lib/ast/expand.js +89 -64
  18. package/dist/lib/ast/features/calc.d.ts +10 -0
  19. package/dist/lib/ast/features/calc.js +62 -24
  20. package/dist/lib/ast/features/if.d.ts +10 -0
  21. package/dist/lib/ast/features/if.js +215 -0
  22. package/dist/lib/ast/features/index.d.ts +6 -0
  23. package/dist/lib/ast/features/index.js +1 -0
  24. package/dist/lib/ast/features/inlinecssvariables.d.ts +15 -0
  25. package/dist/lib/ast/features/inlinecssvariables.js +32 -27
  26. package/dist/lib/ast/features/prefix.d.ts +8 -0
  27. package/dist/lib/ast/features/prefix.js +68 -43
  28. package/dist/lib/ast/features/shorthand.d.ts +12 -0
  29. package/dist/lib/ast/features/shorthand.js +6 -9
  30. package/dist/lib/ast/features/transform.d.ts +10 -0
  31. package/dist/lib/ast/features/transform.js +9 -13
  32. package/dist/lib/ast/features/type.d.ts +15 -0
  33. package/dist/lib/ast/find.d.ts +165 -0
  34. package/dist/lib/ast/find.js +175 -0
  35. package/dist/lib/ast/math/expression.d.ts +18 -0
  36. package/dist/lib/ast/math/expression.js +140 -98
  37. package/dist/lib/ast/math/math.d.ts +6 -0
  38. package/dist/lib/ast/math/math.js +30 -41
  39. package/dist/lib/ast/minify.d.ts +19 -0
  40. package/dist/lib/ast/minify.js +543 -215
  41. package/dist/lib/ast/transform/compute.d.ts +8 -0
  42. package/dist/lib/ast/transform/compute.js +82 -69
  43. package/dist/lib/ast/transform/matrix.d.ts +22 -0
  44. package/dist/lib/ast/transform/matrix.js +12 -26
  45. package/dist/lib/ast/transform/minify.d.ts +5 -0
  46. package/dist/lib/ast/transform/minify.js +20 -20
  47. package/dist/lib/ast/transform/perspective.d.ts +3 -0
  48. package/dist/lib/ast/transform/perspective.js +1 -1
  49. package/dist/lib/ast/transform/rotate.d.ts +12 -0
  50. package/dist/lib/ast/transform/rotate.js +1 -1
  51. package/dist/lib/ast/transform/scale.d.ts +6 -0
  52. package/dist/lib/ast/transform/scale.js +1 -1
  53. package/dist/lib/ast/transform/skew.d.ts +4 -0
  54. package/dist/lib/ast/transform/skew.js +1 -1
  55. package/dist/lib/ast/transform/translate.d.ts +6 -0
  56. package/dist/lib/ast/transform/translate.js +1 -1
  57. package/dist/lib/ast/transform/utils.d.ts +9 -0
  58. package/dist/lib/ast/types.d.ts +903 -0
  59. package/dist/lib/ast/types.js +277 -23
  60. package/dist/lib/ast/walk.d.ts +162 -0
  61. package/dist/lib/ast/walk.js +116 -60
  62. package/dist/lib/fs/resolve.d.ts +20 -0
  63. package/dist/lib/fs/resolve.js +37 -45
  64. package/dist/lib/parser/declaration/list.d.ts +16 -0
  65. package/dist/lib/parser/declaration/list.js +26 -24
  66. package/dist/lib/parser/declaration/map.d.ts +15 -0
  67. package/dist/lib/parser/declaration/map.js +140 -95
  68. package/dist/lib/parser/declaration/set.d.ts +9 -0
  69. package/dist/lib/parser/declaration/set.js +30 -25
  70. package/dist/lib/parser/node.d.ts +7 -0
  71. package/dist/lib/parser/parse.d.ts +107 -0
  72. package/dist/lib/parser/parse.js +1454 -1445
  73. package/dist/lib/parser/tokenize.d.ts +57 -0
  74. package/dist/lib/parser/tokenize.js +557 -404
  75. package/dist/lib/parser/utils/at-rule-container.d.ts +5 -0
  76. package/dist/lib/parser/utils/at-rule-container.js +486 -0
  77. package/dist/lib/parser/utils/at-rule-font-feature-values.d.ts +5 -0
  78. package/dist/lib/parser/utils/at-rule-font-feature-values.js +13 -0
  79. package/dist/lib/parser/utils/at-rule-generic.d.ts +5 -0
  80. package/dist/lib/parser/utils/at-rule-generic.js +118 -0
  81. package/dist/lib/parser/utils/at-rule-import.d.ts +5 -0
  82. package/dist/lib/parser/utils/at-rule-import.js +393 -0
  83. package/dist/lib/parser/utils/at-rule-media.d.ts +5 -0
  84. package/dist/lib/parser/utils/at-rule-media.js +603 -0
  85. package/dist/lib/parser/utils/at-rule-page.d.ts +5 -0
  86. package/dist/lib/parser/utils/at-rule-page.js +28 -0
  87. package/dist/lib/parser/utils/at-rule-support.d.ts +5 -0
  88. package/dist/lib/parser/utils/at-rule-support.js +366 -0
  89. package/dist/lib/parser/utils/at-rule-token.d.ts +1 -0
  90. package/dist/lib/parser/utils/at-rule-when-else.d.ts +5 -0
  91. package/dist/lib/parser/utils/at-rule-when-else.js +363 -0
  92. package/dist/lib/parser/utils/at-rule.d.ts +13 -0
  93. package/dist/lib/parser/utils/at-rule.js +37 -0
  94. package/dist/lib/parser/utils/cache.d.ts +6 -0
  95. package/dist/lib/parser/utils/cache.js +19 -0
  96. package/dist/lib/parser/utils/config.d.ts +2 -0
  97. package/dist/lib/parser/utils/config.js +1 -0
  98. package/dist/lib/parser/utils/declaration-list.d.ts +5 -0
  99. package/dist/lib/parser/utils/declaration.d.ts +18 -0
  100. package/dist/lib/parser/utils/declaration.js +569 -91
  101. package/dist/lib/parser/utils/eq.d.ts +1 -0
  102. package/dist/lib/parser/utils/hash.d.ts +21 -0
  103. package/dist/lib/parser/utils/hash.js +1 -1
  104. package/dist/lib/parser/utils/selector.d.ts +5 -0
  105. package/dist/lib/parser/utils/selector.js +476 -0
  106. package/dist/lib/parser/utils/text.d.ts +3 -0
  107. package/dist/lib/parser/utils/text.js +17 -1
  108. package/dist/lib/parser/utils/token.d.ts +14 -0
  109. package/dist/lib/parser/utils/token.js +102 -0
  110. package/dist/lib/parser/utils/type.d.ts +2 -0
  111. package/dist/lib/parser/utils/type.js +29 -18
  112. package/dist/lib/renderer/render.d.ts +28 -0
  113. package/dist/lib/renderer/render.js +421 -262
  114. package/dist/lib/renderer/sourcemap/lib/encode.d.ts +1 -0
  115. package/dist/lib/renderer/sourcemap/sourcemap.d.ts +26 -0
  116. package/dist/lib/renderer/sourcemap/sourcemap.js +17 -7
  117. package/dist/lib/syntax/color/a98rgb.d.ts +2 -0
  118. package/dist/lib/syntax/color/a98rgb.js +8 -12
  119. package/dist/lib/syntax/color/cmyk.d.ts +10 -0
  120. package/dist/lib/syntax/color/cmyk.js +23 -21
  121. package/dist/lib/syntax/color/color-mix.d.ts +2 -0
  122. package/dist/lib/syntax/color/color-mix.js +88 -77
  123. package/dist/lib/syntax/color/color.d.ts +42 -0
  124. package/dist/lib/syntax/color/color.js +65 -68
  125. package/dist/lib/syntax/color/hex.d.ts +16 -0
  126. package/dist/lib/syntax/color/hex.js +27 -31
  127. package/dist/lib/syntax/color/hsl.d.ts +20 -0
  128. package/dist/lib/syntax/color/hsl.js +5 -12
  129. package/dist/lib/syntax/color/hsv.d.ts +2 -0
  130. package/dist/lib/syntax/color/hwb.d.ts +21 -0
  131. package/dist/lib/syntax/color/hwb.js +8 -21
  132. package/dist/lib/syntax/color/lab.d.ts +25 -0
  133. package/dist/lib/syntax/color/lab.js +20 -21
  134. package/dist/lib/syntax/color/lch.d.ts +23 -0
  135. package/dist/lib/syntax/color/lch.js +13 -15
  136. package/dist/lib/syntax/color/oklab.d.ts +22 -0
  137. package/dist/lib/syntax/color/oklab.js +20 -39
  138. package/dist/lib/syntax/color/oklch.d.ts +20 -0
  139. package/dist/lib/syntax/color/oklch.js +14 -16
  140. package/dist/lib/syntax/color/p3.d.ts +6 -0
  141. package/dist/lib/syntax/color/p3.js +0 -8
  142. package/dist/lib/syntax/color/prophotorgb.d.ts +2 -0
  143. package/dist/lib/syntax/color/rec2020.d.ts +2 -0
  144. package/dist/lib/syntax/color/rec2020.js +9 -13
  145. package/dist/lib/syntax/color/relativecolor.d.ts +13 -0
  146. package/dist/lib/syntax/color/relativecolor.js +68 -41
  147. package/dist/lib/syntax/color/rgb.d.ts +20 -0
  148. package/dist/lib/syntax/color/rgb.js +14 -18
  149. package/dist/lib/syntax/color/srgb.d.ts +23 -0
  150. package/dist/lib/syntax/color/srgb.js +27 -26
  151. package/dist/lib/syntax/color/utils/components.d.ts +2 -0
  152. package/dist/lib/syntax/color/utils/components.js +30 -14
  153. package/dist/lib/syntax/color/utils/distance.d.ts +18 -0
  154. package/dist/lib/syntax/color/utils/distance.js +1 -8
  155. package/dist/lib/syntax/color/utils/matrix.d.ts +6 -0
  156. package/dist/lib/syntax/color/xyz.d.ts +5 -0
  157. package/dist/lib/syntax/color/xyz.js +8 -20
  158. package/dist/lib/syntax/color/xyzd50.d.ts +4 -0
  159. package/dist/lib/syntax/color/xyzd50.js +6 -20
  160. package/dist/lib/syntax/constants.d.ts +67 -0
  161. package/dist/lib/syntax/constants.js +436 -0
  162. package/dist/lib/syntax/syntax.d.ts +38 -0
  163. package/dist/lib/syntax/syntax.js +533 -568
  164. package/dist/lib/validation/config.d.ts +14 -0
  165. package/dist/lib/validation/config.js +72 -33
  166. package/dist/lib/validation/config.json.js +1159 -74
  167. package/dist/lib/validation/json.d.ts +2 -0
  168. package/dist/lib/validation/match.d.ts +38 -0
  169. package/dist/lib/validation/match.js +2985 -0
  170. package/dist/lib/validation/parser/parse.d.ts +8 -0
  171. package/dist/lib/validation/parser/parse.js +684 -935
  172. package/dist/lib/validation/parser/typedef.d.ts +95 -0
  173. package/dist/lib/validation/parser/typedef.js +100 -0
  174. package/dist/lib/validation/utils/list.d.ts +4 -0
  175. package/dist/lib/validation/utils/list.js +4 -11
  176. package/dist/lib/validation/utils/whitespace.d.ts +2 -0
  177. package/dist/lib/validation/utils/whitespace.js +2 -8
  178. package/dist/node.d.ts +207 -0
  179. package/dist/node.js +53 -47
  180. package/dist/web.d.ts +169 -0
  181. package/dist/web.js +50 -41
  182. package/package.json +18 -13
  183. package/playground/index.html +1328 -0
  184. package/playground/sw.js +55 -0
  185. package/playground/tree.js +176 -0
  186. package/dist/lib/syntax/color/utils/constants.js +0 -214
  187. package/dist/lib/syntax/utils.js +0 -70
  188. package/dist/lib/validation/at-rules/container.js +0 -342
  189. package/dist/lib/validation/at-rules/counter-style.js +0 -90
  190. package/dist/lib/validation/at-rules/custom-media.js +0 -50
  191. package/dist/lib/validation/at-rules/document.js +0 -89
  192. package/dist/lib/validation/at-rules/else.js +0 -5
  193. package/dist/lib/validation/at-rules/font-feature-values.js +0 -63
  194. package/dist/lib/validation/at-rules/import.js +0 -150
  195. package/dist/lib/validation/at-rules/keyframes.js +0 -67
  196. package/dist/lib/validation/at-rules/layer.js +0 -41
  197. package/dist/lib/validation/at-rules/media.js +0 -255
  198. package/dist/lib/validation/at-rules/namespace.js +0 -81
  199. package/dist/lib/validation/at-rules/page-margin-box.js +0 -64
  200. package/dist/lib/validation/at-rules/page.js +0 -100
  201. package/dist/lib/validation/at-rules/supports.js +0 -295
  202. package/dist/lib/validation/at-rules/when.js +0 -185
  203. package/dist/lib/validation/atrule.js +0 -184
  204. package/dist/lib/validation/selector.js +0 -36
  205. package/dist/lib/validation/syntax.js +0 -1073
  206. package/dist/lib/validation/syntaxes/complex-selector-list.js +0 -27
  207. package/dist/lib/validation/syntaxes/complex-selector.js +0 -52
  208. package/dist/lib/validation/syntaxes/compound-selector.js +0 -196
  209. package/dist/lib/validation/syntaxes/family-name.js +0 -57
  210. package/dist/lib/validation/syntaxes/keyframe-selector.js +0 -36
  211. package/dist/lib/validation/syntaxes/layer-name.js +0 -57
  212. package/dist/lib/validation/syntaxes/relative-selector-list.js +0 -31
  213. package/dist/lib/validation/syntaxes/relative-selector.js +0 -38
  214. package/dist/lib/validation/syntaxes/selector-list.js +0 -5
  215. package/dist/lib/validation/syntaxes/selector.js +0 -5
  216. package/dist/lib/validation/syntaxes/url.js +0 -40
@@ -0,0 +1,55 @@
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
+ })
@@ -0,0 +1,176 @@
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
+ }
@@ -1,214 +0,0 @@
1
- import { EnumToken } from '../../../ast/types.js';
2
- import '../../../ast/minify.js';
3
- import '../../../ast/walk.js';
4
- import '../../../parser/parse.js';
5
- import '../../../parser/tokenize.js';
6
- import '../../../parser/utils/config.js';
7
- import '../../../renderer/sourcemap/lib/encode.js';
8
-
9
- const colorPrecision = 6;
10
- const anglePrecision = .001;
11
- const colorRange = {
12
- lab: {
13
- l: [0, 100],
14
- a: [-125, 125],
15
- b: [-125, 125]
16
- },
17
- lch: {
18
- l: [0, 100],
19
- c: [0, 150],
20
- h: [0, 360]
21
- },
22
- oklab: {
23
- l: [0, 1],
24
- a: [-0.4, .4],
25
- b: [-0.4, 0.4]
26
- },
27
- oklch: {
28
- l: [0, 1],
29
- a: [0, .4],
30
- b: [0, 0.4]
31
- }
32
- };
33
- const timelineFunc = ['view', 'scroll'];
34
- const generalEnclosedFunc = ['selector', 'font-tech', 'font-format', 'media', 'supports'];
35
- const timingFunc = ['ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', 'step-start', 'step-end', 'steps', 'cubic-bezier'];
36
- const funcLike = [
37
- EnumToken.ParensTokenType,
38
- EnumToken.FunctionTokenType,
39
- EnumToken.UrlFunctionTokenType,
40
- EnumToken.StartParensTokenType,
41
- EnumToken.ImageFunctionTokenType,
42
- EnumToken.TimingFunctionTokenType,
43
- EnumToken.TimingFunctionTokenType,
44
- EnumToken.PseudoClassFuncTokenType,
45
- EnumToken.GridTemplateFuncTokenType
46
- ];
47
- const colorsFunc = ['rgb', 'rgba', 'hsl', 'hsla', 'hwb', 'device-cmyk', 'color-mix', 'color', 'oklab', 'lab', 'oklch', 'lch', 'light-dark'];
48
- const colorFuncColorSpace = ['srgb', 'srgb-linear', 'display-p3', 'prophoto-rgb', 'a98-rgb', 'rec2020', 'xyz', 'xyz-d65', 'xyz-d50'];
49
- const D50 = [0.3457 / 0.3585, 1.00000, (1.0 - 0.3457 - 0.3585) / 0.3585];
50
- const k = Math.pow(29, 3) / Math.pow(3, 3);
51
- const e = Math.pow(6, 3) / Math.pow(29, 3);
52
- // color module v4
53
- const systemColors = new Set(['ActiveText', 'ButtonBorder', 'ButtonFace', 'ButtonText', 'Canvas', 'CanvasText', 'Field', 'FieldText', 'GrayText', 'Highlight', 'HighlightText', 'LinkText', 'Mark', 'MarkText', 'VisitedText', '-webkit-focus-ring-color'].map(m => m.toLowerCase()));
54
- // deprecated
55
- const deprecatedSystemColors = new Set(['ActiveBorder', 'ActiveCaption', 'AppWorkspace', 'Background', 'ButtonFace', 'ButtonHighlight', 'ButtonShadow', 'ButtonText', 'CaptionText', 'GrayText', 'Highlight', 'HighlightText', 'InactiveBorder', 'InactiveCaption', 'InactiveCaptionText', 'InfoBackground', 'InfoText', 'Menu', 'MenuText', 'Scrollbar', 'ThreeDDarkShadow', 'ThreeDFace', 'ThreeDHighlight', 'ThreeDLightShadow', 'ThreeDShadow', 'Window', 'WindowFrame', 'WindowText'].map(t => t.toLowerCase()));
56
- // name to color
57
- const COLORS_NAMES = Object.seal({
58
- 'aliceblue': '#f0f8ff',
59
- 'antiquewhite': '#faebd7',
60
- 'aqua': '#00ffff',
61
- 'aquamarine': '#7fffd4',
62
- 'azure': '#f0ffff',
63
- 'beige': '#f5f5dc',
64
- 'bisque': '#ffe4c4',
65
- 'black': '#000000',
66
- 'blanchedalmond': '#ffebcd',
67
- 'blue': '#0000ff',
68
- 'blueviolet': '#8a2be2',
69
- 'brown': '#a52a2a',
70
- 'burlywood': '#deb887',
71
- 'cadetblue': '#5f9ea0',
72
- 'chartreuse': '#7fff00',
73
- 'chocolate': '#d2691e',
74
- 'coral': '#ff7f50',
75
- 'cornflowerblue': '#6495ed',
76
- 'cornsilk': '#fff8dc',
77
- 'crimson': '#dc143c',
78
- 'cyan': '#00ffff',
79
- 'darkblue': '#00008b',
80
- 'darkcyan': '#008b8b',
81
- 'darkgoldenrod': '#b8860b',
82
- 'darkgray': '#a9a9a9',
83
- 'darkgrey': '#a9a9a9',
84
- 'darkgreen': '#006400',
85
- 'darkkhaki': '#bdb76b',
86
- 'darkmagenta': '#8b008b',
87
- 'darkolivegreen': '#556b2f',
88
- 'darkorange': '#ff8c00',
89
- 'darkorchid': '#9932cc',
90
- 'darkred': '#8b0000',
91
- 'darksalmon': '#e9967a',
92
- 'darkseagreen': '#8fbc8f',
93
- 'darkslateblue': '#483d8b',
94
- 'darkslategray': '#2f4f4f',
95
- 'darkslategrey': '#2f4f4f',
96
- 'darkturquoise': '#00ced1',
97
- 'darkviolet': '#9400d3',
98
- 'deeppink': '#ff1493',
99
- 'deepskyblue': '#00bfff',
100
- 'dimgray': '#696969',
101
- 'dimgrey': '#696969',
102
- 'dodgerblue': '#1e90ff',
103
- 'firebrick': '#b22222',
104
- 'floralwhite': '#fffaf0',
105
- 'forestgreen': '#228b22',
106
- 'fuchsia': '#ff00ff',
107
- 'gainsboro': '#dcdcdc',
108
- 'ghostwhite': '#f8f8ff',
109
- 'gold': '#ffd700',
110
- 'goldenrod': '#daa520',
111
- 'gray': '#808080',
112
- 'grey': '#808080',
113
- 'green': '#008000',
114
- 'greenyellow': '#adff2f',
115
- 'honeydew': '#f0fff0',
116
- 'hotpink': '#ff69b4',
117
- 'indianred': '#cd5c5c',
118
- 'indigo': '#4b0082',
119
- 'ivory': '#fffff0',
120
- 'khaki': '#f0e68c',
121
- 'lavender': '#e6e6fa',
122
- 'lavenderblush': '#fff0f5',
123
- 'lawngreen': '#7cfc00',
124
- 'lemonchiffon': '#fffacd',
125
- 'lightblue': '#add8e6',
126
- 'lightcoral': '#f08080',
127
- 'lightcyan': '#e0ffff',
128
- 'lightgoldenrodyellow': '#fafad2',
129
- 'lightgray': '#d3d3d3',
130
- 'lightgrey': '#d3d3d3',
131
- 'lightgreen': '#90ee90',
132
- 'lightpink': '#ffb6c1',
133
- 'lightsalmon': '#ffa07a',
134
- 'lightseagreen': '#20b2aa',
135
- 'lightskyblue': '#87cefa',
136
- 'lightslategray': '#778899',
137
- 'lightslategrey': '#778899',
138
- 'lightsteelblue': '#b0c4de',
139
- 'lightyellow': '#ffffe0',
140
- 'lime': '#00ff00',
141
- 'limegreen': '#32cd32',
142
- 'linen': '#faf0e6',
143
- 'magenta': '#ff00ff',
144
- 'maroon': '#800000',
145
- 'mediumaquamarine': '#66cdaa',
146
- 'mediumblue': '#0000cd',
147
- 'mediumorchid': '#ba55d3',
148
- 'mediumpurple': '#9370d8',
149
- 'mediumseagreen': '#3cb371',
150
- 'mediumslateblue': '#7b68ee',
151
- 'mediumspringgreen': '#00fa9a',
152
- 'mediumturquoise': '#48d1cc',
153
- 'mediumvioletred': '#c71585',
154
- 'midnightblue': '#191970',
155
- 'mintcream': '#f5fffa',
156
- 'mistyrose': '#ffe4e1',
157
- 'moccasin': '#ffe4b5',
158
- 'navajowhite': '#ffdead',
159
- 'navy': '#000080',
160
- 'oldlace': '#fdf5e6',
161
- 'olive': '#808000',
162
- 'olivedrab': '#6b8e23',
163
- 'orange': '#ffa500',
164
- 'orangered': '#ff4500',
165
- 'orchid': '#da70d6',
166
- 'palegoldenrod': '#eee8aa',
167
- 'palegreen': '#98fb98',
168
- 'paleturquoise': '#afeeee',
169
- 'palevioletred': '#d87093',
170
- 'papayawhip': '#ffefd5',
171
- 'peachpuff': '#ffdab9',
172
- 'peru': '#cd853f',
173
- 'pink': '#ffc0cb',
174
- 'plum': '#dda0dd',
175
- 'powderblue': '#b0e0e6',
176
- 'purple': '#800080',
177
- 'red': '#ff0000',
178
- 'rosybrown': '#bc8f8f',
179
- 'royalblue': '#4169e1',
180
- 'saddlebrown': '#8b4513',
181
- 'salmon': '#fa8072',
182
- 'sandybrown': '#f4a460',
183
- 'seagreen': '#2e8b57',
184
- 'seashell': '#fff5ee',
185
- 'sienna': '#a0522d',
186
- 'silver': '#c0c0c0',
187
- 'skyblue': '#87ceeb',
188
- 'slateblue': '#6a5acd',
189
- 'slategray': '#708090',
190
- 'slategrey': '#708090',
191
- 'snow': '#fffafa',
192
- 'springgreen': '#00ff7f',
193
- 'steelblue': '#4682b4',
194
- 'tan': '#d2b48c',
195
- 'teal': '#008080',
196
- 'thistle': '#d8bfd8',
197
- 'tomato': '#ff6347',
198
- 'turquoise': '#40e0d0',
199
- 'violet': '#ee82ee',
200
- 'wheat': '#f5deb3',
201
- 'white': '#ffffff',
202
- 'whitesmoke': '#f5f5f5',
203
- 'yellow': '#ffff00',
204
- 'yellowgreen': '#9acd32',
205
- 'rebeccapurple': '#663399',
206
- 'transparent': '#00000000'
207
- });
208
- // color to name
209
- const NAMES_COLORS = Object.seal(Object.entries(COLORS_NAMES).reduce((acc, [key, value]) => {
210
- acc[value] = key;
211
- return acc;
212
- }, Object.create(null)));
213
-
214
- export { COLORS_NAMES, D50, NAMES_COLORS, anglePrecision, colorFuncColorSpace, colorPrecision, colorRange, colorsFunc, deprecatedSystemColors, e, funcLike, generalEnclosedFunc, k, systemColors, timelineFunc, timingFunc };
@@ -1,70 +0,0 @@
1
- import { EnumToken } from '../ast/types.js';
2
- import '../ast/minify.js';
3
- import '../ast/walk.js';
4
- import '../parser/parse.js';
5
- import '../parser/tokenize.js';
6
- import '../parser/utils/config.js';
7
- import './color/utils/constants.js';
8
- import '../renderer/sourcemap/lib/encode.js';
9
-
10
- function length2Px(value) {
11
- let result = null;
12
- if (value.typ == EnumToken.NumberTokenType) {
13
- result = +value.val;
14
- }
15
- else {
16
- switch (value.unit) {
17
- case 'cm':
18
- // @ts-ignore
19
- result = value.val * 37.8;
20
- break;
21
- case 'mm':
22
- // @ts-ignore
23
- result = value.val * 3.78;
24
- break;
25
- case 'Q':
26
- // @ts-ignore
27
- result = value.val * 37.8 / 40;
28
- break;
29
- case 'in':
30
- // @ts-ignore
31
- result = value.val / 96;
32
- break;
33
- case 'pc':
34
- // @ts-ignore
35
- result = value.val / 16;
36
- break;
37
- case 'pt':
38
- // @ts-ignore
39
- result = value.val * 4 / 3;
40
- break;
41
- case 'px':
42
- result = +value.val;
43
- break;
44
- }
45
- }
46
- return isNaN(result) ? null : result;
47
- }
48
- /**
49
- * minify number
50
- * @param val
51
- */
52
- function minifyNumber(val) {
53
- val = String(val);
54
- if (val === '0') {
55
- return '0';
56
- }
57
- const chr = val.charAt(0);
58
- if (chr == '-') {
59
- const slice = val.slice(0, 2);
60
- if (slice == '-0') {
61
- return val.length == 2 ? '0' : '-' + val.slice(2);
62
- }
63
- }
64
- if (chr == '0') {
65
- return val.slice(1);
66
- }
67
- return val;
68
- }
69
-
70
- export { length2Px, minifyNumber };