diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:05:55 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:05:55 +0800 |
| commit | c06f7ee0a40255214c477e13d9b956a7e07c2900 (patch) | |
| tree | f5982a568ef8fab865d0142e71c7494fea3e4c1b /node_modules/@csstools/postcss-hwb-function/dist | |
| parent | 3fd9400d4dccc25aa29b5702216732e0b7542073 (diff) | |
postcss,(plugins): nanocss, postcss-preset-env
Diffstat (limited to 'node_modules/@csstools/postcss-hwb-function/dist')
5 files changed, 16 insertions, 0 deletions
diff --git a/node_modules/@csstools/postcss-hwb-function/dist/has-fallback-decl.d.ts b/node_modules/@csstools/postcss-hwb-function/dist/has-fallback-decl.d.ts new file mode 100644 index 00000000..d7ae8d89 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/dist/has-fallback-decl.d.ts @@ -0,0 +1,2 @@ +import type { Declaration } from 'postcss'; +export declare function hasFallback(node: Declaration): boolean; diff --git a/node_modules/@csstools/postcss-hwb-function/dist/has-supports-at-rule-ancestor.d.ts b/node_modules/@csstools/postcss-hwb-function/dist/has-supports-at-rule-ancestor.d.ts new file mode 100644 index 00000000..7fbe0b29 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/dist/has-supports-at-rule-ancestor.d.ts @@ -0,0 +1,3 @@ +import type { Node } from 'postcss'; +export declare const atSupportsHwbParams = "(color: hwb(0 0% 0%))"; +export declare function hasSupportsAtRuleAncestor(node: Node): boolean; diff --git a/node_modules/@csstools/postcss-hwb-function/dist/index.cjs b/node_modules/@csstools/postcss-hwb-function/dist/index.cjs new file mode 100644 index 00000000..19fafe2e --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/dist/index.cjs @@ -0,0 +1 @@ +"use strict";var e=require("@csstools/css-color-parser"),t=require("@csstools/css-parser-algorithms"),r=require("@csstools/css-tokenizer");const s="(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(s))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 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=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(r.tokenize({css:p})),(r=>{if(t.isFunctionNode(r)&&n.test(r.getName())){const t=e.color(r);if(!t)return;if(t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords))return;if(t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))return;return e.serializeRGB(t)}})),i=t.stringify(u);if(i!==p)if(a.variable&&l&&a.parent){const e=a.parent,t=c.atRule({name:"supports",params:s,source:a.source}),r=e.clone();r.removeAll(),r.append(a.clone()),t.append(r),insertAtSupportsAfterCorrectRule(t,e,s),a.replaceWith(a.clone({value:i}))}else l?a.cloneBefore({value:i}):a.replaceWith(a.clone({value:i}))}}};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,module.exports=postcssPlugin; diff --git a/node_modules/@csstools/postcss-hwb-function/dist/index.d.ts b/node_modules/@csstools/postcss-hwb-function/dist/index.d.ts new file mode 100644 index 00000000..0304f878 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/dist/index.d.ts @@ -0,0 +1,9 @@ +import type { PluginCreator } from 'postcss'; +/** postcss-hwb-function plugin options */ +export type pluginOptions = { + /** Preserve the original notation. default: false */ + preserve?: boolean; +}; +/** Transform hwb() functions in CSS. */ +declare const postcssPlugin: PluginCreator<pluginOptions>; +export default postcssPlugin; diff --git a/node_modules/@csstools/postcss-hwb-function/dist/index.mjs b/node_modules/@csstools/postcss-hwb-function/dist/index.mjs new file mode 100644 index 00000000..067e6891 --- /dev/null +++ b/node_modules/@csstools/postcss-hwb-function/dist/index.mjs @@ -0,0 +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 l}from"@csstools/css-tokenizer";const p="(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(p))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 c=/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(!c.test(h))return;if(f&&hasSupportsAtRuleAncestor(i))return;if(hasFallback(i))return;const v=s(o(l({css:h})),(s=>{if(n(s)&&u.test(s.getName())){const o=e(s);if(!o)return;if(o.syntaxFlags.has(t.HasNoneKeywords))return;if(o.syntaxFlags.has(t.RelativeColorSyntax))return;return r(o)}})),d=a(v);if(d!==h)if(i.variable&&f&&i.parent){const e=i.parent,t=m.atRule({name:"supports",params:p,source:i.source}),r=e.clone();r.removeAll(),r.append(i.clone()),t.append(r),insertAtSupportsAfterCorrectRule(t,e,p),i.replaceWith(i.clone({value:d}))}else f?i.cloneBefore({value:d}):i.replaceWith(i.clone({value:d}))}}};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}; |
