diff options
Diffstat (limited to 'node_modules/postcss-custom-selectors')
10 files changed, 40 insertions, 258 deletions
diff --git a/node_modules/postcss-custom-selectors/CHANGELOG.md b/node_modules/postcss-custom-selectors/CHANGELOG.md index 4cca8afa..b20aeb4d 100644 --- a/node_modules/postcss-custom-selectors/CHANGELOG.md +++ b/node_modules/postcss-custom-selectors/CHANGELOG.md @@ -1,218 +1,27 @@ # Changes to PostCSS Custom Selectors -### 7.1.6 +### 7.1.10 -_October 9, 2023_ +_May 4, 2024_ -- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#221) (patch) -- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#232) (patch) -- Updated [`@csstools/cascade-layer-name-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser) to [`1.0.5`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser/CHANGELOG.md#105) (patch) +- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#231) (patch) +- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.6.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#263) (patch) +- Updated [`@csstools/cascade-layer-name-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser) to [`1.0.11`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser/CHANGELOG.md#1011) (patch) -### 7.1.5 +### 7.1.9 -_September 18, 2023_ +_May 4, 2024_ -- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#220) (minor) -- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#231) (patch) -- Updated [`@csstools/cascade-layer-name-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser) to [`1.0.4`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser/CHANGELOG.md#104) (patch) +- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#230) (minor) +- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.6.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#262) (patch) +- Updated [`@csstools/cascade-layer-name-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser) to [`1.0.10`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser/CHANGELOG.md#1010) (patch) -### 7.1.4 +### 7.1.8 -_July 3, 2023_ +_March 13, 2024_ -- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#230) (minor) -- Updated [`@csstools/cascade-layer-name-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser) to [`1.0.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser/CHANGELOG.md#103) (patch) +- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.4`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#224) (patch) +- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.6.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#261) (patch) +- Updated [`@csstools/cascade-layer-name-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser) to [`1.0.9`](https://github.com/csstools/postcss-plugins/tree/main/packages/cascade-layer-name-parser/CHANGELOG.md#109) (patch) -### 7.1.3 - -_April 10, 2023_ - -- Updated `@csstools/css-tokenizer` to `2.1.1` (patch) -- Updated `@csstools/css-parser-algorithms` to `2.1.1` (patch) -- Updated `@csstools/cascade-layer-name-parser` to `1.0.2` (patch) - -### 7.1.2 - -_February 8, 2023_ - -- Reduce the amount of duplicate fallback CSS. - -### 7.1.1 - -_January 28, 2023_ - -- Improve `types` declaration in `package.json` - -### 7.1.0 - -_January 24, 2023_ - -- Added: Support for Cascade Layers. - -### 7.0.0 - -_November 14, 2022_ - -- Updated: Support for Node v14+ (major). -- Removed: `importFrom` feature (breaking). -- Removed: `exportTo` feature (breaking). -- Fixed: follow the specification and use `:is()` in transformed selectors (breaking). -- Added: Support for `@scope` and `@container` as parent rules of `@custom-selector`. -- Fixed: Do not throw when a selector is invalid, show a warning instead. - -```diff -@custom-selector :--heading h1, h2, h3; - -article :--heading + p { - margin-top: 0; -} - -/* becomes */ - -- article h1 + p,article h2 + p,article h3 + p { -+ article :is(h1, h2, h3) + p { - margin-top: 0; -} -``` - -### 6.0.3 - -_June 4, 2022_ - -- Fixed: allow any valid ident in custom selectors (`@custom-selector :--🧑🏾🎤 .singer`) - -### 6.0.2 - -_June 3, 2022_ - -- Fixed: prevent duplicate rules when custom selectors are not defined -- Fixed: selectors not resolving when using with other features like nesting - -### 6.0.1 - -_June 3, 2022_ - -- Fixed: invalid whitespace (https://github.com/csstools/postcss-custom-selectors/pull/55) - -### 6.0.0 - -_January 12, 2021_ - -- Added: Support for PostCSS v8 -- Added: Support for Node v10+ -- Fixed: importing from multiple sources (https://github.com/postcss/postcss-custom-selectors/pull/42) - -### 5.1.2 - -_September 20, 2018_ - -- Fixed: Do not break on an empty `importFrom` object - -### 5.1.1 - -_September 18, 2018_ - -- Fixed: Selectors like `.foo:--h1` become `h1.foo` instead of `.fooh1` - -### 5.1.0 - -_September 12, 2018_ - -- Added: New `exportTo` function to specify where to export custom selectors -- Updated: `importFrom` option to support passing it a function - -### 5.0.0 - -_September 7, 2018_ - -- Added: New `preserve` option to preserve custom selectors and rules using them -- Added: New `importFrom` option to specify where to import custom selectors -- Added: Support for PostCSS v7 -- Added: Support for Node v6+ - -### 4.0.1 - -_May 15, 2017_ - -- Fixed: incorrect export - -### 4.0.0 - -_May 12, 2017_ - -- Added: compatibility with postcss v6.x - -### 3.0.0 - -_August 25, 2015_ - -- Removed: compatibility with postcss v4.x -- Added: compatibility with postcss v5.x - -### 2.3.0 - -_July 14, 2015_ - -* Fixed: Nested/mixed selectors now works correctly -(https://github.com/postcss/postcss-custom-selectors/issues/19) -* Added: `transformMatches` option to limit transformation to :matches() -replacements. - -### 2.2.0 - -_June 30, 2015_ - -* Fixed: No more useless warnings for undefined non custom selectors -(https://github.com/postcss/postcss-custom-selectors/issues/22) -* Changed: warnings now use PostCSS message API - -### 2.1.1 - -_June 30, 2015_ - -* Fixed: the lineBreak option keeping the selectors indent -(https://github.com/postcss/postcss-custom-selectors/issues/18) -* Fixed: the tip of an undefined selector -(https://github.com/postcss/postcss-custom-selectors/issues/20) - -### 2.1.0 - -_June 4, 2015_ - -* Changed: use PostCSS 4.1 plugin API -(https://github.com/postcss/postcss-custom-selectors/issues/13) - -### 2.0.1 - -_June 3, 2015_ - -* Fixed: `(foo, bar)` conversion error exists in the selector - -### 2.0.0 - -_May 29, 2015_ - -* Removed: no longer support `::` or `--` to defined a custom selectors, -you must use the syntax `:--` to define it. -(https://github.com/postcss/postcss-custom-selectors/issues/6) -* Fixed: two or more consecutive hyphens in selector don't output `undefined` -(https://github.com/postcss/postcss-custom-selectors/issues/14) - - -### 1.1.1 - -_April 6, 2015_ - -* Fixed: add support for multilines definition - -### 1.1.0 - -_December 6, 2014_ - -* Added: "lineBreak" option - -### 1.0.0 - -_December 6, 2014_ - -* First release +[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-selectors/CHANGELOG.md) diff --git a/node_modules/postcss-custom-selectors/README.md b/node_modules/postcss-custom-selectors/README.md index a4f55585..71e6626d 100644 --- a/node_modules/postcss-custom-selectors/README.md +++ b/node_modules/postcss-custom-selectors/README.md @@ -1,6 +1,6 @@ # PostCSS Custom Selectors [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS] -[<img alt="npm version" src="https://img.shields.io/npm/v/postcss-custom-selectors.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/custom-selectors.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord] +[<img alt="npm version" src="https://img.shields.io/npm/v/postcss-custom-selectors.svg" height="20">][npm-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]<br><br>[<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/custom-selectors.svg" height="20">][css-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/custom-selectors.svg" height="20">][css-url] ```bash npm install postcss-custom-selectors --save-dev diff --git a/node_modules/postcss-custom-selectors/dist/cascade-layers.d.ts b/node_modules/postcss-custom-selectors/dist/cascade-layers.d.ts deleted file mode 100644 index b9891949..00000000 --- a/node_modules/postcss-custom-selectors/dist/cascade-layers.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { Node, Root } from 'postcss'; -export declare function collectCascadeLayerOrder(root: Root): WeakMap<Node, number>; -export declare function cascadeLayerNumberForNode(node: Node, layers: WeakMap<Node, number>): number; diff --git a/node_modules/postcss-custom-selectors/dist/custom-selectors-from-root.d.ts b/node_modules/postcss-custom-selectors/dist/custom-selectors-from-root.d.ts deleted file mode 100644 index 346923e8..00000000 --- a/node_modules/postcss-custom-selectors/dist/custom-selectors-from-root.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { Result, Root as PostCSSRoot } from 'postcss'; -import type { Root as SelectorRoot } from 'postcss-selector-parser'; -export default function getCustomSelectors(root: PostCSSRoot, result: Result, opts: { - preserve?: boolean; -}): Map<string, SelectorRoot>; diff --git a/node_modules/postcss-custom-selectors/dist/index.cjs b/node_modules/postcss-custom-selectors/dist/index.cjs index 511c133d..69373065 100644 --- a/node_modules/postcss-custom-selectors/dist/index.cjs +++ b/node_modules/postcss-custom-selectors/dist/index.cjs @@ -1 +1 @@ -"use strict";var e=require("postcss-selector-parser"),r=require("@csstools/cascade-layer-name-parser");const t=r.parse("csstools-implicit-layer")[0];function collectCascadeLayerOrder(e){const s=new Map,o=new Map,n=[];e.walkAtRules((e=>{var a;if("layer"!==e.name.toLowerCase())return;{let r=e.parent;for(;r;){if("atrule"!==r.type||"layer"!==r.name.toLowerCase()){if(r===e.root())break;return}r=r.parent}}let l;if(e.nodes)l=normalizeLayerName(e.params,1);else{if(!e.params.trim())return;l=e.params}let c=r.parse(l);if(null!=(a=c)&&a.length){{let r=e.parent;for(;r&&"atrule"===r.type&&"layer"===r.name.toLowerCase();){const e=o.get(r);e?(c=c.map((r=>e.concat(r))),r=r.parent):r=r.parent}}if(r.addLayerToModel(n,c),e.nodes){const r=c[0].concat(t);s.set(e,r),o.set(e,c[0])}}}));for(const e of s.values())r.addLayerToModel(n,[e]);const a=new WeakMap;for(const[e,r]of s)a.set(e,n.findIndex((e=>r.equal(e))));return a}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const s=new Set(["scope","container","layer"]);function isProcessableCustomSelectorRule(e){if("atrule"!==e.type)return!1;if("custom-selector"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes(":--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!s.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function getCustomSelectors(r,t,s){const o=new Map,n=new Map,a=collectCascadeLayerOrder(r);return r.walkAtRules((r=>{var l,c;if(isProcessableCustomSelectorRule(r))try{var u;const t=r.params.trim(),p=e().astSync(t),i=null==p||null==(u=p.nodes)||null==(u=u[0])||null==(u=u.nodes)?void 0:u[0];if(!i||"pseudo"!==i.type||!i.value.startsWith(":--"))return;const m=i.toString(),f=(c=a,(l=r).parent&&"atrule"===l.parent.type&&"layer"===l.parent.name.toLowerCase()?c.has(l.parent)?c.get(l.parent)+1:0:1e7),d=n.get(m)??-1;if(f&&f>=d&&(n.set(m,f),o.set(m,e().astSync(t.slice(m.length).trim()))),!s.preserve){const e=r.parent;r.remove(),removeEmptyAncestorBlocks(e)}}catch(e){r.warn(t,`Failed to parse custom selector : "${r.params}" with message: "${e.message}"`)}})),o}function removeEmptyAncestorBlocks(e){let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformRule(r,t,s){let o=r.selector;try{o=e((r=>{r.walkPseudos((r=>{if(!s.has(r.value))return;const t=e.pseudo({value:":is",nodes:[]});s.get(r.value).each((e=>{t.append(e.clone({}))})),r.replaceWith(t)}))})).processSync(r.selector)}catch(e){return r.warn(t,`Failed to parse selector : "${o}" with message: "${e.message}"`),r.selector}return o}const creator=e=>{const r=Boolean(Object(e).preserve);if("importFrom"in Object(e))throw new Error('[postcss-custom-selectors] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-selectors] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-selectors",prepare(){const e=new WeakSet;let t=new Map;return{Once:(e,{result:s})=>{t=getCustomSelectors(e,s,{preserve:r})},Rule:(s,{result:o})=>{var n;if(e.has(s))return;if(null==(n=s.selector)||!n.includes(":--"))return;const a=transformRule(s,o,t);a!==s.selector&&(e.add(s),s.cloneBefore({selector:a}),r||s.remove())}}}}};creator.postcss=!0,module.exports=creator; +"use strict";var e=require("postcss-selector-parser"),r=require("@csstools/cascade-layer-name-parser");const t=r.parse("csstools-implicit-layer")[0];function collectCascadeLayerOrder(e){const s=new Map,o=new Map,n=[];e.walkAtRules((e=>{if("layer"!==e.name.toLowerCase())return;{let r=e.parent;for(;r;){if("atrule"!==r.type||"layer"!==r.name.toLowerCase()){if(r===e.root())break;return}r=r.parent}}let a;if(e.nodes)a=normalizeLayerName(e.params,1);else{if(!e.params.trim())return;a=e.params}let c=r.parse(a);if(c?.length){{let r=e.parent;for(;r&&"atrule"===r.type&&"layer"===r.name.toLowerCase();){const e=o.get(r);e?(c=c.map((r=>e.concat(r))),r=r.parent):r=r.parent}}if(r.addLayerToModel(n,c),e.nodes){const r=c[0].concat(t);s.set(e,r),o.set(e,c[0])}}}));for(const e of s.values())r.addLayerToModel(n,[e]);const a=new WeakMap;for(const[e,r]of s)a.set(e,n.findIndex((e=>r.equal(e))));return a}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const s=new Set(["scope","container","layer"]);function isProcessableCustomSelectorRule(e){if("atrule"!==e.type)return!1;if("custom-selector"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes(":--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!s.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function getCustomSelectors(r,t,s){const o=new Map,n=new Map,a=collectCascadeLayerOrder(r);return r.walkAtRules((r=>{var c,l;if(isProcessableCustomSelectorRule(r))try{const t=r.params.trim(),p=e().astSync(t),u=p?.nodes?.[0]?.nodes?.[0];if(!u||"pseudo"!==u.type||!u.value.startsWith(":--"))return;const i=u.toString(),m=(l=a,(c=r).parent&&"atrule"===c.parent.type&&"layer"===c.parent.name.toLowerCase()?l.has(c.parent)?l.get(c.parent)+1:0:1e7),f=n.get(i)??-1;if(m&&m>=f&&(n.set(i,m),o.set(i,e().astSync(t.slice(i.length).trim()))),!s.preserve){const e=r.parent;r.remove(),removeEmptyAncestorBlocks(e)}}catch(e){r.warn(t,`Failed to parse selector : "${r.params}" with message: "${e instanceof Error?e.message:e}"`)}})),o}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformRule(r,t,s){let o=r.selector;try{o=e((r=>{r.walkPseudos((r=>{if(!s.has(r.value))return;const t=e.pseudo({value:":is",nodes:[]}),o=s.get(r.value);o&&(o.each((e=>{t.append(e.clone({}))})),r.replaceWith(t))}))})).processSync(r.selector)}catch(e){return r.warn(t,`Failed to parse selector : "${o}" with message: "${e instanceof Error?e.message:e}"`),r.selector}return o}const creator=e=>{const r=Boolean(Object(e).preserve);if("importFrom"in Object(e))throw new Error('[postcss-custom-selectors] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-selectors] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-selectors",prepare(){const e=new WeakSet;let t=new Map;return{postcssPlugin:"postcss-custom-selectors",Once(e,{result:s}){t=getCustomSelectors(e,s,{preserve:r})},Rule(s,{result:o}){if(e.has(s))return;if(!s.selector?.includes(":--"))return;const n=transformRule(s,o,t);n!==s.selector&&(e.add(s),s.cloneBefore({selector:n}),r||s.remove())}}}}};creator.postcss=!0,module.exports=creator; diff --git a/node_modules/postcss-custom-selectors/dist/index.d.ts b/node_modules/postcss-custom-selectors/dist/index.d.ts index aa450f62..d745e5f7 100644 --- a/node_modules/postcss-custom-selectors/dist/index.d.ts +++ b/node_modules/postcss-custom-selectors/dist/index.d.ts @@ -1,8 +1,12 @@ import type { PluginCreator } from 'postcss'; + +declare const creator: PluginCreator<pluginOptions>; +export default creator; + /** postcss-custom-selectors plugin options */ -export type pluginOptions = { +export declare type pluginOptions = { /** Preserve the original notation. default: false */ preserve?: boolean; }; -declare const creator: PluginCreator<pluginOptions>; -export default creator; + +export { } diff --git a/node_modules/postcss-custom-selectors/dist/index.mjs b/node_modules/postcss-custom-selectors/dist/index.mjs index 0c5c5866..8d1b0cb6 100644 --- a/node_modules/postcss-custom-selectors/dist/index.mjs +++ b/node_modules/postcss-custom-selectors/dist/index.mjs @@ -1 +1 @@ -import e from"postcss-selector-parser";import{parse as r,addLayerToModel as t}from"@csstools/cascade-layer-name-parser";const s=r("csstools-implicit-layer")[0];function collectCascadeLayerOrder(e){const o=new Map,n=new Map,a=[];e.walkAtRules((e=>{var l;if("layer"!==e.name.toLowerCase())return;{let r=e.parent;for(;r;){if("atrule"!==r.type||"layer"!==r.name.toLowerCase()){if(r===e.root())break;return}r=r.parent}}let c;if(e.nodes)c=normalizeLayerName(e.params,1);else{if(!e.params.trim())return;c=e.params}let u=r(c);if(null!=(l=u)&&l.length){{let r=e.parent;for(;r&&"atrule"===r.type&&"layer"===r.name.toLowerCase();){const e=n.get(r);e?(u=u.map((r=>e.concat(r))),r=r.parent):r=r.parent}}if(t(a,u),e.nodes){const r=u[0].concat(s);o.set(e,r),n.set(e,u[0])}}}));for(const e of o.values())t(a,[e]);const l=new WeakMap;for(const[e,r]of o)l.set(e,a.findIndex((e=>r.equal(e))));return l}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const o=new Set(["scope","container","layer"]);function isProcessableCustomSelectorRule(e){if("atrule"!==e.type)return!1;if("custom-selector"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes(":--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!o.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function getCustomSelectors(r,t,s){const o=new Map,n=new Map,a=collectCascadeLayerOrder(r);return r.walkAtRules((r=>{var l,c;if(isProcessableCustomSelectorRule(r))try{var u;const t=r.params.trim(),p=e().astSync(t),i=null==p||null==(u=p.nodes)||null==(u=u[0])||null==(u=u.nodes)?void 0:u[0];if(!i||"pseudo"!==i.type||!i.value.startsWith(":--"))return;const m=i.toString(),f=(c=a,(l=r).parent&&"atrule"===l.parent.type&&"layer"===l.parent.name.toLowerCase()?c.has(l.parent)?c.get(l.parent)+1:0:1e7),d=n.get(m)??-1;if(f&&f>=d&&(n.set(m,f),o.set(m,e().astSync(t.slice(m.length).trim()))),!s.preserve){const e=r.parent;r.remove(),removeEmptyAncestorBlocks(e)}}catch(e){r.warn(t,`Failed to parse custom selector : "${r.params}" with message: "${e.message}"`)}})),o}function removeEmptyAncestorBlocks(e){let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformRule(r,t,s){let o=r.selector;try{o=e((r=>{r.walkPseudos((r=>{if(!s.has(r.value))return;const t=e.pseudo({value:":is",nodes:[]});s.get(r.value).each((e=>{t.append(e.clone({}))})),r.replaceWith(t)}))})).processSync(r.selector)}catch(e){return r.warn(t,`Failed to parse selector : "${o}" with message: "${e.message}"`),r.selector}return o}const creator=e=>{const r=Boolean(Object(e).preserve);if("importFrom"in Object(e))throw new Error('[postcss-custom-selectors] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-selectors] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-selectors",prepare(){const e=new WeakSet;let t=new Map;return{Once:(e,{result:s})=>{t=getCustomSelectors(e,s,{preserve:r})},Rule:(s,{result:o})=>{var n;if(e.has(s))return;if(null==(n=s.selector)||!n.includes(":--"))return;const a=transformRule(s,o,t);a!==s.selector&&(e.add(s),s.cloneBefore({selector:a}),r||s.remove())}}}}};creator.postcss=!0;export{creator as default}; +import e from"postcss-selector-parser";import{parse as r,addLayerToModel as t}from"@csstools/cascade-layer-name-parser";const s=r("csstools-implicit-layer")[0];function collectCascadeLayerOrder(e){const o=new Map,n=new Map,a=[];e.walkAtRules((e=>{if("layer"!==e.name.toLowerCase())return;{let r=e.parent;for(;r;){if("atrule"!==r.type||"layer"!==r.name.toLowerCase()){if(r===e.root())break;return}r=r.parent}}let c;if(e.nodes)c=normalizeLayerName(e.params,1);else{if(!e.params.trim())return;c=e.params}let l=r(c);if(l?.length){{let r=e.parent;for(;r&&"atrule"===r.type&&"layer"===r.name.toLowerCase();){const e=n.get(r);e?(l=l.map((r=>e.concat(r))),r=r.parent):r=r.parent}}if(t(a,l),e.nodes){const r=l[0].concat(s);o.set(e,r),n.set(e,l[0])}}}));for(const e of o.values())t(a,[e]);const c=new WeakMap;for(const[e,r]of o)c.set(e,a.findIndex((e=>r.equal(e))));return c}function normalizeLayerName(e,r){return e.trim()?e:"csstools-anon-layer--"+r++}const o=new Set(["scope","container","layer"]);function isProcessableCustomSelectorRule(e){if("atrule"!==e.type)return!1;if("custom-selector"!==e.name.toLowerCase())return!1;if(!e.params||!e.params.includes(":--"))return!1;if(e.nodes&&e.nodes.length>0)return!1;let r=e.parent;for(;r;){if("rule"===r.type)return!1;if("atrule"===r.type&&!o.has(r.name.toLowerCase()))return!1;r=r.parent}return!0}function getCustomSelectors(r,t,s){const o=new Map,n=new Map,a=collectCascadeLayerOrder(r);return r.walkAtRules((r=>{var c,l;if(isProcessableCustomSelectorRule(r))try{const t=r.params.trim(),p=e().astSync(t),u=p?.nodes?.[0]?.nodes?.[0];if(!u||"pseudo"!==u.type||!u.value.startsWith(":--"))return;const i=u.toString(),m=(l=a,(c=r).parent&&"atrule"===c.parent.type&&"layer"===c.parent.name.toLowerCase()?l.has(c.parent)?l.get(c.parent)+1:0:1e7),f=n.get(i)??-1;if(m&&m>=f&&(n.set(i,m),o.set(i,e().astSync(t.slice(i.length).trim()))),!s.preserve){const e=r.parent;r.remove(),removeEmptyAncestorBlocks(e)}}catch(e){r.warn(t,`Failed to parse selector : "${r.params}" with message: "${e instanceof Error?e.message:e}"`)}})),o}function removeEmptyAncestorBlocks(e){if(!e)return;let r=e;for(;r;){if(r.nodes&&r.nodes.length>0)return;const e=r.parent;r.remove(),r=e}}function transformRule(r,t,s){let o=r.selector;try{o=e((r=>{r.walkPseudos((r=>{if(!s.has(r.value))return;const t=e.pseudo({value:":is",nodes:[]}),o=s.get(r.value);o&&(o.each((e=>{t.append(e.clone({}))})),r.replaceWith(t))}))})).processSync(r.selector)}catch(e){return r.warn(t,`Failed to parse selector : "${o}" with message: "${e instanceof Error?e.message:e}"`),r.selector}return o}const creator=e=>{const r=Boolean(Object(e).preserve);if("importFrom"in Object(e))throw new Error('[postcss-custom-selectors] "importFrom" is no longer supported');if("exportTo"in Object(e))throw new Error('[postcss-custom-selectors] "exportTo" is no longer supported');return{postcssPlugin:"postcss-custom-selectors",prepare(){const e=new WeakSet;let t=new Map;return{postcssPlugin:"postcss-custom-selectors",Once(e,{result:s}){t=getCustomSelectors(e,s,{preserve:r})},Rule(s,{result:o}){if(e.has(s))return;if(!s.selector?.includes(":--"))return;const n=transformRule(s,o,t);n!==s.selector&&(e.add(s),s.cloneBefore({selector:n}),r||s.remove())}}}}};creator.postcss=!0;export{creator as default}; diff --git a/node_modules/postcss-custom-selectors/dist/is-processable-custom-selector-rule.d.ts b/node_modules/postcss-custom-selectors/dist/is-processable-custom-selector-rule.d.ts deleted file mode 100644 index 2dd82837..00000000 --- a/node_modules/postcss-custom-selectors/dist/is-processable-custom-selector-rule.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { AtRule } from 'postcss'; -export declare function isProcessableCustomSelectorRule(atRule: AtRule): boolean; diff --git a/node_modules/postcss-custom-selectors/dist/transform-rule.d.ts b/node_modules/postcss-custom-selectors/dist/transform-rule.d.ts deleted file mode 100644 index 2d781eca..00000000 --- a/node_modules/postcss-custom-selectors/dist/transform-rule.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { Result, Rule } from 'postcss'; -import type { Root } from 'postcss-selector-parser'; -export declare function transformRule(rule: Rule, result: Result, customSelectors: Map<string, Root>): null | string; diff --git a/node_modules/postcss-custom-selectors/package.json b/node_modules/postcss-custom-selectors/package.json index 8bd7d773..35f1e177 100644 --- a/node_modules/postcss-custom-selectors/package.json +++ b/node_modules/postcss-custom-selectors/package.json @@ -1,7 +1,7 @@ { "name": "postcss-custom-selectors", "description": "Use Custom Selectors in CSS", - "version": "7.1.6", + "version": "7.1.10", "contributors": [ { "name": "Antonio Laguna", @@ -37,15 +37,18 @@ "engines": { "node": "^14 || ^16 || >=18" }, + "type": "module", "main": "dist/index.cjs", "module": "dist/index.mjs", - "types": "dist/index.d.ts", "exports": { ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.cjs", - "default": "./dist/index.mjs" + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" + }, + "require": { + "default": "./dist/index.cjs" + } } }, "files": [ @@ -55,29 +58,18 @@ "dist" ], "dependencies": { - "@csstools/cascade-layer-name-parser": "^1.0.5", - "@csstools/css-parser-algorithms": "^2.3.2", - "@csstools/css-tokenizer": "^2.2.1", + "@csstools/cascade-layer-name-parser": "^1.0.11", + "@csstools/css-parser-algorithms": "^2.6.3", + "@csstools/css-tokenizer": "^2.3.1", "postcss-selector-parser": "^6.0.13" }, "peerDependencies": { "postcss": "^8.4" }, - "devDependencies": { - "@csstools/postcss-tape": "*" - }, - "scripts": { - "build": "rollup -c ../../rollup/default.mjs", - "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs", - "lint": "node ../../.github/bin/format-package-json.mjs", - "prepublishOnly": "npm run build && npm run test", - "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs", - "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs" - }, "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-selectors#readme", "repository": { "type": "git", - "url": "https://github.com/csstools/postcss-plugins.git", + "url": "git+https://github.com/csstools/postcss-plugins.git", "directory": "plugins/postcss-custom-selectors" }, "bugs": "https://github.com/csstools/postcss-plugins/issues", @@ -95,15 +87,5 @@ "selectors", "specification", "w3c" - ], - "csstools": { - "assumesToProcessBundledCSS": true, - "cssdbId": "custom-selectors", - "exportName": "postcssCustomSelectors", - "humanReadableName": "PostCSS Custom Selectors", - "specUrl": "https://drafts.csswg.org/css-extensions/#custom-selectors" - }, - "volta": { - "extends": "../../package.json" - } + ] } |
