@unocss/transformer-directives 66.3.1 → 66.3.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 +12 -2
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -154,12 +154,22 @@ async function handleFunction({ code, uno, options }, node) {
|
|
|
154
154
|
const { throwOnMissing = true } = options;
|
|
155
155
|
switch (node.name) {
|
|
156
156
|
case "theme": {
|
|
157
|
-
if (node.children.size
|
|
157
|
+
if (!node.children.size)
|
|
158
158
|
throw new Error("theme() expect exact one argument");
|
|
159
159
|
if (node.children.first.type !== "String")
|
|
160
160
|
throw new Error("theme() expect a string argument");
|
|
161
|
+
let defaultValueLoc;
|
|
162
|
+
if (node.children.size > 1) {
|
|
163
|
+
const remains = node.children.toArray().slice(1);
|
|
164
|
+
if (!(remains[0].type === "Operator" && remains[0].value === ","))
|
|
165
|
+
throw new Error("theme() expect a comma between expression string and default value");
|
|
166
|
+
if (remains.length > 1)
|
|
167
|
+
defaultValueLoc = [remains[1].loc.start.offset, node.children.last.loc.end.offset];
|
|
168
|
+
}
|
|
161
169
|
const themeStr = node.children.first.value;
|
|
162
|
-
|
|
170
|
+
let value = transformThemeString(themeStr, uno.config.theme, !defaultValueLoc && throwOnMissing);
|
|
171
|
+
if (!value && defaultValueLoc)
|
|
172
|
+
value = code.slice(defaultValueLoc[0], defaultValueLoc[1]);
|
|
163
173
|
if (value)
|
|
164
174
|
code.overwrite(node.loc.start.offset, node.loc.end.offset, value);
|
|
165
175
|
break;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-directives",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.3.
|
|
4
|
+
"version": "66.3.3",
|
|
5
5
|
"description": "UnoCSS transformer for `@apply` directive",
|
|
6
6
|
"author": "hannoeru <me@hanlee.co>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://unocss.dev",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/unocss/unocss",
|
|
11
|
+
"url": "git+https://github.com/unocss/unocss.git",
|
|
12
12
|
"directory": "packages-presets/transformer-directives"
|
|
13
13
|
},
|
|
14
14
|
"bugs": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"css-tree": "^3.1.0",
|
|
36
|
-
"@unocss/core": "66.3.
|
|
37
|
-
"@unocss/rule-utils": "66.3.
|
|
36
|
+
"@unocss/core": "66.3.3",
|
|
37
|
+
"@unocss/rule-utils": "66.3.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"magic-string": "^0.30.17"
|