styimat 1.2.4 → 1.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styimat",
3
- "version": "1.2.4",
3
+ "version": "1.3.0",
4
4
  "description": "A powerful CSS variable preprocessor with nested selectors, Lab/LCH color spaces conversion and modern color features.",
5
5
  "keywords": [
6
6
  "css",
package/styimat.js CHANGED
@@ -1152,12 +1152,12 @@
1152
1152
  const element = this;
1153
1153
  return new Proxy({}, {
1154
1154
  get(target, prop) {
1155
- const varName = prop.startsWith('--') ? prop : `--${prop}`;
1155
+ const varName = prop.startsWith('$') ? prop.slice(1) : prop;
1156
1156
  return element.style.getPropertyValue(varName);
1157
1157
  },
1158
1158
 
1159
1159
  set(target, prop, value) {
1160
- const varName = prop.startsWith('--') ? prop : `--${prop}`;
1160
+ const varName = prop.startsWith('$') ? prop.slice(1) : prop;
1161
1161
  element.style.setProperty(varName, value);
1162
1162
  return true;
1163
1163
  }
package/styimat.min.js CHANGED
@@ -352,4 +352,4 @@ const labMatch=colorString.match(/lab\(\s*([\d.]+)(%?)\s+([\d.-]+)\s+([\d.-]+)(?
352
352
  // 尝试解析lch()函数格式
353
353
  const lchMatch=colorString.match(/lch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(deg)?(?:\s*\/\s*([\d.%]+))?\s*\)/i);if(lchMatch){let L=parseFloat(lchMatch[1]);const C=parseFloat(lchMatch[3]);let H=parseFloat(lchMatch[4]);const alpha=lchMatch[6]?lchMatch[6].includes("%")?parseFloat(lchMatch[6])/100:parseFloat(lchMatch[6]):null;const lab=lchToLab(L,C,H);const colorStr=generateColorString(lab.L,lab.a,lab.b,defaultConfig,alpha);return{L:L,C:C,H:H,alpha:alpha,lab:lab,rgb:preciseLabToRGB(lab.L,lab.a,lab.b),p3:labToP3(lab.L,lab.a,lab.b),colorString:colorStr}}return null}catch(error){console.warn("无法解析颜色:",colorString,error);return null}}}};
354
354
  // 自动初始化
355
- if(typeof window!=="undefined"){apply();Object.defineProperty(window.HTMLElement.prototype,"cssVar",{get(){const element=this;return new Proxy({},{get(target,prop){const varName=prop.startsWith("--")?prop:`--${prop}`;return element.style.getPropertyValue(varName)},set(target,prop,value){const varName=prop.startsWith("--")?prop:`--${prop}`;element.style.setProperty(varName,value);return true}})}})}return api});
355
+ if(typeof window!=="undefined"){apply();Object.defineProperty(window.HTMLElement.prototype,"cssVar",{get(){const element=this;return new Proxy({},{get(target,prop){const varName=prop.startsWith("$")?prop.slice(1):prop;return element.style.getPropertyValue(varName)},set(target,prop,value){const varName=prop.startsWith("$")?prop.slice(1):prop;element.style.setProperty(varName,value);return true}})}})}return api});