@unocss/transformer-directives 0.57.7 → 0.58.1
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/README.md +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +6 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ Will be transformed to:
|
|
|
46
46
|
|
|
47
47
|
#### CSS Variable Style
|
|
48
48
|
|
|
49
|
-
To be compatible with vanilla CSS, you can use CSS
|
|
49
|
+
To be compatible with vanilla CSS, you can use CSS custom properties to replace the `@apply` directive.
|
|
50
50
|
|
|
51
51
|
```css
|
|
52
52
|
.custom-div {
|
package/dist/index.cjs
CHANGED
|
@@ -87,7 +87,7 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
|
|
|
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 (
|
|
90
|
+
if (/^(['"]).*\1$/.test(body))
|
|
91
91
|
body = body.slice(1, -1);
|
|
92
92
|
}
|
|
93
93
|
if (!body)
|
|
@@ -130,7 +130,10 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
|
|
|
130
130
|
css = `${parent}{${css}}`;
|
|
131
131
|
code.appendLeft(calcOffset(node.loc.end.offset), css);
|
|
132
132
|
} else {
|
|
133
|
-
|
|
133
|
+
if (body2.includes("@"))
|
|
134
|
+
code.appendRight(code.original.length, body2);
|
|
135
|
+
else
|
|
136
|
+
code.appendRight(calcOffset(childNode.loc.end.offset), body2);
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
code.remove(
|
|
@@ -143,7 +146,7 @@ function transformerDirectives(options = {}) {
|
|
|
143
146
|
return {
|
|
144
147
|
name: "@unocss/transformer-directives",
|
|
145
148
|
enforce: options?.enforce,
|
|
146
|
-
idFilter: (id) =>
|
|
149
|
+
idFilter: (id) => core.cssIdRE.test(id),
|
|
147
150
|
transform: (code, id, ctx) => {
|
|
148
151
|
return transformDirectives(code, ctx.uno, options, id);
|
|
149
152
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ interface TransformerDirectivesOptions {
|
|
|
10
10
|
*/
|
|
11
11
|
throwOnMissing?: boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Treat CSS
|
|
13
|
+
* Treat CSS custom properties as @apply directives for CSS syntax compatibility.
|
|
14
14
|
*
|
|
15
15
|
* Pass `false` to disable.
|
|
16
16
|
*
|
|
@@ -18,7 +18,7 @@ interface TransformerDirectivesOptions {
|
|
|
18
18
|
*/
|
|
19
19
|
applyVariable?: false | string | string[];
|
|
20
20
|
/**
|
|
21
|
-
* Treat CSS
|
|
21
|
+
* Treat CSS custom properties as directives for CSS syntax compatibility.
|
|
22
22
|
*
|
|
23
23
|
* Pass `false` to disable, or a string to use as a prefix.
|
|
24
24
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ interface TransformerDirectivesOptions {
|
|
|
10
10
|
*/
|
|
11
11
|
throwOnMissing?: boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Treat CSS
|
|
13
|
+
* Treat CSS custom properties as @apply directives for CSS syntax compatibility.
|
|
14
14
|
*
|
|
15
15
|
* Pass `false` to disable.
|
|
16
16
|
*
|
|
@@ -18,7 +18,7 @@ interface TransformerDirectivesOptions {
|
|
|
18
18
|
*/
|
|
19
19
|
applyVariable?: false | string | string[];
|
|
20
20
|
/**
|
|
21
|
-
* Treat CSS
|
|
21
|
+
* Treat CSS custom properties as directives for CSS syntax compatibility.
|
|
22
22
|
*
|
|
23
23
|
* Pass `false` to disable, or a string to use as a prefix.
|
|
24
24
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface TransformerDirectivesOptions {
|
|
|
10
10
|
*/
|
|
11
11
|
throwOnMissing?: boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Treat CSS
|
|
13
|
+
* Treat CSS custom properties as @apply directives for CSS syntax compatibility.
|
|
14
14
|
*
|
|
15
15
|
* Pass `false` to disable.
|
|
16
16
|
*
|
|
@@ -18,7 +18,7 @@ interface TransformerDirectivesOptions {
|
|
|
18
18
|
*/
|
|
19
19
|
applyVariable?: false | string | string[];
|
|
20
20
|
/**
|
|
21
|
-
* Treat CSS
|
|
21
|
+
* Treat CSS custom properties as directives for CSS syntax compatibility.
|
|
22
22
|
*
|
|
23
23
|
* Pass `false` to disable, or a string to use as a prefix.
|
|
24
24
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -83,7 +83,7 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
|
|
|
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 (
|
|
86
|
+
if (/^(['"]).*\1$/.test(body))
|
|
87
87
|
body = body.slice(1, -1);
|
|
88
88
|
}
|
|
89
89
|
if (!body)
|
|
@@ -126,7 +126,10 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
|
|
|
126
126
|
css = `${parent}{${css}}`;
|
|
127
127
|
code.appendLeft(calcOffset(node.loc.end.offset), css);
|
|
128
128
|
} else {
|
|
129
|
-
|
|
129
|
+
if (body2.includes("@"))
|
|
130
|
+
code.appendRight(code.original.length, body2);
|
|
131
|
+
else
|
|
132
|
+
code.appendRight(calcOffset(childNode.loc.end.offset), body2);
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
135
|
code.remove(
|
|
@@ -139,7 +142,7 @@ function transformerDirectives(options = {}) {
|
|
|
139
142
|
return {
|
|
140
143
|
name: "@unocss/transformer-directives",
|
|
141
144
|
enforce: options?.enforce,
|
|
142
|
-
idFilter: (id) =>
|
|
145
|
+
idFilter: (id) => cssIdRE.test(id),
|
|
143
146
|
transform: (code, id, ctx) => {
|
|
144
147
|
return transformDirectives(code, ctx.uno, options, id);
|
|
145
148
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-directives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.1",
|
|
4
4
|
"description": "UnoCSS transformer for `@apply` directive",
|
|
5
5
|
"author": "hannoeru <me@hanlee.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"css-tree": "^2.3.1",
|
|
36
|
-
"@unocss/core": "0.
|
|
37
|
-
"@unocss/rule-utils": "0.
|
|
36
|
+
"@unocss/core": "0.58.1",
|
|
37
|
+
"@unocss/rule-utils": "0.58.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"magic-string": "^0.30.5"
|