@unocss/transformer-compile-class 0.56.1 → 0.56.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.
- package/dist/index.cjs +6 -1
- package/dist/index.mjs +6 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -9,14 +9,16 @@ function transformerCompileClass(options = {}) {
|
|
|
9
9
|
hashFn = hash,
|
|
10
10
|
keepUnknown = true
|
|
11
11
|
} = options;
|
|
12
|
+
const compiledClass = /* @__PURE__ */ new Set();
|
|
12
13
|
const regexp = typeof trigger === "string" ? RegExp(`(["'\`])${core.escapeRegExp(trigger)}\\s([^\\1]*?)\\1`, "g") : trigger;
|
|
13
14
|
return {
|
|
14
15
|
name: "@unocss/transformer-compile-class",
|
|
15
16
|
enforce: "pre",
|
|
16
|
-
async transform(s, _, { uno, tokens }) {
|
|
17
|
+
async transform(s, _, { uno, tokens, invalidate }) {
|
|
17
18
|
const matches = [...s.original.matchAll(regexp)];
|
|
18
19
|
if (!matches.length)
|
|
19
20
|
return;
|
|
21
|
+
const size = compiledClass.size;
|
|
20
22
|
for (const match of matches) {
|
|
21
23
|
let body = match.length === 4 && match.groups ? core.expandVariantGroup(match[3].trim()) : core.expandVariantGroup(match[2].trim());
|
|
22
24
|
const start = match.index;
|
|
@@ -44,6 +46,7 @@ function transformerCompileClass(options = {}) {
|
|
|
44
46
|
if (existing && existing[1] !== body)
|
|
45
47
|
throw new Error(`Duplicated compile class name "${className}". One is "${body}" and the other is "${existing[1]}" Please choose different class name`);
|
|
46
48
|
}
|
|
49
|
+
compiledClass.add(className);
|
|
47
50
|
replacements.unshift(className);
|
|
48
51
|
if (options.layer)
|
|
49
52
|
uno.config.shortcuts.push([className, body, { layer: options.layer }]);
|
|
@@ -54,6 +57,8 @@ function transformerCompileClass(options = {}) {
|
|
|
54
57
|
}
|
|
55
58
|
s.overwrite(start + 1, start + match[0].length - 1, replacements.join(" "));
|
|
56
59
|
}
|
|
60
|
+
if (compiledClass.size > size)
|
|
61
|
+
invalidate();
|
|
57
62
|
}
|
|
58
63
|
};
|
|
59
64
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -7,14 +7,16 @@ function transformerCompileClass(options = {}) {
|
|
|
7
7
|
hashFn = hash,
|
|
8
8
|
keepUnknown = true
|
|
9
9
|
} = options;
|
|
10
|
+
const compiledClass = /* @__PURE__ */ new Set();
|
|
10
11
|
const regexp = typeof trigger === "string" ? RegExp(`(["'\`])${escapeRegExp(trigger)}\\s([^\\1]*?)\\1`, "g") : trigger;
|
|
11
12
|
return {
|
|
12
13
|
name: "@unocss/transformer-compile-class",
|
|
13
14
|
enforce: "pre",
|
|
14
|
-
async transform(s, _, { uno, tokens }) {
|
|
15
|
+
async transform(s, _, { uno, tokens, invalidate }) {
|
|
15
16
|
const matches = [...s.original.matchAll(regexp)];
|
|
16
17
|
if (!matches.length)
|
|
17
18
|
return;
|
|
19
|
+
const size = compiledClass.size;
|
|
18
20
|
for (const match of matches) {
|
|
19
21
|
let body = match.length === 4 && match.groups ? expandVariantGroup(match[3].trim()) : expandVariantGroup(match[2].trim());
|
|
20
22
|
const start = match.index;
|
|
@@ -42,6 +44,7 @@ function transformerCompileClass(options = {}) {
|
|
|
42
44
|
if (existing && existing[1] !== body)
|
|
43
45
|
throw new Error(`Duplicated compile class name "${className}". One is "${body}" and the other is "${existing[1]}" Please choose different class name`);
|
|
44
46
|
}
|
|
47
|
+
compiledClass.add(className);
|
|
45
48
|
replacements.unshift(className);
|
|
46
49
|
if (options.layer)
|
|
47
50
|
uno.config.shortcuts.push([className, body, { layer: options.layer }]);
|
|
@@ -52,6 +55,8 @@ function transformerCompileClass(options = {}) {
|
|
|
52
55
|
}
|
|
53
56
|
s.overwrite(start + 1, start + match[0].length - 1, replacements.join(" "));
|
|
54
57
|
}
|
|
58
|
+
if (compiledClass.size > size)
|
|
59
|
+
invalidate();
|
|
55
60
|
}
|
|
56
61
|
};
|
|
57
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-compile-class",
|
|
3
|
-
"version": "0.56.
|
|
3
|
+
"version": "0.56.3",
|
|
4
4
|
"description": "Compile group of classes into one class",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@unocss/core": "0.56.
|
|
36
|
+
"@unocss/core": "0.56.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"magic-string": "^0.30.3"
|