@csstools/postcss-hwb-function 2.1.1 → 2.2.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/CHANGELOG.md +11 -0
- package/dist/has-supports-at-rule-ancestor.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +10 -11
- package/dist/on-css-function.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changes to PostCSS HWB Function
|
|
2
2
|
|
|
3
|
+
### 2.2.1 (April 10, 2023)
|
|
4
|
+
|
|
5
|
+
- Updated `@csstools/css-tokenizer` to `2.1.1` (patch)
|
|
6
|
+
- Updated `@csstools/css-parser-algorithms` to `2.1.1` (patch)
|
|
7
|
+
- Updated `@csstools/css-color-parser` to `1.1.2` (patch)
|
|
8
|
+
|
|
9
|
+
### 2.2.0 (March 25, 2023)
|
|
10
|
+
|
|
11
|
+
- Add `@csstools/css-color-parser` dependency for all color value transformations.
|
|
12
|
+
- Add support for `calc` expressions in color components.
|
|
13
|
+
|
|
3
14
|
### 2.1.1 (February 8, 2023)
|
|
4
15
|
|
|
5
16
|
- Reduce the amount of duplicate fallback CSS.
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("
|
|
1
|
+
"use strict";var e=require("@csstools/css-color-parser"),r=require("@csstools/css-parser-algorithms"),t=require("@csstools/css-tokenizer");const s="(color: hwb(0 0% 0%))";function hasSupportsAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if("supports"===r.name.toLowerCase()&&r.params.includes(s))return!0;r=r.parent}else r=r.parent;return!1}function hasFallback(e){const r=e.parent;if(!r)return!1;const t=e.prop.toLowerCase(),s=r.index(e);for(let e=0;e<s;e++){const s=r.nodes[e];if("decl"===s.type&&s.prop.toLowerCase()===t)return!0}return!1}const o=/hwb\(/i,n=/^hwb$/i,postcssPlugin=a=>{const l="preserve"in Object(a)&&Boolean(null==a?void 0:a.preserve);return{postcssPlugin:"postcss-hwb-function",Declaration:(a,{postcss:c})=>{const p=a.value;if(!o.test(p))return;if(l&&hasSupportsAtRuleAncestor(a))return;if(hasFallback(a))return;const u=r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(t.tokenize({css:p})),(t=>{if(r.isFunctionNode(t)&&n.test(t.getName())){const r=e.color(t);if(!r)return;if(r.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords))return;return e.serializeRGB(r)}})),i=r.stringify(u);if(i!==p)if(a.variable&&l&&a.parent){const e=a.parent,r=c.atRule({name:"supports",params:s,source:a.source}),t=e.clone();t.removeAll(),t.append(a.clone()),r.append(t),insertAtSupportsAfterCorrectRule(r,e,s),a.replaceWith(a.clone({value:i}))}else l?a.cloneBefore({value:i}):a.replaceWith(a.clone({value:i}))}}};function insertAtSupportsAfterCorrectRule(e,r,t){let s=r,o=r.next();for(;s&&o&&"atrule"===o.type&&"supports"===o.name.toLowerCase()&&o.params===t;)s=o,o=o.next();s.after(e)}postcssPlugin.postcss=!0,module.exports=postcssPlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"
|
|
1
|
+
import{color as e,SyntaxFlag as t,serializeRGB as r}from"@csstools/css-color-parser";import{replaceComponentValues as s,parseCommaSeparatedListOfComponentValues as o,isFunctionNode as n,stringify as a}from"@csstools/css-parser-algorithms";import{tokenize as p}from"@csstools/css-tokenizer";const c="(color: hwb(0 0% 0%))";function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&t.params.includes(c))return!0;t=t.parent}else t=t.parent;return!1}function hasFallback(e){const t=e.parent;if(!t)return!1;const r=e.prop.toLowerCase(),s=t.index(e);for(let e=0;e<s;e++){const s=t.nodes[e];if("decl"===s.type&&s.prop.toLowerCase()===r)return!0}return!1}const l=/hwb\(/i,u=/^hwb$/i,postcssPlugin=i=>{const f="preserve"in Object(i)&&Boolean(null==i?void 0:i.preserve);return{postcssPlugin:"postcss-hwb-function",Declaration:(i,{postcss:m})=>{const h=i.value;if(!l.test(h))return;if(f&&hasSupportsAtRuleAncestor(i))return;if(hasFallback(i))return;const d=s(o(p({css:h})),(s=>{if(n(s)&&u.test(s.getName())){const o=e(s);if(!o)return;if(o.syntaxFlags.has(t.HasNoneKeywords))return;return r(o)}})),v=a(d);if(v!==h)if(i.variable&&f&&i.parent){const e=i.parent,t=m.atRule({name:"supports",params:c,source:i.source}),r=e.clone();r.removeAll(),r.append(i.clone()),t.append(r),insertAtSupportsAfterCorrectRule(t,e,c),i.replaceWith(i.clone({value:v}))}else f?i.cloneBefore({value:v}):i.replaceWith(i.clone({value:v}))}}};function insertAtSupportsAfterCorrectRule(e,t,r){let s=t,o=t.next();for(;s&&o&&"atrule"===o.type&&"supports"===o.name.toLowerCase()&&o.params===r;)s=o,o=o.next();s.after(e)}postcssPlugin.postcss=!0;export{postcssPlugin as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csstools/postcss-hwb-function",
|
|
3
3
|
"description": "Use hwb() color functions in CSS",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
|
|
6
6
|
"license": "CC0-1.0",
|
|
7
7
|
"funding": {
|
|
@@ -30,23 +30,22 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@csstools/color-
|
|
34
|
-
"
|
|
33
|
+
"@csstools/css-color-parser": "^1.1.2",
|
|
34
|
+
"@csstools/css-parser-algorithms": "^2.1.1",
|
|
35
|
+
"@csstools/css-tokenizer": "^2.1.1"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"postcss": "^8.4"
|
|
38
39
|
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@csstools/postcss-tape": "*"
|
|
42
|
+
},
|
|
39
43
|
"scripts": {
|
|
40
|
-
"prebuild": "npm run clean",
|
|
41
44
|
"build": "rollup -c ../../rollup/default.mjs",
|
|
42
|
-
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true }); fs.mkdirSync('./dist');\"",
|
|
43
45
|
"docs": "node ../../.github/bin/generate-docs/install.mjs",
|
|
44
|
-
"lint": "
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"prepublishOnly": "npm run clean && npm run build && npm run test",
|
|
48
|
-
"test": "node .tape.mjs && npm run test:exports",
|
|
49
|
-
"test:exports": "node ./test/_import.mjs && node ./test/_require.cjs",
|
|
46
|
+
"lint": "node ../../.github/bin/format-package-json.mjs",
|
|
47
|
+
"prepublishOnly": "npm run build && npm run test",
|
|
48
|
+
"test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs",
|
|
50
49
|
"test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
|
|
51
50
|
},
|
|
52
51
|
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-hwb-function#readme",
|