Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
9
Frontend-Learner/node_modules/@csstools/selector-specificity/CHANGELOG.md
generated
vendored
Normal file
9
Frontend-Learner/node_modules/@csstools/selector-specificity/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Changes to Selector Specificity
|
||||
|
||||
### 5.0.0
|
||||
|
||||
_October 23, 2024_
|
||||
|
||||
- Updated: `postcss-selector-parser`
|
||||
|
||||
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity/CHANGELOG.md)
|
||||
18
Frontend-Learner/node_modules/@csstools/selector-specificity/LICENSE.md
generated
vendored
Normal file
18
Frontend-Learner/node_modules/@csstools/selector-specificity/LICENSE.md
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
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.
|
||||
57
Frontend-Learner/node_modules/@csstools/selector-specificity/README.md
generated
vendored
Normal file
57
Frontend-Learner/node_modules/@csstools/selector-specificity/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# Selector Specificity
|
||||
|
||||
[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/selector-specificity.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]
|
||||
|
||||
## Usage
|
||||
|
||||
Add [Selector Specificity] to your project:
|
||||
|
||||
```bash
|
||||
npm install @csstools/selector-specificity --save-dev
|
||||
```
|
||||
|
||||
```js
|
||||
import parser from 'postcss-selector-parser';
|
||||
import { selectorSpecificity } from '@csstools/selector-specificity';
|
||||
|
||||
const selectorAST = parser().astSync('#foo:has(> .foo)');
|
||||
const specificity = selectorSpecificity(selectorAST);
|
||||
|
||||
console.log(specificity.a); // 1
|
||||
console.log(specificity.b); // 1
|
||||
console.log(specificity.c); // 0
|
||||
```
|
||||
|
||||
_`selectorSpecificity` takes a single selector, not a list of selectors (not : `a, b, c`).
|
||||
To compare or otherwise manipulate lists of selectors you need to call `selectorSpecificity` on each part._
|
||||
|
||||
### Comparing
|
||||
|
||||
The package exports a utility function to compare two specificities.
|
||||
|
||||
```js
|
||||
import { selectorSpecificity, compare } from '@csstools/selector-specificity';
|
||||
|
||||
const s1 = selectorSpecificity(ast1);
|
||||
const s2 = selectorSpecificity(ast2);
|
||||
compare(s1, s2); // -1 | 0 | 1
|
||||
```
|
||||
|
||||
- if `s1 < s2` then `compare(s1, s2)` returns a negative number (`< 0`)
|
||||
- if `s1 > s2` then `compare(s1, s2)` returns a positive number (`> 0`)
|
||||
- if `s1 === s2` then `compare(s1, s2)` returns zero (`=== 0`)
|
||||
|
||||
## Prior Art
|
||||
|
||||
- [keeganstreet/specificity](https://github.com/keeganstreet/specificity)
|
||||
- [bramus/specificity](https://github.com/bramus/specificity)
|
||||
|
||||
For CSSTools we always use `postcss-selector-parser` and want to calculate specificity from this AST.
|
||||
|
||||
[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-specificity
|
||||
|
||||
[Selector Specificity]: https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity
|
||||
1
Frontend-Learner/node_modules/@csstools/selector-specificity/dist/index.cjs
generated
vendored
Normal file
1
Frontend-Learner/node_modules/@csstools/selector-specificity/dist/index.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"use strict";var e=require("postcss-selector-parser");function compare(e,t){return e.a===t.a?e.b===t.b?e.c-t.c:e.b-t.b:e.a-t.a}function selectorSpecificity(t,s){const i=s?.customSpecificity?.(t);if(i)return i;if(!t)return{a:0,b:0,c:0};let c=0,n=0,o=0;if("universal"==t.type)return{a:0,b:0,c:0};if("id"===t.type)c+=1;else if("tag"===t.type)o+=1;else if("class"===t.type)n+=1;else if("attribute"===t.type)n+=1;else if(isPseudoElement(t))switch(t.value.toLowerCase()){case"::slotted":if(o+=1,t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case"::view-transition-group":case"::view-transition-image-pair":case"::view-transition-old":case"::view-transition-new":return t.nodes&&1===t.nodes.length&&"selector"===t.nodes[0].type&&selectorNodeContainsNothingOrOnlyUniversal(t.nodes[0])?{a:0,b:0,c:0}:{a:0,b:0,c:1};default:o+=1}else if(e.isPseudoClass(t))switch(t.value.toLowerCase()){case":-webkit-any":case":any":default:n+=1;break;case":-moz-any":case":has":case":is":case":matches":case":not":if(t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case":where":break;case":nth-child":case":nth-last-child":if(n+=1,t.nodes&&t.nodes.length>0){const i=t.nodes[0].nodes.findIndex((e=>"tag"===e.type&&"of"===e.value.toLowerCase()));if(i>-1){const a=e.selector({nodes:[],value:""});t.nodes[0].nodes.slice(i+1).forEach((e=>{a.append(e.clone())}));const r=[a];t.nodes.length>1&&r.push(...t.nodes.slice(1));const l=specificityOfMostSpecificListItem(r,s);c+=l.a,n+=l.b,o+=l.c}}break;case":local":case":global":t.nodes&&t.nodes.length>0&&t.nodes.forEach((e=>{const t=selectorSpecificity(e,s);c+=t.a,n+=t.b,o+=t.c}));break;case":host":case":host-context":if(n+=1,t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case":active-view-transition":case":active-view-transition-type":return{a:0,b:1,c:0}}else e.isContainer(t)&&t.nodes?.length>0&&t.nodes.forEach((e=>{const t=selectorSpecificity(e,s);c+=t.a,n+=t.b,o+=t.c}));return{a:c,b:n,c:o}}function specificityOfMostSpecificListItem(e,t){let s={a:0,b:0,c:0};return e.forEach((e=>{const i=selectorSpecificity(e,t);compare(i,s)<0||(s=i)})),s}function isPseudoElement(t){return e.isPseudoElement(t)}function selectorNodeContainsNothingOrOnlyUniversal(e){if(!e)return!1;if(!e.nodes)return!1;const t=e.nodes.filter((e=>"comment"!==e.type));return 0===t.length||1===t.length&&"universal"===t[0].type}exports.compare=compare,exports.selectorSpecificity=selectorSpecificity,exports.specificityOfMostSpecificListItem=specificityOfMostSpecificListItem;
|
||||
58
Frontend-Learner/node_modules/@csstools/selector-specificity/dist/index.d.ts
generated
vendored
Normal file
58
Frontend-Learner/node_modules/@csstools/selector-specificity/dist/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import type { Node } from 'postcss-selector-parser';
|
||||
|
||||
/**
|
||||
* Options for the calculation of the specificity of a selector
|
||||
*/
|
||||
export declare type CalculationOptions = {
|
||||
/**
|
||||
* The callback to calculate a custom specificity for a node
|
||||
*/
|
||||
customSpecificity?: CustomSpecificityCallback;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compare two specificities
|
||||
* @param s1 The first specificity
|
||||
* @param s2 The second specificity
|
||||
* @returns A value smaller than `0` if `s1` is less specific than `s2`, `0` if `s1` is equally specific as `s2`, a value larger than `0` if `s1` is more specific than `s2`
|
||||
*/
|
||||
export declare function compare(s1: Specificity, s2: Specificity): number;
|
||||
|
||||
/**
|
||||
* Calculate a custom specificity for a node
|
||||
*/
|
||||
export declare type CustomSpecificityCallback = (node: Node) => Specificity | void | false | null | undefined;
|
||||
|
||||
/**
|
||||
* Calculate the specificity for a selector
|
||||
*/
|
||||
export declare function selectorSpecificity(node: Node, options?: CalculationOptions): Specificity;
|
||||
|
||||
/**
|
||||
* The specificity of a selector
|
||||
*/
|
||||
export declare type Specificity = {
|
||||
/**
|
||||
* The number of ID selectors in the selector
|
||||
*/
|
||||
a: number;
|
||||
/**
|
||||
* The number of class selectors, attribute selectors, and pseudo-classes in the selector
|
||||
*/
|
||||
b: number;
|
||||
/**
|
||||
* The number of type selectors and pseudo-elements in the selector
|
||||
*/
|
||||
c: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the most specific selector in a list
|
||||
*/
|
||||
export declare function specificityOfMostSpecificListItem(nodes: Array<Node>, options?: CalculationOptions): {
|
||||
a: number;
|
||||
b: number;
|
||||
c: number;
|
||||
};
|
||||
|
||||
export { }
|
||||
1
Frontend-Learner/node_modules/@csstools/selector-specificity/dist/index.mjs
generated
vendored
Normal file
1
Frontend-Learner/node_modules/@csstools/selector-specificity/dist/index.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
import e from"postcss-selector-parser";function compare(e,t){return e.a===t.a?e.b===t.b?e.c-t.c:e.b-t.b:e.a-t.a}function selectorSpecificity(t,s){const i=s?.customSpecificity?.(t);if(i)return i;if(!t)return{a:0,b:0,c:0};let c=0,n=0,o=0;if("universal"==t.type)return{a:0,b:0,c:0};if("id"===t.type)c+=1;else if("tag"===t.type)o+=1;else if("class"===t.type)n+=1;else if("attribute"===t.type)n+=1;else if(isPseudoElement(t))switch(t.value.toLowerCase()){case"::slotted":if(o+=1,t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case"::view-transition-group":case"::view-transition-image-pair":case"::view-transition-old":case"::view-transition-new":return t.nodes&&1===t.nodes.length&&"selector"===t.nodes[0].type&&selectorNodeContainsNothingOrOnlyUniversal(t.nodes[0])?{a:0,b:0,c:0}:{a:0,b:0,c:1};default:o+=1}else if(e.isPseudoClass(t))switch(t.value.toLowerCase()){case":-webkit-any":case":any":default:n+=1;break;case":-moz-any":case":has":case":is":case":matches":case":not":if(t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case":where":break;case":nth-child":case":nth-last-child":if(n+=1,t.nodes&&t.nodes.length>0){const i=t.nodes[0].nodes.findIndex((e=>"tag"===e.type&&"of"===e.value.toLowerCase()));if(i>-1){const a=e.selector({nodes:[],value:""});t.nodes[0].nodes.slice(i+1).forEach((e=>{a.append(e.clone())}));const r=[a];t.nodes.length>1&&r.push(...t.nodes.slice(1));const l=specificityOfMostSpecificListItem(r,s);c+=l.a,n+=l.b,o+=l.c}}break;case":local":case":global":t.nodes&&t.nodes.length>0&&t.nodes.forEach((e=>{const t=selectorSpecificity(e,s);c+=t.a,n+=t.b,o+=t.c}));break;case":host":case":host-context":if(n+=1,t.nodes&&t.nodes.length>0){const e=specificityOfMostSpecificListItem(t.nodes,s);c+=e.a,n+=e.b,o+=e.c}break;case":active-view-transition":case":active-view-transition-type":return{a:0,b:1,c:0}}else e.isContainer(t)&&t.nodes?.length>0&&t.nodes.forEach((e=>{const t=selectorSpecificity(e,s);c+=t.a,n+=t.b,o+=t.c}));return{a:c,b:n,c:o}}function specificityOfMostSpecificListItem(e,t){let s={a:0,b:0,c:0};return e.forEach((e=>{const i=selectorSpecificity(e,t);compare(i,s)<0||(s=i)})),s}function isPseudoElement(t){return e.isPseudoElement(t)}function selectorNodeContainsNothingOrOnlyUniversal(e){if(!e)return!1;if(!e.nodes)return!1;const t=e.nodes.filter((e=>"comment"!==e.type));return 0===t.length||1===t.length&&"universal"===t[0].type}export{compare,selectorSpecificity,specificityOfMostSpecificListItem};
|
||||
66
Frontend-Learner/node_modules/@csstools/selector-specificity/package.json
generated
vendored
Normal file
66
Frontend-Learner/node_modules/@csstools/selector-specificity/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"name": "@csstools/selector-specificity",
|
||||
"description": "Determine selector specificity with postcss-selector-parser",
|
||||
"version": "5.0.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": ">=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": "^7.0.0"
|
||||
},
|
||||
"scripts": {},
|
||||
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/csstools/postcss-plugins.git",
|
||||
"directory": "packages/selector-specificity"
|
||||
},
|
||||
"bugs": "https://github.com/csstools/postcss-plugins/issues",
|
||||
"keywords": [
|
||||
"css",
|
||||
"postcss-selector-parser",
|
||||
"specificity"
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue