transform-to-unocss-core 0.0.68 → 0.0.70
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 +2 -2
- package/dist/index.cjs +17 -2
- package/dist/index.iife.js +17 -2
- package/dist/index.js +17 -2
- package/dist/index.umd.js +17 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
- 使用:toUnocss('width:100px', isRem) isRem 为true时,会将px转换为rem
|
|
8
8
|
- transformStyleToUnocss
|
|
9
9
|
- 用于行内属性
|
|
10
|
-
- 使用:transformStyleToUnocss("width:100px;height:100px;") isRem 为true时,会将px转换为rem[100px]"
|
|
10
|
+
- 使用:transformStyleToUnocss("width:100px;height:100px;") isRem 为true时,会将px转换为 "rem[100px]"
|
|
11
11
|
- toUnocssClass
|
|
12
12
|
- 用于类名
|
|
13
|
-
- 使用:toUnocssClass('width:100px', isRem) isRem 为true
|
|
13
|
+
- 使用:toUnocssClass('width:100px', isRem) isRem 为true时,会将px转换为rem
|
|
14
14
|
|
|
15
15
|
## License
|
|
16
16
|
|
package/dist/index.cjs
CHANGED
|
@@ -1316,6 +1316,7 @@ const textMap = [
|
|
|
1316
1316
|
"text-align",
|
|
1317
1317
|
"text-align-last",
|
|
1318
1318
|
"text-decoration-line",
|
|
1319
|
+
"text-decoration",
|
|
1319
1320
|
"text-decoration-style",
|
|
1320
1321
|
"text-decoration-color",
|
|
1321
1322
|
"text-decoration-thickness",
|
|
@@ -1338,6 +1339,7 @@ function text(key, val) {
|
|
|
1338
1339
|
if (value === "none") return `normal-case${important}`;
|
|
1339
1340
|
return `${value}${important}`;
|
|
1340
1341
|
}
|
|
1342
|
+
if (key === "text-decoration") return value;
|
|
1341
1343
|
if (key.startsWith("text-decoration") || key === "text-indent") return `${key.split("-")[1]}${getVal(value)}${important}`;
|
|
1342
1344
|
if (key === "text-underline-offset") return `underline-offset${getVal(value)}${important}`;
|
|
1343
1345
|
if (key === "text-align-last") return `${important}[${key}:${value}]`;
|
|
@@ -1633,6 +1635,16 @@ function toUnocss(css, isRem = false) {
|
|
|
1633
1635
|
|
|
1634
1636
|
//#endregion
|
|
1635
1637
|
//#region src/transformer.ts
|
|
1638
|
+
function findFirstColonOutsideBrackets(str) {
|
|
1639
|
+
let bracketDepth = 0;
|
|
1640
|
+
for (let i = 0; i < str.length; i++) {
|
|
1641
|
+
const char = str[i];
|
|
1642
|
+
if (char === "[") bracketDepth++;
|
|
1643
|
+
else if (char === "]") bracketDepth--;
|
|
1644
|
+
else if (char === ":" && bracketDepth === 0) return i;
|
|
1645
|
+
}
|
|
1646
|
+
return -1;
|
|
1647
|
+
}
|
|
1636
1648
|
function createRuleProcessor(config) {
|
|
1637
1649
|
return (v) => {
|
|
1638
1650
|
const anyMatch = config.anyMatch || [];
|
|
@@ -1715,8 +1727,11 @@ const transformer = {
|
|
|
1715
1727
|
function transformStyleToUnocssPre(styles) {
|
|
1716
1728
|
const preTransformedList = [];
|
|
1717
1729
|
const styleToObj = styles.split(";").filter(Boolean).reduce((r, item) => {
|
|
1718
|
-
const
|
|
1719
|
-
if (
|
|
1730
|
+
const splitIndex = findFirstColonOutsideBrackets(item);
|
|
1731
|
+
if (splitIndex === -1) return r;
|
|
1732
|
+
const key = item.substring(0, splitIndex).trim();
|
|
1733
|
+
const value = item.substring(splitIndex + 1).trim();
|
|
1734
|
+
if (key && value) r[key] = value;
|
|
1720
1735
|
return r;
|
|
1721
1736
|
}, {});
|
|
1722
1737
|
for (const key in transformer) {
|
package/dist/index.iife.js
CHANGED
|
@@ -1318,6 +1318,7 @@ const textMap = [
|
|
|
1318
1318
|
"text-align",
|
|
1319
1319
|
"text-align-last",
|
|
1320
1320
|
"text-decoration-line",
|
|
1321
|
+
"text-decoration",
|
|
1321
1322
|
"text-decoration-style",
|
|
1322
1323
|
"text-decoration-color",
|
|
1323
1324
|
"text-decoration-thickness",
|
|
@@ -1340,6 +1341,7 @@ function text(key, val) {
|
|
|
1340
1341
|
if (value === "none") return `normal-case${important}`;
|
|
1341
1342
|
return `${value}${important}`;
|
|
1342
1343
|
}
|
|
1344
|
+
if (key === "text-decoration") return value;
|
|
1343
1345
|
if (key.startsWith("text-decoration") || key === "text-indent") return `${key.split("-")[1]}${getVal(value)}${important}`;
|
|
1344
1346
|
if (key === "text-underline-offset") return `underline-offset${getVal(value)}${important}`;
|
|
1345
1347
|
if (key === "text-align-last") return `${important}[${key}:${value}]`;
|
|
@@ -1635,6 +1637,16 @@ function toUnocss(css, isRem = false) {
|
|
|
1635
1637
|
|
|
1636
1638
|
//#endregion
|
|
1637
1639
|
//#region src/transformer.ts
|
|
1640
|
+
function findFirstColonOutsideBrackets(str) {
|
|
1641
|
+
let bracketDepth = 0;
|
|
1642
|
+
for (let i = 0; i < str.length; i++) {
|
|
1643
|
+
const char = str[i];
|
|
1644
|
+
if (char === "[") bracketDepth++;
|
|
1645
|
+
else if (char === "]") bracketDepth--;
|
|
1646
|
+
else if (char === ":" && bracketDepth === 0) return i;
|
|
1647
|
+
}
|
|
1648
|
+
return -1;
|
|
1649
|
+
}
|
|
1638
1650
|
function createRuleProcessor(config) {
|
|
1639
1651
|
return (v) => {
|
|
1640
1652
|
const anyMatch = config.anyMatch || [];
|
|
@@ -1717,8 +1729,11 @@ const transformer = {
|
|
|
1717
1729
|
function transformStyleToUnocssPre(styles) {
|
|
1718
1730
|
const preTransformedList = [];
|
|
1719
1731
|
const styleToObj = styles.split(";").filter(Boolean).reduce((r, item) => {
|
|
1720
|
-
const
|
|
1721
|
-
if (
|
|
1732
|
+
const splitIndex = findFirstColonOutsideBrackets(item);
|
|
1733
|
+
if (splitIndex === -1) return r;
|
|
1734
|
+
const key = item.substring(0, splitIndex).trim();
|
|
1735
|
+
const value = item.substring(splitIndex + 1).trim();
|
|
1736
|
+
if (key && value) r[key] = value;
|
|
1722
1737
|
return r;
|
|
1723
1738
|
}, {});
|
|
1724
1739
|
for (const key in transformer) {
|
package/dist/index.js
CHANGED
|
@@ -1314,6 +1314,7 @@ const textMap = [
|
|
|
1314
1314
|
"text-align",
|
|
1315
1315
|
"text-align-last",
|
|
1316
1316
|
"text-decoration-line",
|
|
1317
|
+
"text-decoration",
|
|
1317
1318
|
"text-decoration-style",
|
|
1318
1319
|
"text-decoration-color",
|
|
1319
1320
|
"text-decoration-thickness",
|
|
@@ -1336,6 +1337,7 @@ function text(key, val) {
|
|
|
1336
1337
|
if (value === "none") return `normal-case${important}`;
|
|
1337
1338
|
return `${value}${important}`;
|
|
1338
1339
|
}
|
|
1340
|
+
if (key === "text-decoration") return value;
|
|
1339
1341
|
if (key.startsWith("text-decoration") || key === "text-indent") return `${key.split("-")[1]}${getVal(value)}${important}`;
|
|
1340
1342
|
if (key === "text-underline-offset") return `underline-offset${getVal(value)}${important}`;
|
|
1341
1343
|
if (key === "text-align-last") return `${important}[${key}:${value}]`;
|
|
@@ -1631,6 +1633,16 @@ function toUnocss(css, isRem = false) {
|
|
|
1631
1633
|
|
|
1632
1634
|
//#endregion
|
|
1633
1635
|
//#region src/transformer.ts
|
|
1636
|
+
function findFirstColonOutsideBrackets(str) {
|
|
1637
|
+
let bracketDepth = 0;
|
|
1638
|
+
for (let i = 0; i < str.length; i++) {
|
|
1639
|
+
const char = str[i];
|
|
1640
|
+
if (char === "[") bracketDepth++;
|
|
1641
|
+
else if (char === "]") bracketDepth--;
|
|
1642
|
+
else if (char === ":" && bracketDepth === 0) return i;
|
|
1643
|
+
}
|
|
1644
|
+
return -1;
|
|
1645
|
+
}
|
|
1634
1646
|
function createRuleProcessor(config) {
|
|
1635
1647
|
return (v) => {
|
|
1636
1648
|
const anyMatch = config.anyMatch || [];
|
|
@@ -1713,8 +1725,11 @@ const transformer = {
|
|
|
1713
1725
|
function transformStyleToUnocssPre(styles) {
|
|
1714
1726
|
const preTransformedList = [];
|
|
1715
1727
|
const styleToObj = styles.split(";").filter(Boolean).reduce((r, item) => {
|
|
1716
|
-
const
|
|
1717
|
-
if (
|
|
1728
|
+
const splitIndex = findFirstColonOutsideBrackets(item);
|
|
1729
|
+
if (splitIndex === -1) return r;
|
|
1730
|
+
const key = item.substring(0, splitIndex).trim();
|
|
1731
|
+
const value = item.substring(splitIndex + 1).trim();
|
|
1732
|
+
if (key && value) r[key] = value;
|
|
1718
1733
|
return r;
|
|
1719
1734
|
}, {});
|
|
1720
1735
|
for (const key in transformer) {
|
package/dist/index.umd.js
CHANGED
|
@@ -1321,6 +1321,7 @@ const textMap = [
|
|
|
1321
1321
|
"text-align",
|
|
1322
1322
|
"text-align-last",
|
|
1323
1323
|
"text-decoration-line",
|
|
1324
|
+
"text-decoration",
|
|
1324
1325
|
"text-decoration-style",
|
|
1325
1326
|
"text-decoration-color",
|
|
1326
1327
|
"text-decoration-thickness",
|
|
@@ -1343,6 +1344,7 @@ function text(key, val) {
|
|
|
1343
1344
|
if (value === "none") return `normal-case${important}`;
|
|
1344
1345
|
return `${value}${important}`;
|
|
1345
1346
|
}
|
|
1347
|
+
if (key === "text-decoration") return value;
|
|
1346
1348
|
if (key.startsWith("text-decoration") || key === "text-indent") return `${key.split("-")[1]}${getVal(value)}${important}`;
|
|
1347
1349
|
if (key === "text-underline-offset") return `underline-offset${getVal(value)}${important}`;
|
|
1348
1350
|
if (key === "text-align-last") return `${important}[${key}:${value}]`;
|
|
@@ -1638,6 +1640,16 @@ function toUnocss(css, isRem = false) {
|
|
|
1638
1640
|
|
|
1639
1641
|
//#endregion
|
|
1640
1642
|
//#region src/transformer.ts
|
|
1643
|
+
function findFirstColonOutsideBrackets(str) {
|
|
1644
|
+
let bracketDepth = 0;
|
|
1645
|
+
for (let i = 0; i < str.length; i++) {
|
|
1646
|
+
const char = str[i];
|
|
1647
|
+
if (char === "[") bracketDepth++;
|
|
1648
|
+
else if (char === "]") bracketDepth--;
|
|
1649
|
+
else if (char === ":" && bracketDepth === 0) return i;
|
|
1650
|
+
}
|
|
1651
|
+
return -1;
|
|
1652
|
+
}
|
|
1641
1653
|
function createRuleProcessor(config) {
|
|
1642
1654
|
return (v) => {
|
|
1643
1655
|
const anyMatch = config.anyMatch || [];
|
|
@@ -1720,8 +1732,11 @@ const transformer = {
|
|
|
1720
1732
|
function transformStyleToUnocssPre(styles) {
|
|
1721
1733
|
const preTransformedList = [];
|
|
1722
1734
|
const styleToObj = styles.split(";").filter(Boolean).reduce((r, item) => {
|
|
1723
|
-
const
|
|
1724
|
-
if (
|
|
1735
|
+
const splitIndex = findFirstColonOutsideBrackets(item);
|
|
1736
|
+
if (splitIndex === -1) return r;
|
|
1737
|
+
const key = item.substring(0, splitIndex).trim();
|
|
1738
|
+
const value = item.substring(splitIndex + 1).trim();
|
|
1739
|
+
if (key && value) r[key] = value;
|
|
1725
1740
|
return r;
|
|
1726
1741
|
}, {});
|
|
1727
1742
|
for (const key in transformer) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "transform-to-unocss-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.70",
|
|
5
5
|
"description": "A utility to transform CSS to UnoCSS syntax. Supports various CSS properties and custom parsing.",
|
|
6
6
|
"author": "Simon He",
|
|
7
7
|
"license": "MIT",
|