feat: initial commit of Railtrack Pro prototype with complete test suite

This commit is contained in:
Railtrack Pro Dev committed 2026-03-13 14:26:16 +00:00
commit 40500bb503
7790 files changed
+986332

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2022 Bramus Van Damme - https://www.bram.us/
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, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
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.
+164
View File
@@ -0,0 +1,164 @@
[![Calculate CSS Specificity](./screenshots/calculate-specificity.png)](https://codepen.io/bramus/pen/WNXyoYm)
# Specificity
`@bramus/specificity` is a package to calculate the specificity of CSS Selectors. It also includes some convenience functions to compare, sort, and filter an array of specificity values.
Supports [Selectors Level 4](https://www.w3.org/TR/selectors-4/), including those special cases `:is()`, `:where()`, `:not()`, etc.
Demo: [https://codepen.io/bramus/pen/WNXyoYm](https://codepen.io/bramus/pen/WNXyoYm)
## Installation
```bash
npm i @bramus/specificity
```
## Usage / Example
At its core, `@bramus/specificity` exposes a `Specificity` class. Its static `calculate` method can be used to calculate the specificity of a given CSS [Selector List](https://www.w3.org/TR/selectors-4/#grouping) string.
```js
import Specificity from '@bramus/specificity';
const specificities = Specificity.calculate('header:where(#top) nav li:nth-child(2n), #doormat');
```
Because `calculate` accepts a [Selector List](https://www.w3.org/TR/selectors-4/#grouping) — which can contain more than 1 [Selector](https://www.w3.org/TR/selectors-4/#selector) — it will always return an array, with each entry being a `Specificity` instance — one per found selector.
```js
const specificities = Specificity.calculate('header:where(#top) nav li:nth-child(2n), #doormat');
specificities.map((s) => s.toString()); // ~> ["(0,1,3)","(1,0,0)"]
```
💡 If you know you’re passing only a single Selector into `calculate()`, you can use JavaScript’s built-in destructuring to keep your variable names clean.
```js
const [s] = Specificity.calculate('header:where(#top) nav li:nth-child(2n)');
s.toString(); // ~> "(0,1,3)"
```
💡 Under the hood, `@bramus/specificity` uses [CSSTree](https://github.com/csstree/csstree) to do the parsing of strings to Selectors. As a result, the `calculate` method also accepts a [CSSTree AST](https://github.com/csstree/csstree/blob/master/docs/ast.md) of the types `Selector` and `SelectorList`.
If you have a pre-parsed CSSTree AST of the type `Selector` you can pass it into `Specificity.calculateForAST()`. It [performs slightly better](#benchmark) than `Specificity.calculate()` as it needs to check fewer things. It differs from `Specificity.calculate()` in that it does not return an array of `Specificity` instances but only a single value.
## The Return Format
A calculated specificity is represented as an instance of the `Specificity` class. The `Specificity` class includes methods to get the specificity value in a certain format, along with some convenience methods to compare it against other instances.
```js
// 🚀 Thunderbirds are go!
import Specificity from '@bramus/specificity';
// ✨ Calculate specificity for each Selector in the given Selector List
const specificities = Specificity.calculate('header:where(#top) nav li:nth-child(2n), #doormat');
// 🚚 The values in the array are instances of the Specificity class
const s = specificities[0]; // Instance of Specificity
// 👀 Read the specificity value using one of its accessors
s.value; // { a: 0, b: 1, c: 3 }
s.a; // 0
s.b; // 1
s.c; // 3
// 🛠 Convert the calculated value to various formats using one of the toXXX() instance methods
s.toString(); // "(0,1,3)"
s.toArray(); // [0, 1, 3]
s.toObject(); // { a: 0, b: 1, c: 3 }
// 💡 Extract the matched selector string
s.selectorString(); // "header:where(#top) nav li:nth-child(2n)"
// 🔀 Use one of its instance comparison methods to compare it to another Specificity instance
s.isEqualTo(specificities[1]); // false
s.isGreaterThan(specificities[1]); // false
s.isLessThan(specificities[1]); // true
// 💻 Don’t worry about JSON.stringify()
JSON.stringify(s);
// {
// "selector": 'header:where(#top) nav li:nth-child(2n)',
// "asObject": { "a": 0, "b": 1, "c": 3 },
// "asArray": [0, 1, 3],
// "asString": "(0,1,3)",
// }
```
## Utility Functions (Static Methods)
This package also exposes some utility functions to work with specificities. These utility functions are all exposed as static methods on the `Specificity` class.
- Comparing:
- `Specificity.compare(s1, s2)`: Compares s1 to s2. Returns a value that can be:
- `> 0` = Sort s2 before s1 _(i.e. s1 is more specific than s2)_
- `0` = Keep original order of s1 and s2 _(i.e. s1 and s2 are equally specific)_
- `< 0` = Sort s1 before s2 _(i.e. s1 is less specific than s2)_
- `Specificity.equals(s1, s2)`: Returns `true` if s1 and s2 have the same specificity. If not, `false` is returned.
- `Specificity.greaterThan(s1, s2)`: Returns `true` if s1 has a higher specificity than s2. If not, `false` is returned.
- `Specificity.lessThan(s1, s2)`: Returns `true` if s1 has a lower specificity than s2. If not, `false` is returned.
- Sorting:
- `Specificity.sortAsc(s1, s2, …, sN)`: Sorts the given specificities in ascending order _(low specificity to high specificity)_
- `Specificity.sortDesc(s1, s2, …, sN)`: Sorts the given specificities in descending order _(high specificity to low specificity)_
- Filtering:
- `Specificity.min(s1, s2, …, sN)`: Filters out the value with the lowest specificity
- `Specificity.max(s1, s2, …, sN)`: Filters out the value with the highest specificity
A specificity passed into any of these utility functions can be any of:
- An instance of the included `Specificity` class
- A simple Object such as `{'a': 1, 'b': 0, 'c': 2}`
## Utility Functions (Standalone)
All static methods the `Specificity` class exposes are also exported as standalone functions using [Subpath Exports](https://nodejs.org/api/packages.html#subpath-exports).
If you're only interested in including some of these functions into your project you can import them from their Subpath. As a result, your bundle size will be reduced greatly _(except for including the standalone `calculate`, as it returns an array of `Specificity` instances that relies on the whole lot)_
```js
import { calculate, calculateForAST } from '@bramus/specificity/core';
import { compare, equals, greaterThan, lessThan } from '@bramus/specificity/compare';
import { min, max } from '@bramus/specificity/filter';
import { sortAsc, sortDesc } from '@bramus/specificity/sort';
```
## Type Definitions
Although `@bramus/specificity` is written in Vanilla JavaScript, it does include [Type Definitions](https://www.typescriptlang.org/docs/handbook/2/type-declarations.html) which are exposed via its `package.json`.
## Binary/CLI
`@bramus/specificity` exposes a binary named `specificity` to calculate the specificity of a given selector list on the CLI. For each selector that it finds, it'll print out the calculated specificity as a string on a new line.
```bash
$ specificity "header:where(#top) nav li:nth-child(2n), #doormat"
(0,1,3)
(1,0,0)
```
## Benchmark
A benchmark is included, which you can invoke using `npm run benchmark`.
Sample results (tested on a MacBook Air M3):
```
Specificity.calculate(string) x 420,682 ops/sec ±0.34% (98 runs sampled)
Specificity.calculate(ast) - using SelectorList x 8,994,080 ops/sec ±0.25% (98 runs sampled)
Specificity.calculate(ast) - using Selector x 11,054,856 ops/sec ±0.39% (91 runs sampled)
Specificity.calculateForAST(ast) x 12,652,322 ops/sec ±0.35% (96 runs sampled)
```
## License
`@bramus/specificity` is released under the MIT public license. See the enclosed `LICENSE` for details.
## Acknowledgements
The idea to create this package was sparked by [the wonderful Specificity Calculator created by Kilian Valkhof / Polypane](https://polypane.app/css-specificity-calculator/), a highly educational tool that not only calculates the specificity, but also explains which parts are responsible for it.
The heavy lifting of doing the actual parsing of Selectors is done by [CSSTree](https://github.com/csstree/csstree).
Generated Vendored Executable
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env node
import Specificity from '../dist/index.js';
if (!process.argv[2]) {
console.error('❌ Missing selector argument');
process.exit(1);
}
try {
const specificities = Specificity.calculate(process.argv[2]);
console.log(specificities.map((specificity) => `${specificity}`).join('\n'));
} catch (e) {
console.error(`❌ ${e.message}`);
}
+8
View File
@@ -0,0 +1,8 @@
var Kn=Object.create;var Tt=Object.defineProperty;var Qn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var Xn=Object.getPrototypeOf,Jn=Object.prototype.hasOwnProperty;var De=e=>Tt(e,"__esModule",{value:!0});var lt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),vt=(e,t)=>{for(var r in t)Tt(e,r,{get:t[r],enumerable:!0})},Pe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of $n(t))!Jn.call(e,s)&&(r||s!=="default")&&Tt(e,s,{get:()=>t[s],enumerable:!(n=Qn(t,s))||n.enumerable});return e},Zn=(e,t)=>Pe(De(Tt(e!=null?Kn(Xn(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),ti=(e=>(t,r)=>e&&e.get(t)||(r=Pe(De({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var Ue=lt(se=>{var Be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");se.encode=function(e){if(0<=e&&e<Be.length)return Be[e];throw new TypeError("Must be between 0 and 63: "+e)};se.decode=function(e){var t=65,r=90,n=97,s=122,o=48,a=57,h=43,l=47,i=26,c=52;return t<=e&&e<=r?e-t:n<=e&&e<=s?e-n+i:o<=e&&e<=a?e-o+c:e==h?62:e==l?63:-1}});var qe=lt(ae=>{var We=Ue(),oe=5,Ve=1<<oe,He=Ve-1,Ge=Ve;function li(e){return e<0?(-e<<1)+1:(e<<1)+0}function hi(e){var t=(e&1)===1,r=e>>1;return t?-r:r}ae.encode=function(t){var r="",n,s=li(t);do n=s&He,s>>>=oe,s>0&&(n|=Ge),r+=We.encode(n);while(s>0);return r};ae.decode=function(t,r,n){var s=t.length,o=0,a=0,h,l;do{if(r>=s)throw new Error("Expected more digits in base 64 VLQ value.");if(l=We.decode(t.charCodeAt(r++)),l===-1)throw new Error("Invalid base64 digit: "+t.charAt(r-1));h=!!(l&Ge),l&=He,o=o+(l<<a),a+=oe}while(h);n.value=hi(o),n.rest=r}});var Ut=lt(N=>{function ui(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}N.getArg=ui;var Ye=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,fi=/^data:.+\,.+$/;function Ct(e){var t=e.match(Ye);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}N.urlParse=Ct;function ft(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}N.urlGenerate=ft;var pi=32;function mi(e){var t=[];return function(r){for(var n=0;n<t.length;n++)if(t[n].input===r){var s=t[0];return t[0]=t[n],t[n]=s,t[0].result}var o=e(r);return t.unshift({input:r,result:o}),t.length>pi&&t.pop(),o}}var ce=mi(function(t){var r=t,n=Ct(t);if(n){if(!n.path)return t;r=n.path}for(var s=N.isAbsolute(r),o=[],a=0,h=0;;)if(a=h,h=r.indexOf("/",a),h===-1){o.push(r.slice(a));break}else for(o.push(r.slice(a,h));h<r.length&&r[h]==="/";)h++;for(var l,i=0,h=o.length-1;h>=0;h--)l=o[h],l==="."?o.splice(h,1):l===".."?i++:i>0&&(l===""?(o.splice(h+1,i),i=0):(o.splice(h,2),i--));return r=o.join("/"),r===""&&(r=s?"/":"."),n?(n.path=r,ft(n)):r});N.normalize=ce;function je(e,t){e===""&&(e="."),t===""&&(t=".");var r=Ct(t),n=Ct(e);if(n&&(e=n.path||"/"),r&&!r.scheme)return n&&(r.scheme=n.scheme),ft(r);if(r||t.match(fi))return t;if(n&&!n.host&&!n.path)return n.host=t,ft(n);var s=t.charAt(0)==="/"?t:ce(e.replace(/\/+$/,"")+"/"+t);return n?(n.path=s,ft(n)):s}N.join=je;N.isAbsolute=function(e){return e.charAt(0)==="/"||Ye.test(e)};function di(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var r=0;t.indexOf(e+"/")!==0;){var n=e.lastIndexOf("/");if(n<0||(e=e.slice(0,n),e.match(/^([^\/]+:\/)?\/*$/)))return t;++r}return Array(r+1).join("../")+t.substr(e.length+1)}N.relative=di;var ze=function(){var e=Object.create(null);return!("__proto__"in e)}();function Ke(e){return e}function xi(e){return Qe(e)?"$"+e:e}N.toSetString=ze?Ke:xi;function ki(e){return Qe(e)?e.slice(1):e}N.fromSetString=ze?Ke:ki;function Qe(e){if(!e)return!1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(var r=t-10;r>=0;r--)if(e.charCodeAt(r)!==36)return!1;return!0}function Si(e,t,r){var n=K(e.source,t.source);return n!==0||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:K(e.name,t.name)}N.compareByOriginalPositions=Si;function gi(e,t,r){var n;return n=e.originalLine-t.originalLine,n!==0||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:K(e.name,t.name)}N.compareByOriginalPositionsNoSource=gi;function Ci(e,t,r){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0||r)||(n=K(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:K(e.name,t.name)}N.compareByGeneratedPositionsDeflated=Ci;function yi(e,t,r){var n=e.generatedColumn-t.generatedColumn;return n!==Line truncated
`,13,!0)},emit(l){s+=l},result(){return s}};n&&(typeof n.decorator=="function"&&(a=n.decorator(a)),n.sourceMap&&(a=sr(a)),n.mode in Ht&&(a.tokenBefore=Ht[n.mode]));let h={node:l=>a.node(l),children:Pi,token:(l,i)=>a.token(l,i),tokenize:Fi};return a.node(r),a.result()}}var Se={};vt(Se,{AnPlusB:()=>hr,Atrule:()=>ur,AtrulePrelude:()=>fr,AttributeSelector:()=>dr,Block:()=>xr,Brackets:()=>kr,CDC:()=>Sr,CDO:()=>gr,ClassSelector:()=>yr,Combinator:()=>Tr,Comment:()=>vr,Condition:()=>Er,Declaration:()=>wr,DeclarationList:()=>Ar,Dimension:()=>Nr,Feature:()=>Ir,FeatureFunction:()=>Dr,FeatureRange:()=>Pr,Function:()=>Fr,GeneralEnclosed:()=>Rr,Hash:()=>Or,IdSelector:()=>Ur,Identifier:()=>Mr,Layer:()=>Wr,LayerList:()=>Vr,MediaQuery:()=>Hr,MediaQueryList:()=>Gr,NestingSelector:()=>Yr,Nth:()=>zr,Number:()=>Kr,Operator:()=>$r,Parentheses:()=>Xr,Percentage:()=>Zr,PseudoClassSelector:()=>en,PseudoElementSelector:()=>nn,Ratio:()=>sn,Raw:()=>an,Rule:()=>cn,Scope:()=>ln,Selector:()=>un,SelectorList:()=>pn,String:()=>Sn,StyleSheet:()=>gn,SupportsDeclaration:()=>Cn,TypeSelector:()=>Ln,UnicodeRange:()=>Tn,Url:()=>En,Value:()=>wn,WhiteSpace:()=>An});var Y=43,_=45,Gt=110,st=!0,Ri=!1;function qt(e,t){let r=this.tokenStart+e,n=this.charCodeAt(r);for((n===Y||n===_)&&(t&&this.error("Number sign is not allowed"),r++);r<this.tokenEnd;r++)I(this.charCodeAt(r))||this.error("Integer is expected",r)}function pt(e){return qt.call(this,0,e)}function Z(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let r="";switch(t){case Gt:r="N is expected";break;case _:r="HyphenMinus is expected";break}this.error(r,this.tokenStart+e)}}function pe(){let e=0,t=0,r=this.tokenType;for(;r===13||r===25;)r=this.lookupType(++e);if(r!==10)if(this.isDelim(Y,e)||this.isDelim(_,e)){t=this.isDelim(Y,e)?Y:_;do r=this.lookupType(++e);while(r===13||r===25);r!==10&&(this.skip(e),pt.call(this,st))}else return null;return e>0&&this.skip(e),t===0&&(r=this.charCodeAt(this.tokenStart),r!==Y&&r!==_&&this.error("Number sign is expected")),pt.call(this,t!==0),t===_?"-"+this.consume(10):this.consume(10)}function lr(){let e=this.tokenStart,t=null,r=null;if(this.tokenType===10)pt.call(this,Ri),r=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,_))switch(t="-1",Z.call(this,1,Gt),this.tokenEnd-this.tokenStart){case 2:this.next(),r=pe.call(this);break;case 3:Z.call(this,2,_),this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10);break;default:Z.call(this,2,_),qt.call(this,3,st),this.next(),r=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Y)&&this.lookupType(1)===1){let n=0;switch(t="1",this.isDelim(Y)&&(n=1,this.next()),Z.call(this,0,Gt),this.tokenEnd-this.tokenStart){case 1:this.next(),r=pe.call(this);break;case 2:Z.call(this,1,_),this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10);break;default:Z.call(this,1,_),qt.call(this,2,st),this.next(),r=this.substrToCursor(e+n+1)}}else if(this.tokenType===12){let n=this.charCodeAt(this.tokenStart),s=n===Y||n===_,o=this.tokenStart+s;for(;o<this.tokenEnd&&I(this.charCodeAt(o));o++);o===this.tokenStart+s&&this.error("Integer is expected",this.tokenStart+s),Z.call(this,o-this.tokenStart,Gt),t=this.substring(e,o),o+1===this.tokenEnd?(this.next(),r=pe.call(this)):(Z.call(this,o-this.tokenStart+1,_),o+2===this.tokenEnd?(this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10)):(qt.call(this,o-this.tokenStart+2,st),this.next(),r=this.substrToCursor(o+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Y&&(t=t.substr(1)),r!==null&&r.charCodeAt(0)===Y&&(r=r.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:r}}function hr(e){if(e.a){let t=e.a==="+1"&&"n"||e.a==="1"&&"n"||e.a==="-1"&&"-n"||e.a+"n";if(e.b){let r=e.b[0]==="-"||e.b[0]==="+"?e.b:"+"+e.b;this.tokenize(t+r)}else this.tokenize(t)}else this.tokenize(e.b)}function ur(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?(this.token(23,"{"),this.node(e.block),this.token(24,"}")):this.token(17,";")}function fr(e){this.children(e)}var Oi=36,pr=42,Yt=61,_i=94,me=124,Mi=126;function Bi(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(pr)?(t=!0,this.next()):this.isDelim(me)||this.eat(1),this.isDelim(me)?this.charCodeAt(this.tokenStart+1)!==Yt?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function Ui(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Yt&&t!==Mi&&t!==_i&&t!==Oi&&t!==pr&&t!==me&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Yt&&(this.isDelim(Yt)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function mr(){let e=this.tokenStart,t,r=null,n=null,s=null;return this.eat(19),this.skipSC(),t=Bi.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(r=Ui.call(this),this.skipSC(),n=this.t Line truncated
`)}})}var ge=100,Pn=60,Fn=" ";function Rn({source:e,line:t,column:r,baseLine:n,baseColumn:s},o){function a(T,j){return i.slice(T,j).map((tt,$t)=>String(T+$t+1).padStart(k)+" |"+tt).join(`
`)}let h=`
`.repeat(Math.max(n-1,0)),l=" ".repeat(Math.max(s-1,0)),i=(h+l+e).split(/\r\n?|\n|\f/),c=Math.max(1,t-o)-1,f=Math.min(t+o,i.length+1),k=Math.max(4,String(f).length)+1,S=0;r+=(Fn.length-1)*(i[t-1].substr(0,r-1).match(/\t/g)||[]).length,r>ge&&(S=r-Pn+3,r=Pn-2);for(let T=c;T<=f;T++)T>=0&&T<i.length&&(i[T]=i[T].replace(/\t/g,Fn),i[T]=(S>0&&i[T].length>S?"\u2026":"")+i[T].substr(S,ge-2)+(i[T].length>S+ge-1?"\u2026":""));return[a(c,t),new Array(r+k+2).join("-")+"^",a(t,f)].filter(Boolean).join(`
`).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function Ce(e,t,r,n,s,o=1,a=1){return Object.assign(Dn("SyntaxError",e),{source:t,offset:r,line:n,column:s,sourceFragment(l){return Rn({source:t,line:n,column:s,baseLine:o,baseColumn:a},isNaN(l)?0:l)},get formattedMessage(){return`Parse error: ${e}
`+Rn({source:t,line:n,column:s,baseLine:o,baseColumn:a},2)}})}function On(e){let t=this.createList(),r=!1,n={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:r=!0,this.next();continue}let s=e.getNode.call(this,n);if(s===void 0)break;r&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,s,t,n),r=!1),t.push(s)}return r&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,n),t}var _n=()=>{},es=33,rs=35,ye=59,Mn=123,Bn=0;function ns(e){return function(){return this[e]()}}function be(e){let t=Object.create(null);for(let r of Object.keys(e)){let n=e[r],s=n.parse||n;s&&(t[r]=s)}return t}function is(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:be(e.atrule),pseudo:be(e.pseudo),node:be(e.node)};for(let[r,n]of Object.entries(e.parseContext))switch(typeof n){case"function":t.context[r]=n;break;case"string":t.context[r]=ns(n);break}return{config:t,...t,...t.node}}function Un(e){let t="",r="<unknown>",n=!1,s=_n,o=!1,a=new ne,h=Object.assign(new ie,is(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:On,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(i){return i===Mn?1:0},consumeUntilLeftCurlyBracketOrSemicolon(i){return i===Mn||i===ye?1:0},consumeUntilExclamationMarkOrSemicolon(i){return i===es||i===ye?1:0},consumeUntilSemicolonIncluded(i){return i===ye?2:0},createList(){return new P},createSingleNodeList(i){return new P().appendData(i)},getFirstListNode(i){return i&&i.first},getLastListNode(i){return i&&i.last},parseWithFallback(i,c){let f=this.tokenIndex;try{return i.call(this)}catch(k){if(o)throw k;this.skip(f-this.tokenIndex);let S=c.call(this);return o=!0,s(k,S),o=!1,S}},lookupNonWSType(i){let c;do if(c=this.lookupType(i++),c!==13&&c!==25)return c;while(c!==Bn);return Bn},charCodeAt(i){return i>=0&&i<t.length?t.charCodeAt(i):0},substring(i,c){return t.substring(i,c)},substrToCursor(i){return this.source.substring(i,this.tokenStart)},cmpChar(i,c){return ee(t,i,c)},cmpStr(i,c,f){return et(t,i,c,f)},consume(i){let c=this.tokenStart;return this.eat(i),this.substrToCursor(c)},consumeFunctionName(){let i=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),i},consumeNumber(i){let c=t.substring(this.tokenStart,Ot(t,this.tokenStart));return this.eat(i),c},eat(i){if(this.tokenType!==i){let c=gt[i].slice(0,-6).replace(/-/g," ").replace(/^./,S=>S.toUpperCase()),f=`${/[[\](){}]/.test(c)?`"${c}"`:c} is expected`,k=this.tokenStart;switch(i){case 1:this.tokenType===2||this.tokenType===7?(k=this.tokenEnd-1,f="Identifier is expected but function found"):f="Identifier is expected";break;case 4:this.isDelim(rs)&&(this.next(),k++,f="Name is expected");break;case 11:this.tokenType===10&&(k=this.tokenEnd,f="Percent sign is expected");break}this.error(f,k)}this.next()},eatIdent(i){(this.tokenType!==1||this.lookupValue(0,i)===!1)&&this.error(`Identifier "${i}" is expected`),this.next()},eatDelim(i){this.isDelim(i)||this.error(`Delim "${String.fromCharCode(i)}" is expected`),this.next()},getLocation(i,c){return n?a.getLocationRange(i,c,r):null},getLocationFromList(i){if(n){let c=this.getFirstListNode(i),f=this.getLastListNode(i);return a.getLocationRange(c!==null?c.loc.start.offset-a.startOffset:this.tokenStart,f!==null?f.loc.end.offset-a.startOffset:this.tokenStart,r)}return null},error(i,c){let f=typeof c<"u"&&c<t.length?a.getLocation(c):this.eof?a.getLocation(Re(t,t.length-1)):a.getLocation(this.tokenStart);throw new Ce(i||"Unexpected input",t,f.offset,f.line,f.column,a.startLine,a.startColumn)}});return Object.assign(function(i,c){t=i,c=c||{},h.setSource(t,Bt),a.setSource(t,c.offset,c.line,c.column),r=c.filename||"<unknown>",n=Boolean(c.positions),s=typeof c.onParseError=="function"?c.onParseError:_n,o=!1,h.parseAtrulePrelude="parseAtrulePrelude"in c?Boolean(c.parseAtrulePrelude):!0,h.parseRulePrelude="parseRulePrelude"in c?Boolean(c.parseRulePrelude):!0,h.parseValue="parseValue"in c?Boolean(c.parseValue):!0,h.parseCustomProperty="parseCustomProperty"in c?Boolean(c.parseCustomProperty):!1;let{context:f="default",onComment:k}=c;if(!(f in h.context))throw new Error("Unknown context `"+f+"`");typeof k=="function"&&h.forEachToken((T,j,tt)=>{if(T===25){let $t=h.getLocation(j,tt),zn=et(t,tt-2,tt,"*/")?t.slice(j+2,tt-2):t.slice(j+2,tt);k(zn,$t)}});let S=h.context[f].call(h,c);return h.eof||h.error(),S},{SyntaxError:Ce,config:h.config})}var os=35,as=38,cs=42,ls=43,hs=47,Wn=46,us=62,fs=124,ps=126;function ms(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function ds(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return this.lookupType(1)===16?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:this.charCodeAt(this.tokenStar Line truncated
//# sourceMappingURL=index.cjs.map
+7
View File
@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../node_modules/source-map-js/lib/base64.js", "../node_modules/source-map-js/lib/base64-vlq.js", "../node_modules/source-map-js/lib/util.js", "../node_modules/source-map-js/lib/array-set.js", "../node_modules/source-map-js/lib/mapping-list.js", "../node_modules/source-map-js/lib/source-map-generator.js", "../src/index.js", "../node_modules/css-tree/lib/tokenizer/char-code-definitions.js", "../node_modules/css-tree/lib/tokenizer/utils.js", "../node_modules/css-tree/lib/tokenizer/names.js", "../node_modules/css-tree/lib/tokenizer/adopt-buffer.js", "../node_modules/css-tree/lib/tokenizer/OffsetToLocation.js", "../node_modules/css-tree/lib/tokenizer/TokenStream.js", "../node_modules/css-tree/lib/tokenizer/index.js", "../node_modules/css-tree/lib/generator/sourceMap.js", "../node_modules/css-tree/lib/generator/token-before.js", "../node_modules/css-tree/lib/generator/create.js", "../node_modules/css-tree/lib/syntax/node/index-generate.js", "../node_modules/css-tree/lib/syntax/node/AnPlusB.js", "../node_modules/css-tree/lib/syntax/node/Atrule.js", "../node_modules/css-tree/lib/syntax/node/AtrulePrelude.js", "../node_modules/css-tree/lib/syntax/node/AttributeSelector.js", "../node_modules/css-tree/lib/syntax/node/Block.js", "../node_modules/css-tree/lib/syntax/node/Brackets.js", "../node_modules/css-tree/lib/syntax/node/CDC.js", "../node_modules/css-tree/lib/syntax/node/CDO.js", "../node_modules/css-tree/lib/syntax/node/ClassSelector.js", "../node_modules/css-tree/lib/syntax/node/Combinator.js", "../node_modules/css-tree/lib/syntax/node/Comment.js", "../node_modules/css-tree/lib/syntax/node/Condition.js", "../node_modules/css-tree/lib/syntax/node/Declaration.js", "../node_modules/css-tree/lib/syntax/node/DeclarationList.js", "../node_modules/css-tree/lib/syntax/node/Dimension.js", "../node_modules/css-tree/lib/syntax/node/Feature.js", "../node_modules/css-tree/lib/syntax/node/FeatureFunction.js", "../node_modules/css-tree/lib/syntax/node/FeatureRange.js", "../node_modules/css-tree/lib/syntax/node/Function.js", "../node_modules/css-tree/lib/syntax/node/GeneralEnclosed.js", "../node_modules/css-tree/lib/syntax/node/Hash.js", "../node_modules/css-tree/lib/syntax/node/Identifier.js", "../node_modules/css-tree/lib/syntax/node/IdSelector.js", "../node_modules/css-tree/lib/syntax/node/Layer.js", "../node_modules/css-tree/lib/syntax/node/LayerList.js", "../node_modules/css-tree/lib/syntax/node/MediaQuery.js", "../node_modules/css-tree/lib/syntax/node/MediaQueryList.js", "../node_modules/css-tree/lib/syntax/node/NestingSelector.js", "../node_modules/css-tree/lib/syntax/node/Nth.js", "../node_modules/css-tree/lib/syntax/node/Number.js", "../node_modules/css-tree/lib/syntax/node/Operator.js", "../node_modules/css-tree/lib/syntax/node/Parentheses.js", "../node_modules/css-tree/lib/syntax/node/Percentage.js", "../node_modules/css-tree/lib/syntax/node/PseudoClassSelector.js", "../node_modules/css-tree/lib/syntax/node/PseudoElementSelector.js", "../node_modules/css-tree/lib/syntax/node/Ratio.js", "../node_modules/css-tree/lib/syntax/node/Raw.js", "../node_modules/css-tree/lib/syntax/node/Rule.js", "../node_modules/css-tree/lib/syntax/node/Scope.js", "../node_modules/css-tree/lib/syntax/node/Selector.js", "../node_modules/css-tree/lib/syntax/node/SelectorList.js", "../node_modules/css-tree/lib/utils/string.js", "../node_modules/css-tree/lib/syntax/node/String.js", "../node_modules/css-tree/lib/syntax/node/StyleSheet.js", "../node_modules/css-tree/lib/syntax/node/SupportsDeclaration.js", "../node_modules/css-tree/lib/syntax/node/TypeSelector.js", "../node_modules/css-tree/lib/syntax/node/UnicodeRange.js", "../node_modules/css-tree/lib/utils/url.js", "../node_modules/css-tree/lib/syntax/node/Url.js", "../node_modules/css-tree/lib/syntax/node/Value.js", "../node_modules/css-tree/lib/syntax/node/WhiteSpace.js", "../node_modules/css-tree/lib/syntax/config/generator.js", "../node_modules/css-tree/lib/generator/index.js", "../node_modules/css-tree/lib/utils/List.js", "../node_modules/css-tree/lib/utils/create-custom-error.js", "../node_modules/css-tree/lib/parser/SyntaxError.js", "../node_modules/css-tree/lib/parser/sequence.js", "../node_modules/css-tree/lib/parser/create.js", "../node_modules/css-tree/lib/syntax/scope/selector.js", "../node_modules/css-tree/lib/syntax/pseudo/lang.js", "../node_modules/css-tree/lib/syntax/pseudo/index.js", "../node_modules/css-tree/lib/syntax/node/index-parse-selector.js", "../node_modules/css-tree/lib/syntax/config/parser-selector.js", "../node_modules/css-tree/lib/parser/parse-selector.js", "../src/util/compare.js", "../src/util/sort.js", "../src/util/filter.js", "../src/core/calculate.js"],
"sourcesContent": ["/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\nvar intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');\n\n/**\n * Encode an integer in the range of 0 to 63 to a single base 64 digit.\n */\nexports.encode = function (number) {\n if (0 <= number && number < intToCharMap.length) {\n return intToCharMap[number];\n }\n throw new TypeError(\"Must be between 0 and 63: \" + number);\n};\n\n/**\n * Decode a single base 64 character code digit to an integer. Returns -1 on\n * failure.\n */\nexports.decode = function (charCode) {\n var bigA = 65; // 'A'\n var bigZ = 90; // 'Z'\n\n var littleA = 97; // 'a'\n var littleZ = 122; // 'z'\n\n var zero = 48; // '0'\n var nine = 57; // '9'\n\n var plus = 43; // '+'\n var slash = 47; // '/'\n\n var littleOffset = 26;\n var numberOffset = 52;\n\n // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ\n if (bigA <= charCode && charCode <= bigZ) {\n return (charCode - bigA);\n }\n\n // 26 - 51: abcdefghijklmnopqrstuvwxyz\n if (littleA <= charCode && charCode <= littleZ) {\n return (charCode - littleA + littleOffset);\n }\n\n // 52 - 61: 0123456789\n if (zero <= charCode && charCode <= nine) {\n return (charCode - zero + numberOffset);\n }\n\n // 62: +\n if (charCode == plus) {\n return 62;\n }\n\n // 63: /\n if (charCode == slash) {\n return 63;\n }\n\n // Invalid base64 digit.\n return -1;\n};\n", "/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n *\n * Based on the Base 64 VLQ implementation in Closure Compiler:\n * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java\n *\n * Copyright 2011 The Closure Compiler Authors. All rights reserved.\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above\n * copyright notice, this list of conditions and the following\n * disclaimer in the documentation and/or other materials provided\n * with the distribution.\n * * Neither the name of Google Inc. nor the names of its\n * contributors may be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nvar base64 = require('./base64');\n\n// A single base 64 digit can contain 6 bits of data. For the base 64 variable\n// length quantities we use in the source map spec, the first bit is the sign,\n// the next four bits are the actual value, and the 6th bit is the\n// continuation bit. The continuation bit tells us whether there are more\n// digits in this value following this digit.\n//\n// Continuation\n// | Sign\n// | |\n// V V\n// 101011\n\nvar VLQ_BASE_SHIFT = 5;\n\n// binary: 100000\nvar VLQ_BASE = 1 << VLQ_BASE_SHIFT;\n\n// binary: 011111\nvar VLQ_BASE_MASK = VLQ_BASE - 1;\n\n// binary: 100000\nvar VLQ_CONTINUATION_BIT = VLQ_BASE;\n\n/**\n * Converts from a two-complement value to a value where the sign bit is\n * placed in the least significant bit. For example, as decimals:\n * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)\n * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)\n */\nfunction toVLQSigned(aValue) {\n return aValue < 0\n ? ((-aValue) << 1) + 1\n : (aValue << 1) + 0;\n}\n\n/**\n * Converts to a two-complement value from a value where the sign bit is\n * placed in the least significant bit. For example, as decimals:\n * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1\n * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2\n */\nfunction fromVLQSigned(aValue) {\n var isNeLine truncated
"mappings": "wwBAAA,eAOA,GAAI,IAAe,mEAAmE,MAAM,IAK5F,GAAQ,OAAS,SAAU,EAAQ,CACjC,GAAI,GAAK,GAAU,EAAS,GAAa,OACvC,MAAO,IAAa,GAEtB,KAAM,IAAI,WAAU,6BAA+B,IAOrD,GAAQ,OAAS,SAAU,EAAU,CACnC,GAAI,GAAO,GACP,EAAO,GAEP,EAAU,GACV,EAAU,IAEV,EAAO,GACP,EAAO,GAEP,EAAO,GACP,EAAQ,GAER,EAAe,GACf,EAAe,GAGnB,MAAI,IAAQ,GAAY,GAAY,EAC1B,EAAW,EAIjB,GAAW,GAAY,GAAY,EAC7B,EAAW,EAAU,EAI3B,GAAQ,GAAY,GAAY,EAC1B,EAAW,EAAO,EAIx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,cACpC,IAAQ,GACH,EAGF,EAAO,EAAS,KAAM,EAAS,MAExC,EAAQ,mCAAqC,GAW7C,YAA6C,EAAU,EAAU,EAAsB,CACrF,GAAI,GAAM,EAAS,cAAgB,EAAS,cAqB5C,MApBI,KAAQ,GAIZ,GAAM,EAAS,gBAAkB,EAAS,gBACtC,IAAQ,GAAK,IAIjB,GAAM,EAAO,EAAS,OAAQ,EAAS,QACnC,IAAQ,IAIZ,GAAM,EAAS,aAAe,EAAS,aACnC,IAAQ,IAIZ,GAAM,EAAS,eAAiB,EAAS,eACrC,IAAQ,GACH,EAGF,EAAO,EAAS,KAAM,EAAS,MAExC,EAAQ,oCAAsC,GAE9C,YAAmD,EAAU,EAAU,EAAsB,CAC3F,GAAI,GAAM,EAAS,gBAAkB,EAAS,gBAgB9C,MAfI,KAAQ,GAAK,GAIjB,GAAM,EAAO,EAAS,OAALine truncated
"names": []
}
+8
View File
@@ -0,0 +1,8 @@
var jn=Object.create;var Tt=Object.defineProperty;var zn=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames;var Qn=Object.getPrototypeOf,$n=Object.prototype.hasOwnProperty;var Xn=e=>Tt(e,"__esModule",{value:!0});var lt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),$t=(e,t)=>{for(var r in t)Tt(e,r,{get:t[r],enumerable:!0})},Jn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Kn(t))!$n.call(e,s)&&(r||s!=="default")&&Tt(e,s,{get:()=>t[s],enumerable:!(n=zn(t,s))||n.enumerable});return e},Zn=(e,t)=>Jn(Xn(Tt(e!=null?jn(Qn(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var _e=lt(se=>{var Oe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");se.encode=function(e){if(0<=e&&e<Oe.length)return Oe[e];throw new TypeError("Must be between 0 and 63: "+e)};se.decode=function(e){var t=65,r=90,n=97,s=122,o=48,a=57,h=43,l=47,i=26,c=52;return t<=e&&e<=r?e-t:n<=e&&e<=s?e-n+i:o<=e&&e<=a?e-o+c:e==h?62:e==l?63:-1}});var Ve=lt(ae=>{var Me=_e(),oe=5,Be=1<<oe,Ue=Be-1,We=Be;function ci(e){return e<0?(-e<<1)+1:(e<<1)+0}function li(e){var t=(e&1)===1,r=e>>1;return t?-r:r}ae.encode=function(t){var r="",n,s=ci(t);do n=s&Ue,s>>>=oe,s>0&&(n|=We),r+=Me.encode(n);while(s>0);return r};ae.decode=function(t,r,n){var s=t.length,o=0,a=0,h,l;do{if(r>=s)throw new Error("Expected more digits in base 64 VLQ value.");if(l=Me.decode(t.charCodeAt(r++)),l===-1)throw new Error("Invalid base64 digit: "+t.charAt(r-1));h=!!(l&We),l&=Ue,o=o+(l<<a),a+=oe}while(h);n.value=li(o),n.rest=r}});var Bt=lt(N=>{function hi(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}N.getArg=hi;var He=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,ui=/^data:.+\,.+$/;function Ct(e){var t=e.match(He);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}N.urlParse=Ct;function ft(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}N.urlGenerate=ft;var fi=32;function pi(e){var t=[];return function(r){for(var n=0;n<t.length;n++)if(t[n].input===r){var s=t[0];return t[0]=t[n],t[n]=s,t[0].result}var o=e(r);return t.unshift({input:r,result:o}),t.length>fi&&t.pop(),o}}var ce=pi(function(t){var r=t,n=Ct(t);if(n){if(!n.path)return t;r=n.path}for(var s=N.isAbsolute(r),o=[],a=0,h=0;;)if(a=h,h=r.indexOf("/",a),h===-1){o.push(r.slice(a));break}else for(o.push(r.slice(a,h));h<r.length&&r[h]==="/";)h++;for(var l,i=0,h=o.length-1;h>=0;h--)l=o[h],l==="."?o.splice(h,1):l===".."?i++:i>0&&(l===""?(o.splice(h+1,i),i=0):(o.splice(h,2),i--));return r=o.join("/"),r===""&&(r=s?"/":"."),n?(n.path=r,ft(n)):r});N.normalize=ce;function Ge(e,t){e===""&&(e="."),t===""&&(t=".");var r=Ct(t),n=Ct(e);if(n&&(e=n.path||"/"),r&&!r.scheme)return n&&(r.scheme=n.scheme),ft(r);if(r||t.match(ui))return t;if(n&&!n.host&&!n.path)return n.host=t,ft(n);var s=t.charAt(0)==="/"?t:ce(e.replace(/\/+$/,"")+"/"+t);return n?(n.path=s,ft(n)):s}N.join=Ge;N.isAbsolute=function(e){return e.charAt(0)==="/"||He.test(e)};function mi(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var r=0;t.indexOf(e+"/")!==0;){var n=e.lastIndexOf("/");if(n<0||(e=e.slice(0,n),e.match(/^([^\/]+:\/)?\/*$/)))return t;++r}return Array(r+1).join("../")+t.substr(e.length+1)}N.relative=mi;var qe=function(){var e=Object.create(null);return!("__proto__"in e)}();function Ye(e){return e}function di(e){return je(e)?"$"+e:e}N.toSetString=qe?Ye:di;function xi(e){return je(e)?e.slice(1):e}N.fromSetString=qe?Ye:xi;function je(e){if(!e)return!1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(var r=t-10;r>=0;r--)if(e.charCodeAt(r)!==36)return!1;return!0}function ki(e,t,r){var n=K(e.source,t.source);return n!==0||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:K(e.name,t.name)}N.compareByOriginalPositions=ki;function Si(e,t,r){var n;return n=e.originalLine-t.originalLine,n!==0||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:K(e.name,t.name)}N.compareByOriginalPositionsNoSource=Si;function gi(e,t,r){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0||r)||(n=K(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:K(e.name,t.name)}N.compareByGeneratedPositionsDeflated=gi;function Ci(e,t,r){var n=e.generatedColumn-t.generatedColumn;return n!==0||r||(n=K(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.origiLine truncated
`,13,!0)},emit(l){s+=l},result(){return s}};n&&(typeof n.decorator=="function"&&(a=n.decorator(a)),n.sourceMap&&(a=rr(a)),n.mode in Vt&&(a.tokenBefore=Vt[n.mode]));let h={node:l=>a.node(l),children:Di,token:(l,i)=>a.token(l,i),tokenize:Pi};return a.node(r),a.result()}}var Se={};$t(Se,{AnPlusB:()=>ar,Atrule:()=>cr,AtrulePrelude:()=>lr,AttributeSelector:()=>fr,Block:()=>pr,Brackets:()=>mr,CDC:()=>dr,CDO:()=>xr,ClassSelector:()=>Sr,Combinator:()=>yr,Comment:()=>br,Condition:()=>Lr,Declaration:()=>Tr,DeclarationList:()=>vr,Dimension:()=>Er,Feature:()=>wr,FeatureFunction:()=>Ar,FeatureRange:()=>Nr,Function:()=>Ir,GeneralEnclosed:()=>Dr,Hash:()=>Pr,IdSelector:()=>_r,Identifier:()=>Rr,Layer:()=>Mr,LayerList:()=>Br,MediaQuery:()=>Ur,MediaQueryList:()=>Wr,NestingSelector:()=>Hr,Nth:()=>qr,Number:()=>Yr,Operator:()=>zr,Parentheses:()=>Kr,Percentage:()=>$r,PseudoClassSelector:()=>Jr,PseudoElementSelector:()=>tn,Ratio:()=>en,Raw:()=>nn,Rule:()=>sn,Scope:()=>on,Selector:()=>cn,SelectorList:()=>hn,String:()=>dn,StyleSheet:()=>xn,SupportsDeclaration:()=>kn,TypeSelector:()=>Cn,UnicodeRange:()=>yn,Url:()=>Ln,Value:()=>Tn,WhiteSpace:()=>vn});var Y=43,_=45,Ht=110,st=!0,Fi=!1;function Gt(e,t){let r=this.tokenStart+e,n=this.charCodeAt(r);for((n===Y||n===_)&&(t&&this.error("Number sign is not allowed"),r++);r<this.tokenEnd;r++)I(this.charCodeAt(r))||this.error("Integer is expected",r)}function pt(e){return Gt.call(this,0,e)}function Z(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let r="";switch(t){case Ht:r="N is expected";break;case _:r="HyphenMinus is expected";break}this.error(r,this.tokenStart+e)}}function pe(){let e=0,t=0,r=this.tokenType;for(;r===13||r===25;)r=this.lookupType(++e);if(r!==10)if(this.isDelim(Y,e)||this.isDelim(_,e)){t=this.isDelim(Y,e)?Y:_;do r=this.lookupType(++e);while(r===13||r===25);r!==10&&(this.skip(e),pt.call(this,st))}else return null;return e>0&&this.skip(e),t===0&&(r=this.charCodeAt(this.tokenStart),r!==Y&&r!==_&&this.error("Number sign is expected")),pt.call(this,t!==0),t===_?"-"+this.consume(10):this.consume(10)}function or(){let e=this.tokenStart,t=null,r=null;if(this.tokenType===10)pt.call(this,Fi),r=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,_))switch(t="-1",Z.call(this,1,Ht),this.tokenEnd-this.tokenStart){case 2:this.next(),r=pe.call(this);break;case 3:Z.call(this,2,_),this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10);break;default:Z.call(this,2,_),Gt.call(this,3,st),this.next(),r=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Y)&&this.lookupType(1)===1){let n=0;switch(t="1",this.isDelim(Y)&&(n=1,this.next()),Z.call(this,0,Ht),this.tokenEnd-this.tokenStart){case 1:this.next(),r=pe.call(this);break;case 2:Z.call(this,1,_),this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10);break;default:Z.call(this,1,_),Gt.call(this,2,st),this.next(),r=this.substrToCursor(e+n+1)}}else if(this.tokenType===12){let n=this.charCodeAt(this.tokenStart),s=n===Y||n===_,o=this.tokenStart+s;for(;o<this.tokenEnd&&I(this.charCodeAt(o));o++);o===this.tokenStart+s&&this.error("Integer is expected",this.tokenStart+s),Z.call(this,o-this.tokenStart,Ht),t=this.substring(e,o),o+1===this.tokenEnd?(this.next(),r=pe.call(this)):(Z.call(this,o-this.tokenStart+1,_),o+2===this.tokenEnd?(this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10)):(Gt.call(this,o-this.tokenStart+2,st),this.next(),r=this.substrToCursor(o+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Y&&(t=t.substr(1)),r!==null&&r.charCodeAt(0)===Y&&(r=r.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:r}}function ar(e){if(e.a){let t=e.a==="+1"&&"n"||e.a==="1"&&"n"||e.a==="-1"&&"-n"||e.a+"n";if(e.b){let r=e.b[0]==="-"||e.b[0]==="+"?e.b:"+"+e.b;this.tokenize(t+r)}else this.tokenize(t)}else this.tokenize(e.b)}function cr(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?(this.token(23,"{"),this.node(e.block),this.token(24,"}")):this.token(17,";")}function lr(e){this.children(e)}var Ri=36,hr=42,qt=61,Oi=94,me=124,_i=126;function Mi(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(hr)?(t=!0,this.next()):this.isDelim(me)||this.eat(1),this.isDelim(me)?this.charCodeAt(this.tokenStart+1)!==qt?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function Bi(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==qt&&t!==_i&&t!==Oi&&t!==Ri&&t!==hr&&t!==me&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==qt&&(this.isDelim(qt)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function ur(){let e=this.tokenStart,t,r=null,n=null,s=null;return this.eat(19),this.skipSC(),t=Mi.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(r=Bi.call(this),this.skipSC(),n=this.t Line truncated
`)}})}var ge=100,Nn=60,In=" ";function Dn({source:e,line:t,column:r,baseLine:n,baseColumn:s},o){function a(T,j){return i.slice(T,j).map((tt,Qt)=>String(T+Qt+1).padStart(k)+" |"+tt).join(`
`)}let h=`
`.repeat(Math.max(n-1,0)),l=" ".repeat(Math.max(s-1,0)),i=(h+l+e).split(/\r\n?|\n|\f/),c=Math.max(1,t-o)-1,f=Math.min(t+o,i.length+1),k=Math.max(4,String(f).length)+1,S=0;r+=(In.length-1)*(i[t-1].substr(0,r-1).match(/\t/g)||[]).length,r>ge&&(S=r-Nn+3,r=Nn-2);for(let T=c;T<=f;T++)T>=0&&T<i.length&&(i[T]=i[T].replace(/\t/g,In),i[T]=(S>0&&i[T].length>S?"\u2026":"")+i[T].substr(S,ge-2)+(i[T].length>S+ge-1?"\u2026":""));return[a(c,t),new Array(r+k+2).join("-")+"^",a(t,f)].filter(Boolean).join(`
`).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function Ce(e,t,r,n,s,o=1,a=1){return Object.assign(An("SyntaxError",e),{source:t,offset:r,line:n,column:s,sourceFragment(l){return Dn({source:t,line:n,column:s,baseLine:o,baseColumn:a},isNaN(l)?0:l)},get formattedMessage(){return`Parse error: ${e}
`+Dn({source:t,line:n,column:s,baseLine:o,baseColumn:a},2)}})}function Pn(e){let t=this.createList(),r=!1,n={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:r=!0,this.next();continue}let s=e.getNode.call(this,n);if(s===void 0)break;r&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,s,t,n),r=!1),t.push(s)}return r&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,n),t}var Fn=()=>{},ts=33,es=35,ye=59,Rn=123,On=0;function rs(e){return function(){return this[e]()}}function be(e){let t=Object.create(null);for(let r of Object.keys(e)){let n=e[r],s=n.parse||n;s&&(t[r]=s)}return t}function ns(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:be(e.atrule),pseudo:be(e.pseudo),node:be(e.node)};for(let[r,n]of Object.entries(e.parseContext))switch(typeof n){case"function":t.context[r]=n;break;case"string":t.context[r]=rs(n);break}return{config:t,...t,...t.node}}function _n(e){let t="",r="<unknown>",n=!1,s=Fn,o=!1,a=new ne,h=Object.assign(new ie,ns(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Pn,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(i){return i===Rn?1:0},consumeUntilLeftCurlyBracketOrSemicolon(i){return i===Rn||i===ye?1:0},consumeUntilExclamationMarkOrSemicolon(i){return i===ts||i===ye?1:0},consumeUntilSemicolonIncluded(i){return i===ye?2:0},createList(){return new P},createSingleNodeList(i){return new P().appendData(i)},getFirstListNode(i){return i&&i.first},getLastListNode(i){return i&&i.last},parseWithFallback(i,c){let f=this.tokenIndex;try{return i.call(this)}catch(k){if(o)throw k;this.skip(f-this.tokenIndex);let S=c.call(this);return o=!0,s(k,S),o=!1,S}},lookupNonWSType(i){let c;do if(c=this.lookupType(i++),c!==13&&c!==25)return c;while(c!==On);return On},charCodeAt(i){return i>=0&&i<t.length?t.charCodeAt(i):0},substring(i,c){return t.substring(i,c)},substrToCursor(i){return this.source.substring(i,this.tokenStart)},cmpChar(i,c){return ee(t,i,c)},cmpStr(i,c,f){return et(t,i,c,f)},consume(i){let c=this.tokenStart;return this.eat(i),this.substrToCursor(c)},consumeFunctionName(){let i=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),i},consumeNumber(i){let c=t.substring(this.tokenStart,Rt(t,this.tokenStart));return this.eat(i),c},eat(i){if(this.tokenType!==i){let c=gt[i].slice(0,-6).replace(/-/g," ").replace(/^./,S=>S.toUpperCase()),f=`${/[[\](){}]/.test(c)?`"${c}"`:c} is expected`,k=this.tokenStart;switch(i){case 1:this.tokenType===2||this.tokenType===7?(k=this.tokenEnd-1,f="Identifier is expected but function found"):f="Identifier is expected";break;case 4:this.isDelim(es)&&(this.next(),k++,f="Name is expected");break;case 11:this.tokenType===10&&(k=this.tokenEnd,f="Percent sign is expected");break}this.error(f,k)}this.next()},eatIdent(i){(this.tokenType!==1||this.lookupValue(0,i)===!1)&&this.error(`Identifier "${i}" is expected`),this.next()},eatDelim(i){this.isDelim(i)||this.error(`Delim "${String.fromCharCode(i)}" is expected`),this.next()},getLocation(i,c){return n?a.getLocationRange(i,c,r):null},getLocationFromList(i){if(n){let c=this.getFirstListNode(i),f=this.getLastListNode(i);return a.getLocationRange(c!==null?c.loc.start.offset-a.startOffset:this.tokenStart,f!==null?f.loc.end.offset-a.startOffset:this.tokenStart,r)}return null},error(i,c){let f=typeof c<"u"&&c<t.length?a.getLocation(c):this.eof?a.getLocation(De(t,t.length-1)):a.getLocation(this.tokenStart);throw new Ce(i||"Unexpected input",t,f.offset,f.line,f.column,a.startLine,a.startColumn)}});return Object.assign(function(i,c){t=i,c=c||{},h.setSource(t,Mt),a.setSource(t,c.offset,c.line,c.column),r=c.filename||"<unknown>",n=Boolean(c.positions),s=typeof c.onParseError=="function"?c.onParseError:Fn,o=!1,h.parseAtrulePrelude="parseAtrulePrelude"in c?Boolean(c.parseAtrulePrelude):!0,h.parseRulePrelude="parseRulePrelude"in c?Boolean(c.parseRulePrelude):!0,h.parseValue="parseValue"in c?Boolean(c.parseValue):!0,h.parseCustomProperty="parseCustomProperty"in c?Boolean(c.parseCustomProperty):!1;let{context:f="default",onComment:k}=c;if(!(f in h.context))throw new Error("Unknown context `"+f+"`");typeof k=="function"&&h.forEachToken((T,j,tt)=>{if(T===25){let Qt=h.getLocation(j,tt),Yn=et(t,tt-2,tt,"*/")?t.slice(j+2,tt-2):t.slice(j+2,tt);k(Yn,Qt)}});let S=h.context[f].call(h,c);return h.eof||h.error(),S},{SyntaxError:Ce,config:h.config})}var ss=35,os=38,as=42,cs=43,ls=47,Mn=46,hs=62,us=124,fs=126;function ps(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function ms(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return this.lookupType(1)===16?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:this.charCodeAt(this.tokenStar Line truncated
//# sourceMappingURL=index.js.map
+7
View File
@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../node_modules/source-map-js/lib/base64.js", "../node_modules/source-map-js/lib/base64-vlq.js", "../node_modules/source-map-js/lib/util.js", "../node_modules/source-map-js/lib/array-set.js", "../node_modules/source-map-js/lib/mapping-list.js", "../node_modules/source-map-js/lib/source-map-generator.js", "../node_modules/css-tree/lib/tokenizer/char-code-definitions.js", "../node_modules/css-tree/lib/tokenizer/utils.js", "../node_modules/css-tree/lib/tokenizer/names.js", "../node_modules/css-tree/lib/tokenizer/adopt-buffer.js", "../node_modules/css-tree/lib/tokenizer/OffsetToLocation.js", "../node_modules/css-tree/lib/tokenizer/TokenStream.js", "../node_modules/css-tree/lib/tokenizer/index.js", "../node_modules/css-tree/lib/generator/sourceMap.js", "../node_modules/css-tree/lib/generator/token-before.js", "../node_modules/css-tree/lib/generator/create.js", "../node_modules/css-tree/lib/syntax/node/index-generate.js", "../node_modules/css-tree/lib/syntax/node/AnPlusB.js", "../node_modules/css-tree/lib/syntax/node/Atrule.js", "../node_modules/css-tree/lib/syntax/node/AtrulePrelude.js", "../node_modules/css-tree/lib/syntax/node/AttributeSelector.js", "../node_modules/css-tree/lib/syntax/node/Block.js", "../node_modules/css-tree/lib/syntax/node/Brackets.js", "../node_modules/css-tree/lib/syntax/node/CDC.js", "../node_modules/css-tree/lib/syntax/node/CDO.js", "../node_modules/css-tree/lib/syntax/node/ClassSelector.js", "../node_modules/css-tree/lib/syntax/node/Combinator.js", "../node_modules/css-tree/lib/syntax/node/Comment.js", "../node_modules/css-tree/lib/syntax/node/Condition.js", "../node_modules/css-tree/lib/syntax/node/Declaration.js", "../node_modules/css-tree/lib/syntax/node/DeclarationList.js", "../node_modules/css-tree/lib/syntax/node/Dimension.js", "../node_modules/css-tree/lib/syntax/node/Feature.js", "../node_modules/css-tree/lib/syntax/node/FeatureFunction.js", "../node_modules/css-tree/lib/syntax/node/FeatureRange.js", "../node_modules/css-tree/lib/syntax/node/Function.js", "../node_modules/css-tree/lib/syntax/node/GeneralEnclosed.js", "../node_modules/css-tree/lib/syntax/node/Hash.js", "../node_modules/css-tree/lib/syntax/node/Identifier.js", "../node_modules/css-tree/lib/syntax/node/IdSelector.js", "../node_modules/css-tree/lib/syntax/node/Layer.js", "../node_modules/css-tree/lib/syntax/node/LayerList.js", "../node_modules/css-tree/lib/syntax/node/MediaQuery.js", "../node_modules/css-tree/lib/syntax/node/MediaQueryList.js", "../node_modules/css-tree/lib/syntax/node/NestingSelector.js", "../node_modules/css-tree/lib/syntax/node/Nth.js", "../node_modules/css-tree/lib/syntax/node/Number.js", "../node_modules/css-tree/lib/syntax/node/Operator.js", "../node_modules/css-tree/lib/syntax/node/Parentheses.js", "../node_modules/css-tree/lib/syntax/node/Percentage.js", "../node_modules/css-tree/lib/syntax/node/PseudoClassSelector.js", "../node_modules/css-tree/lib/syntax/node/PseudoElementSelector.js", "../node_modules/css-tree/lib/syntax/node/Ratio.js", "../node_modules/css-tree/lib/syntax/node/Raw.js", "../node_modules/css-tree/lib/syntax/node/Rule.js", "../node_modules/css-tree/lib/syntax/node/Scope.js", "../node_modules/css-tree/lib/syntax/node/Selector.js", "../node_modules/css-tree/lib/syntax/node/SelectorList.js", "../node_modules/css-tree/lib/utils/string.js", "../node_modules/css-tree/lib/syntax/node/String.js", "../node_modules/css-tree/lib/syntax/node/StyleSheet.js", "../node_modules/css-tree/lib/syntax/node/SupportsDeclaration.js", "../node_modules/css-tree/lib/syntax/node/TypeSelector.js", "../node_modules/css-tree/lib/syntax/node/UnicodeRange.js", "../node_modules/css-tree/lib/utils/url.js", "../node_modules/css-tree/lib/syntax/node/Url.js", "../node_modules/css-tree/lib/syntax/node/Value.js", "../node_modules/css-tree/lib/syntax/node/WhiteSpace.js", "../node_modules/css-tree/lib/syntax/config/generator.js", "../node_modules/css-tree/lib/generator/index.js", "../node_modules/css-tree/lib/utils/List.js", "../node_modules/css-tree/lib/utils/create-custom-error.js", "../node_modules/css-tree/lib/parser/SyntaxError.js", "../node_modules/css-tree/lib/parser/sequence.js", "../node_modules/css-tree/lib/parser/create.js", "../node_modules/css-tree/lib/syntax/scope/selector.js", "../node_modules/css-tree/lib/syntax/pseudo/lang.js", "../node_modules/css-tree/lib/syntax/pseudo/index.js", "../node_modules/css-tree/lib/syntax/node/index-parse-selector.js", "../node_modules/css-tree/lib/syntax/config/parser-selector.js", "../node_modules/css-tree/lib/parser/parse-selector.js", "../src/util/compare.js", "../src/util/sort.js", "../src/util/filter.js", "../src/core/calculate.js", "../src/index.js"],
"sourcesContent": ["/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\nvar intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');\n\n/**\n * Encode an integer in the range of 0 to 63 to a single base 64 digit.\n */\nexports.encode = function (number) {\n if (0 <= number && number < intToCharMap.length) {\n return intToCharMap[number];\n }\n throw new TypeError(\"Must be between 0 and 63: \" + number);\n};\n\n/**\n * Decode a single base 64 character code digit to an integer. Returns -1 on\n * failure.\n */\nexports.decode = function (charCode) {\n var bigA = 65; // 'A'\n var bigZ = 90; // 'Z'\n\n var littleA = 97; // 'a'\n var littleZ = 122; // 'z'\n\n var zero = 48; // '0'\n var nine = 57; // '9'\n\n var plus = 43; // '+'\n var slash = 47; // '/'\n\n var littleOffset = 26;\n var numberOffset = 52;\n\n // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ\n if (bigA <= charCode && charCode <= bigZ) {\n return (charCode - bigA);\n }\n\n // 26 - 51: abcdefghijklmnopqrstuvwxyz\n if (littleA <= charCode && charCode <= littleZ) {\n return (charCode - littleA + littleOffset);\n }\n\n // 52 - 61: 0123456789\n if (zero <= charCode && charCode <= nine) {\n return (charCode - zero + numberOffset);\n }\n\n // 62: +\n if (charCode == plus) {\n return 62;\n }\n\n // 63: /\n if (charCode == slash) {\n return 63;\n }\n\n // Invalid base64 digit.\n return -1;\n};\n", "/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n *\n * Based on the Base 64 VLQ implementation in Closure Compiler:\n * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java\n *\n * Copyright 2011 The Closure Compiler Authors. All rights reserved.\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above\n * copyright notice, this list of conditions and the following\n * disclaimer in the documentation and/or other materials provided\n * with the distribution.\n * * Neither the name of Google Inc. nor the names of its\n * contributors may be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nvar base64 = require('./base64');\n\n// A single base 64 digit can contain 6 bits of data. For the base 64 variable\n// length quantities we use in the source map spec, the first bit is the sign,\n// the next four bits are the actual value, and the 6th bit is the\n// continuation bit. The continuation bit tells us whether there are more\n// digits in this value following this digit.\n//\n// Continuation\n// | Sign\n// | |\n// V V\n// 101011\n\nvar VLQ_BASE_SHIFT = 5;\n\n// binary: 100000\nvar VLQ_BASE = 1 << VLQ_BASE_SHIFT;\n\n// binary: 011111\nvar VLQ_BASE_MASK = VLQ_BASE - 1;\n\n// binary: 100000\nvar VLQ_CONTINUATION_BIT = VLQ_BASE;\n\n/**\n * Converts from a two-complement value to a value where the sign bit is\n * placed in the least significant bit. For example, as decimals:\n * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)\n * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)\n */\nfunction toVLQSigned(aValue) {\n return aValue < 0\n ? ((-aValue) << 1) + 1\n : (aValue << 1) + 0;\n}\n\n/**\n * Converts to a two-complement value from a value where the sign bit is\n * placed in the least significant bit. For example, as decimals:\n * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1\n * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2\n */\nfunction fromVLQSigned(aValue) {\n var isNeLine truncated
"mappings": "8pBAAA,eAOA,GAAI,IAAe,mEAAmE,MAAM,IAK5F,GAAQ,OAAS,SAAU,EAAQ,CACjC,GAAI,GAAK,GAAU,EAAS,GAAa,OACvC,MAAO,IAAa,GAEtB,KAAM,IAAI,WAAU,6BAA+B,IAOrD,GAAQ,OAAS,SAAU,EAAU,CACnC,GAAI,GAAO,GACP,EAAO,GAEP,EAAU,GACV,EAAU,IAEV,EAAO,GACP,EAAO,GAEP,EAAO,GACP,EAAQ,GAER,EAAe,GACf,EAAe,GAGnB,MAAI,IAAQ,GAAY,GAAY,EAC1B,EAAW,EAIjB,GAAW,GAAY,GAAY,EAC7B,EAAW,EAAU,EAI3B,GAAQ,GAAY,GAAY,EAC1B,EAAW,EAAO,EAIxB,GAAY,EACP,GAIL,GAAY,EACP,GAIF,MCjET,eAqCA,GAAI,IAAS,KAcT,GAAiB,EAGjB,GAAW,GAAK,GAGhB,GAAgB,GAAW,EAG3B,GAAuB,GAQ3B,YAAqB,EAAQ,CAC3B,MAAO,GAAS,EACV,EAAC,GAAW,GAAK,EAClB,IAAU,GAAK,EAStB,YAAuB,EAAQ,CAC7B,GAAI,GAAc,GAAS,KAAO,EAC9B,EAAU,GAAU,EACxB,MAAO,GACH,CAAC,EACD,EAMN,GAAQ,OAAS,SAA0B,EAAQ,CACjD,GAAI,GAAU,GACV,EAEA,EAAM,GAAY,GAEtB,EACE,GAAQ,EAAM,GACd,KAAS,GACL,EAAM,GAGR,IAAS,IAEX,GAAW,GAAO,OAAO,SAClB,EAAM,GAEf,MAAO,IAOT,GAAQ,OAAS,SAA0B,EAAM,EAAQ,EAAW,CAClE,GAAI,GAAS,EAAK,OACd,EA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@@ -0,0 +1,59 @@
// Types & Classes
export type SpecificityArray = [number, number, number];
export type SpecificityObject = { a: number; b: number; c: number };
export default class Specificity {
static calculate(selector: string | CSSTreeAST): Array<Specificity>;
static calculateForAST(selectorAST: CSSTreeAST): Specificity;
static compare(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): number;
static equals(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
static lessThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
static greaterThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
static min(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
static max(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
static sortAsc(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
static sortDesc(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
constructor(value: SpecificityObject, selector?: any);
value: SpecificityObject;
selector: string | CSSTreeAST;
set a(arg: number);
get a(): number;
set b(arg: number);
get b(): number;
set c(arg: number);
get c(): number;
selectorString(): string;
toObject(): SpecificityObject;
toArray(): SpecificityArray;
toString(): string;
toJSON(): {
selector: string;
asObject: SpecificityObject;
asArray: SpecificityArray;
asString: string;
};
isEqualTo(otherSpecificity: SpecificityInstanceOrObject): boolean;
isGreaterThan(otherSpecificity: SpecificityInstanceOrObject): boolean;
isLessThan(otherSpecificity: SpecificityInstanceOrObject): boolean;
}
type SpecificityInstanceOrObject = Specificity | SpecificityObject;
type CSSTreeAST = Object; // @TODO: Define shape
// CORE
export function calculate(selector: string | CSSTreeAST): Array<Specificity>;
export function calculateForAST(selectorAST: CSSTreeAST): Specificity;
// UTIL: COMPARE
export function equals(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
export function greaterThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
export function lessThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
export function compare(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): number;
// UTIL: FILTER
export function min(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
export function max(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
// UTIL: SORT
export function sortAsc(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject[];
export function sortDesc(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject[];
+92
View File
@@ -0,0 +1,92 @@
{
"name": "@bramus/specificity",
"version": "2.4.2",
"description": "Calculate specificity of a CSS Selector",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"exports": {
".": {
"browser": "./dist/index.js",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./core": {
"import": "./src/core/index.js"
},
"./util": {
"import": "./src/util/index.js"
},
"./compare": {
"import": "./src/util/compare.js"
},
"./filter": {
"import": "./src/util/filter.js"
},
"./sort": {
"import": "./src/util/sort.js"
}
},
"unpkg": "./dist/index.js",
"jsdelivr": "./dist/index.js",
"files": [
"bin",
"src",
"dist",
"index.d.ts"
],
"types": "./index.d.ts",
"bin": {
"specificity": "./bin/cli.js"
},
"scripts": {
"build-esm": "esbuild --bundle ./src/index.js --outfile=./dist/index.js --format=esm --sourcemap --minify",
"build-cjs": "esbuild --bundle ./src/index.js --outfile=./dist/index.cjs --format=cjs --sourcemap --minify",
"lint": "prettier --check '{src,test}/**/*.{ts,tsx,js,jsx}'",
"format": "prettier --write '{src,test}/**/*.{ts,tsx,js,jsx}'",
"build": "npm run build-esm && npm run build-cjs",
"prepack": "npm run prevent-dirty-tree && npm run test",
"prepublish": "npm run build",
"pretest": "npm run build",
"test": "mocha",
"prebenchmark": "npm run build",
"benchmark": "node ./benchmark/bench.cjs",
"beta-version-patch": "npm version $(semver $npm_package_version -i prerelease --preid beta)",
"beta-version-minor": "npm version $(semver $npm_package_version -i preminor --preid beta)",
"beta-version-major": "npm version $(semver $npm_package_version -i premajor --preid beta)",
"rc-version": "npm version $(semver $npm_package_version -i prerelease --preid rc)",
"final-release": "npm version $(semver $npm_package_version -i)",
"preversion": "npm run prevent-dirty-tree && npm run test",
"prevent-dirty-tree": "exit $(git status --porcelain | wc -l)"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bramus/specificity.git"
},
"keywords": [
"css",
"specificity"
],
"author": {
"name": "Bramus Van Damme",
"email": "[email protected]",
"twitter": "@bramus",
"web": "https://www.bram.us/"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/bramus/specificity/issues"
},
"homepage": "https://github.com/bramus/specificity#readme",
"devDependencies": {
"benchmark": "^2.1.4",
"esbuild": "^0.25.0",
"microtime": "^3.1.1",
"mocha": "^11.1.0",
"prettier": "^3.5.1",
"semver": "^7.7.1"
},
"dependencies": {
"css-tree": "^3.0.0"
}
}
+260
View File
@@ -0,0 +1,260 @@
import parse from 'css-tree/selector-parser';
import Specificity from '../index.js';
import { max } from './../util/index.js';
/** @param {import('css-tree').Selector} selectorAST */
const calculateForAST = (selectorAST) => {
// Quit while you're ahead
if (!selectorAST || selectorAST.type !== 'Selector') {
throw new TypeError(`Passed in source is not a Selector AST`);
}
// https://www.w3.org/TR/selectors-4/#specificity-rules
let a = 0; /* ID Selectors */
let b = 0; /* Class selectors, Attributes selectors, and Pseudo-classes */
let c = 0; /* Type selectors and Pseudo-elements */
selectorAST.children.forEach((child) => {
switch (child.type) {
case 'IdSelector':
a += 1;
break;
case 'AttributeSelector':
case 'ClassSelector':
b += 1;
break;
case 'PseudoClassSelector':
switch (child.name.toLowerCase()) {
// “The specificity of a :where() pseudo-class is replaced by zero.”
case 'where':
// Noop :)
break;
case '-webkit-any':
case 'any':
if (child.children?.first) {
b += 1;
}
break;
// “The specificity of an :is(), :not(), or :has() pseudo-class is replaced by the specificity of the most specific complex selector in its selector list argument.“
case '-moz-any':
case 'is':
case 'matches':
case 'not':
case 'has':
if (child.children?.first) {
// Calculate Specificity from nested SelectorList
const max1 = max(...calculate(child.children.first));
// Adjust orig specificity
a += max1.a;
b += max1.b;
c += max1.c;
}
break;
// “The specificity of an :nth-child() or :nth-last-child() selector is the specificity of the pseudo class itself (counting as one pseudo-class selector) plus the specificity of the most specific complex selector in its selector list argument”
case 'nth-child':
case 'nth-last-child':
b += 1;
if (child.children?.first?.selector) {
// Calculate Specificity from SelectorList
const max2 = max(...calculate(child.children.first.selector));
// Adjust orig specificity
a += max2.a;
b += max2.b;
c += max2.c;
}
break;
// “The specificity of :host is that of a pseudo-class. The specificity of :host() is that of a pseudo-class, plus the specificity of its argument.”
// “The specificity of :host-context() is that of a pseudo-class, plus the specificity of its argument.”
case 'host-context':
case 'host':
b += 1;
if (child.children?.first?.children) {
// Workaround to a css-tree bug in which it allows complex selectors instead of only compound selectors
// We work around it by filtering out any Combinator and successive Selectors
const childAST = { type: 'Selector', children: [] };
let foundCombinator = false;
child.children.first.children.forEach((entry) => {
if (foundCombinator) return false;
if (entry.type === 'Combinator') {
foundCombinator = true;
return false;
}
childAST.children.push(entry);
});
// Calculate Specificity from Selector
const childSpecificity = calculate(childAST)[0];
// Adjust orig specificity
a += childSpecificity.a;
b += childSpecificity.b;
c += childSpecificity.c;
}
break;
// Improper use of Pseudo-Class Selectors instead of a Pseudo-Element
// @ref https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements#index
case 'after':
case 'before':
case 'first-letter':
case 'first-line':
c += 1;
break;
default:
b += 1;
break;
}
break;
case 'PseudoElementSelector':
switch (child.name) {
// “The specificity of ::slotted() is that of a pseudo-element, plus the specificity of its argument.”
case 'slotted':
c += 1;
if (child.children?.first?.children) {
// Workaround to a css-tree bug in which it allows complex selectors instead of only compound selectors
// We work around it by filtering out any Combinator and successive Selectors
const childAST = { type: 'Selector', children: [] };
let foundCombinator = false;
child.children.first.children.forEach((entry) => {
if (foundCombinator) return false;
if (entry.type === 'Combinator') {
foundCombinator = true;
return false;
}
childAST.children.push(entry);
});
// Calculate Specificity from Selector
const childSpecificity = calculate(childAST)[0];
// Adjust orig specificity
a += childSpecificity.a;
b += childSpecificity.b;
c += childSpecificity.c;
}
break;
case 'view-transition-group':
case 'view-transition-image-pair':
case 'view-transition-old':
case 'view-transition-new':
// The specificity of a view-transition selector with a * argument is zero.
if (child.children?.first?.value === '*') {
break;
}
// The specificity of a view-transition selector with an argument is the same
// as for other pseudo - elements, and is equivalent to a type selector.
c += 1;
break;
default:
c += 1;
break;
}
break;
case 'TypeSelector':
// Omit namespace
let typeSelector = child.name;
if (typeSelector.includes('|')) {
typeSelector = typeSelector.split('|')[1];
}
// “Ignore the universal selector”
if (typeSelector !== '*') {
c += 1;
}
break;
default:
// NOOP
break;
}
});
return new Specificity({ a, b, c }, selectorAST);
};
const convertToAST = (source) => {
// The passed in argument was a String.
// ~> Let's try and parse to an AST
if (typeof source === 'string' || source instanceof String) {
try {
return parse(source, {
context: 'selectorList',
});
} catch (e) {
throw new TypeError(`Could not convert passed in source '${source}' to SelectorList: ${e.message}`);
}
}
// The passed in argument was an Object.
// ~> Let's verify if it's a AST of the type Selector or SelectorList
if (source instanceof Object) {
if (source.type && ['Selector', 'SelectorList'].includes(source.type)) {
return source;
}
// Manually parsing subtree when the child is of the type Raw, most likely due to https://github.com/csstree/csstree/issues/151
if (source.type && source.type === 'Raw') {
try {
return parse(source.value, {
context: 'selectorList',
});
} catch (e) {
throw new TypeError(`Could not convert passed in source to SelectorList: ${e.message}`);
}
}
throw new TypeError(`Passed in source is an Object but no AST / AST of the type Selector or SelectorList`);
}
throw new TypeError(`Passed in source is not a String nor an Object. I don't know what to do with it.`);
};
/**
* @param {string} selector
* @returns {Specificity[]}
*/
const calculate = (selector) => {
// Quit while you're ahead
if (!selector) {
return [];
}
// Make sure we have a SelectorList AST
// If not, an exception will be thrown
const ast = convertToAST(selector);
// Selector?
if (ast.type === 'Selector') {
return [calculateForAST(selector)];
}
// SelectorList?
// ~> Calculate Specificity for each contained Selector
if (ast.type === 'SelectorList') {
const specificities = [];
ast.children.forEach((childAST) => {
const specificity = calculateForAST(childAST);
specificities.push(specificity);
});
return specificities;
}
};
export { calculate, calculateForAST };
+1
View File
@@ -0,0 +1 @@
export { calculate, calculateForAST } from './calculate.js';
+135
View File
@@ -0,0 +1,135 @@
import generate from 'css-tree/generator';
import { calculate, calculateForAST } from './core/index.js';
import { compare, equals, greaterThan, lessThan } from './util/compare.js';
import { min, max } from './util/filter.js';
import { sortAsc, sortDesc } from './util/sort.js';
class NotAllowedError extends Error {
constructor() {
super('Manipulating a Specificity instance is not allowed. Instead, create a new Specificity()');
}
}
class Specificity {
constructor(value, selector = null) {
this.value = value;
this.selector = selector;
}
get a() {
return this.value.a;
}
set a(val) {
throw new NotAllowedError();
}
get b() {
return this.value.b;
}
set b(val) {
throw new NotAllowedError();
}
get c() {
return this.value.c;
}
set c(val) {
throw new NotAllowedError();
}
selectorString() {
// this.selector already is a String
if (typeof this.selector === 'string' || this.selector instanceof String) {
return this.selector;
}
// this.selector is a Selector as parsed by CSSTree
if (this.selector instanceof Object) {
if (this.selector.type === 'Selector') {
return generate(this.selector);
}
}
// this.selector is something else …
return '';
}
toObject() {
return this.value;
}
toArray() {
return [this.value.a, this.value.b, this.value.c];
}
toString() {
return `(${this.value.a},${this.value.b},${this.value.c})`;
}
toJSON() {
return {
selector: this.selectorString(),
asObject: this.toObject(),
asArray: this.toArray(),
asString: this.toString(),
};
}
isEqualTo(otherSpecificity) {
return equals(this, otherSpecificity);
}
isGreaterThan(otherSpecificity) {
return greaterThan(this, otherSpecificity);
}
isLessThan(otherSpecificity) {
return lessThan(this, otherSpecificity);
}
static calculate(selector) {
return calculate(selector);
}
static calculateForAST(selector) {
return calculateForAST(selector);
}
static compare(s1, s2) {
return compare(s1, s2);
}
static equals(s1, s2) {
return equals(s1, s2);
}
static lessThan(s1, s2) {
return lessThan(s1, s2);
}
static greaterThan(s1, s2) {
return greaterThan(s1, s2);
}
static min(...specificities) {
return min(...specificities);
}
static max(...specificities) {
return max(...specificities);
}
static sortAsc(...specificities) {
return sortAsc(...specificities);
}
static sortDesc(...specificities) {
return sortDesc(...specificities);
}
}
export default Specificity;
+23
View File
@@ -0,0 +1,23 @@
const compare = (s1, s2) => {
if (s1.a === s2.a) {
if (s1.b === s2.b) {
return s1.c - s2.c;
}
return s1.b - s2.b;
}
return s1.a - s2.a;
};
const equals = (s1, s2) => {
return compare(s1, s2) === 0;
};
const greaterThan = (s1, s2) => {
return compare(s1, s2) > 0;
};
const lessThan = (s1, s2) => {
return compare(s1, s2) < 0;
};
export { compare, equals, greaterThan, lessThan };
+13
View File
@@ -0,0 +1,13 @@
import { sortAsc, sortDesc } from './sort.js';
const max = (...specificities) => {
const sorted = sortDesc(...specificities);
return sorted[0];
};
const min = (...specificities) => {
const sorted = sortAsc(...specificities);
return sorted[0];
};
export { max, min };
+3
View File
@@ -0,0 +1,3 @@
export * from './compare.js';
export * from './sort.js';
export * from './filter.js';
+21
View File
@@ -0,0 +1,21 @@
import { compare } from './compare.js';
const sort = (specificities, order = 'ASC') => {
const sorted = specificities.sort(compare);
if (order === 'DESC') {
return sorted.reverse();
}
return sorted;
};
const sortAsc = (...specificities) => {
return sort(specificities, 'ASC');
};
const sortDesc = (...specificities) => {
return sort(specificities, 'DESC');
};
export { sortAsc, sortDesc };