summaryrefslogtreecommitdiff
path: root/node_modules/postcss-lab-function/dist
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:05:55 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:05:55 +0800
commitc06f7ee0a40255214c477e13d9b956a7e07c2900 (patch)
treef5982a568ef8fab865d0142e71c7494fea3e4c1b /node_modules/postcss-lab-function/dist
parent3fd9400d4dccc25aa29b5702216732e0b7542073 (diff)
postcss,(plugins): nanocss, postcss-preset-env
Diffstat (limited to 'node_modules/postcss-lab-function/dist')
-rw-r--r--node_modules/postcss-lab-function/dist/has-fallback-decl.d.ts2
-rw-r--r--node_modules/postcss-lab-function/dist/has-supports-at-rule-ancestor.d.ts2
-rw-r--r--node_modules/postcss-lab-function/dist/index.cjs1
-rw-r--r--node_modules/postcss-lab-function/dist/index.d.ts15
-rw-r--r--node_modules/postcss-lab-function/dist/index.mjs1
5 files changed, 21 insertions, 0 deletions
diff --git a/node_modules/postcss-lab-function/dist/has-fallback-decl.d.ts b/node_modules/postcss-lab-function/dist/has-fallback-decl.d.ts
new file mode 100644
index 00000000..d7ae8d89
--- /dev/null
+++ b/node_modules/postcss-lab-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/postcss-lab-function/dist/has-supports-at-rule-ancestor.d.ts b/node_modules/postcss-lab-function/dist/has-supports-at-rule-ancestor.d.ts
new file mode 100644
index 00000000..a46009ec
--- /dev/null
+++ b/node_modules/postcss-lab-function/dist/has-supports-at-rule-ancestor.d.ts
@@ -0,0 +1,2 @@
+import type { Node } from 'postcss';
+export declare function hasSupportsAtRuleAncestor(node: Node): boolean;
diff --git a/node_modules/postcss-lab-function/dist/index.cjs b/node_modules/postcss-lab-function/dist/index.cjs
new file mode 100644
index 00000000..2259a5d0
--- /dev/null
+++ b/node_modules/postcss-lab-function/dist/index.cjs
@@ -0,0 +1 @@
+"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("@csstools/css-tokenizer"),r=require("@csstools/css-color-parser"),t=require("@csstools/css-parser-algorithms");function hasFallback(e){const s=e.parent;if(!s)return!1;const r=e.prop.toLowerCase(),t=s.index(e);for(let e=0;e<t;e++){const t=s.nodes[e];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()){if(-1!==s.params.toLowerCase().indexOf("lab("))return!0;if(-1!==s.params.toLowerCase().indexOf("lch("))return!0}s=s.parent}else s=s.parent;return!1}const a=/(lab|lch)\(/i,o=/^(lab|lch)$/i,basePlugin=e=>({postcssPlugin:"postcss-lab-function",Declaration:n=>{const l=n.value;if(!a.test(l))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;const i=s.tokenize({css:l}),u=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(i),(e=>{if(t.isFunctionNode(e)&&o.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.serializeRGB(s)}})),c=t.stringify(u);if(c===l)return;let p=c;null!=e&&e.subFeatures.displayP3&&(p=t.stringify(t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(i),(e=>{if(t.isFunctionNode(e)&&o.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.colorDataFitsRGB_Gamut(s)?r.serializeRGB(s):r.serializeP3(s)}})))),n.cloneBefore({value:c}),null!=e&&e.subFeatures.displayP3&&p!==c&&n.cloneBefore({value:p}),null!=e&&e.preserve||n.remove()}});basePlugin.postcss=!0;const postcssPlugin=s=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},s);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-lab-function",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
diff --git a/node_modules/postcss-lab-function/dist/index.d.ts b/node_modules/postcss-lab-function/dist/index.d.ts
new file mode 100644
index 00000000..e94b09fe
--- /dev/null
+++ b/node_modules/postcss-lab-function/dist/index.d.ts
@@ -0,0 +1,15 @@
+import type { PluginCreator } from 'postcss';
+/** postcss-lab-function plugin options */
+export type pluginOptions = {
+ /** Preserve the original notation. default: false */
+ preserve?: boolean;
+ /** Enable "@csstools/postcss-progressive-custom-properties". default: true */
+ enableProgressiveCustomProperties?: boolean;
+ /** Toggle sub features. default: { displayP3: true } */
+ subFeatures?: {
+ /** Enable displayP3 fallbacks. default: true */
+ displayP3?: boolean;
+ };
+};
+declare const postcssPlugin: PluginCreator<pluginOptions>;
+export default postcssPlugin;
diff --git a/node_modules/postcss-lab-function/dist/index.mjs b/node_modules/postcss-lab-function/dist/index.mjs
new file mode 100644
index 00000000..42a57148
--- /dev/null
+++ b/node_modules/postcss-lab-function/dist/index.mjs
@@ -0,0 +1 @@
+import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as e}from"@csstools/css-tokenizer";import{color as r,SyntaxFlag as t,serializeRGB as o,colorDataFitsRGB_Gamut as a,serializeP3 as n}from"@csstools/css-color-parser";import{replaceComponentValues as l,parseCommaSeparatedListOfComponentValues as u,isFunctionNode as i,stringify as p}from"@csstools/css-parser-algorithms";function hasFallback(s){const e=s.parent;if(!e)return!1;const r=s.prop.toLowerCase(),t=e.index(s);for(let s=0;s<t;s++){const t=e.nodes[s];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}function hasSupportsAtRuleAncestor(s){let e=s.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name.toLowerCase()){if(-1!==e.params.toLowerCase().indexOf("lab("))return!0;if(-1!==e.params.toLowerCase().indexOf("lch("))return!0}e=e.parent}else e=e.parent;return!1}const c=/(lab|lch)\(/i,f=/^(lab|lch)$/i,basePlugin=s=>({postcssPlugin:"postcss-lab-function",Declaration:m=>{const b=m.value;if(!c.test(b))return;if(hasFallback(m))return;if(hasSupportsAtRuleAncestor(m))return;const g=e({css:b}),y=l(u(g),(s=>{if(i(s)&&f.test(s.getName())){const e=r(s);if(!e)return;if(e.syntaxFlags.has(t.HasNoneKeywords))return;if(e.syntaxFlags.has(t.RelativeColorSyntax))return;return o(e)}})),d=p(y);if(d===b)return;let h=d;null!=s&&s.subFeatures.displayP3&&(h=p(l(u(g),(s=>{if(i(s)&&f.test(s.getName())){const e=r(s);if(!e)return;if(e.syntaxFlags.has(t.HasNoneKeywords))return;if(e.syntaxFlags.has(t.RelativeColorSyntax))return;return a(e)?o(e):n(e)}})))),m.cloneBefore({value:d}),null!=s&&s.subFeatures.displayP3&&h!==d&&m.cloneBefore({value:h}),null!=s&&s.preserve||m.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-lab-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default};