styimat 1.2.3 → 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 +9 -11
- package/styimat.js +2 -2
- package/styimat.min.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "styimat",
|
|
3
|
-
"version": "1.
|
|
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",
|
|
@@ -43,15 +43,13 @@
|
|
|
43
43
|
"test": "echo \"No tests yet\" && exit 0",
|
|
44
44
|
"build:min": "npx terser styimat.js -o styimat.min.js --comments '/^!'",
|
|
45
45
|
"prepare": "npm run build:min",
|
|
46
|
-
"prepublishOnly": "npm run build:min
|
|
47
|
-
"postpublish": "
|
|
48
|
-
"release": "npm
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"git:
|
|
53
|
-
"git:
|
|
54
|
-
"git:push": "git push",
|
|
55
|
-
"git:auto": "git add . && git commit -m 'Auto commit' && git push"
|
|
46
|
+
"prepublishOnly": "npm run build:min",
|
|
47
|
+
"postpublish": "npm run git:auto-tag",
|
|
48
|
+
"release": "npm publish",
|
|
49
|
+
"publish:patch": "npm version patch --no-git-tag-version && npm publish",
|
|
50
|
+
"publish:minor": "npm version minor --no-git-tag-version && npm publish",
|
|
51
|
+
"publish:major": "npm version major --no-git-tag-version && npm publish",
|
|
52
|
+
"git:auto-commit": "git add . && git commit -m 'chore: auto commit for publish' || echo 'No changes to commit'",
|
|
53
|
+
"git:auto-tag": "git tag -d v$(node -p \"require('./package.json').version\") 2>/dev/null || true && git tag -a v$(node -p \"require('./package.json').version\") -m 'Version $(node -p \"require('./package.json').version\")' && git push && git push --tags"
|
|
56
54
|
}
|
|
57
55
|
}
|
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('
|
|
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('
|
|
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("
|
|
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});
|