@unocss/transformer-directives 66.1.2 → 66.1.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 +5 -14
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expandVariantGroup, notNull, regexScopePlaceholder, toArray, cssIdRE } from '@unocss/core';
|
|
2
|
-
import { transformThemeFn, transformThemeString, hasThemeFn, hasIconFn } from '@unocss/rule-utils';
|
|
2
|
+
import { transformThemeFn, transformThemeString, calcMaxWidthBySize, hasThemeFn, hasIconFn } from '@unocss/rule-utils';
|
|
3
3
|
import { generate, parse, clone, List, walk } from 'css-tree';
|
|
4
4
|
|
|
5
5
|
async function handleApply(ctx, node) {
|
|
@@ -44,9 +44,9 @@ async function parseApply({ code, uno, applyVariable }, node, childNode) {
|
|
|
44
44
|
return;
|
|
45
45
|
let semicolonOffset = original[childNode.loc.end.offset] === ";" ? 1 : original[childNode.loc.end.offset] === "@" ? -1 : 0;
|
|
46
46
|
for (const i of utils) {
|
|
47
|
-
const [, _selector, body2, parent] = i;
|
|
47
|
+
const [, _selector, body2, parent, meta] = i;
|
|
48
48
|
const selectorOrGroup = _selector?.replace(regexScopePlaceholder, " ") || _selector;
|
|
49
|
-
if (parent || selectorOrGroup && selectorOrGroup !== ".\\-"
|
|
49
|
+
if (parent || selectorOrGroup && selectorOrGroup !== ".\\-" || meta?.noMerge) {
|
|
50
50
|
let newSelector = generate(node.prelude);
|
|
51
51
|
const className = code.slice(node.prelude.loc.start.offset, node.prelude.loc.end.offset);
|
|
52
52
|
if (selectorOrGroup && selectorOrGroup !== ".\\-") {
|
|
@@ -194,11 +194,8 @@ function handleScreen({ code, uno }, node) {
|
|
|
194
194
|
breakpointName = match[2];
|
|
195
195
|
}
|
|
196
196
|
const resolveBreakpoints = () => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
breakpoints = uno.userConfig.theme.breakpoints;
|
|
200
|
-
if (!breakpoints)
|
|
201
|
-
breakpoints = uno.config.theme.breakpoints;
|
|
197
|
+
const key = uno.config.presets.some((p) => p.name === "@unocss/preset-wind4") ? "breakpoint" : "breakpoints";
|
|
198
|
+
const breakpoints = uno.config.theme[key];
|
|
202
199
|
return breakpoints ? Object.entries(breakpoints).sort((a, b) => Number.parseInt(a[1].replace(/[a-z]+/gi, "")) - Number.parseInt(b[1].replace(/[a-z]+/gi, ""))).map(([point, size]) => ({ point, size })) : void 0;
|
|
203
200
|
};
|
|
204
201
|
const variantEntries = (resolveBreakpoints() ?? []).map(({ point, size }, idx) => [point, size, idx]);
|
|
@@ -228,12 +225,6 @@ function handleScreen({ code, uno }, node) {
|
|
|
228
225
|
);
|
|
229
226
|
}
|
|
230
227
|
}
|
|
231
|
-
function calcMaxWidthBySize(size) {
|
|
232
|
-
const value = size.match(/^-?\d+\.?\d*/)?.[0] || "";
|
|
233
|
-
const unit = size.slice(value.length);
|
|
234
|
-
const maxWidth = Number.parseFloat(value) - 0.1;
|
|
235
|
-
return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
|
|
236
|
-
}
|
|
237
228
|
|
|
238
229
|
async function transformDirectives(code, uno, options, filename, originalCode, offset) {
|
|
239
230
|
let { applyVariable } = options;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-directives",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.1.
|
|
4
|
+
"version": "66.1.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": "^3.1.0",
|
|
36
|
-
"@unocss/core": "66.1.
|
|
37
|
-
"@unocss/rule-utils": "66.1.
|
|
36
|
+
"@unocss/core": "66.1.3",
|
|
37
|
+
"@unocss/rule-utils": "66.1.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"magic-string": "^0.30.17"
|