@unocss/postcss 0.55.7 → 0.56.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/dist/index.cjs +8 -1
- package/dist/index.mjs +8 -1
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const postcss = require('postcss');
|
|
|
8
8
|
const core = require('@unocss/core');
|
|
9
9
|
const config = require('@unocss/config');
|
|
10
10
|
const cssTree = require('css-tree');
|
|
11
|
+
const ruleUtils = require('@unocss/rule-utils');
|
|
11
12
|
const MagicString = require('magic-string');
|
|
12
13
|
|
|
13
14
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
@@ -96,8 +97,9 @@ async function parseTheme(root, uno, directiveName) {
|
|
|
96
97
|
const rawArg = match[1].trim();
|
|
97
98
|
if (!rawArg)
|
|
98
99
|
throw new Error(`${directiveName}() expect exact one argument, but got 0`);
|
|
100
|
+
const [rawKey, alpha] = rawArg.slice(1, -1).split("/");
|
|
99
101
|
let value = uno.config.theme;
|
|
100
|
-
const keys =
|
|
102
|
+
const keys = rawKey.trim().split(".");
|
|
101
103
|
keys.every((key) => {
|
|
102
104
|
if (value[key] != null)
|
|
103
105
|
value = value[key];
|
|
@@ -108,6 +110,11 @@ async function parseTheme(root, uno, directiveName) {
|
|
|
108
110
|
return true;
|
|
109
111
|
});
|
|
110
112
|
if (typeof value === "string") {
|
|
113
|
+
if (alpha) {
|
|
114
|
+
const color = ruleUtils.parseCssColor(value);
|
|
115
|
+
if (color)
|
|
116
|
+
value = ruleUtils.colorToString(color, alpha);
|
|
117
|
+
}
|
|
111
118
|
const code = new MagicString__default(decl.value);
|
|
112
119
|
code.overwrite(
|
|
113
120
|
match.index,
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import postcss from 'postcss';
|
|
|
6
6
|
import { expandVariantGroup, notNull, regexScopePlaceholder, warnOnce, createGenerator } from '@unocss/core';
|
|
7
7
|
import { loadConfig } from '@unocss/config';
|
|
8
8
|
import { parse, generate, clone } from 'css-tree';
|
|
9
|
+
import { parseCssColor, colorToString } from '@unocss/rule-utils';
|
|
9
10
|
import MagicString from 'magic-string';
|
|
10
11
|
|
|
11
12
|
const defaultFilesystemGlobs = [
|
|
@@ -87,8 +88,9 @@ async function parseTheme(root, uno, directiveName) {
|
|
|
87
88
|
const rawArg = match[1].trim();
|
|
88
89
|
if (!rawArg)
|
|
89
90
|
throw new Error(`${directiveName}() expect exact one argument, but got 0`);
|
|
91
|
+
const [rawKey, alpha] = rawArg.slice(1, -1).split("/");
|
|
90
92
|
let value = uno.config.theme;
|
|
91
|
-
const keys =
|
|
93
|
+
const keys = rawKey.trim().split(".");
|
|
92
94
|
keys.every((key) => {
|
|
93
95
|
if (value[key] != null)
|
|
94
96
|
value = value[key];
|
|
@@ -99,6 +101,11 @@ async function parseTheme(root, uno, directiveName) {
|
|
|
99
101
|
return true;
|
|
100
102
|
});
|
|
101
103
|
if (typeof value === "string") {
|
|
104
|
+
if (alpha) {
|
|
105
|
+
const color = parseCssColor(value);
|
|
106
|
+
if (color)
|
|
107
|
+
value = colorToString(color, alpha);
|
|
108
|
+
}
|
|
102
109
|
const code = new MagicString(decl.value);
|
|
103
110
|
code.overwrite(
|
|
104
111
|
match.index,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/postcss",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.1",
|
|
4
4
|
"description": "PostCSS plugin for UnoCSS",
|
|
5
5
|
"author": "sibbng <sibbngheid@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,9 +39,10 @@
|
|
|
39
39
|
"css-tree": "^2.3.1",
|
|
40
40
|
"fast-glob": "^3.3.1",
|
|
41
41
|
"magic-string": "^0.30.3",
|
|
42
|
-
"postcss": "^8.4.
|
|
43
|
-
"@unocss/config": "0.
|
|
44
|
-
"@unocss/core": "0.
|
|
42
|
+
"postcss": "^8.4.30",
|
|
43
|
+
"@unocss/config": "0.56.1",
|
|
44
|
+
"@unocss/core": "0.56.1",
|
|
45
|
+
"@unocss/rule-utils": "0.56.1"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
48
|
"build": "unbuild",
|