@unocss/extractor-arbitrary-variants 0.60.3 → 0.61.0
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.mjs +34 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import { defaultSplitRE, isValidSelector } from '@unocss/core';
|
|
2
2
|
|
|
3
|
+
function hash(str) {
|
|
4
|
+
let i;
|
|
5
|
+
let l;
|
|
6
|
+
let hval = 2166136261;
|
|
7
|
+
for (i = 0, l = str.length; i < l; i++) {
|
|
8
|
+
hval ^= str.charCodeAt(i);
|
|
9
|
+
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
|
|
10
|
+
}
|
|
11
|
+
return `00000${(hval >>> 0).toString(36)}`.slice(-6);
|
|
12
|
+
}
|
|
13
|
+
function transformSkipCode(code, map, SKIP_RULES_RE, keyFlag) {
|
|
14
|
+
for (const item of Array.from(code.matchAll(SKIP_RULES_RE))) {
|
|
15
|
+
if (item != null) {
|
|
16
|
+
const matched = item[0];
|
|
17
|
+
const withHashKey = `${keyFlag}${hash(matched)}`;
|
|
18
|
+
map.set(withHashKey, matched);
|
|
19
|
+
code = code.replace(matched, withHashKey);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return code;
|
|
23
|
+
}
|
|
24
|
+
function restoreSkipCode(code, map) {
|
|
25
|
+
for (const [withHashKey, matched] of map.entries())
|
|
26
|
+
code = code.replaceAll(withHashKey, matched);
|
|
27
|
+
return code;
|
|
28
|
+
}
|
|
29
|
+
|
|
3
30
|
const sourceMapRE = /\/\/#\s*sourceMappingURL=.*\n?/g;
|
|
4
31
|
function removeSourceMap(code) {
|
|
5
32
|
if (code.includes("sourceMappingURL="))
|
|
@@ -19,7 +46,14 @@ function splitCodeWithArbitraryVariants(code) {
|
|
|
19
46
|
}
|
|
20
47
|
for (const match of code.matchAll(quotedArbitraryValuesRE))
|
|
21
48
|
result.push(match[0]);
|
|
49
|
+
const skipMap = /* @__PURE__ */ new Map();
|
|
50
|
+
const skipFlag = "@unocss-skip-arbitrary-brackets";
|
|
51
|
+
code = transformSkipCode(code, skipMap, /-\[[^\]]*\]/g, skipFlag);
|
|
52
|
+
if (!code)
|
|
53
|
+
return result;
|
|
22
54
|
code.split(defaultSplitRE).forEach((match) => {
|
|
55
|
+
if (match.includes(skipFlag))
|
|
56
|
+
match = restoreSkipCode(match, skipMap);
|
|
23
57
|
if (isValidSelector(match) && !arbitraryPropertyCandidateRE.test(match))
|
|
24
58
|
result.push(match);
|
|
25
59
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/extractor-arbitrary-variants",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.61.0",
|
|
5
5
|
"description": "Extractor arbitrary variants for utilities",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@unocss/core": "0.
|
|
36
|
+
"@unocss/core": "0.61.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "unbuild",
|