@unocss/transformer-directives 0.62.2 → 0.62.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.mjs +8 -6
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -98,7 +98,7 @@ async function parseApply({ code, uno, applyVariable }, node, childNode) {
|
|
|
98
98
|
}, []);
|
|
99
99
|
if (!utils.length)
|
|
100
100
|
return;
|
|
101
|
-
|
|
101
|
+
let simicolonOffset = original[childNode.loc.end.offset] === ";" ? 1 : original[childNode.loc.end.offset] === "@" ? -1 : 0;
|
|
102
102
|
for (const i of utils) {
|
|
103
103
|
const [, _selector, body2, parent] = i;
|
|
104
104
|
const selectorOrGroup = _selector?.replace(regexScopePlaceholder, " ") || _selector;
|
|
@@ -124,10 +124,11 @@ async function parseApply({ code, uno, applyVariable }, node, childNode) {
|
|
|
124
124
|
let css = `${newSelector.replace(/.\\-/g, className)}{${body2}}`;
|
|
125
125
|
if (parent)
|
|
126
126
|
css = `${parent}{${css}}`;
|
|
127
|
+
simicolonOffset = 0;
|
|
127
128
|
code.appendLeft(node.loc.end.offset, css);
|
|
128
129
|
} else {
|
|
129
130
|
if (body2.includes("@"))
|
|
130
|
-
code.appendRight(original.length
|
|
131
|
+
code.appendRight(original.length, body2);
|
|
131
132
|
else
|
|
132
133
|
code.appendRight(childNode.loc.end.offset + simicolonOffset, body2);
|
|
133
134
|
}
|
|
@@ -167,12 +168,13 @@ async function transformDirectives(code, uno, options, filename, originalCode, o
|
|
|
167
168
|
applyVariable = ["--at-apply", "--uno-apply", "--uno"];
|
|
168
169
|
}
|
|
169
170
|
applyVariable = toArray(applyVariable || []);
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
const
|
|
171
|
+
const parseCode = originalCode || code.original;
|
|
172
|
+
const hasApply = parseCode.includes("@apply") || applyVariable.some((s) => parseCode.includes(s));
|
|
173
|
+
const hasScreen = parseCode.includes("@screen");
|
|
174
|
+
const hasThemeFn$1 = hasThemeFn(parseCode);
|
|
173
175
|
if (!hasApply && !hasThemeFn$1 && !hasScreen)
|
|
174
176
|
return;
|
|
175
|
-
const ast = parse(
|
|
177
|
+
const ast = parse(parseCode, {
|
|
176
178
|
parseCustomProperty: true,
|
|
177
179
|
parseAtrulePrelude: false,
|
|
178
180
|
positions: true,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-directives",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.62.
|
|
4
|
+
"version": "0.62.3",
|
|
5
5
|
"description": "UnoCSS transformer for `@apply` directive",
|
|
6
6
|
"author": "hannoeru <me@hanlee.co>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"css-tree": "^2.3.1",
|
|
36
|
-
"@unocss/
|
|
37
|
-
"@unocss/
|
|
36
|
+
"@unocss/core": "0.62.3",
|
|
37
|
+
"@unocss/rule-utils": "0.62.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"magic-string": "^0.30.11"
|