@unocss/transformer-compile-class 66.6.6-beta.1 → 66.6.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.mjs +6 -8
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { escapeRegExp, expandVariantGroup } from "@unocss/core";
|
|
2
|
-
|
|
3
2
|
//#region src/index.ts
|
|
4
3
|
function transformerCompileClass(options = {}) {
|
|
5
4
|
const { trigger = /(["'`])\s*:uno-?(?<name>\S+)?:\s([\s\S]*?)\1/g, classPrefix = "uno-", hashFn = hash, keepUnknown = true, alwaysHash = false } = options;
|
|
@@ -24,14 +23,14 @@ function transformerCompileClass(options = {}) {
|
|
|
24
23
|
body = known.join(" ");
|
|
25
24
|
}
|
|
26
25
|
if (body) {
|
|
27
|
-
let hash
|
|
26
|
+
let hash;
|
|
28
27
|
let explicitName = false;
|
|
29
28
|
if (match.groups && match.groups.name) {
|
|
30
|
-
hash
|
|
31
|
-
if (alwaysHash) hash
|
|
29
|
+
hash = match.groups.name;
|
|
30
|
+
if (alwaysHash) hash += `-${hashFn(body)}`;
|
|
32
31
|
explicitName = true;
|
|
33
|
-
} else hash
|
|
34
|
-
const className = `${classPrefix}${hash
|
|
32
|
+
} else hash = hashFn(body);
|
|
33
|
+
const className = `${classPrefix}${hash}`;
|
|
35
34
|
if (tokens && tokens.has(className) && explicitName) {
|
|
36
35
|
const existing = uno.config.shortcuts.find((i) => i[0] === className);
|
|
37
36
|
if (existing && existing[1] !== body) throw new Error(`Duplicated compile class name "${className}". One is "${body}" and the other is "${existing[1]}". Please choose different class name or set 'alwaysHash' to 'true'.`);
|
|
@@ -62,6 +61,5 @@ function hash(str) {
|
|
|
62
61
|
}
|
|
63
62
|
return `00000${(hval >>> 0).toString(36)}`.slice(-6);
|
|
64
63
|
}
|
|
65
|
-
|
|
66
64
|
//#endregion
|
|
67
|
-
export { transformerCompileClass as default };
|
|
65
|
+
export { transformerCompileClass as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-compile-class",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.6.
|
|
4
|
+
"version": "66.6.7",
|
|
5
5
|
"description": "Compile group of classes into one class",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@unocss/core": "66.6.
|
|
32
|
+
"@unocss/core": "66.6.7"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"magic-string": "^0.30.21"
|