@unocss/postcss 66.6.6 → 66.6.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/esm.mjs +16 -22
- package/dist/index.cjs +5 -5
- package/dist/index.mjs +1 -3
- package/package.json +6 -6
package/dist/esm.mjs
CHANGED
|
@@ -7,10 +7,8 @@ import { calcMaxWidthBySize, hasThemeFn, transformThemeFn } from "@unocss/rule-u
|
|
|
7
7
|
import postcss from "postcss";
|
|
8
8
|
import { glob } from "tinyglobby";
|
|
9
9
|
import { clone, generate, parse } from "css-tree";
|
|
10
|
-
|
|
11
10
|
//#region ../../virtual-shared/integration/src/defaults.ts
|
|
12
11
|
const defaultFilesystemGlobs = ["**/*.{html,js,ts,jsx,tsx,vue,svelte,astro,elm,php,phtml,mdx,md,marko}"];
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
13
|
//#region src/apply.ts
|
|
16
14
|
async function parseApply(root, uno, directiveName) {
|
|
@@ -39,8 +37,8 @@ async function parseApply(root, uno, directiveName) {
|
|
|
39
37
|
const prelude = clone(node.prelude);
|
|
40
38
|
prelude.children.forEach((child) => {
|
|
41
39
|
const parentSelectorAst = clone(selectorAST);
|
|
42
|
-
parentSelectorAst.children.forEach((i
|
|
43
|
-
if (i
|
|
40
|
+
parentSelectorAst.children.forEach((i) => {
|
|
41
|
+
if (i.type === "ClassSelector" && i.name === "\\-") Object.assign(i, clone(child));
|
|
44
42
|
});
|
|
45
43
|
Object.assign(child, parentSelectorAst);
|
|
46
44
|
});
|
|
@@ -67,7 +65,6 @@ async function parseApply(root, uno, directiveName) {
|
|
|
67
65
|
});
|
|
68
66
|
await Promise.all(promises);
|
|
69
67
|
}
|
|
70
|
-
|
|
71
68
|
//#endregion
|
|
72
69
|
//#region src/screen.ts
|
|
73
70
|
async function parseScreen(root, uno, directiveName) {
|
|
@@ -94,11 +91,11 @@ async function parseScreen(root, uno, directiveName) {
|
|
|
94
91
|
size,
|
|
95
92
|
idx
|
|
96
93
|
]);
|
|
97
|
-
const generateMediaQuery = (breakpointName
|
|
98
|
-
const [, size, idx] = variantEntries.find((i) => i[0] === breakpointName
|
|
99
|
-
if (prefix
|
|
100
|
-
else if (prefix
|
|
101
|
-
else throw new Error(`breakpoint variant not supported: ${prefix
|
|
94
|
+
const generateMediaQuery = (breakpointName, prefix) => {
|
|
95
|
+
const [, size, idx] = variantEntries.find((i) => i[0] === breakpointName);
|
|
96
|
+
if (prefix) if (prefix === "lt") return `(max-width: ${calcMaxWidthBySize(size)})`;
|
|
97
|
+
else if (prefix === "at") return `(min-width: ${size})${variantEntries[idx + 1] ? ` and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})` : ""}`;
|
|
98
|
+
else throw new Error(`breakpoint variant not supported: ${prefix}`);
|
|
102
99
|
return `(min-width: ${size})`;
|
|
103
100
|
};
|
|
104
101
|
if (!variantEntries.find((i) => i[0] === breakpointName)) throw new Error(`breakpoint ${breakpointName} not found`);
|
|
@@ -106,7 +103,6 @@ async function parseScreen(root, uno, directiveName) {
|
|
|
106
103
|
rule.params = `${generateMediaQuery(breakpointName, prefix)}`;
|
|
107
104
|
});
|
|
108
105
|
}
|
|
109
|
-
|
|
110
106
|
//#endregion
|
|
111
107
|
//#region src/theme.ts
|
|
112
108
|
async function parseTheme(root, uno) {
|
|
@@ -114,7 +110,6 @@ async function parseTheme(root, uno) {
|
|
|
114
110
|
decl.value = transformThemeFn(decl.value, uno.config.theme);
|
|
115
111
|
});
|
|
116
112
|
}
|
|
117
|
-
|
|
118
113
|
//#endregion
|
|
119
114
|
//#region src/esm.ts
|
|
120
115
|
function createPlugin(options) {
|
|
@@ -182,10 +177,10 @@ function createPlugin(options) {
|
|
|
182
177
|
await parseApply(root, uno, directiveMap.apply);
|
|
183
178
|
await parseTheme(root, uno);
|
|
184
179
|
await parseScreen(root, uno, directiveMap.screen);
|
|
185
|
-
promises.push(...plainContent.map(async (c
|
|
186
|
-
if (typeof c
|
|
187
|
-
if (typeof c
|
|
188
|
-
const { matched } = await uno.generate(c
|
|
180
|
+
promises.push(...plainContent.map(async (c, idx) => {
|
|
181
|
+
if (typeof c === "function") c = await c();
|
|
182
|
+
if (typeof c === "string") c = { code: c };
|
|
183
|
+
const { matched } = await uno.generate(c.code, { id: c.id ?? `__plain_content_${idx}__` });
|
|
189
184
|
for (const candidate of matched) classes.add(candidate);
|
|
190
185
|
}));
|
|
191
186
|
await Promise.all(promises);
|
|
@@ -227,15 +222,15 @@ function createPlugin(options) {
|
|
|
227
222
|
} else includeLayers.push(name);
|
|
228
223
|
}
|
|
229
224
|
if (excludeLayers.length > 0 && includeLayers.length > 0) console.warn(`Warning: Mixing normal and negated layer names in "@${directiveMap.unocss} ${rule.params}" is not recommended.`);
|
|
230
|
-
let result
|
|
225
|
+
let result = "";
|
|
231
226
|
if (includeLayers.length > 0) {
|
|
232
|
-
result
|
|
227
|
+
result = includeLayers.map((i) => (i === "all" ? c.getLayers() : c.getLayer(i)) || "").filter(Boolean).join("\n");
|
|
233
228
|
excludes.push(...includeLayers);
|
|
234
229
|
} else if (excludeLayers.length > 0) {
|
|
235
|
-
result
|
|
230
|
+
result = c.getLayers(void 0, excludeLayers) || "";
|
|
236
231
|
excludes.push(...excludeLayers);
|
|
237
232
|
}
|
|
238
|
-
const css = postcss.parse(result
|
|
233
|
+
const css = postcss.parse(result);
|
|
239
234
|
css.walkDecls((declaration) => {
|
|
240
235
|
declaration.source = source;
|
|
241
236
|
});
|
|
@@ -250,6 +245,5 @@ function createPlugin(options) {
|
|
|
250
245
|
});
|
|
251
246
|
};
|
|
252
247
|
}
|
|
253
|
-
|
|
254
248
|
//#endregion
|
|
255
|
-
export { createPlugin };
|
|
249
|
+
export { createPlugin };
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
3
5
|
//#region src/index.ts
|
|
4
6
|
function unocss(options = {}) {
|
|
5
7
|
var _options$directiveMap;
|
|
@@ -14,7 +16,5 @@ function unocss(options = {}) {
|
|
|
14
16
|
}
|
|
15
17
|
unocss.postcss = true;
|
|
16
18
|
unocss.default = unocss;
|
|
17
|
-
var src_default = unocss;
|
|
18
|
-
|
|
19
19
|
//#endregion
|
|
20
|
-
exports.default =
|
|
20
|
+
exports.default = unocss;
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/postcss",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.6.
|
|
4
|
+
"version": "66.6.7",
|
|
5
5
|
"description": "PostCSS plugin for UnoCSS",
|
|
6
6
|
"author": "sibbng <sibbngheid@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"import": "./dist/index.mjs",
|
|
23
|
+
"require": "./dist/index.cjs"
|
|
24
24
|
},
|
|
25
25
|
"./esm": "./dist/esm.mjs",
|
|
26
26
|
"./package.json": "./package.json"
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"css-tree": "^3.1.0",
|
|
51
51
|
"postcss": "^8.5.6",
|
|
52
52
|
"tinyglobby": "^0.2.15",
|
|
53
|
-
"@unocss/config": "66.6.
|
|
54
|
-
"@unocss/
|
|
55
|
-
"@unocss/
|
|
53
|
+
"@unocss/config": "66.6.7",
|
|
54
|
+
"@unocss/rule-utils": "66.6.7",
|
|
55
|
+
"@unocss/core": "66.6.7"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsdown --config-loader unrun",
|