transform-to-unocss-core 0.0.68 → 0.0.69

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 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时,isRem 为true时,会将px转换为rem
13
+ - 使用:toUnocssClass('width:100px', isRem) isRem 为true时,会将px转换为rem
14
14
 
15
15
  ## License
16
16
 
package/dist/index.cjs CHANGED
@@ -1633,6 +1633,16 @@ function toUnocss(css, isRem = false) {
1633
1633
 
1634
1634
  //#endregion
1635
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
+ }
1636
1646
  function createRuleProcessor(config) {
1637
1647
  return (v) => {
1638
1648
  const anyMatch = config.anyMatch || [];
@@ -1715,8 +1725,11 @@ const transformer = {
1715
1725
  function transformStyleToUnocssPre(styles) {
1716
1726
  const preTransformedList = [];
1717
1727
  const styleToObj = styles.split(";").filter(Boolean).reduce((r, item) => {
1718
- const [key, value] = item.split(":");
1719
- if (key.trim() && (value === null || value === void 0 ? void 0 : value.trim())) r[key.trim()] = value.trim();
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;
1720
1733
  return r;
1721
1734
  }, {});
1722
1735
  for (const key in transformer) {
@@ -1635,6 +1635,16 @@ function toUnocss(css, isRem = false) {
1635
1635
 
1636
1636
  //#endregion
1637
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
+ }
1638
1648
  function createRuleProcessor(config) {
1639
1649
  return (v) => {
1640
1650
  const anyMatch = config.anyMatch || [];
@@ -1717,8 +1727,11 @@ const transformer = {
1717
1727
  function transformStyleToUnocssPre(styles) {
1718
1728
  const preTransformedList = [];
1719
1729
  const styleToObj = styles.split(";").filter(Boolean).reduce((r, item) => {
1720
- const [key, value] = item.split(":");
1721
- if (key.trim() && (value === null || value === void 0 ? void 0 : value.trim())) r[key.trim()] = value.trim();
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;
1722
1735
  return r;
1723
1736
  }, {});
1724
1737
  for (const key in transformer) {
package/dist/index.js CHANGED
@@ -1631,6 +1631,16 @@ function toUnocss(css, isRem = false) {
1631
1631
 
1632
1632
  //#endregion
1633
1633
  //#region src/transformer.ts
1634
+ function findFirstColonOutsideBrackets(str) {
1635
+ let bracketDepth = 0;
1636
+ for (let i = 0; i < str.length; i++) {
1637
+ const char = str[i];
1638
+ if (char === "[") bracketDepth++;
1639
+ else if (char === "]") bracketDepth--;
1640
+ else if (char === ":" && bracketDepth === 0) return i;
1641
+ }
1642
+ return -1;
1643
+ }
1634
1644
  function createRuleProcessor(config) {
1635
1645
  return (v) => {
1636
1646
  const anyMatch = config.anyMatch || [];
@@ -1713,8 +1723,11 @@ const transformer = {
1713
1723
  function transformStyleToUnocssPre(styles) {
1714
1724
  const preTransformedList = [];
1715
1725
  const styleToObj = styles.split(";").filter(Boolean).reduce((r, item) => {
1716
- const [key, value] = item.split(":");
1717
- if (key.trim() && (value === null || value === void 0 ? void 0 : value.trim())) r[key.trim()] = value.trim();
1726
+ const splitIndex = findFirstColonOutsideBrackets(item);
1727
+ if (splitIndex === -1) return r;
1728
+ const key = item.substring(0, splitIndex).trim();
1729
+ const value = item.substring(splitIndex + 1).trim();
1730
+ if (key && value) r[key] = value;
1718
1731
  return r;
1719
1732
  }, {});
1720
1733
  for (const key in transformer) {
package/dist/index.umd.js CHANGED
@@ -1638,6 +1638,16 @@ function toUnocss(css, isRem = false) {
1638
1638
 
1639
1639
  //#endregion
1640
1640
  //#region src/transformer.ts
1641
+ function findFirstColonOutsideBrackets(str) {
1642
+ let bracketDepth = 0;
1643
+ for (let i = 0; i < str.length; i++) {
1644
+ const char = str[i];
1645
+ if (char === "[") bracketDepth++;
1646
+ else if (char === "]") bracketDepth--;
1647
+ else if (char === ":" && bracketDepth === 0) return i;
1648
+ }
1649
+ return -1;
1650
+ }
1641
1651
  function createRuleProcessor(config) {
1642
1652
  return (v) => {
1643
1653
  const anyMatch = config.anyMatch || [];
@@ -1720,8 +1730,11 @@ const transformer = {
1720
1730
  function transformStyleToUnocssPre(styles) {
1721
1731
  const preTransformedList = [];
1722
1732
  const styleToObj = styles.split(";").filter(Boolean).reduce((r, item) => {
1723
- const [key, value] = item.split(":");
1724
- if (key.trim() && (value === null || value === void 0 ? void 0 : value.trim())) r[key.trim()] = value.trim();
1733
+ const splitIndex = findFirstColonOutsideBrackets(item);
1734
+ if (splitIndex === -1) return r;
1735
+ const key = item.substring(0, splitIndex).trim();
1736
+ const value = item.substring(splitIndex + 1).trim();
1737
+ if (key && value) r[key] = value;
1725
1738
  return r;
1726
1739
  }, {});
1727
1740
  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.68",
4
+ "version": "0.0.69",
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",