@unocss/transformer-directives 0.58.5 → 0.58.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.cjs +8 -8
- package/dist/index.mjs +8 -8
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -83,15 +83,14 @@ async function handleApply(ctx, node) {
|
|
|
83
83
|
async function parseApply({ code, uno, offset, applyVariable }, node, childNode) {
|
|
84
84
|
const calcOffset = (pos) => offset ? pos + offset : pos;
|
|
85
85
|
let body;
|
|
86
|
-
if (childNode.type === "Atrule" && childNode.name === "apply" && childNode.prelude && childNode.prelude.type === "Raw")
|
|
86
|
+
if (childNode.type === "Atrule" && childNode.name === "apply" && childNode.prelude && childNode.prelude.type === "Raw")
|
|
87
87
|
body = childNode.prelude.value.trim();
|
|
88
|
-
|
|
88
|
+
else if (childNode.type === "Declaration" && applyVariable.includes(childNode.property) && childNode.value.type === "Raw")
|
|
89
89
|
body = childNode.value.value.trim();
|
|
90
|
-
if (/^(['"]).*\1$/.test(body))
|
|
91
|
-
body = body.slice(1, -1);
|
|
92
|
-
}
|
|
93
90
|
if (!body)
|
|
94
91
|
return;
|
|
92
|
+
if (/^(['"]).*\1$/.test(body))
|
|
93
|
+
body = body.slice(1, -1);
|
|
95
94
|
const classNames = core.expandVariantGroup(body).split(/\s+/g).map((className) => className.trim().replace(/\\/, ""));
|
|
96
95
|
const utils = (await Promise.all(
|
|
97
96
|
classNames.map((i) => uno.parseToken(i, "-"))
|
|
@@ -105,6 +104,7 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
|
|
|
105
104
|
}, []);
|
|
106
105
|
if (!utils.length)
|
|
107
106
|
return;
|
|
107
|
+
const simicolonOffset = code.toString()[childNode.loc.end.offset] === ";" ? 1 : 0;
|
|
108
108
|
for (const i of utils) {
|
|
109
109
|
const [, _selector, body2, parent] = i;
|
|
110
110
|
const selectorOrGroup = _selector?.replace(core.regexScopePlaceholder, " ") || _selector;
|
|
@@ -132,14 +132,14 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
|
|
|
132
132
|
code.appendLeft(calcOffset(node.loc.end.offset), css);
|
|
133
133
|
} else {
|
|
134
134
|
if (body2.includes("@"))
|
|
135
|
-
code.appendRight(code.original.length, body2);
|
|
135
|
+
code.appendRight(code.original.length + simicolonOffset, body2);
|
|
136
136
|
else
|
|
137
|
-
code.appendRight(calcOffset(childNode.loc.end.offset), body2);
|
|
137
|
+
code.appendRight(calcOffset(childNode.loc.end.offset + simicolonOffset), body2);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
code.remove(
|
|
141
141
|
calcOffset(childNode.loc.start.offset),
|
|
142
|
-
calcOffset(childNode.loc.end.offset)
|
|
142
|
+
calcOffset(childNode.loc.end.offset + simicolonOffset)
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
145
|
|
package/dist/index.mjs
CHANGED
|
@@ -79,15 +79,14 @@ async function handleApply(ctx, node) {
|
|
|
79
79
|
async function parseApply({ code, uno, offset, applyVariable }, node, childNode) {
|
|
80
80
|
const calcOffset = (pos) => offset ? pos + offset : pos;
|
|
81
81
|
let body;
|
|
82
|
-
if (childNode.type === "Atrule" && childNode.name === "apply" && childNode.prelude && childNode.prelude.type === "Raw")
|
|
82
|
+
if (childNode.type === "Atrule" && childNode.name === "apply" && childNode.prelude && childNode.prelude.type === "Raw")
|
|
83
83
|
body = childNode.prelude.value.trim();
|
|
84
|
-
|
|
84
|
+
else if (childNode.type === "Declaration" && applyVariable.includes(childNode.property) && childNode.value.type === "Raw")
|
|
85
85
|
body = childNode.value.value.trim();
|
|
86
|
-
if (/^(['"]).*\1$/.test(body))
|
|
87
|
-
body = body.slice(1, -1);
|
|
88
|
-
}
|
|
89
86
|
if (!body)
|
|
90
87
|
return;
|
|
88
|
+
if (/^(['"]).*\1$/.test(body))
|
|
89
|
+
body = body.slice(1, -1);
|
|
91
90
|
const classNames = expandVariantGroup(body).split(/\s+/g).map((className) => className.trim().replace(/\\/, ""));
|
|
92
91
|
const utils = (await Promise.all(
|
|
93
92
|
classNames.map((i) => uno.parseToken(i, "-"))
|
|
@@ -101,6 +100,7 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
|
|
|
101
100
|
}, []);
|
|
102
101
|
if (!utils.length)
|
|
103
102
|
return;
|
|
103
|
+
const simicolonOffset = code.toString()[childNode.loc.end.offset] === ";" ? 1 : 0;
|
|
104
104
|
for (const i of utils) {
|
|
105
105
|
const [, _selector, body2, parent] = i;
|
|
106
106
|
const selectorOrGroup = _selector?.replace(regexScopePlaceholder, " ") || _selector;
|
|
@@ -128,14 +128,14 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
|
|
|
128
128
|
code.appendLeft(calcOffset(node.loc.end.offset), css);
|
|
129
129
|
} else {
|
|
130
130
|
if (body2.includes("@"))
|
|
131
|
-
code.appendRight(code.original.length, body2);
|
|
131
|
+
code.appendRight(code.original.length + simicolonOffset, body2);
|
|
132
132
|
else
|
|
133
|
-
code.appendRight(calcOffset(childNode.loc.end.offset), body2);
|
|
133
|
+
code.appendRight(calcOffset(childNode.loc.end.offset + simicolonOffset), body2);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
code.remove(
|
|
137
137
|
calcOffset(childNode.loc.start.offset),
|
|
138
|
-
calcOffset(childNode.loc.end.offset)
|
|
138
|
+
calcOffset(childNode.loc.end.offset + simicolonOffset)
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-directives",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.7",
|
|
4
4
|
"description": "UnoCSS transformer for `@apply` directive",
|
|
5
5
|
"author": "hannoeru <me@hanlee.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"css-tree": "^2.3.1",
|
|
36
|
-
"@unocss/core": "0.58.
|
|
37
|
-
"@unocss/rule-utils": "0.58.
|
|
36
|
+
"@unocss/core": "0.58.7",
|
|
37
|
+
"@unocss/rule-utils": "0.58.7"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"magic-string": "^0.30.
|
|
40
|
+
"magic-string": "^0.30.8"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "unbuild",
|