summaryrefslogtreecommitdiff
path: root/node_modules/@csstools/selector-resolve-nested
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:10:59 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:41:44 +0800
commitfc87c009806dcc98867f6b58efe29b042aa01dee (patch)
tree8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/@csstools/selector-resolve-nested
parent3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff)
node: updatemain
Diffstat (limited to 'node_modules/@csstools/selector-resolve-nested')
-rw-r--r--node_modules/@csstools/selector-resolve-nested/CHANGELOG.md31
-rw-r--r--node_modules/@csstools/selector-resolve-nested/LICENSE.md18
-rw-r--r--node_modules/@csstools/selector-resolve-nested/README.md33
-rw-r--r--node_modules/@csstools/selector-resolve-nested/dist/index.cjs1
-rw-r--r--node_modules/@csstools/selector-resolve-nested/dist/index.d.ts47
-rw-r--r--node_modules/@csstools/selector-resolve-nested/dist/index.mjs1
-rw-r--r--node_modules/@csstools/selector-resolve-nested/package.json79
7 files changed, 0 insertions, 210 deletions
diff --git a/node_modules/@csstools/selector-resolve-nested/CHANGELOG.md b/node_modules/@csstools/selector-resolve-nested/CHANGELOG.md
deleted file mode 100644
index 3120273a..00000000
--- a/node_modules/@csstools/selector-resolve-nested/CHANGELOG.md
+++ /dev/null
@@ -1,31 +0,0 @@
-# Changes to Selector Resolve Nested
-
-## 1.1.0
-
-_February 1, 2024_
-
-- Add `flattenNestedSelector` function to support more kinds of static analysis for nested selectors.
-
-## 1.0.3
-
-_January 25, 2024_
-
-- Correctly add child nodes to newly constructed `Selector` and `Root` AST nodes.
-
-## 1.0.2
-
-_January 22, 2024_
-
-- Preserve extra/unknown fields on source objects of AST nodes
-
-### 1.0.1
-
-_January 21, 2024_
-
-- Improve source index resolution
-
-### 1.0.0
-
-_January 21, 2024_
-
-- Initial version
diff --git a/node_modules/@csstools/selector-resolve-nested/LICENSE.md b/node_modules/@csstools/selector-resolve-nested/LICENSE.md
deleted file mode 100644
index e8ae93b9..00000000
--- a/node_modules/@csstools/selector-resolve-nested/LICENSE.md
+++ /dev/null
@@ -1,18 +0,0 @@
-MIT No Attribution (MIT-0)
-
-Copyright © CSSTools Contributors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the “Software”), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/node_modules/@csstools/selector-resolve-nested/README.md b/node_modules/@csstools/selector-resolve-nested/README.md
deleted file mode 100644
index 9f7aa7b0..00000000
--- a/node_modules/@csstools/selector-resolve-nested/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-# Selector Resolve Nested
-
-[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/selector-resolve-nested.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]
-
-## API
-
-[Read the API docs](./docs/selector-resolve-nested.md)
-
-## Usage
-
-Add [Selector Resolve Nested] to your project:
-
-```bash
-npm install @csstools/selector-resolve-nested --save-dev
-```
-
-```js
-import { resolveNestedSelector } from '@csstools/selector-resolve-nested';
-import parser from 'postcss-selector-parser';
-
-const a = parser().astSync('.foo &');
-const b = parser().astSync('.bar');
-
-resolveNestedSelector(a, b); // '.foo .bar'
-```
-
-[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
-[discord]: https://discord.gg/bUadyRwkJS
-[npm-url]: https://www.npmjs.com/package/@csstools/selector-resolve-nested
-
-[Selector Resolve Nested]: https://github.com/csstools/postcss-plugins/tree/main/packages/selector-resolve-nested
diff --git a/node_modules/@csstools/selector-resolve-nested/dist/index.cjs b/node_modules/@csstools/selector-resolve-nested/dist/index.cjs
deleted file mode 100644
index 754d81ac..00000000
--- a/node_modules/@csstools/selector-resolve-nested/dist/index.cjs
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";var e=require("postcss-selector-parser");function sourceFrom(e){return{sourceIndex:e.sourceIndex??0,source:e.source}}function sortCompoundSelectorsInsideComplexSelector(o){const t=[];let r=[];o.each((o=>{if("combinator"===o.type)return t.push(r,[o]),void(r=[]);if(e.isPseudoElement(o))return t.push(r),void(r=[o]);if("universal"===o.type&&r.find((e=>"universal"===e.type)))o.remove();else{if("tag"===o.type&&r.find((e=>"tag"===e.type))){o.remove();const t=e.selector({value:"",...sourceFrom(o)});t.append(o);const n=e.pseudo({value:":is",...sourceFrom(o)});return n.append(t),void r.push(n)}r.push(o)}})),t.push(r);const n=[];for(let e=0;e<t.length;e++){const o=t[e];o.sort(((e,o)=>selectorTypeOrder(e)-selectorTypeOrder(o))),n.push(...o)}o.removeAll();for(let e=n.length-1;e>=0;e--)n[e].remove(),o.prepend(n[e])}function selectorTypeOrder(t){return e.isPseudoElement(t)?o.pseudoElement:o[t.type]}const o={universal:0,tag:1,pseudoElement:2,nesting:3,id:4,class:5,attribute:6,pseudo:7,comment:8};function prepareParentSelectors(o,t=!1){if(t||!isCompoundSelector(o.nodes)){const t=e.pseudo({value:":is",...sourceFrom(o)});return o.nodes.forEach((e=>{t.append(e.clone())})),[t]}return o.nodes[0].nodes.map((e=>e.clone()))}function isCompoundSelector(o){return 1===o.length&&!o[0].nodes.some((o=>"combinator"===o.type||e.isPseudoElement(o)))}function combinationsWithSizeN(e,o){if(o<2)throw new Error("n must be greater than 1");if(e.length<2)throw new Error("s must be greater than 1");if(Math.pow(e.length,o)>1e4)throw new Error("Too many combinations when trying to resolve a nested selector with lists, reduce the complexity of your selectors");const t=[];for(let e=0;e<o;e++)t[e]=0;const r=[];for(;;){const n=[];for(let s=o-1;s>=0;s--){let o=t[s];if(o>=e.length){if(o=0,t[s]=0,0===s)return r;t[s-1]+=1}n[s]=e[o].clone()}r.push(n),t[t.length-1]++}}exports.flattenNestedSelector=function flattenNestedSelector(o,t){const r=[];for(let n=0;n<o.nodes.length;n++){const s=o.nodes[n].clone();let c,l=0;{let o=!1;s.walkNesting((()=>{o=!0,l++})),o?"combinator"===s.nodes[0]?.type&&(s.prepend(e.nesting({...sourceFrom(s)})),l++):(s.prepend(e.combinator({value:" ",...sourceFrom(s)})),s.prepend(e.nesting({...sourceFrom(s)})),l++)}let p=[];if(l>1&&t.nodes.length>1)p=combinationsWithSizeN(t.nodes,l),c=p.length;else{c=t.nodes.length;for(let e=0;e<t.nodes.length;e++){p.push([]);for(let o=0;o<l;o++)p[e].push(t.nodes[e].clone())}}for(let e=0;e<c;e++){let o=0;const t=s.clone();t.walkNesting((t=>{const r=p[e][o];o++,t.replaceWith(...r.nodes)})),r.push(t)}}const n=e.root({value:"",...sourceFrom(o)});return r.forEach((e=>{n.append(e)})),n},exports.resolveNestedSelector=function resolveNestedSelector(o,t){const r=[];for(let n=0;n<o.nodes.length;n++){const s=o.nodes[n].clone();{let o=!1;s.walkNesting((()=>(o=!0,!1))),o?"combinator"===s.nodes[0]?.type&&s.prepend(e.nesting({...sourceFrom(s)})):(s.prepend(e.combinator({value:" ",...sourceFrom(s)})),s.prepend(e.nesting({...sourceFrom(s)})))}{const e=new Set;s.walkNesting((o=>{const r=o.parent;e.add(r),"pseudo"===r.parent?.type&&":has"===r.parent.value?.toLowerCase()?o.replaceWith(...prepareParentSelectors(t,!0)):o.replaceWith(...prepareParentSelectors(t))}));for(const o of e)sortCompoundSelectorsInsideComplexSelector(o)}s.walk((e=>{"combinator"===e.type&&""!==e.value.trim()?(e.rawSpaceAfter=" ",e.rawSpaceBefore=" "):(e.rawSpaceAfter="",e.rawSpaceBefore="")})),r.push(s)}const n=e.root({value:"",...sourceFrom(o)});return r.forEach((e=>{n.append(e)})),n};
diff --git a/node_modules/@csstools/selector-resolve-nested/dist/index.d.ts b/node_modules/@csstools/selector-resolve-nested/dist/index.d.ts
deleted file mode 100644
index 4150620b..00000000
--- a/node_modules/@csstools/selector-resolve-nested/dist/index.d.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Resolve nested selectors following the CSS nesting specification.
- *
- * @example
- *
- * ```js
- * import { resolveNestedSelector } from '@csstools/selector-resolve-nested';
- * import parser from 'postcss-selector-parser';
- *
- * const selector = parser().astSync('.foo &');
- * const parent = parser().astSync('.bar');
- *
- * // .foo .bar
- * console.log(
- * resolveNestedSelector(selector, parent).toString()
- * )
- * ```
- *
- * @packageDocumentation
- */
-
-import type { Root } from 'postcss-selector-parser';
-
-/**
- * Flatten a nested selector against a given parent selector.
- *
- * ⚠️ This is not a method to generate the equivalent un-nested selector.
- * It is purely a method to construct a single selector AST that contains the parts of both the current and parent selector.
- * It will not have the correct specificity and it will not match the right elements when used as a selector.
- * It will not always serialize to a valid selector.
- *
- * @param selector - The selector to resolve.
- * @param parentSelector - The parent selector to resolve against.
- * @returns The resolved selector.
- */
-export declare function flattenNestedSelector(selector: Root, parentSelector: Root): Root;
-
-/**
- * Resolve a nested selector against a given parent selector.
- *
- * @param selector - The selector to resolve.
- * @param parentSelector - The parent selector to resolve against.
- * @returns The resolved selector.
- */
-export declare function resolveNestedSelector(selector: Root, parentSelector: Root): Root;
-
-export { }
diff --git a/node_modules/@csstools/selector-resolve-nested/dist/index.mjs b/node_modules/@csstools/selector-resolve-nested/dist/index.mjs
deleted file mode 100644
index ec2a460d..00000000
--- a/node_modules/@csstools/selector-resolve-nested/dist/index.mjs
+++ /dev/null
@@ -1 +0,0 @@
-import e from"postcss-selector-parser";function sourceFrom(e){return{sourceIndex:e.sourceIndex??0,source:e.source}}function sortCompoundSelectorsInsideComplexSelector(o){const t=[];let r=[];o.each((o=>{if("combinator"===o.type)return t.push(r,[o]),void(r=[]);if(e.isPseudoElement(o))return t.push(r),void(r=[o]);if("universal"===o.type&&r.find((e=>"universal"===e.type)))o.remove();else{if("tag"===o.type&&r.find((e=>"tag"===e.type))){o.remove();const t=e.selector({value:"",...sourceFrom(o)});t.append(o);const n=e.pseudo({value:":is",...sourceFrom(o)});return n.append(t),void r.push(n)}r.push(o)}})),t.push(r);const n=[];for(let e=0;e<t.length;e++){const o=t[e];o.sort(((e,o)=>selectorTypeOrder(e)-selectorTypeOrder(o))),n.push(...o)}o.removeAll();for(let e=n.length-1;e>=0;e--)n[e].remove(),o.prepend(n[e])}function selectorTypeOrder(t){return e.isPseudoElement(t)?o.pseudoElement:o[t.type]}const o={universal:0,tag:1,pseudoElement:2,nesting:3,id:4,class:5,attribute:6,pseudo:7,comment:8};function resolveNestedSelector(o,t){const r=[];for(let n=0;n<o.nodes.length;n++){const s=o.nodes[n].clone();{let o=!1;s.walkNesting((()=>(o=!0,!1))),o?"combinator"===s.nodes[0]?.type&&s.prepend(e.nesting({...sourceFrom(s)})):(s.prepend(e.combinator({value:" ",...sourceFrom(s)})),s.prepend(e.nesting({...sourceFrom(s)})))}{const e=new Set;s.walkNesting((o=>{const r=o.parent;e.add(r),"pseudo"===r.parent?.type&&":has"===r.parent.value?.toLowerCase()?o.replaceWith(...prepareParentSelectors(t,!0)):o.replaceWith(...prepareParentSelectors(t))}));for(const o of e)sortCompoundSelectorsInsideComplexSelector(o)}s.walk((e=>{"combinator"===e.type&&""!==e.value.trim()?(e.rawSpaceAfter=" ",e.rawSpaceBefore=" "):(e.rawSpaceAfter="",e.rawSpaceBefore="")})),r.push(s)}const n=e.root({value:"",...sourceFrom(o)});return r.forEach((e=>{n.append(e)})),n}function prepareParentSelectors(o,t=!1){if(t||!isCompoundSelector(o.nodes)){const t=e.pseudo({value:":is",...sourceFrom(o)});return o.nodes.forEach((e=>{t.append(e.clone())})),[t]}return o.nodes[0].nodes.map((e=>e.clone()))}function isCompoundSelector(o){return 1===o.length&&!o[0].nodes.some((o=>"combinator"===o.type||e.isPseudoElement(o)))}function combinationsWithSizeN(e,o){if(o<2)throw new Error("n must be greater than 1");if(e.length<2)throw new Error("s must be greater than 1");if(Math.pow(e.length,o)>1e4)throw new Error("Too many combinations when trying to resolve a nested selector with lists, reduce the complexity of your selectors");const t=[];for(let e=0;e<o;e++)t[e]=0;const r=[];for(;;){const n=[];for(let s=o-1;s>=0;s--){let o=t[s];if(o>=e.length){if(o=0,t[s]=0,0===s)return r;t[s-1]+=1}n[s]=e[o].clone()}r.push(n),t[t.length-1]++}}function flattenNestedSelector(o,t){const r=[];for(let n=0;n<o.nodes.length;n++){const s=o.nodes[n].clone();let c,l=0;{let o=!1;s.walkNesting((()=>{o=!0,l++})),o?"combinator"===s.nodes[0]?.type&&(s.prepend(e.nesting({...sourceFrom(s)})),l++):(s.prepend(e.combinator({value:" ",...sourceFrom(s)})),s.prepend(e.nesting({...sourceFrom(s)})),l++)}let p=[];if(l>1&&t.nodes.length>1)p=combinationsWithSizeN(t.nodes,l),c=p.length;else{c=t.nodes.length;for(let e=0;e<t.nodes.length;e++){p.push([]);for(let o=0;o<l;o++)p[e].push(t.nodes[e].clone())}}for(let e=0;e<c;e++){let o=0;const t=s.clone();t.walkNesting((t=>{const r=p[e][o];o++,t.replaceWith(...r.nodes)})),r.push(t)}}const n=e.root({value:"",...sourceFrom(o)});return r.forEach((e=>{n.append(e)})),n}export{flattenNestedSelector,resolveNestedSelector};
diff --git a/node_modules/@csstools/selector-resolve-nested/package.json b/node_modules/@csstools/selector-resolve-nested/package.json
deleted file mode 100644
index eff305ec..00000000
--- a/node_modules/@csstools/selector-resolve-nested/package.json
+++ /dev/null
@@ -1,79 +0,0 @@
-{
- "name": "@csstools/selector-resolve-nested",
- "description": "Resolve nested CSS selectors",
- "version": "1.1.0",
- "contributors": [
- {
- "name": "Antonio Laguna",
- "email": "antonio@laguna.es",
- "url": "https://antonio.laguna.es"
- },
- {
- "name": "Romain Menke",
- "email": "romainmenke@gmail.com"
- }
- ],
- "license": "MIT-0",
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/csstools"
- },
- {
- "type": "opencollective",
- "url": "https://opencollective.com/csstools"
- }
- ],
- "engines": {
- "node": "^14 || ^16 || >=18"
- },
- "type": "module",
- "main": "dist/index.cjs",
- "module": "dist/index.mjs",
- "exports": {
- ".": {
- "import": {
- "types": "./dist/index.d.ts",
- "default": "./dist/index.mjs"
- },
- "require": {
- "default": "./dist/index.cjs"
- }
- }
- },
- "files": [
- "CHANGELOG.md",
- "LICENSE.md",
- "README.md",
- "dist"
- ],
- "peerDependencies": {
- "postcss-selector-parser": "^6.0.13"
- },
- "devDependencies": {
- "postcss-selector-parser": "^6.0.13"
- },
- "scripts": {
- "build": "rollup -c ../../rollup/default.mjs",
- "docs": "node ../../.github/bin/generate-docs/api-documenter.mjs",
- "lint": "node ../../.github/bin/format-package-json.mjs",
- "prepublishOnly": "npm run build && npm run test",
- "stryker": "stryker run --logLevel error",
- "test": "node --test ./test/index.mjs ./test/_import.mjs && node ./test/_require.cjs"
- },
- "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/selector-resolve-nested#readme",
- "repository": {
- "type": "git",
- "url": "https://github.com/csstools/postcss-plugins.git",
- "directory": "packages/selector-resolve-nested"
- },
- "bugs": "https://github.com/csstools/postcss-plugins/issues",
- "keywords": [
- "css",
- "nested",
- "postcss-selector-parser"
- ],
- "volta": {
- "extends": "../../package.json"
- }
-}